Skip to content

Instantly share code, notes, and snippets.

@a-laughlin
a-laughlin / eslint-pushed-changes.sh
Created March 15, 2017 19:45 — forked from stalniy/eslint-pushed-changes.sh
ESLINT + pre-receive git hook
#!/bin/bash
TEMPDIR=`mktemp -d`
ESLINTRC=$TEMPDIR/.eslintrc
COMMAND="eslint --color -c $ESLINTRC --rule 'import/no-unresolved: 0' --rule 'import/no-duplicates: 0' --rule 'import/export: 0'"
git show HEAD:.eslintrc > $ESLINTRC
echo "### Ensure changes follow our code style... ####"
# See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive
@a-laughlin
a-laughlin / ObjectCreationPerformance.js
Last active May 1, 2017 03:04
memory allocation of different js objects
window.__MemoryTest__ = {
proto:[],
concat:[],
creat:[],
newFn:[],
factory:[]
};
function proto(){return new Foo()}
function concat(){return Object.assign({},baseObj)}
@a-laughlin
a-laughlin / components.js
Last active August 15, 2017 09:21
Hyper-Composable React Architecture
// This is a file from an experiment in hyper-decoupled, hyper-composable React architecture.
//
// A lot of it will seem really odd unless you're familiar with Higher Order Components/Functions.
//
// Some highlights:
// - Every component is a single semantic HTML element composed together with behaviors,
// attributes, styles, content, data, etc.
// - Every component is exported for reuse.
// - Any component may make any other(s) its child(ren), in any order.
// - Components get their data from graphql and redux state, so are usually standalone.
@a-laughlin
a-laughlin / userGoalsHOC.js
Created August 17, 2017 22:27
User Goals HOC
// HOC designed around enabling components to consistently work with user's mental state, rather than just program state.
// storing this here for reference...
import React from 'react'; // so jsx parsing works
import {withProps,withReducer,mapProps,setPropTypes,branch} from 'recompose';
import {ifElse} from 'ramda';
import {
spread, rest, pick, isString, compose, pipe, uniq, startCase, get, map, values, flatten, sortBy,
filter, identity, keys, without, omit, transform as transformFP
} from 'lodash/fp';
# from toolz.functoolz import curry,partial,compose,flip,pipe as datapipe
#logic
def cond(predicateFnMatrix):
def condInner(*args):
for (predicate,fn) in predicateFnMatrix:
if predicate(*args):
return fn(*args)
return condInner
@a-laughlin
a-laughlin / discrete_math_reference.rtf
Last active June 5, 2019 22:55
Discrete Math Reference Table
https://docs.google.com/spreadsheets/d/1-2aTdkutAdywzBSHjpiK7zGMAczX_QW6euPczfyxa68/edit#gid=0
@a-laughlin
a-laughlin / python_a_reference.md
Last active August 11, 2019 12:59
python reference

Python Reference

CheatSheets

Python Basics: Data Science

importing data

python 3 (pt 1 of 2)

python 3 (pt 2 of 2)

@a-laughlin
a-laughlin / command-line-reference.md
Last active May 8, 2024 11:15
Command Line Reference bash sed diff awk vim
@a-laughlin
a-laughlin / gh_projects_issue_creator.js
Last active March 4, 2019 00:55
Bookmarklet To Create New Github Projects Issues Using Template
javascript:((alert,$)=>{
const story_template = '### Story\nAs a ___, I should be able to ___, so that ___.\n\n### Acceptance Criteria\n - [ ] __\n - [ ] __\n - [ ] __\n - [ ] Tests Written (TDD)\n - [ ] Code Written\n - [ ] Documentation Written in Relevant Readme\n\n### Depends On\n- NA\n\n### Relates To\n- NA';
/*utility*/
const poll = (interval=100,maxwait=1000)=>(predicate,msg)=>(new Promise((res,rej)=>{
let waited = -1;
const t = setInterval(()=>{
const passes = predicate();
if(passes){clearInterval(t);res(passes);}
if((waited+=interval)>=maxwait) {clearInterval(t);rej(msg);}
},interval);
@a-laughlin
a-laughlin / react-app-time-progression.txt
Last active September 30, 2019 19:01
React UI App Progression time steps, for graph decomposition per step.
// assumes create-react-app, and files served from src/
T0: define time
file tree exists. Nothing imported. Static intra-file code graphs exist.
T1: JS run time starts.
index.js imports files:
Functions in imported files run: JS graphs updated.
Conceptual component graph exists.
T2: React run time starts
App Component runs. Virtual dom root exists.
loop: