Skip to content

Instantly share code, notes, and snippets.

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(){
@re5et
re5et / grepkill.sh
Created June 7, 2012 20:26
grepkill
#! /bin/bash
case "$1" in
'' | -h | --help)
NOARGS=1 ;;
-d)
DRY=1; FIND=$2 ;;
*)
DRY=0; FIND=$1 ;;
esac
@re5et
re5et / gist:1384314
Created November 21, 2011 23:16
jQuery detach, work, reattach
(function($) {
$.fn.dwr = function(fn){
return this.each(function() {
var $this = $(this);
var tmpElement = $('<div/>');
$(this).after(tmpElement);
$this.detach();
fn.call(this);
tmpElement.replaceWith($this);
});
@re5et
re5et / gist:981235
Created May 19, 2011 17:05
git pre-commit hook to keep console.log out of commited code.
#!/bin/sh
has_console_log=$(git diff --cached | fgrep 'console.log')
if [ "$has_console_log" != "" ]
then
echo "ERROR: You have console.log in your commit. Remove them."
exit 1
fi