Skip to content

Instantly share code, notes, and snippets.

👾
Work from Spaces

Braden Schaeffer bschaeffer

View GitHub Profile
@bschaeffer
bschaeffer / main.go
Created Jan 18, 2019
WaitGroup example
View main.go
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
@bschaeffer
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 = Mutex.new
@cond = ConditionVariable.new
View config.yml
version: 2.0
jobs:
build:
working_directory: ~/prism
docker:
- image: ruby:2.2.4-alpine
- image: percona:5.6.35
environment:
- MYSQL_ROOT_PASSWORD=
@bschaeffer
bschaeffer / nginx_rails_asset_headers.conf
Created May 12, 2015
nginx_rails_asset_headers.conf
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
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 = (
SELECT COUNT(*)
FROM model_with_counter_cache
WHERE model_with_counter_cache.reference = model_with_column.id
)
@bschaeffer
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?
!!just_created
end
private
@bschaeffer
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, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking biginterview.com (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/Atom.app/Contents/Frameworks/Atom Helper.app/Contents/MacOS/Atom 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
bschaeffer / flash.coffee
Created Sep 18, 2014
Flash to Javascript Callbacks
View flash.coffee
# 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
bschaeffer / features.md
Last active Aug 29, 2015
Big Interview Feature Attack Zones
View features.md

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.