Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
nybblr / metaproxy.js
Created October 28, 2017 18:43
Metaproxy: The proxy that doesn't do anything
View metaproxy.js
/* Metaproxy
* The proxy that doesn't do anything
let target = { a: 1, b: 2, c: 3 }
let handler = new Proxy({}, {
get: (...args) => Reflect[args[1]](...args)
n1ru4l / HTTPGetRequestForQueriesInterface.js
Created May 30, 2017 14:46
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(`&`);
jacob-beltran / requestAnimationFrame.js
Last active April 17, 2020 04:05
React Performance: requestAnimationFrame Example
View requestAnimationFrame.js
// How to ensure that our animation loop ends on component unount
componentDidMount() {
componentWillUnmount() {
eiriklv / avoiding-exceptions.js
Last active February 2, 2019 12:13
Exception free JavaScript?
View avoiding-exceptions.js
* Check out error handling in golang:
* Wrap an "unsafe" promise
function safePromise(promise) {
return promise
sindresorhus /
Last active February 16, 2022 07:17
Results are as expected. Async comes with a slight overhead because of the event loop, but has many other benefits. So unless you know you won't need it, go for async.

Measuring sync vs async child processes in Node.js

  • macOS 10.12.3
  • Node.js 7.4.0


const childProcess = require('child_process');
yossorion /
Last active November 10, 2023 22:44
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

SimplGy /
Last active July 27, 2023 07:30
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
# TODO: look at paralellization for perf boost
# Constants
mattes / og.txt
Last active May 7, 2022 01:53
Open Graph debugger
View og.txt - - -
View AbortablePromise.js
const ABORTABLE_ERROR_KEY = '__abortablePromise';
* @typedef {Promise.<*>} AbortablePromise
* @property {function} abort Additional method for abort original promise
View types.markdown

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.