Skip to content

Instantly share code, notes, and snippets.

@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.
@elvuel
elvuel / 1-layout.html
Created February 21, 2012 04:09 — forked from mxriverlynn/1-layout.html
render backbone views with jquery templates
<html>
<head>
<script src="jquery-1.6.1.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="underscore-min.js"></script>
<script src="backbone-min.js"></script>
<script src="example.js"></script>
<style type="text/css">
fieldset {
@elvuel
elvuel / jasmine.yml
Created March 2, 2012 08:09 — forked from juno/jasmine.yml
jasmine initで生成されるjasmine.yml
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
@elvuel
elvuel / eventmachine-fork-example.rb
Created March 6, 2012 13:22 — forked from kwilczynski/eventmachine-fork-example.rb
EventMachine with fork and children ...
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
@elvuel
elvuel / cranking.rb
Created March 6, 2012 13:23 — forked from raggi/cranking.rb
EventMachine.crank
require 'thread'
module EventMachine
module Test
module Utils
module Cranking
# Stolen from MenTaLguYs Omnibus
class Waiter
def initialize