Skip to content

Instantly share code, notes, and snippets.

irb(main):016:0> ThinkingSphinx.search 'test', :classes => [Article, BlogPost]
Sphinx Querying: 'test'
Sphinx (0.004608s) Found 20 results
Article Load (0.5ms) SELECT `emp_articles`.* FROM `emp_articles` WHERE (`emp_articles`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
(Object doesn't support #inspect)
=>
irb(main):017:0>
@vwall
vwall / tpl-cukeapp.rb
Created May 17, 2011 03:30 — forked from paulmars/template.rb
Rails 3, RSpec, Cucumber, Factory_Girl, HAML, SASS, Devise, Formtastic Template
## Rails App Template
## Updated for Rails 3.0.7
## Created on 10/23/10
## Updated on 5/7/11
## Run using $ rails new [appname] -JT -m tpl-cukeapp.rb
## Gems
# Warden and Devise for security
gem 'warden', '1.0.4'
@vwall
vwall / USAGE.md
Created June 4, 2011 08:56 — forked from kossnocorp/USAGE.md
MacVim with Drawer compile manual

Clone & Build

curl https://gist.github.com/raw/970438/caff9a09ed2d223b1123a69ede17cb19ad352af9/build.sh | sh
@vwall
vwall / gist:1130130
Created August 7, 2011 06:31 — forked from dkubb/gist:1130086
case with predicates
require 'rubygems'
require 'backports' # aliases Proc#=== to Proc#call
rs = (0..10000).to_a.sample(30)
rs.each do |r|
case r
when lambda { |n| n.zero? } then puts "#{r} is zero"
when lambda { |n| (n % 5).zero? } then puts "#{r} is fiven"
when lambda { |n| (n % 4).zero? } then puts "#{r} is fourven"
@vwall
vwall / new.rb
Created August 14, 2011 04:18 — forked from jferris/new.rb
New FactoryGirl definition syntax
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password "test"
aliased_as :author
end
@vwall
vwall / gist:1144716
Created August 14, 2011 08:47 — forked from ZhangHanDong/gist:1033906
MongoId Counter Cahce
#
# lib/mongoid/counter_cache.rb
# ruby
#
# Created by Zhang Alex on 2011-06-17.
# Copyright 2011 __ZhangHanDong__. All rights reserved.
#
# ===================================
# class Forum
# references_many :topics
@vwall
vwall / gist:1191752
Created September 3, 2011 20:37
Convert iterm2.plist to xml
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist /tmp/
$ plutil -convert xml1 /tmp/com.googlecode.iterm2.plist
$ vi /tmp/com.googlecode.iterm2.plist # ... do whatever you want
You can convert it back to a binary file with
$ plutil -convert binary1 FILENAME
@vwall
vwall / tired.rb
Created September 24, 2011 17:48 — forked from karmi/tired.rb
Template for generating a no-frills Rails application with support for ElasticSearch full-text search via the Tire gem
# ===================================================================================================================
# Template for generating a no-frills Rails application with support for ElasticSearch full-text search via Tire
# ===================================================================================================================
#
# This file creates a basic, fully working Rails application with support for ElasticSearch full-text search
# via the Tire gem [http://github.com/karmi/tire].
#
# You DON'T NEED ELASTICSEARCH INSTALLED, it is installed and launched automatically by this script.
#
# Requirements
@vwall
vwall / Gemfile
Created October 3, 2011 23:27
How to setup Compass Twitter Bootstrap
group :assets do
gem 'sass-rails', ">= 3.1"
gem 'coffee-rails', ">= 3.1"
gem 'uglifier'
gem "compass", ">= 0.12.alpha.0"
gem 'compass_twitter_bootstrap'
end
@vwall
vwall / bootstrap.sh
Created October 27, 2011 05:23 — forked from knzconnor/bootstrap.sh
An example bash bootstrap to get workstation set-up with chef - update YOUR_ORG below
#!/usr/bin/env sh
#After forking and editing YOUR_ORG to point at the right repo can be run via:
#bash <(curl -s https://raw.github.com/gist/THEIDOFYOURFORKEDGIST)
#if you use `curl xxx | sh` input will be messed up and there will be no pauses
#I keep XCode and gcc on a thumbdrive along with java, for speeding things up
#http://support.apple.com/downloads/DL1421/en_US/JavaForMacOSX10.7.dmg
read -p "Install XCode or gcc (http://github.com/kennethreitz/osx-gcc-installer)"
#setup your ssh keys for github