Skip to content

Instantly share code, notes, and snippets.

Work from Spaces

Braden Schaeffer bschaeffer

View GitHub Profile
bschaeffer / main.go
Created Jan 18, 2019
WaitGroup example
View main.go
package main
import (
var wg sync.WaitGroup
bschaeffer / load_test.rb
Last active Sep 26, 2018
Load testing example (producer->consumer pattern)
View load_test.rb
class LoadTest
def initialize(time:, rate:, pool:)
@time = time
@rate = rate
@pool = pool
@requests = []
@started = false
@shutdown = false
@lock =
@cond =
View config.yml
version: 2.0
working_directory: ~/prism
- image: ruby:2.2.4-alpine
- image: percona:5.6.35
bschaeffer / nginx_rails_asset_headers.conf
Created May 12, 2015
View nginx_rails_asset_headers.conf
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
bschaeffer / migration.rb
Last active Dec 15, 2015
Mass update counter cache columns (with Rails references)
View migration.rb
class UpdateCounters < ActiveRecord::Migration
def up
say_with_time 'Updating counter_cache_column for ModelWithColumn' do
ActiveRecord::Base.connection.execute <<-SQL
UPDATE model_with_column
SET counter_cache_column = (
FROM model_with_counter_cache
WHERE model_with_counter_cache.reference =
bschaeffer / just_created.rb
Last active Sep 12, 2015
Rails 4 compatible #just_created?
View just_created.rb
class User < ActiveRecord::Base
attr_accessor :just_created
after_create :set_just_created
def just_created?
bschaeffer / untitled
Created Dec 10, 2014
Apache Bench: Rackspace (Blog+Rails+nginx)
View untitled
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,
Benchmarking (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
View atom-crash.txt
Process: Atom Helper [76665]
Path: /Applications/ Helper
Identifier: com.github.atom.helper
Version: 0.146.0 (0.146.0)
Code Type: X86-64 (Native)
Parent Process: Atom [73996]
Responsible: Atom [73996]
User ID: 501
Date/Time: 2014-11-13 17:06:29.571 -0500
bschaeffer /
Created Sep 18, 2014
Flash to Javascript Callbacks
# Embed the player
swfobject.embedSWF url, 'BIVideoPlayer', width, height, swfVersion, xiSwfUrl,
callback: 'customCallback'
playerId: 'BIVideoPlayer'
# Flash Event Handler
window.customCallback = (event, playerId, data) ->
selector = "#" + playerId
jQuery(selector).trigger(event, data)
bschaeffer /
Last active Aug 29, 2015
Big Interview Feature Attack Zones

Big Interview Feature Attack Zones

Each feature should basically be seen as one task, and we should focus on one task at a time. The sub tasks below each feature are just there to explain total work associated with it.

These are in no particular order.

You can’t perform that action at this time.