Skip to content

Instantly share code, notes, and snippets.

Testing statuses

Mikael Brevik mikaelbr

Testing statuses
Block or report user

Report or block mikaelbr

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
mikaelbr / adhoc-dom-abstraction.js
Last active Feb 28, 2019
Example simple ad-hoc declarative ui framework
View adhoc-dom-abstraction.js
function createUiFramework() {
const isEvent = k => k.indexOf("on") === 0;
const eventName = k => k.substr(2).toLowerCase();
function attrs(el, obj) {
for (let k in obj) {
if (isEvent(k)) {
el.addEventListener(eventName(k), obj[k]);
} else if (k !== "class") {
el.setAttribute(k, obj[k]);
} else {
mikaelbr /
Last active Sep 7, 2018
Guide for working with git and github for Variant

Routines for working with content on Github for Variant

We are open. This means we should work in an open way. Run like an open source project. Any significant amount of work* should be done through Pull Requests. Pull Requests are suggestions for a project which projects can accept and update their own content. This is a great way to frame discussions.

(* Significant amount of work in both scope and impact. Things like infrastructure, bug fixing, minor details can be committed directly to master without doing a Pull Request.


Pull Requests should be reviewed equally, no matter who created the pull request. Communication should be polite, friendly and welcoming. Even though the change isn't what we want, we should appreciate the work put into it and the effort.

mikaelbr / proxy-set-investigate.js
Last active Mar 8, 2018
Trigger debugger when something sets a specific property on an object
View proxy-set-investigate.js
Array = new Proxy(Array, {
set(target, prop, value) {
if (prop === 'map') {
return Reflect.set(target, prop, value);
defineProperty (target, prop, descriptor) {
if (prop === 'map') {

Higher Order Components vs Higher Order Functions operating on Components (HoFooC™)

A higher order function would be a function taking a function as input, or returning a function. Such as:

function logger (fn) {
  return function (...args) {
    console.log('Invoking with', ...args);
    return fn(...args);
View emoji-lang.js
const scope = {};
function def(id, fn) {
scope[id] = fn;
function explode(id) {
return scope[id] ? [id] : id.split('\u200d');
function getFns(id) {
return explode(id).map(function(ii) {
if (!scope[ii])
external findIndex : array 'a => ('a => bool) => int = "" [@@bs.send];
type tile =
| Walls
| Person
| Floor;
type direction =
| Up
| Left
View .gitalias
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
alias gp='git push'
alias gpl='git pull --rebase'
alias gpd='git pull origin'
alias gf='git fetch'
alias gfa='git fetch --all'
alias gs='git status'
View validator.js
// pick is something ala lodash pick (fetching nested values from objects), but in it's simplest case
function pick (name, obj) {
return obj[name];
function validate (name, predicate, message, obj) {
if (!predicate(pick(name, obj))) {
return { valid: false, message, name };
external pi : float = "Math.PI" [@@bs.val];
let drawLine len ctxt => {
Canvas.lineTo ctxt len 0.0;
Canvas.translate ctxt len 0.0;
let start ctxt (w, h) => {
Canvas.moveTo ctxt 50.0 h;
Canvas.translate ctxt 50.0 h;
open Token
let (<|) x f = x f;;
let (<<) f g x = f(g(x));;
let string_of_char = String.make 1;;
let string_of_char_list =
List.fold_left (^) "" << string_of_char;;
let rec list_char = function
| "" -> []
| ch ->
You can’t perform that action at this time.