Skip to content

Instantly share code, notes, and snippets.

View minhajuddin's full-sized avatar
⌨️
Beep boop, beep boop

Khaja Minhajuddin minhajuddin

⌨️
Beep boop, beep boop
View GitHub Profile
# Taken from passenger_memory_stats script
# Returns the private dirty RSS for the given process, in KB.
def determine_private_dirty_rss(pid)
total = 0
File.read("/proc/#{pid}/smaps").split("\n").each do |line|
line =~ /^(Private)_Dirty: +(\d+)/
if $2
total += $2.to_i
end
@bitzesty
bitzesty / enviroment.rb
Created December 26, 2009 23:20
rails metal to be used with carrierwave (gridfs) and MongoMapper
config.metals = ["Gridfs"]
@atmos
atmos / lojack-proxy.god.rb
Created November 13, 2010 03:05
god configs for camo.
God.watch do |w|
w.uid = "git"
w.gid = "git"
w.name = "camo"
w.pid_file = "/data/camo/tmp/camo.pid"
w.interval = 30.seconds
w.env = {
"PORT" => '8080',
"CAMO_KEY" => '0x24FEEDFACEDEADBEEFCAFE'
@pwim
pwim / dateinput_converter.js
Created November 19, 2010 06:21
Convert Rails style date input to jQuery Tools' dateinput
// Based on http://snipt.net/boriscy/datetime-jquery-formtastic/
$.tools.dateinput.localize("ja", {
months: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月',
shortMonths: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月',
days: '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日',
shortDays: '日,月,火,水,木,金,土'
});
$.tools.dateinput.conf.format = 'yyyy-mm-dd';
@minhajuddin
minhajuddin / post-receive-hook.rb
Created December 10, 2010 09:48
Post receive hook for git syncing
#!/usr/bin/env ruby
class Sync
def initialize(gitpart)
@from, @to, @ref = gitpart.split
@branch = @ref.split('/').last
end
def exec
@minhajuddin
minhajuddin / README.md
Created September 9, 2011 03:26
Rails initial setup checklist

Checklist for a rails app

  • Is email setup properly
  • New relic setup to recieve errors, performance stats, availability check.
  • Exception mailer wired up for exceptions
  • Wire up a settings library ( https://github.com/viatropos/cockpit or https://github.com/wycats/moneta or a simple settings file )
  • Wireup a few basic initializers containing extension methods for Strings, Time etc,. (create a gem for this?)
  • Setup capistrano
  • Setup foreman (with upstart export templates)
  • Setup logrotate for the production.log
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@etrepum
etrepum / gist:2655724
Created May 10, 2012 20:36
Cowboy graceful acceptor shutdown
-export([graceful_stop/1, graceful_stop_proc/1]).
graceful_stop(Timeout) ->
lists:foreach(fun stop_listener/1, supervisor:which_children(cowboy_sup)),
proc_lib:spawn(?MODULE, graceful_stop_proc, [Timeout]).
graceful_stop_proc(Timeout) ->
true = register(graceful_stop, self()),
lager:critical("SHUTDOWN with timeout of ~p msec", [Timeout]),
TRef = erlang:start_timer(Timeout, self(), not_so_graceful),
@rmw
rmw / hash.rb
Created May 16, 2012 13:50
Extend Ruby Hash with method to return a recursive OpenStruct
class Hash
# options:
# :exclude => [keys] - keys need to be symbols
def to_ostruct_recursive(options = {})
convert_to_ostruct_recursive(self, options)
end
private
def convert_to_ostruct_recursive(obj, options)
result = obj

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)