Skip to content

Instantly share code, notes, and snippets.

@silviorelli
silviorelli / config.ru
Created April 8, 2011 10:30
config.ru for using POW Rack server with Rails 2
# Rails.root/config.ru
require "./config/environment"
run ActionController::Dispatcher.new
@tjsingleton
tjsingleton / heroku_env_logger.rb
Created May 12, 2011 15:23
Middleware that logs heroku requests into redis.
require "csv"
class HerokuEnvLogger
PREFIX = "HerokuRequest"
TIME_STEP = 1.minute * 1000 # ms
EXPIRE_IN = 6.hours
KEYS = %w[HTTP_X_REQUEST_START
HTTP_X_HEROKU_QUEUE_WAIT_TIME
HTTP_X_HEROKU_QUEUE_DEPTH
HTTP_X_HEROKU_DYNOS_IN_USE]
@karmi
karmi / elastic_search_ngram_analyzer_for_urls.sh
Created May 24, 2011 15:32
NGram Analyzer in ElasticSearch
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@ericallam
ericallam / gist:1019446
Created June 10, 2011 18:35
How to log all queries for a PostgreSQL homebrew install on OS X

Open the postgresql.conf config file:

$> mate /usr/local/var/postgres/postgresql.conf

Uncomment the line with 'log_destination' and set it to 'syslog'

log_destination = 'syslog'

Open the syslog config:

@jacortinas
jacortinas / app_config.rb
Created July 1, 2011 15:42
Redis Logging
# config/initializers/app_config.rb
# An initializer that contains config stuff
# ...
class RedisConfig < Settingslogic
source "#{Rails.root}/config/redis.yml"
namespace Rails.env
end
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@mihar
mihar / gist:1263820
Created October 5, 2011 06:55
JavaScript equivalent of Array#to_sentence from Rails
Array.prototype.to_sentence = function() {
return this.join(", ").replace(/,\s([^,]+)$/, ' and $1')
}
@grosser
grosser / rails_admin_without_devise.md
Last active July 27, 2016 06:25 — forked from huned/rails_admin_without_devise.md
Using RailsAdmin without devise

Using rails_admin without devise

Add RailsAdmin to your Gemfile

do NOT add devise

gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"

Bundle

@cblunt
cblunt / Gemfile
Created October 21, 2011 08:55
Configure Carrierwave for Amazon S3 Storage and Heroku
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL
@travisjeffery
travisjeffery / .zshrc
Created October 26, 2011 15:17
Automagical Bundle Exec (ZSH)
BUNDLED_COMMANDS=(rails rake rspec ruby sass sass-convert spec spork)
is-bundler-installed()
{
which bundle > /dev/null 2>&1
}
is-within-bundled-project()
{
local dir="$(pwd)"