Skip to content

Instantly share code, notes, and snippets.

Amanda Falke abstractmachines

View GitHub Profile
@abstractmachines
abstractmachines / bash-profile.md
Last active Aug 1, 2018
Bash Profile (for upcoming dotfiles repo)
View bash-profile.md
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

# This runs nvm on each new shell session.
enter_directory() {
  if [[ $PWD == $PREV_PWD ]]; then
    return
  fi
View git-workshop.md

git Workshop: Motivation

The majority of blogs and documentation about git are one of two things:

  1. technically correct while being very difficult for newbies to digest,

OR

  1. technically incorrect "guides" which help people learn, but miss many CS fundamentals and details and/or advise learners to "avoid/ignore" "advanced" features which software engineers use daily on the job.

This workshop serves to instruct on the industry usage of git using methods and theory that are agreed-upon by most senior engineers, and to do so while covering CS and SWE fundamentals. As such, this workshop will address the features of git which many blogs state are "too hard to use" such as rebasing, as these git workflows are considered a fundamental practice of intermediate git operation when collaborating on teams.

@abstractmachines
abstractmachines / iterator-string-for-of-spread.js
Last active Nov 2, 2017
JavaScript Iterators: Strings, spread, and for of
View iterator-string-for-of-spread.js
/* JavaScript Iterators
Strings as data source; for of and spread operator as data consumers
Strings can be consumed as iterables using the spread operator.
Note that strings will be parsed according to code points, not by character,
and so num characters parsed will be somewhat nondeterministic.
Sources:
1 - Axel Rauschmeyer: http://exploringjs.com/es6/ch_iteration.html
2 - http://www.zsoltnagy.eu/es6-iterators-and-generators-in-practice/
@abstractmachines
abstractmachines / set-map-iterator.js
Last active Jul 5, 2018
JavaScript Iterators: Sets and Maps
View set-map-iterator.js
/* JavaScript Iterators
Sets and Maps
Sets and Maps can be made Iterable/Iterator by using the methods .entries(), .keys(),
values(), and/or via for of construct.
A Set is a unique (non repeated) version of a Bag data structure. Characteristic equation
is contains() or has().
A Map (in JS) is a key-value pair data structure, unordered (in order of insertion).
@abstractmachines
abstractmachines / arrayiterator.js
Last active Jul 5, 2018
JavaScript Iterators : Arrays
View arrayiterator.js
/* JavaScript Iterators
An Iterator Object is a data structure that has a .next() method that can be called repeatedly.
Iterators use the Well Known Symbol called Symbol.iterator.
(The Iterable Object has an Iterator pointer for indexing.)
The Iterator object has two properties, value and done (boolean). Iteration will continue so
long as done is falsey. Once done is truthy, iteration stops.
Just like C++ iterators for C++ data structures, JavaScript iterators iterate through an entire
@abstractmachines
abstractmachines / Symbol.hasinstance.js
Last active Feb 23, 2018
Well Known Symbols : instanceof via custom Symbol.hasinstance
View Symbol.hasinstance.js
/* Well Known Symbols : Symbol.hasinstance
sources:
1 - https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols/
2 - http://exploringjs.com/es6/ch_symbols.html
3 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
4 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
Well Known Symbols are Reflection via implementation in ES6.
Reflection in Metaprogramming: observing low level internals of a programming language/program.
@abstractmachines
abstractmachines / promiseunderthehood.js
Created Oct 26, 2017
Dave's pwomise. Remember that the catch is not implemented correctly, recall the tree structure of Promise.
View promiseunderthehood.js
class Pwomise {
constructor (fn) {
fn(this._resolve.bind(this), this._reject.bind(this))
this._thens = []
this._catches = []
}
_resolve (value) {
while (this._thens.length > 0) {
this._thens.pop()(value)
View transducers.js
/** Implementing transformations (like map and filter) with reducers. **/
// https://www.webpackbin.com/bins/-Kvmn0gWkIMmtnFnkcu_
// https://medium.com/@roman01la/understanding-transducers-in-javascript-3500d3bd9624
// take all evens, multiply by 2, log that.
const arr = ['1', '2', '3', '4', '5', '6']
console.log('Chaining map and filter.')
You can’t perform that action at this time.