Skip to content

Instantly share code, notes, and snippets.

@oakfang
oakfang / gist:9719014
Created March 23, 2014 04:55
pytest-tree
import colorama as color
from os import path
import pytest
from _pytest.terminal import TerminalReporter
PASSED = 0
FAILED = 2
OTHER = 1
COLORS = {PASSED: "GREEN",
@oakfang
oakfang / python.cpp
Created June 13, 2014 18:16
python macros
#include <iostream>
#include <vector>
#include <functional>
#define var auto
#define in :
#define lambda(...) [](__VA_ARGS__)
#define print(X) std::cout<<X<<std::endl
#define def(TYPE, FUNC, ...) auto FUNC(__VA_ARGS__) -> TYPE
/*
@oakfang
oakfang / gist:ab514fa869225bc1b56b
Last active August 29, 2015 14:14
Turn your beautiful style sheep into CSS style sheets with ease!
/*
sheep.js
Turn your beautiful style sheep into CSS style sheets with ease!
*/
(function (globals) {
var forEachDOM = function (selector, callback) {
Array.prototype.forEach.call(document.querySelectorAll(selector), callback);
};
@oakfang
oakfang / git-blog
Created April 28, 2015 12:25
Git commands to make life easier
# Show all commits of current branch since its beginning
# Add flags as though it were git log
git log $(git parent)..HEAD $*
@oakfang
oakfang / main.pony
Created May 5, 2015 13:14
My first pony script
interface Shouter
fun shout(env: Env)
class Person
let name: String
var age: U8
new create(name': String, age':U8) =>
name = name'
age = age'
from pluginable import Pluginable
class MyClass(Pluginable):
pass
@oakfang
oakfang / webworker.js
Last active October 19, 2015 13:52
WebWorker module
function functionToBlob(func) {
return new Blob([`(${func.toString()})()`]);
}
function importAsBlob(func) {
return new Blob([`var ${func.name} = ${func.toString()}`]);
}
function getFunctionUrl(func, imported) {
return URL.createObjectURL((imported ? importAsBlob : functionToBlob)(func));
@oakfang
oakfang / wat.js
Created November 3, 2015 15:07
Prototype and for...in
// using ES5, but still relevant
var map = {
a: 1,
b: 2
};
Object.prototype.thisIsReallyReallyPrivate = 'foo'
for (var key in map) {
console.log(key);
function exporter(publics, privates) {
privates = privates || {};
var all = Object.assign({}, publics, privates);
publics.__test = function (t) {
var str = t.toString().match(/\{((.|\s)*)\}/)[1];
with (all) {
eval(str);
}
};
return publics;
@oakfang
oakfang / d.hs
Last active December 4, 2015 01:11
A Numenera attack roller written in Haskeel for infix functions
import ArgParse
import Dice.IO
import Dice.Pure
handleOptions :: Option -> IO ()
handleOptions (Level level) = rollAgainst level >>= (\result -> putStrLn $ rollMessage result)
main = do
argparse handleOptions