Skip to content

Instantly share code, notes, and snippets.

View coopermaruyama's full-sized avatar

Cooper Maruyama coopermaruyama

View GitHub Profile
# Using redirection, run a command only if the previous command's exit code is 0,
command &>/dev/null && conditionalcommand
# example:
tmux has-session -t mysession &>/dev/null && echo "mysession exists!"
@coopermaruyama
coopermaruyama / git-notes.sh
Last active August 29, 2015 14:25
Git Notes
# ---------------------------------------------------
# Correct workflow when working with forked upstreams.
# ---------------------------------------------------
git fetch origin --prune
# If you haven't made any local changes:
git checkout branch-name
git merge --ff-only origin/branch-name
# If you have local changes, you'll get this error: fatal: Not possible to fast-forward, aborting.
@coopermaruyama
coopermaruyama / docker-notes.sh
Last active August 29, 2015 14:26
Docker Notes
# --------------------------------------------------------------------------------------------------------
# BASIC ACTIONS
# -------------------------------------------------------------------------------------------------------
# start up a new machine
docker-machine create --driver virtualbox dev
# list VMs
docker-machine ps
/*=============================================================================
= Scales
=============================================================================*/
.text-xxs {
font-size: 0.8rem;
}
.text-xs {
font-size: 1rem;
}
@coopermaruyama
coopermaruyama / utilities.scss
Created November 19, 2015 09:02
Utils SASS file
/*=============================================================================
= Scales
=============================================================================*/
//
// Text
//
$textSizes: (
(xxs, .8rem),
(xs, 1rem),
(sm, 1.2rem),
@coopermaruyama
coopermaruyama / .eslintrc
Last active November 21, 2015 22:18
UI Team ESLint (+ Miguel's suggestions)
{
"root": true,
"env": {
"es6": true,
"browser": true
},
"rules": {
"indent": [2, "tab"],
"strict": [2, "global"],
"no-use-before-define": 0,
@coopermaruyama
coopermaruyama / vim-notes
Created December 10, 2015 00:10
My VIM Notes
# manually specify syntax
:set syntax=js
// view 'recent' files
:buffers // open a 'recent' file
:buffer nameFromList
// diff file against any arbitrary text in v-split
@coopermaruyama
coopermaruyama / compare_collections.js
Created May 12, 2016 23:41
ES6: Check if array contains an item in another array
const arr = [1,2,3];
const otherArr = [3,4,5];
arr.some(a => otherArr.some(b => a === b)); // => true
// using a collection and comparing with keys
const collection = [{a: 1}, {a: 2}, {a: 3}];
const collection2 = [{a: 3}, {a: 4}, {a: 5}];
collection.some(a => collection2.some(b => a.a === b.a)); // => true
@coopermaruyama
coopermaruyama / rescursiveReduce.js
Last active May 27, 2016 00:41
ES6: Recursive vertical reducer
//
// * Given some data that looks like this:
//
// let data = [
// {
// key: 'a',
// value: 'a1',
// children: [
// {
// key: 'b',