Skip to content

Instantly share code, notes, and snippets.

@joewalker
joewalker / flatmap.js
Created May 11, 2017
Annoying flow problem
View flatmap.js
// @flow
type FlatMapMapper<In, Out> = (elem: In, index: number, arr: In[]) => Out | Out[];
function flatMap<In, Out>(arr: In[], mapFunc: FlatMapMapper<In, Out>): Out[] {
const result = [];
for (const [ index, elem ] of arr.entries()) {
const x = mapFunc(elem, index, arr);
// We allow mapFunc() to return non-Arrays
if (Array.isArray(x)) {
@joewalker
joewalker / repl_against_tofino.clj
Created Dec 12, 2016
Get a repl that allows you to use your tofino profile to practice your datascript
View repl_against_tofino.clj
; $ cd .../datomish
; lein repl
(require '[datomish.api :as d])
(require '[datomish.sqlite])
(require '[datomish.jdbc-sqlite])
(require '[clojure.core.async :as async])
; You'll need to replace $HOME with whatever $HOME is, and if not on a mac, do something AppData like
View webpack.mutate.js
import webpack from 'webpack';
import config from './webpack.config';
import { mapObject } from './web/util/util';
export const original = config;
/**
* Development config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.dev.js
@joewalker
joewalker / webpack.mutate.js
Created Jan 27, 2016
Keep your core webpack config simple and mutate it with ES.whatever Object Rest/Spread
View webpack.mutate.js
import webpack from 'webpack';
import config from './webpack.config';
import { mapObject } from './web/util/util';
export const original = config;
/**
* Development config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.dev.js
View scope.js
function decorate(func) {
return func();
}
function Foo(name) {
this.name = name;
}
Foo.prototype = {
View hackerrank-test.js
function trim(value) {
return value.replace(/\[\]/g, '').replace(/\{\}/g, '').replace(/\(\)/g, '');
}
function braces(value) {
while (true) {
var newValue = trim(value);
if (value === newValue) {
return (value === '' ? 'YES' : 'NO');
@joewalker
joewalker / nesting_tojson.js
Created Jul 27, 2015
What happens if you nest toJSON functions?
View nesting_tojson.js
var obj = {
foo: 'foo',
toJSON: function() {
return {
bar: 'bar',
toJSON: function() {
return {
baz: 'baz'
};
View designer.html
<link href="../paper-input/paper-input.html" rel="import">
<link href="../paper-button/paper-button.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;
View keybase.md

Keybase proof

I hereby claim:

  • I am joewalker on github.
  • I am joewalker (https://keybase.io/joewalker) on keybase.
  • I have a public key whose fingerprint is 4095 0774 8EC8 CFB7 6F38 86AB 1074 915B 5725 BBE4

To claim this, I am signing this object:

View gist:bfcb032e4564829b05c1
let foo = new Set;
foo.add("jsonable");
console.log(JSON.stringify(foo)); // "{}"
You can’t perform that action at this time.