Skip to content

Instantly share code, notes, and snippets.

Simon Kusterer xat

Block or report user

Report or block xat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View promise-pipe.js
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) => {
View keybase.md

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:

View gist:a9fae4828b6defd013ea
var last = function(fn, l) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(l);
return l = fn.apply(null, args);
};
};
View gist:9452fcb14e5d8440563a
var contains = function(arr, cb) {
for (var i=0, len=arr.length; i<len; i++) {
if (cb(arr[i], i)) return true;
}
return false;
};
View gist:2cf34c8d3dd069a5ed42
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 Oct 12, 2014
start playback of a youtube clip on chromecast using castv2
View gist:9ccf5eab2d0adb34fe8d
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;
View gist:f4a743fd824e8d2b2d56
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 Aug 29, 2015
simple flood script
View gist:3ad9e6637944082b46ef
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) {
View gist:fbcf91eab6fd55d0dbf4
var spawn = require('child_process').spawn;
var tailStream = function(file) {
return spawn('tail', ['-f', file]).stdout;
};
tailStream('./blah.txt').pipe( ... );
View gist:4f05f3e0d1f54c2daeda
$.fn.sorty = function(fn) {
return this.each(function() {
var $el = $(this);
$el.html($el.children().sort(fn));
});
};
You can’t perform that action at this time.