Skip to content

Instantly share code, notes, and snippets.

View cookrn's full-sized avatar
👻

Ryan Cook cookrn

👻
View GitHub Profile
@cookrn
cookrn / install.bash
Created February 28, 2012 02:02
Simple Bash Script To Bootstrap Ubuntu Server
#!/bin/bash
## README
# To run this script
# => scp it to the server
# => run `sudo bash install.bash`
# Preparations
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list # MongoDB Prep
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 # MongoDB Prep
@cookrn
cookrn / rake.zsh
Created February 19, 2012 20:43
Run rake with environment properly loaded
#!/usr/bin/env zsh
rvm-shell "ruby-1.9.3-p0" -c "foreman run bundle exec rake "$argv
@cookrn
cookrn / app.js
Created December 26, 2011 20:18
Push to Resque Queue from Node
require( './boot' );
var DbItem = require( './db_item' )
, item = new DbItem( '123456abcdefg' );
item.queue( function( error , response ){
console.log( 'Response: ' + response );
process.exit();
} );
@cookrn
cookrn / Gemfile
Created December 12, 2011 22:29
Sample RBX Error Output
source :rubygems
gem "sinatra"
group :development do
gem "foreman"
end
# HOLE 1
#
# Given a number the function returns “Fizz” if it is a multiple of 3,
# “Buzz” if it is a multiple of 5 and “FizzBuzz” if it is a multiple of
# 15. If the number is not a multiple of 3 or 5 then the number is
# returned as a string.
# Original answer
def fizzbuzz( n )
b,m="Buzz",n%5==0;n%3==0?"Fizz#{b if m}":m ?b:n
@cookrn
cookrn / core.clj
Created July 27, 2011 18:02
Your First Clojure Web App
(ns myfirstwebapp.core)
(defn app [req]
{:status 200
:headers {"content-Type" "text/html"}
:body "Hello World!"})
@cookrn
cookrn / config.ru
Created June 10, 2011 20:39
Rack 1.3.0 & Serving Static Files
# Set Our Root Path
::ROOT = File.dirname( File.expand_path( __FILE__ ) )
# Boot The App
require "#{ROOT}/config/boot.rb"
# Serve our index file by default
use Rack::Static , :urls => { "/" => "index.html" } , :root => "public"
# Setup Rack
@cookrn
cookrn / other_resource_presenter.rb
Created May 3, 2011 18:51
Presenters As A Solution To as_json Woes In Rails APIs
# app/presenters/api/v1/other_resource_presenter.rb
class Api::V1::OtherResourcePresenter
attr_reader :other_resource
def initialize( other_resource )
@other_resource = other_resource
end
def as_json( include_root = false )
@cookrn
cookrn / error.out
Created April 30, 2011 21:11
Cinderella Error
INFO: Installing homebrew[git] version 1.7.5
[Sat, 30 Apr 2011 15:08:58 -0600] ERROR: script[updating homebrew from github] (/Users/ryancook/.cinderella/cookbooks/homebrew/recipes/default.rb:59:in `from_file') had an error:
"bash" "/var/folders/qA/qA-aECR1F4GtR+JLdwoQe++++TI/-Tmp-/chef-script20110430-6842-1e4llqv-0" returned 1, expected 0
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/mixin/command.rb:184:in `handle_command_failures'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/mixin/command.rb:131:in `run_command'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/provider/execute.rb:49:in `action_run'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/provider/script.rb:33:in `action_run'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/resource.rb:395:in `send'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/resource.rb:395:in `run_action'
/Library/Ruby/Gems/1.8/gems/chef-0.9.16/bin/../lib/chef/runner.rb:53:in `run_action'