Skip to content

Instantly share code, notes, and snippets.

View dydx's full-sized avatar
🎯
Focusing

Josh Sandlin dydx

🎯
Focusing
View GitHub Profile
// Transducer (architect astronaut speak):
// * a powerful and composable way to build algorithmic transformations
//
// Transducer (laymans speak):
// * a generic and composable way to operate on a collection of values,
// * producing a new value or a new collection of values.
//
// The word transducer itself can be split into two parts that reflect
// this definition.
//
console.log([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((x) => x + 1));
console.log([1, 2, 4, 5, 6, 7, 7, 8, 9, 10].filter((x) => x % 2 === 0));
console.log([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
.map((x) => x + 1)
.filter((x) => x % 2 === 0));
const mapIncReducer = (result, input) => result.concat(input + 1);
console.log([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].reduce(mapIncReducer, []));
@dydx
dydx / output.txt
Last active January 28, 2016 21:48
Opened mongoose connection
Successfully created and inserted new records
---------
Black 2016 BMW 135is
Silver 2016 BMW 335is
Red 2016 BMW 535is
Alpine White 2016 BMW M6
---------
UPDATED:
Japan Red 2016 BMW M6
@dydx
dydx / car.js
Created January 26, 2016 16:50
'use strict';
class Car {
constructor(year, make, model, convertible) {
this.year = year;
this.make = make;
this.model = model;
// default parameters, much?
if (typeof convertible === 'undefined') {
this.convertible = false;
@dydx
dydx / sandwiches.js
Last active January 26, 2016 15:34
loosely comparing blocking vs non-blocking
$> time node sandwich.js
-> making a burger for marc
-> making a pb&j for mike
-> making a reuben for shawn
<- shawn's reuben is ready in 1399ms
<- mike's pb&j is ready in 1478ms
<- marc's burger is ready in 3327ms
node sandwich.js 0.08s user 0.02s system 2% cpu 3.431 total
$> time node sandwich.js
-> making a burger for marc
@dydx
dydx / react_stuff.js
Last active January 25, 2016 05:20
I kinda like this syntax a lot more than the class syntax
var todos = ["Learn React", "Make a Cool Thing", "Retire Early"];
// This is our top-level Component, we render this
const TodosComponent = props => {
const Todos = renderTodos(props.todos);
return (
<ul>
{ Todos }
</ul>
@dydx
dydx / Dokku.md
Created January 14, 2016 21:25
Dokku Stuff
@dydx
dydx / gist:309662761d47c9c6a5b2
Created January 8, 2016 20:09
This is the failing test result after creating the spec for CachedScore AR model
RockScore
returns 0 for unpopular terms
returns 10 for popular terms
returns mediocre results for mediocre terms
does not divide by zero
ScoreCache
returns cached scores if they exist (FAILED - 1)
when the term is not cached
recomputes scores (FAILED - 2)
@dydx
dydx / Functional Core, Imperative Shell
Created January 8, 2016 01:10 — forked from jhrr/Functional Core, Imperative Shell
Notes and links for ideas about Gary Bernhardt's "functional core, imperative shell"
http://www.infoq.com/presentations/Simple-Made-Easy
http://www.infoq.com/presentations/integration-tests-scam
http://blog.thecodewhisperer.com/2010/09/14/when-is-it-safe-to-introduce-test-doubles
http://youtu.be/yTkzNHF6rMs
http://pyvideo.org/video/1670/boundaries
http://skillsmatter.com/podcast/ajax-ria/enumerators
http://alistair.cockburn.us/Hexagonal+architecture
http://c2.com/cgi/wiki?PortsAndAdaptersArchitecture
http://www.confreaks.com/videos/977-goruco2012-hexagonal-rails
http://www.confreaks.com/videos/1255-rockymtnruby2012-to-mock-or-not-to-mock
@dydx
dydx / runner.sh
Last active January 5, 2016 04:45
#!/bin/bash
# $> runner.sh <lib> <spec>
# Demo: http://recordit.co/7eR5hp1BP1
watch_dir=$1
watch_dir2=$2
dir_hashes () {
find $1 $2 -type f -exec md5 '{}' ';' | awk '{print $4}'