Log in

On Vox: 橫濱山下公園





Originally posted on gugod.vox.com

Jobs about this framework

Recenty used Rails for $work, and came up this function to make it more convenient to retrieve remote records in a many-to-many relationship with a join-table used to saved the relationship and it'll takes a .map-conversion away to get the actual records.

Here's what we came up:
module AsynapseSupport
def has_(prefix, item)
prefix = prefix.to_s
item = item.to_s

sy = "#{prefix}_#{item}"
mo = sy.camelcase.singularize

self.class_eval <
has_many :_#{sy}, :class_name => "#{mo}"
def #{sy}
_#{sy}.map { |f| f.#{item.singularize} }
If your mixin this module in your ActiveRecord::Base, then you can say this in your user.rb model class:
  has_ :favorite, :chatrooms
It'll make an favorite_chatrooms method to retrieve a list of "Chatroom" instead of retrieving a list of "FavoriteChatroom", which is the behaviour if you say:
  has_many :favorite_chatrooms
Our has_ method, although seems to be a controversial name, is pretty handy to deal with many-to-many relationship.

Project asynapse: http://code.google.com/p/asynapse/

Help me choose!

The battey of my MacbookPro starts go bad. Besides exchange current one from apple store, I want to know if it's worth it to buy an extra one.

Help me choose!

Don't, it's not worth it.

Buy an extra battery, that's really handy.

Before you click, give us some idea of why you feel that way.




8 days a week.

As Google calculates that "8 (days a week) = 1.14285714", this long week is indeed over. Now we're at ground zero, hopefully everything can only go better, and I just realized that this is the first cup of coffee ever since the beginning.

The actual usage of USB Missile Launcher.

YAPC::Asia rocks because a guy just  fired his boss  an USB missile rocks too in the lighting talk and everyone see that happening from the guy's webcam in his office.