Skip to content

Instantly share code, notes, and snippets.

@elvuel
elvuel / gist:1311124
Created October 25, 2011 02:18 — forked from wildjcrt/gist:919198
.profile
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
[[ -s /Users/jcrt/.rvm/scripts/rvm ]] && source /Users/jcrt/.rvm/scripts/rvm
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
@elvuel
elvuel / git_svn_bash_prompt.sh
Created October 27, 2011 02:10 — forked from alexspurling/git_svn_bash_prompt.sh
Update of prompt colours and terminal title
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
# USAGE:
@elvuel
elvuel / 0.md
Created October 28, 2011 09:31 — forked from rstacruz/0.md
JST support for Sinatra

JST Support for Sinatra

Usage

class App < Sinatra::Base
  register 'sinatra/jstsupport'
  serve_jst '/jst.js'
end

This serves all JST files found in /views/**/*.jst.* as /jst.js.

@elvuel
elvuel / error_handler.rb
Created November 4, 2011 09:32 — forked from bdotdub/error_handler.rb
Hoptoad notifier for Sinatra
error do
exception = request.env['sinatra.error']
Hoptoad::Notifier.send_error exception, params, request.env if %w(staging production).include?(ENV['RACK_ENV'])
erb :five_hundred
end
@elvuel
elvuel / 4gb_dev_postgresql.conf
Created December 21, 2011 05:50 — forked from DBNess/4gb_dev_postgresql.conf
tuned /usr/local/var/postgres/postgresql.conf
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
@elvuel
elvuel / person_test.rb
Created January 19, 2012 03:46 — forked from tenderlove/person_test.rb
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
end
@elvuel
elvuel / when-proc.rb
Created January 19, 2012 05:20 — forked from mrb/when-proc.rb
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def am_i_awesome?
@elvuel
elvuel / switch.rb
Created January 19, 2012 05:31 — forked from jbr/switch.rb
ruby 1.9.2 case-like switch
# In response to:
# http://mlomnicki.com/ruby/tricks-and-quirks/2011/02/10/ruby-tricks2.html
# Ruby 1.9.2 has some neat stuff that lets us make a readable
# alternative case statement that calls each method in turn.
# 1.9.2 features used:
# * hashes are ordered in 1.9.2
# * cool JSON-style hash syntax
# * concise lambda syntax
@elvuel
elvuel / ruby-1.9-tips.rb
Created January 19, 2012 06:27 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@elvuel
elvuel / raw_file_upload.rb
Created February 17, 2012 06:02
Paperclip + valums’s file-uploader problem on Heroku
FIXED: See the next file for a working RawFileUpload class.
UPDATE: Heroku uses thin server and I use webrick. When I tried thin on my local machine, it didn't work.
So, the conclusion is there is some difference between webrick and thin that's causing the problem.
This file is related to this blog post:
http://mooooooooooo.wordpress.com/2010/12/03/paperclip-valums%E2%80%99s-file-uploader-and-middleware-continued/
The code in the blog post works fine on my local machine but not on Heroku.