Skip to content

Instantly share code, notes, and snippets.

Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@jwang
jwang / gist:3363574
Created August 15, 2012 20:54 — forked from ambar/gist:1534274
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@jwang
jwang / env.rb
Created September 8, 2011 08:11 — forked from bmabey/env.rb
how to get spork working for cucumber in a rails app
require 'rubygems'
require 'spork'
Spork.prefork do
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'webrat'
@jwang
jwang / gist:1189621
Created September 2, 2011 19:29 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Senior Software Engineer
Favorite Python project: Etsy's StatsD - https://github.com/etsy/statsd
Favorite Conference: Google I/O
Python Experience Level: Beginner
@jwang
jwang / EGOCache.h
Created May 5, 2011 07:35 — forked from enormego/EGOCache.h
Caching for Objective-C/iPhone -- All new updates will be here: http://github.com/enormego/EGOCache
//
// EGOCache.h
// enormego
//
// Created by Shaun Harrison on 7/4/09.
// Copyright 2009 enormego. All rights reserved.
//
#import <Foundation/Foundation.h>
//
// EGOTitledTableViewCell.h
// EGOClasses
//
// Created by Shaun Harrison on 6/2/09.
// Copyright 2009 enormego. All rights reserved.
//
#import <UIKit/UIKit.h>
require 'openid'
require 'net/http'
require 'appengine-apis/urlfetch'
class MyFetcher < OpenID::StandardFetcher
def fetch(url, body=nil, headers=nil, redirect_limit=REDIRECT_LIMIT)
raise OpenID::FetchingError, "Blank URL: #{url}" if url.blank?
headers ||= {}
headers['User-agent'] ||= USER_AGENT

The DeferredDispatcher is a way to get around the 30-second limit for App Engine requests. We don't want spin-up to be a "show stopper", and we want every request to have a full 30 seconds to do "real work". We added this to appengine-rack 0.0.7, so folks won't need an additional require. The DeferredDispatcher works by using redirects to break up a loading request into 3 parts.

  1. initialize the jruby runtime and jruby-rack
  2. require the framework, and create a new dispatcher
  3. process the real request, with a full 30 seconds

We are inside jruby-rack, so obviously the runtime and Jruby-rack have initialized, so first we set @runtime to true (from nil) and redirect. Next pass, we notice that the @rack_app is nil, so we require the framework (which can take some time) and create a new dispatcher (these have been passed in as a hash) and redirect. In the final pass, we hand the environment to the dispatcher, to do the original "work" of the request.