Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
case "$1" in
'' | -h | --help)
NOARGS=1 ;;
-d)
DRY=1; FIND=$2 ;;
*)
DRY=0; FIND=$1 ;;
esac
@re5et
re5et / git_repo_sync.sh
Created March 7, 2013 01:26
git repo sync
#! /usr/bin/env bash
checkout_dir=$1
from_remote=$2
to_remote=$3
cd $checkout_dir
(defun prettify-json ()
"NOTE: requires ruby in $PATH. Replace a valid json region with
pretty printed json By default uses the jj method to print,
uses pp if there is a prefix argument"
(interactive)
(let* ((print-method (if current-prefix-arg "pp" "jj"))
(cmd (format
"ruby -e 'require \"json\"; require \"pp\"; %s JSON.parse(gets)'" print-method)))
(shell-command-on-region
(region-beginning)
Namespaced = {}
class Foo
constructor: ->
@property = 'i am Foo'
class Namespaced.Foo
constructor: ->
class Foo
# always works
def read_instance_property
bar
end
# assigns thing, but not Foo instance thing
def write_instance_property
thing = 'baz'
@re5et
re5et / magit-quick-stash.el
Created January 31, 2013 23:31
magit quick stash
(defun magit-quick-stash ()
"Immediately stash with mesage
WIP on branchname: short-sha commit-message"
(interactive)
(magit-stash ""))
(add-hook
'magit-status-mode-hook
(lambda ()
@re5et
re5et / gist:4550500
Created January 16, 2013 20:18
Make magit not alter the branch name you are checking out when creating a local tracking branch.
;; M-x customize-variable RET magit-default-tracking-name-function RET
;; Set "other" to magit-tracking-name-unfucked-with
(defun magit-tracking-name-unfucked-with (remote branch)
branch)
@re5et
re5et / gist:3042846
Created July 3, 2012 20:29
jquery little bit lazier map / collect method
(function($){
$.collect = function(){
var selector = arguments[0];
var fn = arguments[1];
var arg = arguments[2];
var collected = [];
$(selector).each(function(){
value = arg ? $(this)[fn](arg) : $(this)[fn]();
collected.push(value);
});
@re5et
re5et / gist:3041583
Created July 3, 2012 18:23 — forked from davidmfoley/gist:3041435
Object Before / After differ.
var Differ = function(obj){
this.obj = obj;
};
Differ.prototype.cacheVars = function(){
this.cache = {};
for(var prop in this.obj){
this.cache[prop] = this.obj[prop];
}
};
@re5et
re5et / gist:3036720
Created July 3, 2012 01:00
JavaScript Window global var differ.
var GlobalVars = function(){};
GlobalVars.prototype.cacheVars = function(){
this.cache = {};
for(var prop in window){
this.cache[prop] = window[prop];
}
};
GlobalVars.prototype.diff = function(){