Skip to content

Instantly share code, notes, and snippets.

View wryk's full-sized avatar

Milia wryk

View GitHub Profile
export default getFunctionArguments
var COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg
var ARGUMENTS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m
var COMMA = /,/
/*
* @param {Function} fn
* @return {Array<String>}
**/
export default lazy
import defer from 'defer'
/**
* @param {Function} fn
* @return {Function}
**/
function lazy (fn) {
return function () {
@wryk
wryk / index.js
Created September 8, 2014 13:27
wryk/function-worker
import inherit from 'inherit';
export default CallbackWorker;
var inherit = function(a, b){
var fn = function(){};
fn.prototype = b.prototype;
a.prototype = new fn;
a.prototype.constructor = a;
};
@wryk
wryk / analyzer.js
Created September 8, 2014 13:24
wryk/speaking
import Emitter from 'emitter';
import configurable from 'configurable';
import analyzer from './analyzer.js';
var DEFAULT_OPTIONS = {
interval: 0,
threshold: 0
};
export default function startMeasure () {
var start = Date.now()
return function stopMeasure () {
return Date.now() - start
}
}
@wryk
wryk / all.js
Last active August 29, 2015 14:05
promise stuff
import cast from 'cast'
/**
* @param {*} values
* @return {Promise}
* @resolve {*}
* @reject {Error}
**/
export default function all (values) {
return new Promise(function (resolve, reject) {
@wryk
wryk / accessible.php
Last active August 29, 2015 14:05
reusable php stuff
<?php
trait Accessible {
public function __get ($name) {
$getter = 'get' . ucfirst($name);
if (method_exists($this, $getter)) {
return $this->$getter();
} else if (property_exists($this, $name)) {
return $this->$name;
import Todo from 'model'
import TodoView from 'view'
let firstThing = new Todo("write better specs")
let secondThing = new Todo("drink a ''pac à l'eau''")
let firstThingView = new TodoView(firstThing)
let secondThingView = new TodoView(secondThing)
document.body.appendChild(firstThingView)
import scriptToWorker from 'script-to-worker'
export default function functionToWorker (fn) {
return scriptToWorker('(' + fn.toString() + ')()')
}
import objectUrl from 'object-url'
export default function scriptToWorker (script) {
var blob = new Blob([script], {type: 'application/javascript'})
var url = objectUrl.create(blob)
var worker = new Worker(url)
objectUrl.revoke(url)
return worker
}