This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WebHook < ActiveRecord::Base | |
class << self | |
# Pushes a job onto a queue | |
def visit!(visit) | |
JobQueue.new(:events).push({ | |
:type => 'visit', | |
:visit_id => visit.id, | |
:user_id => visit.user_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JobQueue | |
def initialize(name, options={}) | |
@key = [:job_queue, Merb.env, name].join | |
@queue = SQS.queue(@key, true, 200) | |
@cache = options[:cache] || CACHE | |
@logger = options[:logger] || Merb.logger | |
end | |
def push(options={}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order < ActiveRecord::Base | |
SECRET = '3a9392e86049546fcff5e21e3c89564deb8bd9d4' | |
def self.find_by_token(token) | |
id, sig = token.split('-') | |
record = find(id) | |
if record.nil? || token != record.token | |
raise ActiveRecord::RecordNotFound, "invalid sig" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0"> | |
<id>tag:gowalla.com,2009:/visits/all</id> | |
<title>Gowalla Checkins</title> | |
<updated>2010-02-02T09:59:14+00:00</updated> | |
<link rel="self" href="http://gowalla.com/visits/all.atom"/> | |
<link rel="alternate" href="http://gowalla.com/visits/all"/> | |
<author> | |
<name>Gowalla</name> | |
</author> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0"> | |
<id>tag:gowalla.com,2009:/visits/all</id> | |
<title>Gowalla Checkins</title> | |
<updated>2010-02-02T09:59:14+00:00</updated> | |
<link rel="self" href="http://gowalla.com/visits/all.atom"/> | |
<link rel="alternate" href="http://gowalla.com/visits/all"/> | |
<author> | |
<name>Gowalla</name> | |
</author> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VisitorStats | |
def initialize | |
@redis = Redis.new | |
end | |
# every time there's a hit, increment a counter for the | |
# day and week, and add the session id to a set of unique | |
# vistitors for the day/week | |
def hit(session_id) | |
today = Date.today |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Beer To Beer Networking" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get an instance of the Chronologic client | |
chronologic = Chronologic::Client.new | |
# Cache metadata for users, spots, etc. | |
chronologic.object(:user_1, {:name => 'Scott Raymond'}) | |
chronologic.object(:user_2, {:name => 'Josh Williams'}) | |
chronologic.object(:spot_1, {:name => 'Gowalla HQ'}) | |
# Create subscriptions when one user follows another, etc. | |
chronologic.subscribe(:user_2_friends, :user_1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UITextFieldDelegate method, called when the "Return" key is pressed. | |
// Either advance the cursor to the next empty field, or submit the form. | |
// | |
- (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
if([usernameField.text length] == 0) { | |
[usernameField becomeFirstResponder]; | |
} else if ([passwordField.text length] == 0) { | |
[passwordField becomeFirstResponder]; | |
} else { |