Skip to content

Instantly share code, notes, and snippets.

@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 / dig.rb
Created March 2, 2012 01:29
ruby hash dig
class Hash
def dig(*path)
path.inject(self) do |location, key|
location.is_a?(Hash) ? location[key] : nil
end
end
end
@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
@re5et
re5et / test
Created May 6, 2011 03:00
a test gist
revision 3
@re5et
re5et / gist:863259
Created March 9, 2011 23:42
change_source_images_collection_name.rb
class ChangeSourceImagesCollectionName < Mongoid::Migration
def self.up
collection = connection.collection('source_images')
collection.rename('imagickals')
end
def self.down
collection = connection.collection('imagickals')
collection.rename('source_images')
end
(defun next-instance-of()
"Find next instance of current word."
(interactive)
(let (myStr)
(setq myStr (thing-at-point 'word))
(search-forward myStr)
(backward-word)
))
(defun previous-instance-of()