This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First extend ActiveRecord::Base to allow us to override connections | |
module ActiveRecord | |
class Base | |
# Sets the active connection to conn and runs the given block. Active | |
# connection is reset to it's previous value once the block finishes. | |
def self.using_connection(conn) | |
old_connection = use_connection(conn) | |
ret = yield if block_given? | |
use_connection(old_connection) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# apache tuned to just exhaust memory under load with mri | |
# | |
# ree shows system savings of ~60 MB over mri with 4 concurrent requests under light load | |
# for approx 23% decrease in memory usage | |
# | |
# free/swap idle -- 272008 / 30288 | |
# free/swap ree -- 71812 / 30288 | |
# free/swap idle -- 271748 / 30284 | |
# free/swap mri -- 12908 / 32324 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## monit.d/memcached.monitrc | |
check process memcached | |
group memcached | |
with pidfile /var/run/memcached/memcached.pid | |
start program = "/etc/init.d/memcached start" | |
stop program = "/etc/init.d/memcached stop" | |
if failed port 11211 4 times within 5 cycles then restart | |
if 4 restarts within 5 cycles then timeout | |
depends on memcached_bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CTGW | |
class Application < Sinatra::Base | |
helpers do | |
def protect! | |
unless authorized? | |
response['WWW-Authenticate'] = %(Basic realm="ClearTool Remote Gateway") | |
response['Content-Type'] = 'application/x-yaml' | |
halt [401, CTGW::Response.new( | |
:status => 'error', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source /Users/reinh/.screenrc | |
# Default screens | |
split | |
screen -t autospec 1 ./script/autospec | |
focus | |
screen -t shell1 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.resources :teams, :member => {:review => :get, :completed => :any, :disqualify => :put, :post_receive_hook => :post}, | |
:collection => {:statistics => :get, :dashboard => :get, :search => :get} do |team| | |
team.resources :invites, :controller => 'team_invites' | |
team.resources :comments, :controller => 'comments' | |
team.resources :verification_results, :as => 'verification-results', :only => [:index, :show, :create] | |
team.resources :members, :controller => 'teams', :only => [:destroy] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter' | |
# You'll need to get this info from your Twitter Developer account | |
Twitter.configure do |config| | |
config.consumer_key = YOUR_CONSUMER_KEY | |
config.consumer_secret = YOUR_CONSUMER_SECRET | |
config.oauth_token = YOUR_OAUTH_TOKEN | |
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### app/assets/javascripts/foo.js.coffee | |
Foo = | |
bar: -> | |
"baz" | |
# Have to add this to get Foo into the global namespace | |
# so Jasmine tests can see it | |
window.Foo = Foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simplified representation of source data | |
data = ["A", "B", "B", "A", "C", "A", "D"] | |
Stream.transform(data, "", fn(line, acc) -> | |
if line == "A" do | |
if acc == "", do: {[], line}, else: {[acc], line} | |
else | |
{[], acc <> line} | |
end | |
end) |> Enum.to_list | |
# Desired: ["ABB", "AC", "AD"] |