This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepMap(obj, fn, that) { | |
var stack = {0: {obj: obj}}, | |
sp = 0, | |
ss = 1, | |
scope, keys, i, val; | |
while ((scope = stack[sp++])) { | |
keys = Object.keys(scope.obj); | |
for (i = 0; i < keys.length; i++) { | |
val = scope.obj[keys[i]]; | |
fn.call(that, val, keys[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TrueXMLHttpRequest = XMLHttpRequest; | |
XMLHttpRequest = function(){ | |
this.status = 0; | |
this.readyState = 0; | |
return this; | |
} | |
XMLHttpRequest.prototype.open = function(meth, uri, asyn){ | |
if(!uri){ | |
throw {}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/ariya/phantomjs.git | |
cd phantomjs | |
git checkout f6abcfe67620f8fdceae89cc4ba0451c37a3ef9d | |
wget https://gist.github.com/m1el/5937163/raw/68f1b1f34296ccf68008c1c0b28bdb1faf3371fe/phantomjs-exec-patch.diff | |
patch -p1 < phantomjs-exec-patch.diff | |
# configure, make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.386 | |
//.model tiny | |
//.code | |
//org 100h | |
function init_graphics() { | |
document.body.appendChild(canvas = document.createElement('canvas')) | |
canvas.width = 640 | |
canvas.height = 480 | |
ctx = canvas.getContext('2d') | |
var data = ctx.getImageData(0,0, 640,480), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_sum(n, s, base=10, startwith=None): | |
startwith = startwith or [] | |
start = int(startwith[0]) if len(startwith) > 0 else -1 | |
if n == 1: | |
if s < base: | |
yield str(s) | |
else: | |
for i in range(max(0, start, s - (n - 1) * (base - 1)), min(s, base - 1) + 1): | |
for sub in gen_sum(n - 1, s - i, base, startwith[1:] if i == start else None): | |
yield str(i) + sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// solver for http://www.dota2.com/quiz | |
setInterval(function() { | |
$.map(g_Solution, function(e) { | |
$('#sourceItems, #recipeItem') | |
.find('div[style*="' + e.img + '"]:not(.disabled):eq(0)') | |
.trigger('mousedown'); | |
}); | |
}, 2500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function astar_path(field, start, end) { | |
start = {x: start.x, y: start.y, cost: 0}; | |
var queue = [start], | |
visited = {}, | |
node; | |
visited[start.x + ':' + start.y] = start; | |
while ((node = queue.shift())) { | |
var neighbors = get_neighbors(field, node); | |
if (get_distance(node, end) === 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m1el@blackninja:~$ strace python -c 'print "hello world"' 2>&1 | wc -l | |
784 | |
m1el@blackninja:~$ strace perl -e 'print "hello world"' 2>&1 | wc -l | |
169 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $x(xpath, root) { | |
root = root ? root : document; | |
try { | |
var nodes = document.evaluate(xpath, root, null, 7, null); | |
} catch(e) { | |
return []; | |
} | |
var result = []; | |
for(var i = 0; i < nodes.snapshotLength; i++) { | |
result[i] = nodes.snapshotItem(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When testing changes, the easiest way to reload the theme is with /RELOAD. | |
# This reloads the configuration file too, so if you did any changes remember | |
# to /SAVE it first. Remember also that /SAVE overwrites the theme file with | |
# old data so keep backups :) | |
# TEMPLATES: | |
# The real text formats that irssi uses are the ones you can find with | |
# /FORMAT command. Back in the old days all the colors and texts were mixed | |
# up in those formats, and it was really hard to change the colors since you |