April 2008
1 post
Help! The price of video content has fallen, and... →
March 2008
1 post
Case insensitive regexes for Ruby on Rails routes,... →
February 2008
2 posts
List all undeliverable messages in your exim queue
sudo script/exipick -bpru -show-vars=recipients | grep recipients | cut -d “’” -f 2 | sort | uniq
Suppress Ruby warnings at runtime, without...
def without_warnings ov = $VERBOSE $VERBOSE = nil ret = yield $VERBOSE = ov ret end
September 2007
3 posts
Rendering from script/console
It turns out Rails has a nice little undocumented trick for rendering things from script/console or script/runner: app.get(“/path/to/render”) my_response_body = app.response.body If you want to render something you don’t have an action for, just define it on the controller right there: class MyController def my_render render :partial => “shared/foo” ...
Setting file descriptor limits →
To install the postgres gem on debian
sudo apt-get install ruby1.8-dev sudo apt-get install postgresql-dev libpq-dev cd /var/lib/gems/1.8/gems/postgres-0.7.1 sudo ruby extconf.rb —with-pgsql-lib-dir=/usr/lib/postgresql/8.1/lib/ —with-pgsql-include-dir=/usr/include/postgresql/ sudo make sudo make install
July 2007
2 posts
Ruby on Rails HTTP based authorization: def get_auth_data user, pass, authdata = ”, ”, nil # mod rewrite, normal, apache [‘X-HTTP_AUTHORIZATION’, ‘HTTP_AUTHORIZATION’, ‘Authorization’].each do |key| # extract authorisation credentials if request.env.has_key? key authdata = @request.env[key].to_s.split end ...
Development coordination through chat →
June 2007
5 posts
Getting NetConnection.Connect.Failed every time you try to connect from a NetConnection? Make sure you can run telnet serveraddress 1935 first, so that you know that the server is actually listening. Make sure you have the security settings to allow the NetConnection to work. Run nc -l -p 1935 to listen on 1935 and try connecting to localhost. If you see a bunch of binary crap, it’s...
Detecting microphone activity levels in flash requires a few magic incantations to get it to work: mic = Microphone.get(); mic.onActivity = function(){} _root.attachAudio(mic); // now you can read the activityLevel trace(mic.activityLevel);
The ActiveRecord documentation for date_select contains the cryptic statement: "The selects are prepared for multi-parameter assignment to an Active Record object."10 minutes googling later... "Besides that, it's now possible to do multi-parameter assigns that can even be type-casted. This is extremely helpful to do something like this for date attributes: post.attributes = { ...
In Lua 5.0, you can get the arguments to a script with: argv = arg In Lua 5.1, this will fail horribly. This bug is present in luaunit, which works only with Lua 5.0.
Yet another serialization of my life
I wonder if any of these will ever stick.