Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
module Boolean
end
class TrueClass
include Boolean
end
class FalseClass
include Boolean
end
@deepak
deepak / functions.sh
Created August 28, 2012 05:40 — forked from foca/functions.sh
# cd into a matching gem directory. Pass a grep compatible
# regular expression. If you don't pass anything, it goes
# to the root gem directory.
cdgem ()
{
local gempath=$(gem env gemdir)/gems;
if [[ $1 == "" ]]; then
pushd $gempath;
return;
fi;
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
# hairy and cryptic
def self.set_by
lookup = LOOKUP_CHAIN.each
begin
meth = lookup.next
end while !(locale = send("by_#{meth}", meth) rescue nil);
locale
end
@deepak
deepak / gist:737196
Created December 11, 2010 06:30 — forked from anonymous/gist:734122
forked bcuz it was anonymous (could it be deleted .. dunno)
~/projects/jruby ➔ jmap -histo 19907 | grep rubyobj | head -50
116: 1945 46680 rubyobj.Gem.Version
118: 1898 45552 rubyobj.Gem.Version
120: 1826 43824 rubyobj.Gem.Requirement
123: 1804 43296 rubyobj.Gem.Requirement
158: 914 21936 rubyobj.Gem.Dependency
166: 876 21024 rubyobj.Gem.Dependency
209: 463 11112 rubyobj.Gem.Specification
211: 455 10920 rubyobj.Gem.Specification
319: 142 3408 rubyobj.ActiveSupport.TimeZone
#
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
require 'benchmark'
module Kernel
alias old_require require
def require(path)
#unless caller.find { |caller_line| caller_line.match /dependencies\.rb/ }
# return old_require(path)
#end
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <ilya@igvita.com>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +