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
mikaelbr / destructuring.js
Last active Sep 7, 2019
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
View destructuring.js
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@mikaelbr
mikaelbr / gulpfile.js
Created Jan 14, 2014
Example gulpfile for complete set-up.
View gulpfile.js
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var less = require('gulp-less');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var minifyCSS = require('gulp-minify-css');
var embedlr = require('gulp-embedlr');
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])
@mikaelbr
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
mikaelbr / gulfile.js
Created Jan 18, 2014
Example gulpfile with no colors on gulp-mocha
View gulfile.js
var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('default', function () {
gulp.src('test/*.js')
.pipe(mocha({
useColors: false
}));
})
@mikaelbr
mikaelbr / Program.cs
Created Aug 19, 2014
OWIN test for hosting static files
View Program.cs
using System;
using System.Diagnostics;
using Microsoft.Owin.Hosting;
using Microsoft.Owin.FileSystems;
using Microsoft.Owin.StaticFiles;
using Owin;
namespace Test.Owin.StaticFiles
{
public class Program
@mikaelbr
mikaelbr / 01-routines.md
Last active Sep 7, 2018
Guide for working with git and github for Variant
View 01-routines.md

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.

Reviewing

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.

View orientation.js
export default function compass (onChange, onFirst = function () { }) {
let hasListened = false;
OrientationPublisher.init(trigger);
function trigger (...args) {
if (!hasListened) {
onFirst(...args);
hasListened = true;
View flow-intro.md

Table of Contents

  1. Basic syntax
  2. Flow Examples
  3. Advanced features
  4. Using with existing libraries (flow-typed and libdefs)
  5. Tooling
  6. Try

1. Basics

@mikaelbr
mikaelbr / index.html
Created Sep 15, 2013
A simple piano-key to sound script based on michaelmp/js-piano. Index.html shows how the actual sounds are included.
View index.html
<!DOCTYPE html>
<html>
<head>
<title>FRP Piano</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<audio id="sound-A2" src="samples/A2.ogg" preload="auto"></audio>
<audio id="sound-B2" src="samples/B2.ogg" preload="auto"></audio>
You can’t perform that action at this time.