Skip to content

Instantly share code, notes, and snippets.

View chris's full-sized avatar
🏠
Working from home

Chris Bailey chris

🏠
Working from home
View GitHub Profile
@chris
chris / rails_resources.md
Created April 26, 2014 22:48 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@chris
chris / 0_reuse_code.js
Created April 26, 2014 22:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chris
chris / fizzbuzz.exs
Created December 5, 2013 02:10
FizzBuzz in Elixir (one of the many ways to do it). From the PragProg book.
defmodule FizzBuzz do
def upto(n) when n > 0, do: 1..n |> Enum.map(&fizzbuzz/1)
defp fizzbuzz(n) when rem(n,3) == 0 and rem(n,5) == 0, do: "FizzBuzz"
defp fizzbuzz(n) when rem(n,3) == 0, do: "Fizz"
defp fizzbuzz(n) when rem(n,5) == 0, do: "Buzz"
defp fizzbuzz(n), do: n
end
FizzBuzz.upto(100) |> Enum.join(" ") |> IO.puts
@chris
chris / eydeploy.rb
Last active December 24, 2015 01:29
Prevent Engine Yard deploy process' symlink of shared/config files from traversing subdirectories
def symlink_tasks
super.map do |task|
if task.first == 'Symlink other shared config files'
[task[0], task[1].sub(/-type/, '-maxdepth 1 -type')]
else
task
end
end
end
@chris
chris / db_table_sizes.sql
Created August 24, 2012 17:34
Calculate DB table sizes/data use
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 20
#
# Block particular IP addresses from our API
#
location ~ ^/api/ {
# A Kayak IP address we saw running through each of our cities
deny 209.104.235.1;
#deny 207.86.76.138;
}
@chris
chris / gist:1280470
Created October 12, 2011 06:47
rubygems error
/usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:539:in `normalize_yaml_input': invalid byte sequence in US-ASCII (ArgumentError)
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:479:in `from_yaml'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:190:in `load_gemspec'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:54:in `block in initialize'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:64:in `block in each'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `loop'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:55:in `each'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:35:in `initialize'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:20:in `new'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:20:in `open'
@chris
chris / nodejs_recipe.rb
Created May 13, 2011 05:55
Chef recipe to install node.js on Engine Yard AppCloud
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Build and install node.js
#
if ['app','app_master','solo'].include?(node[:instance_role])
version_tag = "v0.4.8"
source_base_dir = "/data/nodejs"
@chris
chris / gist:969685
Created May 12, 2011 23:39
ffi gem install fail
[chris@dealbase hotelstonight (html5 *)]$ bundle update ffi
Updating git://github.com/ffi/ffi.git
Fetching source index for http://rubygems.org/
Could not find gem 'ffi (>= 0, runtime)' in git://github.com/ffi/ffi.git (at 2a2c034).
Source does not contain any versions of 'ffi (>= 0, runtime)'
@chris
chris / gist:924829
Created April 18, 2011 04:45
EY chef deploy fail
[Sun, 17 Apr 2011 21:40:19 -0700] INFO: Starting Chef Solo Run
/etc/chef-custom/recipes/cookbooks/mongodb/attributes/recipe.rb:8:in `from_file': undefined method `[]' for nil:NilClass (NoMethodError)
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook.rb:73:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook.rb:71:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook.rb:71:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/compile.rb:61:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook_loader.rb:107:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook_loader.rb:106:in `each_value'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook_loader.rb:106:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/c