Putting the mongrel port number in your logfile filename
01 July 2008
in links
tagged with
[mongrel]
[rails]
[ruby]
[sysadmin]
By default mongrels all log into a single logfile. This makes debugging a complete pain. Putting the process PID into the filename is easy, but getting the current mongrel process’ allocated port is slightly harder.
Taming the autotest Beast with FSEvents » rails symphonies
30 November 2007
in links
tagged with
[autotest]
[fsevents]
[leopard]
[rails]
Cunning trick to avoid polling on leopard for autotest
http://rails.aizatto.com/2007/11/28/taming-the-autotest-b...
jRails - jQuery on Rails
21 November 2007
in links
tagged with
[javascript]
[jquery]
[rails]
Makes all the Rails JS helpers work with jQuery, rather than prototype
Learning Ruby using Rails
16 November 2007
in blog
tagged with
[programming]
[python]
[rails]
[ruby]
Recently I got dropped in the deep end and had to learn both Ruby and Rails very quickly. I didn’t think this would be a problem - everyone raves about how easy Rails is to pick up, right? - and it wasn’t. The problem is actually arriving now, as I start trying to use Ruby for things other than Rails applications. And I can’t, because I’ve learned all sorts of nice Ruby tricks that looked like they were core language features but actually turn out to be added to the built-in Ruby objects by Rails.
For instance, I really like the 3.days convention for turning numbers into time intervals. That’s added by this extension. In fact, in digging for this, I found out just how many things Rails adds to core Ruby. I’m scared.
I’m torn. I’d like to consider messing with the built in objects confusing and dangerous. And I’ve been bitten by this before. I’ve also had problems where one module’s patching to a Ruby builtin interferes with another module’s patching of the same object. Lovely.
At the same time, though, I love it. I love both the huge convenience and readability of being able to write Time.now + 3.days, and the fact that the language lets me do this. All languages should be this consistent - none of this ‘some types are special’ crap.
There are trade-offs. I love Python, but I hate that map is a global function and not a method on arrays, and I hate that certain types are special and immutable. But I’m sure there are scary speed benefits from doing things this way.
I wonder if part of the reason that Ruby has this ‘just for Rails’ reputation is because, having learned Ruby for Rails, you can’t use that Ruby for anything else without unlearning a stack of habits?
Irritating 2038 Ruby / Rails behaviour
17 October 2007
in blog
tagged with
[bug]
[rails]
[ruby]
In a rails console:
>> (Time.now + 30.years).class
=> Time
>> (Time.now + 31.years).class
=> DateTime
>> (Time.now + 30.years).to_s
=> "Sat Oct 17 17:27:11 +0100 2037"
>> (Time.now + 31.years).to_s
=> "2038-10-17T17:27:13+01:00"
Time objects after about August 2028 can’t be expressed internally as ‘UNIX epoch (1st January 1970) plus N seconds’ where N is a 32 bit integer. Once a Time object tries to express a date after this point, it gets silently converted to a DateTime object, which presumably uses a different internal representation. It also stringifies differently, has different methods, and is just generally annoying behaviour.
When you have dates in a MySQL database, and use ActiveRecord, DATETIME columns come out of the table as either a Time or a DateTime object depending on what the expressed date is. Lovely. This bug indicates that dates before 1970 behave similarly (they can’t be expressed as unsigned epoch times either).
This is apparently desired behaviour.
Update: Apparently, DateTime objects are also much slower than Date objects.
Getting ActiveRecord objects by ID
02 October 2007
in blog
tagged with
[optimization]
[rails]
[ruby]
I’m trying to speed up a rails app here, and I’ve been making some assumptions that I’ve realised may not actually be true.
Specifically, if I have a list of IDs, I’ve been assuming that
list_of_ids.map{|id| Model.find(id) }
is going to be slower than
Model.find( list_of_ids )
Presumably, the latter will only make one SQL call to fetch all the objects, but the former will make a call per ID. This is because I’m used to perl, where the ORMs are stupid, the language is fast, and the DB is always the bottleneck.
But the sort of SQL produced by the supposedly slower approach is much more cacheable. The supposedly faster approach will tend to generate a different SQL query every time, whereas a sufficiently smart cache layer could intercept the SQL calls of the later approach and just hand back the models.
Initial benchmarking seems to have the one-SQL-call approach faster anyway. It does turn out to have a disadvantage, though - Model.find( ids ) doesn’t return objects in the same order that the IDs were in, whereas the map approach does. That’s fairly easy to fix, though:
class ActiveRecord::Base
class << self
def find_in_order( ids )
# return all instances with the passed ids, in the order that the ids are in
objects = self.find( ids )
objects = objects.sort_by{|o|ids.index(o.id)}
return objects
end
end
end
Revolution On Rails: [PLUGIN RELEASE] Metrics
27 September 2007
in links
tagged with
[metrics]
[profile]
[rails]
[ruby]
Profile individual functions inside a rails application
http://revolutiononrails.blogspot.com/2007/06/plugin-rele...
Monkeybars
21 September 2007
in links
tagged with
[rails]
[ruby]
[swing]
write swing apps in rails. This scares me.
Rails: Calling render() outside your Controllers
17 September 2007
in links
tagged with
[mvc]
[rails]
[render]
[ruby]
[template]
Yet more glorious peversion of MVC - this time, rendering rails templates from inside your models.
http://blog.yanime.org/articles/2006/08/05/rails-calling-...
typography-helper - Google Code
05 September 2007
in links
tagged with
[plugin]
[rails]
[ruby]
[typogrify]
the python/django typogrify filters, ported to ruby/rails.
#9117 ([PATCH] :trailing_slash option support for UrlWriter#url_for) - Rails Trac - Trac
05 September 2007
in links
tagged with
[rails]
[trailing_slash]
[url]
I like trailing slashes, and I like violating MVC, so I must watch this patch.
[Helma-user] Rail-like URL Routing Script
26 July 2007
in links
tagged with
[helma]
[javascript]
[rails]
Rails-style routing for Helma. I find the default Helma URL dispatching very annoying - this is far better.
http://grazia.helma.at/pipermail/helma-user/2005-November...
Joyeur: Joyeur: Joyent Slingshot
23 March 2007
in links
tagged with
[app]
[development]
[offline]
[rails]
[ruby]
[slignshot]
Rails apps turned into offline-capable Mac .apps with very little work. awesomely cool stuff. I may need to have a look at rails again.
Hivelogic: Articles: Building Ruby, Rails, LightTPD, and MySQL on Tiger
16 November 2006
in links
tagged with
[compiling]
[rails]
[ruby]
Gah, I really resent having to do this.
http://hivelogic.com/articles/2005/12/01/ruby_rails_light...
Top 30 Ruby on Rails Tutorials
20 July 2006
in links
tagged with
[rails]
[ruby]
[tutorials]
I guess I should have a look at this Rails thing, then
http://www.econsultant.com/web-developer/ruby-rails-tutor...
RailsConf Europe 2006
08 June 2006
in links
tagged with
[conference]
[london]
[rails]
[ruby]
I’m going to this. I should try to learn some rails, I guess.
London web frameworks night
29 October 2005
in links
tagged with
[catalyst]
[london]
[rails]
[social]
[web]