Code Snippets

Ruby Script to Update Github Repos and Fetch Changesets for Redmine

I recently started using Redmine for numerous projects and could not be happier with the application so far. Not only is it actively developed and already includes a ton of great features but it doesn’t seem bloated at all. Many of the projects I have configured for Redmine have their code base stored on Github so I needed to find a way to add code updates that referenced tickets to the tickets themselves. At first I was having a bit of trouble understanding exactly how this should be achieved but after digging around it ended up being pretty easy. You will need to configure local repos underneath your Redmine project that are updated fairly regularly and then after they are updated you will need to run a script that updates the any ticket that code has been associated with.

Code Snippets

Add Google Content Ads Between Your WordPress Search Results

I have been thinking about the best way to display ads on my WordPress blog search results for a long time because there are numerous options. You could just display content ads at the top, bottom, or both locations, you could add a WordPress plugin, or you could create a custom page with Google custom search results geared for your page. I played around with the latter two options but wasn’t happy with eaither result. One of the ways to do the Google custom search results is using an iFrame and iFrames suck. Anyway I decided to add some custom PHP code to display the ads however I ran into a problem quickly which was the fact that you can only display 3 of the same ad on any one page so if you want to display ads in between each search result it would get a bit more tricky.

Code Snippets

WordPress NextGen Gallery – Add Date Print Out to Compact Album Listings

I was working on my personal blog and wanted to add the date or a date range to the top of each gallery when they are listed out. The blog I am speaking of uses WordPress, WP version 2.7, with the NextGen Gallery plugin, NGG version 1.2.1, for pictures. I list the all of the galleries by using the album compact function so the below howto relates to that function only. What it will do is simply print out anything in the description field right above the image you have highlighted for each gallery. Since I was not using the description for anything else I just add the date or a date range into that field such as 01-01-2009 or 04-16-2009 to 08-10-2009.  Follow the directions below and you can print out anything you like above each gallery listing.

The NextGen Gallery shortcode used to display the galleries:

php

  1. [album=3,compact]

Code Snippets

MySQL Ruby Gem: `require’: no such file to load — mysql (LoadError)

I am starting to learn ruby and am working on a test script to import some data into a MySQL database. I am using the below code found on kitebird.com to first get the MySQL connection from Ruby working. The code was producing an error which I figured might be because I installed the MySQL Ruby gem instead of installing the MySQL Ruby module from source.

The below code attempts to connect to the MySQL server to return the MySQL server version.