Skip to content

Instantly share code, notes, and snippets.

View adamgiese's full-sized avatar

Adam Giese adamgiese

View GitHub Profile
@adamgiese
adamgiese / .gitconfig
Last active August 30, 2022 16:31
Some of my favorite git aliases
[alias]
# git grep
todos = grep -i todo -- ':/'
fonts = grep -E "(font)(-family)?:" -- "*.css" "*.scss"
hooks = grep -w -E "use[A-Z]+[a-zA-Z]*"
list-hooks = !git grep -Eho "use[A-Z]+[a-zA-Z]*" | sort | uniq | less
search-all = !git rev-list --all | xargs git grep
@adamgiese
adamgiese / ramda-music.js
Created October 3, 2018 12:53
Parsing shorthand with Ramda
import { pipe, split, map, match, head, applySpec, join, addIndex, last, add } from 'ramda';
import { Time } from 'tone';
const indexedMap = addIndex(map);
const calcDuration = pipe(split('@'), last);
const parseShorthand = pipe(
split(','),
indexedMap(
applySpec({
@adamgiese
adamgiese / restaurant-list.js
Last active July 23, 2018 04:35
Restaurants List
const restaurants = [
{
name: "Dan's Hamburgers",
price: 'cheap',
cuisine: 'burger',
},
{
name: "Austin's Pizza",
price: 'moderate',
cuisine: 'pizza',
@adamgiese
adamgiese / restaurant-chain.js
Created July 17, 2018 13:52
Declarative Arrays: Chain Restaurant
const currentTime = 15; // 3:00 PM
const isOpen = ({hours: {open, close} }) =>
currentTime > open && currentTime < close;
const isFood = ({cuisine}) => cuisine !== 'Coffee';
const toName = ({name}) => name;
const openRestaurants = restaurants
.filter(isOpen)
.filter(isFood)
.map(toName)
@adamgiese
adamgiese / restaurant-reducer.js
Created July 17, 2018 13:50
Declarative Arrays: Restaurant Reducer
const currentTime = 15; // 3:00 PM
const toOpenRestaurants = (openRestaurants, restaurant) => {
const {
name,
cuisine,
hours: {
open,
close,
}
} = restaurant;
@adamgiese
adamgiese / restaurant.js
Created July 17, 2018 13:48
Example Restaurant Payload
const restaurants = [
{
name: "Pizza Planet",
cuisine: 'Pizza',
hours: {
open: 11,
close: 22,
},
},
{
@adamgiese
adamgiese / callback-parameters.js
Created July 17, 2018 13:46
Declarative Arrays: Naming Callback Parameters
const cart = [
{
name: 'Waterloo Sparkling Water',
quantity: 4,
price: 1,
},
{
name: 'High Brew Coffee',
quantity: 2,
price: 2,
@adamgiese
adamgiese / naming-callbacks.js
Created July 17, 2018 13:43
Declarative Arrays: Naming Callbacks
const newEngland = [0,3,6,19,6];
const atlanta = [0,21,7,0,0];
const toScore = (accumulator, value) => accumulator + value;
const atlantaScore = atlanta.reduce((accumulator, value) => accumulator + value);
const newEnglandScore = newEngland.reduce(toScore);
console.log(Math.max(newEnglandScore, atlantaScore));
@adamgiese
adamgiese / divisible-by-three-filter.js
Created July 17, 2018 13:07
Declarative Arrays: Divisible By 3 Filter
const numbers = [1,2,3,4,5,6,7,8,9];
const divisibleByThree = numbers.filter(currentValue => currentValue % 3 === 0);
console.log(divisibleByThree); // [3,6,9];
@adamgiese
adamgiese / square-map.js
Created July 17, 2018 13:03
Declarative Arrays: Square map
const numbers = [1,2,3,4,5];
const squares = numbers.map(currentValue => currentValue * currentValue);
console.log(squares); // [1,4,9,16,25];