Skip to content

Instantly share code, notes, and snippets.

View CrowdHailer's full-sized avatar

Peter Saxton CrowdHailer

View GitHub Profile
@peerreynders
peerreynders / AddressInput.js
Created October 22, 2018 14:21
gen-browser Pinger/Ponger refactor - no async await
// file: src/AddressInput.js
import {getPropPathValue} from './Misc';
// --- DOM hook
const _addressInput = document.querySelector('main input[type="text"]');
function selectAddress(event) {
const name = getPropPathValue(event, ['target','constructor','name'], null);
if(name == 'HTMLInputElement') {
event.target.select();
@SLsthompson
SLsthompson / State.ex
Last active June 9, 2016 19:00
State monad implemented in Elixir
defmodule State do
# At each stage of computation, State builds a function. That
# function accepts an "initial state" as an argument and returns
# a tuple containing a final computed value, and a final state
# The basis of State accepts a value and returns a function.
# The function returned accepts a state and returns a tuple with the
# value and the state.
def unit(value) do
@CrowdHailer
CrowdHailer / command don't query
Last active August 29, 2015 14:11
Tell don't ask and service objects
gist
@eethann
eethann / _.objMapFunctions.js
Created August 23, 2012 01:05
Underscore mixin with common iterator functions adapted to work with objects and maintain key/val pairs.
_.mixin({
// ### _.objMap
// _.map for objects, keeps key/value associations
objMap: function (input, mapper, context) {
return _.reduce(input, function (obj, v, k) {
obj[k] = mapper.call(context, v, k, input);
return obj;
}, {}, context);
},
// ### _.objFilter