Skip to content

Instantly share code, notes, and snippets.

View awwright's full-sized avatar

Austin Wright awwright

View GitHub Profile
@awwright
awwright / protected.js
Last active July 6, 2020 22:49
A pattern for protected class properties in ECMAScript
"use strict";
class A {
#writableSide;
#writableSideInit = false;
constructor(x) {
this.#writableSide = {a: x};
}
initWritableSide() {
if(this.#writableSideInit) throw new Error('writableSide already initialized');
@awwright
awwright / .deprecated.md
Last active July 20, 2020 00:24
Node.js Simplex Pair Proposal
@awwright
awwright / .deprecated.md
Last active February 7, 2023 00:55
Reporting progress of a long-running operation in HTTP
@awwright
awwright / localtabs.md
Last active August 29, 2015 14:10 — forked from eevee/spabs.md

Death to spaces, long live tabs

Why tabs?

  1. No more arguments over how many spaces an indent is, and no more inconstistent indenting throughout the project, no more problems when copying/pasting examples. Indent is one tab, period. An indent will never be two tabs, ever.
  2. You can't accidently highlight half a tab

Tabs must only be found at the beginning of a line.

Checking out space indents as tabs in Git

@awwright
awwright / Makefile
Created March 5, 2014 08:23
Node.js Makefile Build
OUT_BINNAME ?= node
# Default target
all: $(OUT_BINNAME)
printall:
@echo $(NODE_OBJECTS)
# Specify BUILDTYPE=Release on the command line for a release build.
@awwright
awwright / gist:5923322
Last active December 19, 2015 08:09 — forked from apipkin/gist:5923314
spinner = {
fn: function () {
var char = spinner.chars[++spinner.offset%spinner.chars.length];
process.stdout.write('\x1B[s' + char + '\x1B[u');
},
chars: ['—', '\\', '|', '/'],
offset: 0
timer: null,
speed: 100
@awwright
awwright / connection.js
Created March 15, 2013 05:55
marcello3d/node-mongolian lib/connection.js rewrite
var tls = require('tls');
var net = require('net');
var events = require('events');
var util = require('util');
function Connection(options) {
this.maxMessageSize = options && options.maxMessageSize || 1024*1024*32;
var self = this;
// Would prefer to use an actual Function-subclass a lá `from`, so that I don't have to manually
// attach a .toString() to each instance; but this will do for the moment.
// FIXME: Will currently error out if you curry in more arguments than the function needs
define(Function.prototype, 'curry', function(){
var self = this;
var result = new Function('bound', 'args',
"return this.apply("
+" typeof bound === 'object' || typeof bound === 'function'? bound:this"
+" , curried.concat([].slice.call(args)) )"
@awwright
awwright / protoinspect.js
Created November 18, 2012 17:45 — forked from jonvuri/protoinspect.js
Inspect prototypes
var util=require('util');
module.exports = function protoinspect(object, showHidden, depth, colors) {
return util.inspect(object, showHidden, depth, colors) + '\n' + (Object.getPrototypeOf(object)!=Object.prototype ? protoinspect(Object.getPrototypeOf(object), showHidden, depth, colors) : '');
}
module.exports.log = function protoinspectLog(object, showHidden, depth){
console.log(module.exports(object, showHidden, depth, true));
}
@awwright
awwright / BOOTSTRAP.JS
Created August 4, 2012 04:58
CONSOLE.LOG IN ALL CAPS
GLOBAL[[[]+[][[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+!![]+!![]+!![]]+[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+!![]+!![]+!![]+!![]+!![]+!![]]+[[]+[][[]]][+[]][+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]+[[]+!![]][+[]][+!![]]+[[]+[][[]]][+[]][+[]]+[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]+[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+!![]+!![]+!![]+!![]+!![]+!![]]+[[]+!![]][+[]][+!![]]][[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+!![]+!![]+!![]]+[[]+/!/[[[]+!![]][+[]][+[]]+[[]+![]][+[]][+!![]+!![]+!![]+!![]]+[[]+![]][+[]][+!![]+!![]+!![]]+[[]+!![]][+[]][+[]]]][+[]][+