Skip to content

Instantly share code, notes, and snippets.

View nkabrown's full-sized avatar

Nathan Brown nkabrown

View GitHub Profile

Currying Demonstrated and Explained

const getCommand = commands => word => key => key in commands ? commands[key](word) : null;

Wow! What is that? It sure looks cool but what is actually going on there?

That is a curried function and I hope to explain to you over the next page or two what that is and why you might prefer to write this function in that way rather than this:

function getCommand(commands, word, key) {

One line of grep explained:

grep 'TODO' -r -n --exclude-dir={node_modules,.git,lib} --exclude={"*bundle.js","*.map","*.min.js","*.csv",todos.txt} . > todos.txt

This command searches through a directory and its subdirectories for TODO comments and writes them to a text file.

grep is a file pattern searcher and 'TODO' is the pattern we are searching our directories and files for

-r – search recursively through a directory and its subdirectories

@nkabrown
nkabrown / Legend.js
Last active October 6, 2017 18:30
makeover monday - descending triangle bar graph
'use strict';
const d3 = require('./d3.min.js');
export class Legend {
constructor(el, d, r, rm, m, w, h) {
this.mount = el;
this.data = d;
this.regions = r;
this.regionsMap = rm;
this.margin = m;
@nkabrown
nkabrown / react-native-port8081-workaround.md
Last active September 18, 2017 14:02
McAfee port 8081 workaround for react-native ios simulator

In <Project>/node_modules/react-native/React/React.xcodeproj/project.pbxproj replace all occurances of 'port 8081' with '8088'. Redone every time you npm install or yarn add a dependency

Open project in xcode by File -> Open -> <Project>.xcodeproj. Then go to <Project>/AppDelegate.m and change jsCodeLocation to jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8088/index.ios.bundle?platform=ios&dev=true"];

Run packager on port 8088 react-native start --port 8088.

Then run react-native run-ios.

Remove annoying Connection has no connected handler warning. react-native log-ios | grep -v nw_connection_get_connected

@nkabrown
nkabrown / frequencyTable.html
Last active October 6, 2017 18:36
frequency distribution table
<figure>
<figcaption>
</figcaption>
<table>
<thead>
</thead>
<tbody>
</tbody>
</table>
<small></small>
@nkabrown
nkabrown / date-exercise.js
Created March 30, 2017 02:01
exercises with javascript date objects
// create a date object with today's date
// create a date object with the date of 1 January 2017
// find the number of days between today and 1 Jan 2017
// create an array of date objects from our start date to our end date
// randomly set a boolean workout property on each date object in our array
@nkabrown
nkabrown / mentorship.md
Last active May 23, 2017 17:35
Mentorship ideas

Git lesson

Explain the difference between a tree and graph data structure

Explain what a directed acyclic graph is

Talk about .git directory and sub-directories

Show the github api and demonstrate it by creating issues from the command line

#Presentations

make sure that key repeat is low

test before hand on Windows and Mac

know what size magnification your screen needs to be for presentations

always make two demo videos — fast and slow

@nkabrown
nkabrown / index.js
Created September 20, 2016 03:13
requirebin sketch
const choo = require('choo');
const html = require('choo/html');
const app = choo();
app.model({
state: { list: [] },
reducers: {
add: (data, state) => {
const newList = state.list.slice();
newList.push(data);
@nkabrown
nkabrown / index.js
Created August 31, 2016 19:19
requirebin sketch
const choo = require('choo');
const html = require('choo/html');
const app = choo();
app.model({
state: { word: '', count: 0, answers: [] },
reducers: {
add: (data, state) => ({ word: data, count: data.length }),
save: (data, state) => {