Skip to content

Instantly share code, notes, and snippets.

View angeloashmore's full-sized avatar

Angelo Ashmore angeloashmore

View GitHub Profile
@angeloashmore
angeloashmore / repository_timestamps.rb
Created February 20, 2015 20:38
Lotus::Model timestamps handling using an entity's @created_at and @updated_at via its Repository.
module Lotus
module Repository
# Timestamps handling using an entity's @created_at and @updated_at.
#
# @since 0.2.4
module Timestamps
# Override existing public API into hosting class to support @created_at
# and @updated_at using Ruby implementations (database agnostic).
#
# @since 0.2.4
@angeloashmore
angeloashmore / Results
Last active April 2, 2017 10:41
Repeat artists for Pokemon on /r/place
// Magikarp
{
"ZiingIsMyName": 8,
"OhLookAThrowaway6": 19,
"BerryPi": 10,
"YouHateTheMost": 31,
"KuKKilicious": 11,
"BloodyShine": 13,
"OhLookAThrowaway4": 19,
"Powerdrift": 12,
@angeloashmore
angeloashmore / vimium-options
Last active June 23, 2017 05:17
Vimium Options
vimium-options
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@angeloashmore
angeloashmore / Preload.js
Last active January 23, 2018 22:24
React Preload Component
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { withStatechart } from 'react-automata'
const statechart = {
initial: 'idle',
states: {
idle: {
on: {
LOAD: 'loading',
@angeloashmore
angeloashmore / guide.md
Created March 15, 2018 00:47
Setup macOS nodejs development environment
  1. Install Homebrew

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Create a Brewfile

    touch ~/Brewfile
@angeloashmore
angeloashmore / valuesDeep.js
Created August 20, 2018 08:30
Returns all deeply nested values of the supplied object.
import * as R from 'ramda'
import * as RA from 'ramda-adjunct'
export const valuesDeep =
R.cond([
[
RA.isPlainObj,
R.pipe(
R.values,
R.map(x => valuesDeep(x)),
@angeloashmore
angeloashmore / useDispatcher.js
Created April 17, 2019 00:03
Reducer-style action handler hook. Send actions using a { type, payload } action descriptor.
import {
__,
compose,
difference,
has
isFunction,
isPlainObject,
keys,
negate,
} from 'lodash/fp'
@angeloashmore
angeloashmore / useScrollYDirection.js
Created May 6, 2019 20:58
Basic scrollY direction hook. -1 if up, 1 if down, 0 if static.
import { useState, useCallback, useEffect, useRef } from 'react'
const isBrowser = typeof window !== 'undefined'
export const useScrollDirection = ({ threshold = 0 }) => {
const UP = -1
const STATIC = 0
const DOWN = 1
const prev = useRef(isBrowser ? window.scrollY : 0)
@angeloashmore
angeloashmore / gatsby-build-time-optimizations.md
Last active October 4, 2019 19:56
Strategies to shorten build times for Gatsby websites.

Gatsby Build Time Optimizations

Strategies to shorten build times for Gatsby websites.

Gatsby Image

Reduce number of breakpoints using srcSetBreakpoints

srcSetBreakpoints sets the quantity and dimensions of the images provided to the srcset property. By default, Gatsby Image (via gatsby-plugin-sharp)