Skip to content

Instantly share code, notes, and snippets.

View jonasfj's full-sized avatar

Jonas Finnemann Jensen jonasfj

View GitHub Profile
@jonasfj
jonasfj / rAF.js
Last active December 10, 2015 13:08 — forked from paulirish/rAF.js
A list-based fallback implementation of `requestAnimationFrame` that reduces the number of `setTimeout`s needed.
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
// list-based fallback implementation by Jonas Finnemann Jensen
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@jonasfj
jonasfj / TelemetryTestServer.js
Created August 21, 2013 18:39
Test server for printing telemetry data to terminal...
#! /usr/local/bin/node
var express = require('express');
var zlib = require('zlib');
var fs = require('fs');
var app = express();
app.post('/*', function(req, res){
console.log("-----------------------------------------------------------------------------");
console.log('POST /' + req.originalUrl);
var chunks = [];
@jonasfj
jonasfj / README.md
Last active December 23, 2015 07:39
A preliminary telemtry dashboard test...

Custom Telemetry Dashboard Test

More info later.

def list_partitions(bucket, prefix='', level=0, schema=None, include_keys=False):
#print "Listing...", prefix, level
if schema is not None:
allowed_values = schema.sanitize_allowed_values()
delimiter = '/'
if level > 3:
delimiter = '.'
for k in bucket.list(prefix=prefix, delimiter=delimiter):
partitions = k.name.split("/")
if level > 3:
@jonasfj
jonasfj / mkdirp.h
Created December 4, 2013 23:07
A quick and dirty implementation of `mkdir -p` for C++, enjoy.
#ifndef MKDIRP_H
#define MKDIRP_H
#include <sys/stat.h>
#include <errno.h>
#define DEFAULT_MODE S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
/** Utility function to create directory tree */
bool mkdirp(const char* path, mode_t mode = DEFAULT_MODE) {
@jonasfj
jonasfj / README.md
Last active January 2, 2016 08:59
Custom telemetry dashboard

Custom Telemetry Dashboard

This is an example of how to make a custom telemetry dashboard. The following files are specific to this example dashboard:

  • index.html
  • script.js
  • style.css
@jonasfj
jonasfj / aws-sdk-promise.js
Created January 17, 2014 00:10
Simple example of how to patch `AWS.Request` (on node.js) to return a promise. Monkey patching sucks, but this is at least somewhat safe, and makes the API much nicer to work with. An alternative would be to add a `.then` to `AWS.Request`, however, it would be hard to implement this in compliance with the A+ specification.
var aws = require('aws-sdk');
var Promise = require('promise');
/** Patch aws.Request to have a promise() method that returns a promise */
exports.patch = function() {
aws.Request.prototype.promise = function() {
var that = this;
return new Promise(function(accept, reject) {
that.on('complete', function(response) {
if (response.error) {
@jonasfj
jonasfj / Vagrantfile
Created January 28, 2014 21:34
Carry AWS credentials into vagrantfile...
if ENV['AWS_ACCESS_KEY_ID'] == nil or ENV['AWS_SECRET_ACCESS_KEY'] == nil
raise Vagrant::Errors::VagrantError.new,
"This vagrantfile requires AWS credentials as environment variables!\n"
end
Vagrant.configure("2") do |config|
config.vm.box = "jonasfj-taskcluster-dev-0.0.0"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/20140126/saucy-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provision "shell", inline: <<-SCRIPT
@jonasfj
jonasfj / CCS.js
Last active August 29, 2015 14:01
Initial work on a CCS workbench implementation in Javascript
/** Calculus of Communicating Systems */
(function(CCS){
/** CCS Process System
* When creating a CCS process hierarchy this class must be used to all CCS
* objects within the labelled transition system.
* All CCS objects will have a reference to this object, as the object will
* responsible for caching objects, assigning ids, etc.
@jonasfj
jonasfj / Vagrantfile
Created June 24, 2014 00:43
**vagrant file** commonly used for taskcluster...
Vagrant.configure("2") do |config|
config.vm.box = "taskcluster-dev-0.1.0"
config.vm.box_url = "https://s3.amazonaws.com/task-cluster-dev/0.1.0/taskcluster_dev.box"
end