Skip to content

Instantly share code, notes, and snippets.

@nick-desteffen
nick-desteffen / schedule
Created April 21, 2014 18:15
RailsConf 2014 Schedule
Tuesday
8:00 - Convention Registration - Registration
9:15-10:30 - Sheraton Ballroom - Keynote
10:30-11:00 - Exhibit Hall - Break
11:00-11:40 - Ballroom 5 - Saving the World (literally) with Ruby on Rails
11:50-12:30 - Michigan AB - Rack::Attack: Protect your app with this one weird gem!
12:30-1:40 - Exhibit Hall - Lunch
1:40-12:30 - Ballroom 5 - Distributed Request Tracing
2:30-3:10 - Ballroom 5 - Rack-AMQP: Ditch HTTP inside SOA!
3:20-4:00 - Ballroom 1-3 - Advanced aRel: When ActiveRecord Just Isn't Enough
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@nick-desteffen
nick-desteffen / engineyard.rake
Created September 20, 2011 03:25
EngineYard AppCloud Deployment Script
namespace :engineyard do
@environment = "your_application_production"
@git_tag = "HEAD"
desc "Upload Chef Deploy recipes"
task :upload_chef_recipes => [:environment, :set_eyrc] do
sh "cd ey-cloud-recipes && bundle exec ey recipes upload -e #{@environment}"
end
@nick-desteffen
nick-desteffen / parans_test.rb
Created September 23, 2011 22:24
Parans Test
######
###### Write a function that accepts a string of parenthesis, return true if it is a valid string, false if not.
###### Strings are valid if all parens close, ie: () or (()) or (()()()) are valid, ()), ((), )( etc. would be invalid.
###### An empty string is also valid.
######
require 'test/unit'
def valid_parans(string)
@nick-desteffen
nick-desteffen / rescue_nil_bad.rb
Created March 25, 2012 15:27
Why rescue nil is bad
class Category < ActiveRecord::Base
def ask_question(question)
## Code to check some other system for the answer, Redis or Memcached maybe.
raise "System is unavailable, you should turn it on"
end
end
params = {category_id: 1, question: "Why did the quick brown fox jump over the lazy dog?"}
@nick-desteffen
nick-desteffen / rescue_nil_bad_fixed.rb
Created March 25, 2012 15:35
Why rescue nil is bad - fixed
class Category < ActiveRecord::Base
def ask_question(question)
begin
## Code to check some other system for the answer, Redis or Memcached maybe.
raise "System is unavailable, you should turn it on"
rescue Exception => e
## Do something with exception
puts "System is unavailable"
return nil
@nick-desteffen
nick-desteffen / nginx.conf
Created September 23, 2012 15:42
Nginx Upstart script
# nginx
description "nginx http daemon"
author "George Shammas <georgyo@gmail.com>"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/opt/nginx/sbin/nginx
env PID=/var/run/nginx.pid
@nick-desteffen
nick-desteffen / .gitignore
Created November 13, 2012 04:36 — forked from pcdinh/.gitignore
fabfile to deploy flask app to nginx/supervisor/uwsgi stack
.idea/*
*.pyc
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db