Skip to content

Instantly share code, notes, and snippets.

@bryzettler
bryzettler / iterm2-solarized.md
Created May 24, 2016 16:15 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

// Takes an `array` a `callback` and an `initialValue`
// uses an inner `recursiveFn` to iterate over all array values
// calling the `callback` on each one
const reduce = (orgArray, callback, initialValue) => (
(function recursiveFn(idx, acc) {
// base condition to end looping
if (idx > orgArray.length - 1) return acc;
// calculate and pass values to next step
return recursiveFn(idx + 1, callback(acc, orgArray[idx], idx, orgArray))
// start the iterations at orgArray[0]
const records = [
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"},
{ title: "Rocket to Russia", artist: "Ramones", type: "LP", lengthSec: 1906, released: "1977"},
...etc
];
records.filter(record => record.lengthSec > (60 * 60))
.map(record => ({
...record,
['display']: `${record.artist} - ${record.title} (${record.released})`
// item is named record for easily knowing what
// we're operating on
records.reduce((acc, record) => {
// Recored is not longer than 60 mins
// return acc as is, doing nothing with record (filter)
if (record.lengthSec > (60 * 60)) return acc;
// Destructure acc into new array
// Destructure record into new object and add display prop
return [
const records = [
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"},
{ title: "Rocket to Russia", artist: "Ramones", type: "LP", lengthSec: 1906, released: "1977"},
...etc
];
const wayOne = Object.assign({}, records);
const wayTwo = { ...records };
/*
=> {
const records = [
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"},
{ title: "Rocket to Russia", artist: "Ramones", type: "LP", lengthSec: 1906, released: "1977"},
...etc
];
// es5
const way = records.reduce((acc, record) => {
acc[`${record.title} - ${record.artist}`] = record;
const records = [
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"},
{ title: "Rocket to Russia", artist: "Ramones", type: "LP", lengthSec: 1906, released: "1977"},
{ title: "London Calling", artist: "The Clash", type: "LP", lengthSec: 3903, released: "1979"},
{ title: "Ramones", artist: "Ramones", type: "LP", lengthSec: 1755, released: "1976"},
...etc
];
const removeIndexes = [1, 2];
records.reduceRight((acc, item, idx) => {
const apiResponse = [
{first: 'Bob', favorite: 'The Clash'},
{first: 'Linda', favorite: 'Ramones'},
{first: 'Amy', favorite: 'The Clash'},
];
const friendConstants = ['Bob', 'Amy', 'James', 'Tiffany', 'Linda'];
friendConstants.reduce((acc, friend, idx, orgArray) => ({
// Check for friend in apiResponse
// if there pull them out otherwise we create a default objecct
// Materialize
<Button
children=node
className=string
disabled=bool
flat=bool
large=bool
floating=bool
icon=string
onClick=func
// Materialize
<Input
s=number // ##########
m=number // Media query sizes
l=number // ##########
children=node
className=string
label=node
error=string
success=string