Skip to content

Instantly share code, notes, and snippets.

View lukemelia's full-sized avatar
💭
Making Yapp better all the time and likely working on some Ember.js OSS

Luke Melia lukemelia

💭
Making Yapp better all the time and likely working on some Ember.js OSS
View GitHub Profile
How we're using Hydra's listener and messaging architecture to have each runner spin up a database after it boots. See also: http://github.com/ngauthier/hydra/wikis/multiple-test-databases
#!/usr/bin/env ruby
url = `git config --get remote.origin.url`.chomp
url.gsub!(%r|git://github.com/(.*\.git)|, '[email protected]:\1')
if url =~ /^git@github/
puts "git remote rm writeable"
puts `git remote rm writeable`
puts "git remote add writeable #{url}"
puts `git remote add writeable #{url}`
else
raise "only supports github URLs"
[11:13-focus!][weplay(masterΔ)]$ gem install memcached
Building native extensions. This could take a while...
gem install memcache-clientSuccessfully installed memcached-0.19.3
1 gem installed
[11:14-focus!][weplay(masterΔ)]$ gem install memcache-client
Successfully installed memcache-client-1.8.3
1 gem installed
[11:18-focus!][weplay(masterΔ)]$ rake environment
(in /Users/lmelia/devprojects/weplay)
rake aborted!
if defined?(Unicorn)
class Unicorn::HttpRequest
alias _read read
undef_method :read
def read(socket)
_read(socket)
REQ.update('HTTP_X_REQUEST_START' => "t=#{((Time.now.to_f) * 1e6).to_i.to_s}")
end
end
ActiveRecord::Base.class_eval do
# ActiveRecord looks up the columns for a table each time it loads a class using that table
# With STI, this means repeated calls to 'SHOW FIELDS FROM table_name' for each subclass.
def self.columns
@@table_columns ||= {}
unless @@table_columns[table_name]
retrieved_columns = connection.columns(table_name, "#{name} Columns")
retrieved_columns.each { |column| column.primary = column.name == primary_key }
@@table_columns[table_name] = retrieved_columns
New York, New York, 2459115
Los Angeles, California, 2442047
Chicago, Illinois, 2379574
Houston, Texas, 2424766
Phoenix, Arizona, 2471390
Philadelphia, Pennsylvania, 2471217
San Antonio, Texas, 2487796
Dallas, Texas, 2388929
San Diego, California, 2487889
San Jose, California, 2488042
module Steps
module OauthHelper
def oauth_get(client_application, oauth_token, url)
oauth_headers_factory = OAuthHeadersFactory.new(client_application, oauth_token)
get_via_redirect(url, nil, oauth_headers_factory.headers_for_get(url))
end
def oauth_post(client_application, oauth_token, url, params)
oauth_headers_factory = OAuthHeadersFactory.new(client_application, oauth_token)
post_via_redirect(url,
require 'redis'
# SADD key, member
# Adds the specified <i>member</i> to the set stored at <i>key</i>.
redis = Redis.new
redis.sadd 'my_set', 'foo' # => true
redis.sadd 'my_set', 'bar' # => true
redis.sadd 'my_set', 'bar' # => false
redis.smembers 'my_set' # => ["foo", "bar"]
WE.RealtimeNotificationListener = (function(){
var instanceMethods = {};
var staticMethods = {
listen: function(channel, notificationHandler) {
var realtimeNotificationsUrl = "http://" + location.host + "/rt/notifications?id=" + channel;
var realtimeNotificationsCookieName = 'channel_last_mod_' + channel;
var storedLastModifiedDate = $.cookie(realtimeNotificationsCookieName);
if (storedLastModifiedDate !== null) {
$.lastModified[realtimeNotificationsUrl] = storedLastModifiedDate;
}
POST http://www.kaltura.com/index.php/partnerservices2/getuiconf
Host: www.kaltura.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive