Skip to content

Instantly share code, notes, and snippets.

var mufasa = {
name: "Mufasa",
sing() {
var inner = function() {
console.log("inner:this", this);
};
var innerStrict = function() {
'use strict';
console.log("innerStrict:this", this);
};
@a-laughlin
a-laughlin / lexical_and_variable_environments.md
Created July 25, 2020 01:53
execution context, lexical environments, variable environments

example to illustrate variable values in different scopes, in both assignment and re-assignment cases.

... html here ...
<script>
// Scope chain example, showing lexical and variable environments in a call tree.
// "this" is always window
// [name] is execution context. E.g., "win" is the window execution context.
// "[name]Vars" corresponds to [name]'s variable environment (function scoped, identifiers defined with var, and function args)
// "[name]Lexs" corresponds to [name]'s lexical environment (block scoped, identifiers defined with const and let)
@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:
@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 / command-line-reference.md
Last active May 8, 2024 11:15
Command Line Reference bash sed diff awk vim
@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 / 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
# 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 / 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';
@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.