This file contains 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 'benchmark' | |
class CottonThread | |
attr_reader :threads, :procs | |
def initialize | |
@threads, @procs = [], [] | |
end | |
def sow(proc) |
This file contains 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 'ostruct' | |
data = [] | |
data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => nil) | |
data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => 50) | |
data << OpenStruct.new(:city => 'London', :qtr => 1, :sales => 50) | |
data << OpenStruct.new(:city => 'London', :qtr => 2, :sales => 200) | |
data << OpenStruct.new(:city => 'London', :qtr => 3, :sales => 300) | |
data << OpenStruct.new(:city => 'London', :qtr => 4, :sales => 400) |
This file contains 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
namespace :db do | |
namespace :data do | |
desc "Dump data into sql script file: filename=[target filename]" | |
task :dump => 'environment' do | |
environment = (ENV.include?("RAILS_ENV")) ? (ENV["RAILS_ENV"]) : 'development' | |
ENV["RAILS_ENV"] = RAILS_ENV = environment | |
database = get_database(environment) | |
user = database | |
password = ENV['PASSWORD'] |
This file contains 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
#!/usr/bin/env ruby | |
unless ARGV.count >= 2 | |
puts "Please provide two files to perform diff..." | |
exit | |
end | |
def load_file file | |
arr = File.readlines(file).map(&:chomp).compact | |
arr.shift if arr.first =~ /^#/ |
This file contains 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
upstream app { | |
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name www.app.com; | |
rewrite ^/(.*) http://app.com/$1 permanent; | |
} | |
server { |
This file contains 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
gource -1280x720 -o - --title "VZ-APP" --hide date,filenames,mouse --start-date '2014-08-01 00:00:01' --disable-bloom --logo app/assets/images/homepage/play_symbol.png --auto-skip-seconds 1 --seconds-per-day 0.25 --start-position 0.7 --font-size 6 | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4 | |
gource -768x540 -o - --title "VZ-APP" --start-date '2014-08-01 00:00:01' --disable-bloom --logo app/assets/images/homepage/play_symbol.png --auto-skip-seconds 1 --seconds-per-day 0.5 --font-size 6 | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4 | |
hide options: bloom,date,dirnames,files,filenames,mouse,progress,tree,users,usernames | |
This file contains 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
# .memcached-dump.macdots_function | |
# mac-dots custom function | |
# requires mac-dots version >= 0.7.5 | |
# https://gist.github.com/edjames/9d5681d608b302dba855 | |
# Usage: | |
# $> memcached-dump | |
memcached-dump() { |
This file contains 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
class MultiCache | |
include Singleton | |
attr_reader :rails_cache, :custom_cache | |
def initialize | |
@rails_cache = Rails.cache | |
@custom_cache = ActiveSupport::Cache::MemCacheStore.new( | |
'your-cache-ip-address', :namespace => 'rails4-namespace') | |
end |
This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am edjames on github. | |
* I am grokling (https://keybase.io/grokling) on keybase. | |
* I have a public key whose fingerprint is 8186 635A FD92 0FFF 896F D1B8 A55F 2A0A 4CF6 1080 | |
To claim this, I am signing this object: |
This file contains 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
#!/bin/bash | |
echo "-------------------------------" | |
echo "Starting user-data execution..." | |
echo "-------------------------------" | |
cd /root | |
# | |
# Setup swap for better performance |
OlderNewer