This file contains hidden or 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
#!/bin/sh | |
filename=$(basename $1) | |
outputdir=$(dirname $1) | |
tempdir=$(mktemp -d -t 'png') | |
tempfile1="$tempdir/$filename" | |
tempfile2=$(mktemp -t 'png') | |
outputfile="$outputdir/$filename" | |
pngnq -f -e '.png' -d $tempdir $outputfile && |
This file contains hidden or 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 toAscii(src) { | |
var ch, str, i, result = ''; | |
// `str` should now be 'double-escaped' e.g. a newline in the | |
// original `src` should be represented by '\\n' in `str` | |
str = JSON.stringify(str); | |
// we start from str[1] and stop at str[-1] to | |
// drop the opening and closing quote marks when | |
// using JSON.stringify |
This file contains hidden or 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
#!/usr/bin/python | |
import sys | |
from optparse import OptionParser | |
from lxml import html | |
from lxml.cssselect import CSSSelector | |
from lxml.etree import XPath | |
def main(): | |
parser = OptionParser(description="Select elements from an html file with css selectors", |
This file contains hidden or 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
// This is a port of an old scheme implementation of a Mathematica style 'Take' function | |
// (https://gist.github.com/379285) | |
// | |
// It takes the same arguments documented here: http://reference.wolfram.com/mathematica/ref/Take.html | |
// | |
// `take(arr, n);` returns the first `n` elements of `arr` | |
// `take(arr, -n);` returns the last `n` elements of `arr` | |
// `take(arr, [m, n]);` returns elements `m` through `n` of `arr` | |
// `take(arr, pat1, pat2, ...)` gives a nested array in which elements specified by `pat-i` are | |
// taken at level i in arr |
This file contains hidden or 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 assert = require('assert'), | |
toBytes = require('./utf8.js').toBytes, | |
toUTF8Bytes = require('./utf8.js').toUTF8Bytes, | |
fromUTF8Bytes = require('./utf8.js').fromUTF8Bytes; | |
assert.deepEqual(toBytes(0x0), [0]); | |
assert.deepEqual(toBytes(0xff), [0xff]); | |
assert.deepEqual(toBytes(0x01ff), [0x01, 0xff]); | |
assert.deepEqual(toBytes(0xffff), [0xff, 0xff]); |
This file contains hidden or 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 cleanString(str, method, r) { | |
var result = '', | |
max = str.length, | |
i, ch; | |
for (i = 0; i < max; i++) { | |
ch = str.charCodeAt(i); | |
if (ch < 128) { | |
result += str.charAt(i); |
This file contains hidden or 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
// Simple recursive pattern matching | |
// ================================= | |
// | |
// The provided `match` function matches recursively against | |
// javascript values, and returns a set of bindings made against | |
// the source. | |
// | |
// in these examples `match._` is aliased as `_`. | |
// | |
// `match(_, data)` succeeds |
This file contains hidden or 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
require(["src/Color"], function (Color) { | |
var getContext, runTests, width = 150, height = 150; | |
getContext = function (width, height) { | |
var c = document.createElement('canvas'); | |
c.width = width; | |
c.height = height; | |
return c.getContext('2d'); | |
}; |
This file contains hidden or 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
#!/bin/sh | |
# uglifyjs as a beautifier https://github.com/mishoo/UglifyJS | |
# install with npm, `npm install -g uglifyjs` | |
uglifyjs --beautify --no-squeeze --no-mangle "$*" |
This file contains hidden or 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
// Me circa April 2009 | |
Array.implement({ | |
"collect": function collect(fn, bind) { | |
// fn.calls that throw an exception are | |
// excluded and the index is not incremented | |
// so that it's like they were never there. | |
// can be used instead of a.map( ... ).filter( ... ) | |
// -------------------------------------------------- | |
// Throwing is quite slow though, so you'd only really | |
// want to use it when fn is already throwing errors IMO |