Skip to content

Instantly share code, notes, and snippets.

I am attesting that this GitHub handle xat is linked to the Tezos account tz1P9djZkQKQdvt68eixoyBf8ezNYjgrEdue for tzprofiles
sig:edsigtue5MxmvLyCQsaXQGDNJ5hb3ovPMQjZkK6twewkscXr98ZCGUTN8zHqR9X4wqoZrJg6vy4EffLmipjmcYc9NtEypfSPWGg
const pipeline = (...fns) => (val) => fns.reduce((prom, fn) => prom.then(fn), Promise.resolve(val));
const myPipe = pipeline(
(val) => val + 1,
(val) => val + 1
);
Promise.resolve(1)
.then(myPipe)
.then((result) => {

Keybase proof

I hereby claim:

  • I am xat on github.
  • I am xat (https://keybase.io/xat) on keybase.
  • I have a public key whose fingerprint is FAF5 5550 9A02 5279 1FB0 76F3 5B49 2B19 0149 FC24

To claim this, I am signing this object:

var last = function(fn, l) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(l);
return l = fn.apply(null, args);
};
};
@xat
xat / gist:9452fcb14e5d8440563a
Created November 7, 2014 19:42
contains.js
var contains = function(arr, cb) {
for (var i=0, len=arr.length; i<len; i++) {
if (cb(arr[i], i)) return true;
}
return false;
};
var group = function(arr, cb, ctx) {
var buckets = [];
for (var i=0, len=arr.length; i<len; i++) {
if (cb.call(ctx, arr[i], i) || !buckets.length) {
buckets.push([arr[i]]);
} else {
buckets[buckets.length-1].push(arr[i]);
}
}
return buckets;
@xat
xat / gist:9ccf5eab2d0adb34fe8d
Created October 12, 2014 19:07
start playback of a youtube clip on chromecast using castv2
var castv2Cli = require('castv2-client');
var inherits = require('util').inherits;
var Application = castv2Cli.Application;
var RequestResponseController = castv2Cli.RequestResponseController;
var extend = require('xtend');
var noop = function() {};
var slice = Array.prototype.slice;
var Api = function(client, session) {
var that = this;
var localfiles = function(opts, player, type, next) {
if (type !== 'launch') return next();
if (isUrl(opts.path)) return next();
// start local webserver, change the path to an url
};
var defaultmedia = function(opts, player, type, next) {
player.on('app-launch-pre', function(err, app) {
@xat
xat / gist:3ad9e6637944082b46ef
Last active August 29, 2015 14:06
simple flood script
var net = require('net');
var HOST = 'localhost';
var PORT = 7777;
var WORKERS = 1;
var TIMEOUT = 30; // sec
var data = 'FLOODATTACK';
var counter = 0;
var circulate = function(arr) {
var spawn = require('child_process').spawn;
var tailStream = function(file) {
return spawn('tail', ['-f', file]).stdout;
};
tailStream('./blah.txt').pipe( ... );