Skip to content

Instantly share code, notes, and snippets.

Avatar

Kris Kowal kriskowal

View GitHub Profile
View gist:90410
(function() {
var NARWHAL_HOME = Packages.java.lang.System.getenv("NARWHAL_HOME");
var JSPATH = Packages.java.lang.System.getenv("JSPATH");
var NARWHALPATH = Packages.java.lang.System.getenv("NARWHALPATH");
$LOAD_PATH = NARWHAL_HOME + "/lib/platforms/rhino:" + NARWHAL_HOME + "/lib";
if (JSPATH) $LOAD_PATH += ":" + JSPATH;
if (NARWHALPATH) $LOAD_PATH += ":" + NARWHALPATH;
View gist:92762
from StringIO import StringIO
buffer = StringIO()
buffer.write('Hello,')
buffer.write(' ')
buffer.write('World!')
assert buffer.getvalue() == 'Hello, World!'
buffer = StringIO(buffer.getvalue())
assert buffer.read(7) == "Hello, "
assert buffer.read() == "World!"
View gist:97875
var base = require('chiron/base');
var sandbox = require('chiron/sandbox').sandbox;
base.forEach([
'absolute',
'cyclic',
'exactExports',
'hasOwnProperty',
'method',
View gist:97893
var sandboxing = require('chiron/sandbox');
var sandbox = sandboxing.sandbox;
var base = require('chiron/base');
var mime = require('chiron/mime');
exports.main = function (env) {
var log = base.List();
var environment = {'print': log.push};
environment.print = log.push;
View gist:119759
function git-branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(git-branch)\[\033[00m\] \$ '
View gist:148771
# apt-get install curl
read -p 'login: ' USER
read -s -p 'password: ' PASSWORD
curl --silent -b twitter-cookie.txt -c twitter-cookie.txt \
--user-agent Mozilla/4.0 \
-d username_or_email="$USER" \
-d password="$PASSWORD" \
-d 'commit=Sign In' \
View gist:151542
http://dict.tu-chemnitz.de/dings.cgi?query=%s&lang=en&service=deen&opterrors=0&optpro=0&iservice=&comment=&email=&mozcharset=iso-8859-1
# in Firefox, add a bookmark with this location, and set the keyword to "de" or something.
# At the location bar, type "de könig". Observe that the umlaut gets encoded properly,
# instead of the UTF-8 default. &mozcharset= is a FF workaround for setting the charset.
View gist:178258
exports.NarwhalParser = type([args.Parser], function (self, supr) {
self.option('-h', '--help')
.help('displays help')
.action(function () {
});
});
exports.ObjjParser = type([exports.NarwhalParser], function (self, supr) {
View gist:181135
# generate crazy mixed version, and sort them dewey decimal
echo {11,1}.{11,1}.{11,1}.{11,1} | xargs -n 1 \
| awk 'BEGIN{FS="."}{print $4, $1, $2, $3}' \
| sort -ns \
| awk '{print $4, $1, $2, $3}' \
| sort -ns \
| awk '{print $4, $1, $2, $3}' \
| sort -ns \
| awk '{print $4, $1, $2, $3}' \
| sort -ns \
View gist:181225
var jna = Packages.com.sun.jna;
var clib = jna.NativeLibrary.getInstance(jna.Platform.isWindows() ? "msvcrt" : "c");
var csystem = clib.getFunction("system");
csystem.invoke(["echo Hello, World!"]);
You can’t perform that action at this time.