Skip to content

Instantly share code, notes, and snippets.

View yrgoldteeth's full-sized avatar

Nicholas Fine yrgoldteeth

View GitHub Profile
<div class='posts'>
<ul class='posts'>
require 'rubygems'
require 'sinatra'
set :public, Proc.new { File.join(root, "_site") }
# This before filter ensures that your pages are only ever served
# once (per deploy) by Sinatra, and then by Varnish after that
before do
response.headers['Cache-Control'] = 'public, max-age=31557600' # 1 year
end
# Neat litle sinatra app that allows hosting of static sites
# on heroku. I don't remember where I found this, but thanks
# if you're out there.
require 'rubygems'
require 'sinatra'
set :public, Proc.new { File.join(root, "_site") }
# This before filter ensures that your pages are only ever served
# once (per deploy) by Sinatra, and then by Varnish after that
:markdown
# #{underwriter_initials} Adverse Action Letter
#### #{notice_date}
#### #{first_name} #{last_name}
#### #{applicant_address_1}
#### #{applicant_address_2}
#### #{applicant_city}, #{applicant_state} #{applicant_zip}
Dear Applicant:
# I want this method in ruby-core
def let
yield
end
def fib(i)
let do |n = 1, result = 0|
if i == -1
result
else
class Hash
# Return a new hash with all keys converted to camelcase
def camelize_keys
dup.camelize_keys!
end
# Destructively convert all keys to camelcase
def camelize_keys!
keys.each do |key|
@yrgoldteeth
yrgoldteeth / .bashrc
Created April 26, 2011 16:10
my .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
@yrgoldteeth
yrgoldteeth / aliases
Created April 26, 2011 16:11
aliases
#directory stuff
alias la='ls -a'
alias ll='ls -l'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ~='cd ~'
@yrgoldteeth
yrgoldteeth / elite
Created April 26, 2011 16:12
bash prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function elite
{
local GRAY="\[\033[1;30m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local CYAN="\[\033[0;36m\]"
# **Whereabouts** is a Rails plugin that generates a polymorphic, inheritable
# Address model. Install it as a Rails plugin (Rails 3.x+ required)
#
# rails plugin install http://github.com/yrgoldteeth/whereabouts.git
#
# The most simple use case creates a has_one relationship with
# a generic Address:
#
# class Foo < ActiveRecord::Base
# has_whereabouts