Skip to content

Instantly share code, notes, and snippets.

View richardking's full-sized avatar

Richard King richardking

  • Instacart
  • San Francisco, CA
View GitHub Profile
>> BackgroundCache.cache!('every_10_minutes_2')
(every_10_minutes_2) /articles
(every_10_minutes_2) /mma?utm_source=philly
(every_10_minutes_2) /nfl?utm_source=courant
(every_10_minutes_2) /college-football?utm_source=courant
(every_10_minutes_2) /nfl?utm_source=baltimore_sun
(every_10_minutes_2) /college-football?utm_source=baltimore_sun
(every_10_minutes_2) /nfl?utm_source=la_times
(every_10_minutes_2) /college-football?utm_source=la_times
(every_10_minutes_2) /nfl?utm_source=seattle_pi
@richardking
richardking / deploy.rb
Last active December 18, 2015 08:29 — forked from bkutil/deploy.rb
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
after "deploy:restart", "resque:stop_workers"
namespace :resque do
task :stop_workers, :except => { :no_release => true } do
run "cd #{current_path} && rake RAILS_ENV=#{rails_env} resque:stop_workers"
end
end

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
@richardking
richardking / gist:6325780
Created August 24, 2013 02:53
instance_eval, class_eval
Ruby: instance_eval and class_eval method definitions
In yesterday's entry on Cleaning up Controller Tests you can find the following code.
# example 1
...
test_class.class_eval do
define_method :setup do
...
end
end
test_class.class_eval &block
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@richardking
richardking / gist:6586664
Created September 16, 2013 21:10
resque script
➜ breport git:(rc-7197-team-stream-twitter) ✗ cat bin/resque
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
begin
require 'redis-namespace'
rescue LoadError
require 'rubygems'
require 'redis-namespace'
end
Florida Gators
Tennessee Volunteers
Georgia Bulldogs
Kentucky Wildcats
South Carolina Gamecocks
Vanderbilt Commodores
Arkansas Razorbacks
Auburn Tigers
LSU Tigers
Alabama Crimson Tide
@richardking
richardking / gist:7202064
Last active December 26, 2015 19:29
NFL
delta
BUF
delta
MIA
delta
NE
delta
delta
Boston
BOS
delta
Nets
Brooklyn
BKN
delta