Skip to content

Instantly share code, notes, and snippets.

@karmi
karmi / resque_workers.rake
Created May 11, 2010 16:45
Our Rake task for running multiple Resque workers in production
namespace :queues do
desc "Run Resque workers with options and job classes loaded"
# Run with & appended to daemonize
task :workers => :environment do
def pid_directory
Rails.root.join('tmp', 'pids')
end
# Abstract classes, const_get etc examples for a dev friend
class String
# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/string/inflections.rb#L44-49
def camelize
self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
end
module MyParsers
@karmi
karmi / slingshot.rb
Created February 6, 2011 14:17
Sketch of a Ruby API for ElasticSearch [http://elasticsearch.com]
# Sketch of a Ruby API for ElasticSearch [http://elasticsearch.com]
require 'rubygems'
require 'curb'
require 'rest_client'
require 'yajl/json_gem'
module Slingshot
def http
@karmi
karmi / collection.rb
Created March 8, 2011 11:59
Module which allows to use a proxy class for wrapping collections of all sorts.
# = Collection
#
# Module which allows to use a proxy class for wrapping collections of all sorts.
#
# Let's take a collection of articles, for example (see also the test suite below).
#
# The collection item class could look like this:
#
# class Article
# attr_reader :title
@krisleech
krisleech / README.md
Created February 23, 2012 15:50
A Micro Gem for commenting out lines of Ruby/Erb
hide do          
          _     _     _            
    /\  /(_) __| | __| | ___ _ __  
   / /_/ / |/ _` |/ _` |/ _ \ '_ \ 
  / __  /| | (_| | (_| |  __/ | | |
  \/ /_/ |_|\__,_|\__,_|\___|_| |_|
end
@karmi
karmi / .gitignore
Last active December 24, 2015 14:53
Build a virtual machine with Elasticsearch from scratch with Vagrant
.vagrant
Gemfile.lock
Berksfile.lock
tmp/
@mbostock
mbostock / .block
Last active February 9, 2016 01:56
Accelerate, Then Coast
license: gpl-3.0
@karmi
karmi / post-receive-deploy.rb
Created June 17, 2010 13:21
Example script to deploy a Rails application via Git post-receive hook
#!/usr/bin/env ruby
# Example script to deploy a Rails application via Git post-receive hook
#
# INSTALL
#
# $ curl http://gist.github.com/442106.txt -o post-receive
# $ mv post-receive path/to/to/your/repo.git/hooks/post-receive
# $ chmod +x post-receive
@karmi
karmi / mac_os_setup.sh
Created December 19, 2010 13:43
Installation Instructions For Setting Up A Clean Mac OS X System
# =====================================================
# Installation instructions for a clean Mac OS X system
# =====================================================
#
# <https://gist.github.com/747336>
#
# Keep only `.ssh` and `.profile.local` files from backup
# + Clean up Apple Ruby
#!/usr/bin/env sh
# I've adapted this from the following, which was in turn adapted from the link
# below it:
# * https://raw.github.com/gist/2108403/hack.sh
# * https://github.com/mathiasbynens/dotfiles/blob/master/.osx
echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
# defaults write NSGlobalDomain AppleKeyboardUIMode -int 3