Ruby

Bubble Sort

I did some more comparative programming around Bubble Sort recently which I decided to post here, to both save it for myself and share with others. This time rather than posting multiple entries (one for each language) I have decided to throw them all in the same pot.

No votes yet

CruiseControl Project Operations

One of the developers I work with figured out the URL for firing the various CruiseControl build operations (resume, pause, build, etc) and it was jokingly noted that now all we need is a Ruby script to fire them.

And so, viola! Here is a simple ruby script that will do just that. It will run the specified operation command on one project (or all if no project is specified). You do have to configure the script with your CruiseControl url and your project names, but it’s well worth it.

No votes yet

Playlist Randomization II

Yesterday I posted a little script for randomizing WinAmp playlists, Playlist Randomization. I ended the post with an interest in writing the same thing in Ruby. I was able to do it in about ten minutes.

# rand_playlist.rb
lines = []
File.open("#{ARGV[0]}","r") do |file|
    while(line = file.gets)
        unless line[0..0] == '#' 
            lines << line
        end
    end
end

lines.sort! { rand(3) - 1 }

out_file = File.new("random_#{ARGV[0]}","w");
lines.each do |line|
No votes yet