Skip to content

Instantly share code, notes, and snippets.

View mafintosh's full-sized avatar

Mathias Buus mafintosh

View GitHub Profile
#!/bin/bash
for i in {1..5}; do
"$@" && exit 0
sleep 1
done
var JSONStream = require('JSONStream');
// server ...
var stringify = JSONStream.stringify();
stringify.pipe(stream);
terminal.on('stdout', function(id, dock, data) {
stringify.write({
id: id,
dock: dock,
data: data.toString()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
namespace RedisPublisher
{
class Publisher
{
@mafintosh
mafintosh / output
Created April 9, 2014 11:37
node test/run.js test/experimental_tests/hyperlevel-clone.js
TAP version 13
# setup
# clone from hyperlevel server
ok 1 no open err
npm http GET https://registry.npmjs.org/leveldown-hyper
npm http 200 https://registry.npmjs.org/leveldown-hyper
npm http GET https://registry.npmjs.org/leveldown-hyper/-/leveldown-hyper-0.10.1.tgz
npm http 200 https://registry.npmjs.org/leveldown-hyper/-/leveldown-hyper-0.10.1.tgz
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/nan
var fbackup = require('folder-backup')
var request = require('request')
module.exports = function(dat, remote, cb) {
copyMeta(dat, remote, function(err, backend) {
if (err) return cb(err, err.message)
if (backend === 'leveldown-hyper') hyperClone(dat, remote, cb)
else normalClone(dat, remote, cb)
})
}
/** @jsx React.DOM */
var React = require('react')
var lex = require('lexicographic-integer')
module.exports = React.createClass({ displayName: 'SearchPopup',
propTypes: {
// onSelect: React.PropTypes.func.isRequired,
// items: React.PropTypes.arrayOf(
// React.PropTypes.shape({
// columns: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
@mafintosh
mafintosh / consumer.js
Last active August 29, 2015 14:00
stdout blocks but says its flushing - see testcase.sh
// do nothing
setInterval(function() {
// just to keep the program going
}, 1000)
@mafintosh
mafintosh / test-no-stdin.js
Created April 18, 2014 17:08
epipe from stdin
// run this: node test-no-stdin.js | cat -
var buf = new Buffer(512);
var cnt = 0;
buf.fill(97);
setInterval(function() {
console.log(buf.toString()+' #'+(cnt++));
}, 5);
@mafintosh
mafintosh / 7481.js
Created April 18, 2014 20:48
Single file test case for nodejs/node-v0.x-archive#7481
var proc = require('child_process');
if (process.argv[2] === 'test') {
var stdin = process.stdin; // this line breaks things
var buf = new Buffer(512);
var cnt = 0;
buf.fill(97);