Skip to content

Instantly share code, notes, and snippets.

View jamiew's full-sized avatar

Jamie Dubs jamiew

View GitHub Profile
everynone: 0
animalcolm: 7
aam: 0
alexlora: 0
caviarcontent: 0
ruairirobinson: 0
danieldaniel: 0
sweatshopped: 0
vjurjen: 0
cokau: 0
@jamiew
jamiew / bookmarklet.js
Created September 7, 2012 23:31
New VHX bookmarklet code
javascript:function%20bkload()%7Bvar%20d=document,z=d.createElement('scr'+'ipt'),b=d.body;try%7Bif(!b)throw(0);d.title='(Loading...)%20'+d.title;z.setAttribute('src','//community.vhx.tv/videos/bookmarklet.js');b.appendChild(z)%7Dcatch(e)%7Balert('Please%20wait%20until%20the%20page%20has%20loaded.')%7D%7Dbkload();void(0);
@jamiew
jamiew / easy-git.rdoc
Created August 13, 2012 04:36 — forked from caseypugh/easy-git.rdoc
GIT MADE EASY

Checkout new repo

git clone git@github.com:vhx/watchlater

go into your vhx folder

cd ~/dev/vhx

Checks current status of modified files

git status

Shows you all the current modifications

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 $?