Skip to content

Instantly share code, notes, and snippets.

View timoxley's full-sized avatar

Tim Kevin Oxley timoxley

View GitHub Profile
@timoxley
timoxley / 0.11.7
Last active December 28, 2015 09:29
roboskirt install failure node 0.11.x
> node-gyp rebuild
gyp http GET http://nodejs.org/dist/v0.11.7/node-v0.11.7.tar.gz
gyp http 200 http://nodejs.org/dist/v0.11.7/node-v0.11.7.tar.gz
CC(target) Release/obj.target/sundown/src/autolink.o
CC(target) Release/obj.target/sundown/src/buffer.o
CC(target) Release/obj.target/sundown/src/houdini_href_e.o
CC(target) Release/obj.target/sundown/src/houdini_html_e.o
CC(target) Release/obj.target/sundown/src/houdini_html_u.o
In file included from ../src/houdini_html_u.c:6:
@timoxley
timoxley / dynamichtmlimport.js
Last active March 6, 2020 16:00
dynamic html imports hack
// currently polymer only only loads html imports
// on first page load. After the first pass over the document,
// adding any additional <link> elements will have no effect.
// This adds a link to src, and forces polymer to load it
function load(src, fn) {
var link = document.createElement('link')
link.setAttribute('rel', 'import')
link.setAttribute('href', src)
document.body.appendChild(link)
@timoxley
timoxley / test.js
Created November 12, 2013 08:10
how to do deep equal on sparse array?
var require('assert')
var a = []
// make sparse array
a[20] = true
var b = []
// try copying a's items into b with splice
@timoxley
timoxley / ndarray-paste.js
Created August 28, 2013 15:15
paste an ndarray into another ndarray
var ops = require('ndarray-ops')
// paste an ndarray into another ndarray at an offset
module.exports = function(arr) {
return function plot(template, offset) {
var t = arr
.hi(offset[0] + template.shape[0], offset[1] + template.shape[1])
.lo(offset[0], offset[1])
ops.assign(t, template)
}
@timoxley
timoxley / retry.js
Created August 1, 2013 01:59
Retry requests N times, or until receive a 200
/*
* Annoying server that only responds 200
* on every 3rd try.
*/
var http = require('http')
var concat = require('concat-stream')
var count = 0
var s = http.createServer(function(req, res) {
@timoxley
timoxley / invert.js
Last active December 18, 2015 09:49
pausing a stream in shoejs
var http = require('http');
var ecstatic = require('ecstatic')(__dirname + '/static');
var shoe = require('../../');
var through = require('through')
var net = require('net')
// Goal:
// pipe connection on port 10000 to port 9999
// but do some async operation
// before doing so
@timoxley
timoxley / gist:5721056
Last active December 18, 2015 03:49
some fat modules
du -h -d1 ./node_modules | grep M
1.1M ./node_modules/brfs
13M ./node_modules/browserify
1.4M ./node_modules/hyperspace
14M ./node_modules/reconnect
16M ./node_modules/shoe
49M ./node_modules
@timoxley
timoxley / example.js
Created May 31, 2013 08:57
trying to pipe net stream through http auth then back out as a net stream
var net = require('net')
var http = require('http')
var auth = require('../')
var server = net.createServer(function(socket) {
socket.pipe(auth()).pipe(remoteConnection)
}).listen(8081)
var remoteServer = http.createServer(function(req, res) {
@timoxley
timoxley / gist:5676388
Created May 30, 2013 08:02
probably need to pause?
from = require('from')
through = require('through')
concat = require('concat-stream')
from([1,2,3,4,5])
.pipe(through(function(data) {
setTimeout(function(){
console.log('pushing data', data)
this.push(data)
}.bind(this), 300)