Skip to content

Instantly share code, notes, and snippets.

@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;
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) => {
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename');
phantom.exit(1);
} else {
address = system.args[1];
output = system.args[2];
@xat
xat / gist:6141235
Last active December 20, 2015 13:49
<?php
function treeWalker($fnCallback, $strTable, $intStart=0, $orderBy='pid, sorting')
{
$arrItemsByPid = array();
$arrItems = \Database::getInstance()->execute('SELECT * FROM ' . $strTable . ' ORDER BY ' . $orderBy)->fetchAllAssoc();
$strResult = '';
foreach($arrItems as $arrItem)
@xat
xat / gist:5690206
Last active December 17, 2015 23:38
<?php
function setter($val) {
return function(&$val) use ($val) {}
};
$fooSetter = setter('foo');
$fooSetter($x);
@xat
xat / scheduler.js
Last active December 14, 2015 01:39
A simple demonstrantion of a sheduler done in Node.JS. Tasks can be split up in multiple Queues. Tasks can be marked as "exclusive" if they should not be run concurrent with other tasks.
var http = require('http'),
async = require('async'),
queueBuilder,
taskBuilder,
counter,
maxConcurrent = Number.POSITIVE_INFINITY,
debug = true,
queues = {},
tasks = {};
@xat
xat / gist:4574119
Created January 19, 2013 18:21
The goal is to find a nice way to merge multiple configs where the inner-configs ($localConfig) are able to unset keys of the outer-configs ($globalConfig)
<?php
// Global Configuration
$globalConfig = array
(
'key1' => 'val1',
'key2' => array
(
'key2.1' => 'val2.1',
'key2.2' => 'val2.2',
@xat
xat / gist:4426999
Created January 1, 2013 12:09
The Problem is, func_get_args() generates copies of the arguments and we need references.
<?php
class MyHook
{
public function run(&$arg)
{
$arg = 'bar';
}
}

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: