Launch the rhythm visualization demo Continuing from my first iteration on a visual metronome, this is an improvement to simplify things while providing greater control in the UI for: tempo, cycles (bars), beats, and emphasis highlighting (nth). My intention is for this to evolve toward a metric modulation visualization. I moved from the traditional European [...]
Category Archives: code
Command finished notification with Ruby
I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify. $ a-long-running-command | notify notify.rb Make it executable add an alias to it in ~/.bashrc Requires: ruby, rubygems, and libnotify. Similar solutions: “alert” alias (I’ll be switching to this in Maverick), [...]
Ruby Duration
Download ruby duration lib Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format. Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format. Usage: Passing a String Passing an Fixnum (of seconds) Example valid input strings: “2 weeks”, [...]
ruby on rails – has and belongs to many view plugin
So I’ll never have to write another has_and_belongs_to_many view again, here’s a plugin that dynamically makes 2 <ul> lists which you drag and drop both ways to manage the association. http://svn.ahabman.com/public/many_to_many_view/ From the readme: Assumming you have an @project var and you want to associate people with it. “shared/m2m”, :locals => { :thing => @project, [...]
You can’t use class variables in rails.
You can’t use class variables in rails. Unless you’d like to develop in production mode (specifically with config.cache_classes = true). In development mode all classes are reloaded on each request, which clears all class variables. I had the perfect place to use them – while running a mass synchronization, and needing to store the timestamp [...]
ruby csv to structured hash
I had a csv like this: object color flavor shape apple red sweet round banana yellow sweet long lemon yellow sour round and I wanted a ruby hash structured like this: So I wrote this, which does the job:
Ruby conversion module
This is a ruby module useful for conversions dealing with length, weight, torque.
Rails redirect_to :back in Internet Explorer
Today I realized that the rails command redirect_to :back does not work in Internet Explorer because redirect_to :back depends on the HTTP_REFERER http header, which IE does not send. I was capturing an onclick event with jQuery and was able to sending along the current URL as a query string, which provided an easy way [...]