- Start a Sinatra server on port 4000
- GET / to that server triggers a
git pull
and mod_rails restart - Hit port 4000 locally after pushing
This file contains hidden or 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
<ol class="latest_uploads"> | |
<%= render :partial => "composition", :collection => @playlist.listings.compositions %> | |
</ol> |
This file contains hidden or 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 hidden or 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
testapp |
This file contains hidden or 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
# Lo-fi client for the Facebook API. E.g.: | |
# | |
# fb = FacebookClient.new(:api_key => 'api-key', :secret => 'secret') | |
# fb.call 'users.getInfo', :session_key => 'session-key', :uids => 'user-id', :fields => 'birthday' | |
# | |
# by Scott Raymond <[email protected]> | |
# Public Domain. | |
# | |
class FacebookClient | |
def initialize(default_params={}) |
This file contains hidden or 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
module Harmony | |
# Allows accessing config variables from harmony.yml like so: | |
# Harmony[:domain] => harmonyapp.com | |
def self.[](key) | |
unless @config | |
raw_config = File.read(Rails.root + "/config/harmony.yml") | |
@config = YAML.load(raw_config)[Rails.env].symbolize_keys | |
end | |
@config[key] | |
end |
This file contains hidden or 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 Class | |
def memoize(*methods) | |
methods.each do |method_name| | |
safe_method_name = method_name.to_s.gsub(/(\!|\?)/, '_') | |
class_eval(" | |
alias :'#{safe_method_name}_without_memo' :'#{method_name}' | |
def #{method_name} | |
if defined?(@#{safe_method_name}) | |
@#{safe_method_name} |
This file contains hidden or 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
# This is how you can get a user's location using MacRuby and CoreLocation | |
framework 'CoreLocation' | |
def locationManager(manager, didUpdateToLocation: new_location, fromLocation: old_location) | |
puts "location: #{new_location.description}" | |
exit | |
end | |
loc = CLLocationManager.alloc.init | |
loc.delegate = self |
This file contains hidden or 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
def test_something_for_real | |
flunk <<-ABBOT_AND_COSTELLO | |
hey buddy, you should probably rename this file and start testing for real. | |
For Rael? | |
No real... | |
What's real? Rael? | |
Rael? You mean Rails? | |
Who's talking about Rails, all I want to know is if the test is for Rael... | |
ABBOT_AND_COSTELLO | |
end |
This file contains hidden or 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
# sometimes you really _do_ want a global... | |
# alternately, stick it as a method on a Module somewhere, App.logger or whatever, but it's still just as much of a smell. | |
# replace STDERR with your filename of choice. | |
$logger = Logger.new(STDERR) | |
$logger.formatter = proc { |severity, datetime, progname, msg| | |
"#{severity} - #{progname} - [#{datetime.strftime("%d/%m/%Y %H:%M:%S")}] #{msg}\n" | |
} | |
run(Rack::Builder.new { |