strings of my
incoherence
I'm Tal Atlas. I'm currently finishing up my masters in microelectronic materials after getting a Physics BS at Colorado School of Mines. I'm a hobbyist photographer and Rails programmer. This is a collection of random things I find intresting from across the web.

All posts tagged ruby.

Blackbook automates the nitty-gritty of importing contacts from various services and files and exporting them as VCard, XML, or simple Hash. Utilize those contacts from services like AOL, GMail, Yahoo Mail, Hotmail or CSV to help your social networking site become GIGANTIC overnight! You’ll be able to get big and sell for millions before anyone figures out it’s just like every other social network.

purzelrakete’s blackbook

Sounds like the tool I want to use!

ruby gem Tags
dannygarcia:


Dropzone
Drop stuff in this thing’s stuff to do stuff.


The fact that the extension API for this is based on ruby is making me want to buy it.

dannygarcia:

Dropzone

Drop stuff in this thing’s stuff to do stuff.

The fact that the extension API for this is based on ruby is making me want to buy it.

The 2nd “stable” release of Shoes just came out.

The 2nd “stable” release of Shoes just came out.

ruby shoes Tags
named_scope find options

strelau:

Let’s say you have


named_scope :red, :conditions => {:color => 'red'}

Do not do this:


Shirt.red(:limit => 1) #=> ALL red shirts

You will get all red shirts. I don’t care how many you limit to, you will get them all. Instead, you need to chain using find(:all) or it’s alias all:


Shirt.red.all(:limit => 1) #=> ONE red shirt

This has been your Rails public service announcement for 17 September 2008.

Wouldn’t it be easier to do this:?


Shirt.red.first/last
Ruby Rails Tags
More & Tricks

strelau:

Compare:


> def double(n)
>  n * 2
> end

> (1..5).map {|n| double(n)}
=> [2, 4, 6, 8, 10]

> (1..5).map &method(:double)
=> [2, 4, 6, 8, 10]

Explanation: method returns a Method object representing the named method. Method defines to_proc to return the Proc corresponding to the method. And we know that our trusty friend & tries to convert the object to a Proc using it’s to_proc method.

(via Giles Bowkett)

May as well add into this:


> (1..5).map {|n| n.double}
=> [2, 4, 6, 8, 10]

> (1..5).map {&double}
=> [2, 4, 6, 8, 10]

I generally prefer to use collect over map. It gives a better idea of what the method does, then again it is 4 characters longer :P.

ruby tips Tags
ruby tricks Tags