Det er mye enklere å teste når testene kjører av seg selv og maser når det må mases. Med ZenTest og test_notifier får du beskjed når ting går galt helt automagisk – og det via libnotify/knotify. For en kjapp oppskrift, se her: getting started with autotest
Category: programming
capistrano ftw
This is just a small nod in the direction of capistrano, the rails deployment machine. It gives great satisfaction to commit your latest fixes to master and run a quick “cap deploy”, and a few seconds later having an up to date server on the other end.
No need to meddle with the server, it is all automagic:)
Now – back to work…
personal ruby buddha machine
Some days ago I came across a post on the FM3 buddha machine. Finding it a fascinating concept, and being able to download their samples I sprinkled a few lines of ruby over them an stirred. Voilà – my own personal buddha machine playing wonderful ambient soundscapes in a random fashion. Using the sdl_ruby library, the whole thing became surprisingly simple:
#!/usr/bin/ruby -w
require 'sdl'
SDL.init(SDL::INIT_AUDIO)
SDL::Mixer.open(44100,SDL::Mixer::DEFAULT_FORMAT,2,4096)
clips = Dir.new('audio').entries.delete_if {|x| ! (x =~ /wav$/)}
while true
for i in 1..SDL::Mixer.allocate_channels(4)
if not SDL::Mixer.play?(i)
SDL::Mixer.playChannel(i,SDL::Mixer::Wave.load("audio/"+clips[rand(clips.length)]),rand(30))
end
end
sleep 0.5
end
Numerical sorting in ruby
Quick note on how to do numerical sorting in ruby.
When calling sort, ruby will perform a lexicographical sorting by default, meaning that the following array
a=["0","10","9","1"]
a.sort.each{|val| p val}
will output
"0" "1" "10" "9"
If this is not what you want, this might be it:
a.sort{|x,y| x.to_i < => y.to_i}.each { |val| p val }
outputs:
"0" "1" "9" "10"
Yay, blocks to the rescue:)
Notat til meg selv:
bruk
<%= stylesheet_link_tag "cssfil" %>
for å inkludere css, så slipper man trøblete proxy-servere som bare vil servere gamle versjoner.