Skip to content

Instantly share code, notes, and snippets.

View mohnish's full-sized avatar

Mohnish Thallavajhula mohnish

View GitHub Profile
@mohnish
mohnish / example.js
Created August 1, 2013 05:17 — forked from tj/example.js
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
alias gd="git diff"
alias gc="git clone"
alias ga="git add"
alias gbd="git branch -D"
alias gst="git status"
alias gca="git commit -a -m"
alias gpt="git push --tags"
alias gp="git push"
alias gpr="git pull-request"
alias grh="git reset --hard"
@mohnish
mohnish / bash
Created August 5, 2013 18:18 — forked from tj/bash
#!/usr/bin/env bash
repo=$1
rm -fr /tmp/gpm \
&& mkdir /tmp/gpm \
&& cd /tmp/gpm \
&& curl -#L https://github.com/$repo/tarball/master \
| tar zx --strip 1 \
&& make install
@mohnish
mohnish / .zshrc
Created October 2, 2013 05:10 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@mohnish
mohnish / type.js
Created November 6, 2013 14:00 — forked from jonbretman/type.js
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
# In the model
class Foo < ActiveRecord::Base
default_scope Hash.new {|hash, key| key == :conditions ? {:baz => I18n.locale.to_s } : nil }
named_scope :bar, lambda { { :conditions => { :bar => 1..10 } } }
end
# In action
ree-1.8.7-2010.02 > I18n.locale = 'fr'
=> "fr"
ree-1.8.7-2010.02 > Foo.bar
@mohnish
mohnish / example.js
Created January 23, 2014 05:49 — forked from tj/example.js
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);