Skip to content

Instantly share code, notes, and snippets.

>> fd = User.new
=> #<User id: nil, created_at: nil, updated_at: nil>
>> fd.save
SQL (0.4ms) BEGIN
SQL (10.6ms) INSERT INTO `users` (`created_at`, `updated_at`) VALUES (?, ?) [["created_at", Mon, 20 Jun 2011 01:01:40 UTC +00:00], ["updated_at", Mon, 20 Jun 2011 01:01:40 UTC +00:00]]
(1.6ms) COMMIT
=> true
>> fd
=> #<User id: 0, created_at: "2011-06-20 01:01:40", updated_at: "2011-06-20 01:01:40">
>> User.find 1
@maxhodak
maxhodak / thrift-puzzle.mdown
Created April 30, 2011 00:37
thrift-puzzle

Add Yourself

Difficulty: Easy; Requires Thrift version 0.6.0 or later

Add yourself to our employee candidate database using Thrift. It's really simple: there's a server, RecruitingService, running on http://sanger.transcriptic.com:9194 that responds to one call, addCandidate. Pass it the right params and you'll be on your way. The Thrift interface spec you need is here: https://gist.github.com/949280

End result: You'll get the string "Success!" returned.

@maxhodak
maxhodak / recruiting.thrift
Created April 30, 2011 00:32
Engineering recruiting puzzle
#!/usr/local/bin/thrift --gen py
service RecruitingService {
string addCandidate(1:string email, 2:string first_name, 3:string last_name)
}
{
"name": item['brand'],
"store": item['store_host'],
"url": item['url'],
"crawl_history": [datetime.datetime.utcnow()]
}
self.mongo_conn.brands.insert({
"name": item['brand'],
def geography(datum):
if datum in ("CT","DE","ME","MD","MA","NH","NJ","NY","PA","RI","VT"):
return (1, 0, 0, 0, 0)
elif datum in ("AL","AR","GA","KY","LA","MS","NC","SC","TN","VA","WV"):
return (0, 1, 0, 0, 0)
elif datum in ("IL","IN","IA","KS","MI","MN","MO","NE","ND","OH","SD","WI"):
return (0, 0, 1, 0, 0)
elif datum in ("AZ","NM","OK","TX"):
return (0, 0, 0, 1, 0)
elif datum in ("AK","CA","CO","HI","ID","MT","NV","OR","UT","WA","WY"):
(defmacro import-headers [class-name]
`(do
(import ~(symbol (format "com.myfit.%s.thrift.%s" class-name class-name)))
(import ~(symbol (format "com.myfit.%s.thrift.ServerImpl" class-name)))))
(defn run [class-name addr port]
(import-headers class-name)
...)
#!/usr/local/bin/thrift --gen py
service QuantiosJobs {
string addEmployee(1:string email, 2:string first_name, 3:string last_name, 4:string phone_number, 5:binary why_hire_me)
}