Skip to content

Instantly share code, notes, and snippets.

James Halliday substack

Block or report user

Report or block substack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View xkcd 2010-04-01 source through jsbeautifier.js
(function (a) {
a.browserTest = function (e, g) {
var f = "unknown",
d = "X",
b = function (k, j) {
for (var c = 0; c < j.length; c = c + 1) {
k = k.replace(j[c][0], j[c][1])
}
return k
},
View javascript-style.js
var win = $('<div class="window">').
attr('tabindex', 0). // needed for keydown/keyup
data('vm_id', vm_id).
width(400).
height(200).
draggable();
// versus:
var win = $('<div>')
. addClass('window')
View gd-magick-benchmarks.hs
{-# LANGUAGE BangPatterns #-}
module Main where
import Data.Time.Clock.POSIX (getPOSIXTime)
import Data.Time.Clock (NominalDiffTime)
import Control.Applicative ((<$>))
import Control.Monad (forM_)
import qualified Graphics.GD as GD
import qualified Graphics.Transform.Magick.Images as Mk
View require.js
var required = {};
function require (src) {
if (required[src]) return required[src];
var exports = {};
(function () {
eval(getSync('/js/' + src));
}).call(exports);
required[src] = exports;
View npm-publish-not-ok
sunspot : node-rfb $ npm publish .
npm it worked if it ends with ok
npm sudo false
npm configfile /home/substack/.npm
npm cli [ 'publish', '.' ]
npm version 0.1.19
npm publish [ '.' ]
npm readJson package.json
npm packTar . /home/substack/prefix/lib/node/.npm/.cache/rfb/0.0.1/package.tgz
npm exec tar "czf" "/home/substack/prefix/lib/node/.npm/.cache/rfb/0.0.1/package.tgz" "--exclude" ".git" "node-rfb"
View missing_methods.js
if (!Object.keys) Object.keys = function (obj) {
var keys = [];
for (var key in obj) {
var skip = typeof(obj[key]) == 'function'
&& ('__enumerable__' in obj[key]);
if (!skip) keys.push(key);
}
return keys;
};
View unpublish_publish_npm.txt
sunspot : dnode $ npm unpublish dnode 0.0.1
npm it worked if it ends with ok
npm sudo false
npm configfile /home/substack/.npmrc
npm cli [ 'unpublish', 'dnode', '0.0.1' ]
npm version 0.1.19
npm unpublish [ 'dnode', '0.0.1' ]
npm GET dnode
npm PUT dnode/-rev/1-bb535089d6d353b957e578eb5b2c5076
npm GET dnode
View sign-up.pl
#!/usr/bin/env perl
use warnings;
use strict;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use DBI;
use URI::Escape qw/uri_escape/;
my $cgi = CGI->new;
my $email = $cgi->param('email') or fail('Email not defined');
View dsl-modem-iptables
# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 192.168.227.2
TCPMSS tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
TCPMSS tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
View dnode-auth.js
#!/usr/bin/env node
var DNode = require('dnode').DNode;
function VMPool (user) {
this.moo = function (f) {
f(user + ' moooooooooo!');
};
}
DNode(function (client,conn) {
this.authenticate = function (user,pass,cb) {
You can’t perform that action at this time.