Skip to content

Instantly share code, notes, and snippets.

View nodirt's full-sized avatar

Nodir Turakulov nodirt

View GitHub Profile
@nodirt
nodirt / classArg.py
Created January 23, 2012 04:59
Constructor as an argument
def mymap(fn, iterable):
for x in iterable:
yield fn(x)
class A(object):
def __init__(self, x):
self.x = x
@nodirt
nodirt / FakeMap.js
Created December 12, 2011 23:29
Indexers in JavaScript
function FakeMap() {
var data = [];
function indexOf(key) {
var i;
for (i = 0; i < data.length; i++) {
if (data[i].key === key) return i;
}
return -1;
}
@nodirt
nodirt / gist:1469584
Created December 12, 2011 23:12
Find lost, unreachable commits
# retrieves commit relative date and message
humanify() {
while read hash; do
# echo to trim the new line
echo $( git log -n 1 ..$hash --format='%ci : %h : %s%n%b' )
done
}
# show the commits!
git fsck --unreachable | grep -oP '(?<=commit )\w+' | humanify | sort