Skip to content

Instantly share code, notes, and snippets.

View jamiew's full-sized avatar

Jamie Dubs jamiew

View GitHub Profile
class ApplicationController
after_filter :set_access_control_headers
def set_access_control_headers
# Any domain
# headers['Access-Control-Allow-Origin'] = '*'
# Specific domain
# config/environments/production.rb
# We're on Heroku, just output straight to STDOUT
# This is required because we're using Unicorn, too: https://github.com/ryanb/cancan/issues/511#issuecomment-3643266
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
$ cat config/initializers/new_relic_reconnect.rb
# Ensure the agent is started using Unicorn
# This is needed when using Unicorn and preload_app is not set to true.
# See http://support.newrelic.com/kb/troubleshooting/unicorn-no-data
NewRelic::Agent.after_fork(:force_reconnect => true) if defined? Unicorn
@jamiew
jamiew / Procfile
Last active October 4, 2015 12:28
Using unicorn on Heroku
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
class ThingsController < ApplicationController
before_filter :get_thing!, :only => [:show]
before_filter :friends_only!, :only => [:show]
def show
render @thing
end
@jamiew
jamiew / each vs map.rb
Created April 19, 2012 20:32
each vs map usage in ruby
json = ActiveSupport::JSON.decode(google)['predictions']
# sort of traditional for() loop style
results = []
json.each do |location|
results << {
:short => 'foo',
:long => 'bar'
}
end
$ cat deploy
#!/bin/sh
# any extra arguments are passed to `git push`, e.g. -f
app='vhx-artists'
remote='heroku'
git push $remote master $1 || exit $?
heroku run rake assets:precompile --app=$app || exit $?
@jamiew
jamiew / heroku_unicorn_logger_fix.rb
Created March 28, 2012 15:25
Fix Heroku cedar app logging with Rails 3.1 and Unicorn
# config/environments/production.rb
# We're on Heroku, just output straight to STDOUT
# This is required because we're using Unicorn: https://github.com/ryanb/cancan/issues/511#issuecomment-3643266
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
<meta property="og:type" content="vhxtv_ns:video" />
<meta property="og:title" content="Brimley's Breath" />
<meta property="og:image" content="http://b.vimeocdn.com/ts/617/924/61792473_200.jpg" />
<meta property="og:description" content="From inaugural Tricorn" />
<meta property="og:url" content="http://vhx.tv/1234" />
<meta property="og:video" content="http://www.vimeo.com/moogaloop.swf?clip_id=3102336" />
<meta property="og:video:url" content="http://vimeo.com/3102336" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:video:width" content="560" />
<meta property="og:video:height" content="315" />
:tddium:
:environment:
'RAILS_ENV': 'test'