Skip to content

Instantly share code, notes, and snippets.

@walling
walling / example1-first-usage.js
Last active June 21, 2017 20:30
blog-post-2017-06-21-examples
var conllu = require('conllu-stream');
var fs = require('fs');
fs.createReadStream('ud-treebanks-v2.0/UD_German/de-ud-train.conllu')
.pipe(conllu())
.on('data', sentence => {
console.log(sentence.features.sent_id, sentence.toString());
});
@walling
walling / chained-colors-es5.js
Last active December 8, 2016 15:29
Primitive replacement for chalk NPM
// ES5 version of chalk replacement with chaining :)
var util = require("util");
function C(text) {
var self = {};
Object.keys(util.inspect.colors).forEach(function(name) {
var color = util.inspect.colors[name];
self[name] = function() {
return C(util.format("\x1B[%sm%s\x1B[%sm", color[0], text, color[1]));
@walling
walling / onename.txt
Created October 24, 2014 14:21
onename.io verification
Verifying that +walling is my Bitcoin username. You can send me #bitcoin here: https://onename.io/walling

Keybase proof

I hereby claim:

  • I am walling on github.
  • I am walling (https://keybase.io/walling) on keybase.
  • I have a public key whose fingerprint is 98EE 3E03 D907 B87C 06B8 E054 4DE0 3A0D C7F3 64FA

To claim this, I am signing this object:

@walling
walling / bad-transform-stream.js
Created August 19, 2014 14:38
Bad Transform Stream
// dd if=/dev/urandom of=file count=10 bs=1m
var through2 = require('through2');
var fs = require('fs');
fs.createReadStream('file').pipe(slowTransform()).pipe(process.stdout);
function slowTransform() {
return through2(function(buffer, encoding, callback) {
var self = this;
@walling
walling / server.js
Created July 30, 2014 09:21
node-async-caching-example
var common = require('common'); // npm install --save common
/**
* Super nice funktion som laver fetcher noget data asynkront.
*/
function loadThings(id, callback) {
// ...
}
@walling
walling / Makefile
Created December 10, 2013 12:43
Reduced test case for segmentation fault for libvips VImage() constructor on Mac OS X
main: main.cc
$(CXX) $< `PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig pkg-config --cflags --libs vipsCC` -o $@
@walling
walling / term2html.js
Created November 19, 2013 10:09
Convert terminal output including ANSI escape sequences to HTML. Only handles simple cases!
'use strict';
var defaultColors = [ '#000', '#D00', '#00CF12', '#C2CB00', '#3100CA',
'#E100C6', '#00CBCB', '#C7C7C7', '#686868', '#FF5959', '#00FF6B',
'#FAFF5C', '#775AFF', '#FF47FE', '#0FF', '#FFF' ];
function term2html(text, options) {
options = options || {};
var colors = options.colors || defaultColors;
@walling
walling / sikkerhed.js
Last active December 16, 2015 19:19
Sikkerhed i JavaScript-applikationer.
/*jshint strict:true*/
(function() {
'use strict';
// Nyt scope, som ikke er tilgængeligt udefra.
// Bind reference til alle funktioner, som vi bruger, for at mindske risikoen for overskrivning.
var Number_toString_ = Number.prototype.toString;
var encodeURIComponent_ = encodeURIComponent;
var apply_ = Function.prototype.apply;
@walling
walling / livestyle-client.log
Created February 24, 2012 14:20
Livestyle 0.0.14 debugging on Windows 7
socket.io present, connecting
test.html:18Subscribing to 1 files:
/test.css
test.html:18Received change notification for /test.css, refreshing
test.html:18Received change notification for /test.css, refreshing
##### Until this point it worked; it updated the CSS in the browser the first time. #####
test.html:18Received change notification for /test.css, refreshing
test.html:18Received change notification for /test.css, refreshing