Skip to content

Instantly share code, notes, and snippets.


Eirik L. Vullum eiriklv

View GitHub Profile
View HTTPGetRequestForQueriesInterface.js
import { HTTPFetchNetworkInterface, printAST } from 'apollo-client';
* Serialize a object to a query string
* @source
function serialize( obj ) {
return `?` + Object.keys(obj).map(k => k + `=` + encodeURIComponent(obj[k])).join(`&`);
eiriklv / requestAnimationFrame.js
Created Aug 20, 2017 — forked from jacob-beltran/requestAnimationFrame.js
React Performance: requestAnimationFrame Example
View requestAnimationFrame.js
// How to ensure that our animation loop ends on component unount
componentDidMount() {
componentWillUnmount() {

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

eiriklv / SyncPath.js
Created Mar 1, 2017 — forked from davideast/SyncPath.js
Firebase Social Network Client Fanout
View SyncPath.js
export class SyncPath {
constructor(rootRef, path) {
this._rootRef = rootRef;
this.user = this._rootRef.getAuth();
this._userDataRef = this._rootRef.child(path).child(this.user.uid); = {};
this._userDataRef.on('value', (snap) => = snap.val() || {});
keys() {
return Object.keys(;

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
eiriklv / firebase_workers.js
Created Jan 2, 2017 — forked from anantn/firebase_workers.js
Firebase: Implementing a worker queue pattern using firebase_queue_pop.js
View firebase_workers.js
var Firebase = require("./firebase-node.js");
function Queue(ref) {
this._ref = ref;
Queue.prototype.pop = function(cb) {
this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb));
eiriklv /
Created Nov 27, 2016 — forked from SimplGy/
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
# Constants
SKIP_SIZE=3 # Every new block is sampled by skipping this amount of blocks to the next position
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<div id="root"></div>
<script id="jsbin-javascript">
eiriklv / church.js
Created Sep 20, 2016 — forked from arian/church.js
Church Numerals, Booleans, Pairs and Lists in JavaScript (ES6)
View church.js
// conversions
let c2i = x => x(y => y + 1, 0)
let c2star = x => x(y => y + '*', '')
let c2b = x => x('True', 'False')
let c2a = xs => xs((y, ys) => [c2i(y)].concat(ys), [])
// numbers
let zero = (s,z) => z
let one = (s,z) => s(z)