Skip to content

Instantly share code, notes, and snippets.

View gist:014bdd4ec24c56dcf66d
vagrant@reddit:~$ sudo reddit-stop
vagrant@reddit:~$ sudo reddit-start
vagrant@reddit:~$ ps -ef | grep reddit
rabbitmq 1408 1400 1 02:11 ? 00:00:30 /usr/lib/erlang/erts-5.10.4/bin/beam.smp -W w -K true -A30 -P 1048576 -- -root /usr/lib/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.2.4/sbin/../ebin -noshell -noinput -s rabbit boot -sname rabbit@reddit -boot start_sasl -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/rabbit@reddit.log"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/rabbit@reddit-sasl.log"} -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/lib/rabbitmq/lib/rabbitmq_server-3.2.4/sbin/../plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/rabbit@reddit-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesi
View gist:04a70fe7bf8e444ef37f
vagrant@reddit:~$ set -e
vagrant@reddit:~$ apt_get=/usr/bin/apt-get
vagrant@reddit:~$ ln=/bin/ln
vagrant@reddit:~$ wget=/usr/bin/wget
vagrant@reddit:~$ service=/usr/sbin/service
vagrant@reddit:~$ reddit_run=/usr/local/bin/reddit-run
vagrant@reddit:~$ init_ctl=/sbin/initctl
vagrant@reddit:~$ export REDDIT_USER=vagrant
View gist:a19d198e604c28289299
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: reddit-vagrant_default_1446339977960_21381
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
View gist:b463bc62d0caaf4dcf42
module Celluloid
class Thread < ::Thread
def []= key, value
if key_on_thread? key
thread_vars[key] = value

Keybase proof

I hereby claim:

  • I am barmstrong on github.
  • I am barmstrong ( on keybase.
  • I have a public key whose fingerprint is 04E5 646B 0985 2F02 DBA9 D1B0 F644 1CB3 7764 6F68

To claim this, I am signing this object:

View gist:4200530
<div class="coinbase-button" data-code="818bdfa54c1525d774440edbd267ee60"></div>
<script src="" type="text/javascript"></script>
View faster_fetch.rb
# Another attempt using the built in Rails.cache.fetch (better serialization/deserialization)
class ActiveSupport::Cache::DalliStore
def fast_fetch(name, options=nil)
options ||= {}
name = expanded_key name
dupe_name = name+'_dupe'
if block_given?
unless options[:force]
View gist:3797160
require 'sunspot'
require 'mongoid'
require 'sunspot/rails'
class Post
include Mongoid::Document
field :title
include Sunspot::Mongoid
searchable do
text :title
barmstrong / gist:1323865
Created Oct 28, 2011
processing large csv files in ruby
View gist:1323865
class ZendeskTicketsJob
extend Resque::Plugins::ExponentialBackoff
@queue = :low
FIELDS = ['zendesk_id', 'requester_id', 'assignee_id', 'group', 'subject', 'tags', 'status', 'priority', 'via', 'ticket_type', 'created_at', 'assigned_at', 'solved_at', 'resolution_time', 'satisfaction', 'group_stations', 'assignee_stations', 'reopens', 'replies', 'first_reply_time_in_minutes', 'first_reply_time_in_minutes_within_business_hours', 'first_resolution_time_in_minutes', 'first_resolution_time_in_minutes_within_business_hours', 'full_resolution_time_in_minutes', 'full_resolution_time_in_minutes_within_business_hours', 'agent_wait_time_in_minutes', 'agent_wait_time_in_minutes_within_business_hours', 'requester_wait_time_in_minutes', 'requester_wait_time_in_minutes_within_business_hours', 'reservation_code', 'requires_manual_closing']
def self.perform(url)
`rm /tmp/zendesk_tickets*`
`wget #{url} -O /tmp/`
`unzip -p /tmp/ > /tmp/zendesk_tickets.csv`
barmstrong / gist:1302842
Created Oct 21, 2011
Ruby script to connect to New Relic and turn on our flame lamp!
View gist:1302842
#!/usr/bin/env ruby
## as seen on
THRESHOLD = 1000 # milliseconds
flame_on = false
def log ms, msg
puts "#{} \t #{ms}ms \t #{msg}"