Skip to content

Instantly share code, notes, and snippets.

View wesm87's full-sized avatar
:shipit:

Wes Moberly wesm87

:shipit:
  • Curative
  • Cincinnati, OH
View GitHub Profile
@wesm87
wesm87 / keyBy.js
Last active January 2, 2018 17:32
Reduce an array of objects to a map keyed by the specified property
const recordList = [
{ id: 1, a: 'b' },
{ id: 2, foo: 'bar' },
{ id: 3, hello: 'world' },
]
/**
* Lodash FP Version
*/
import { keyBy, property } from 'lodash/fp'
@wesm87
wesm87 / stubValue.js
Last active January 2, 2018 17:46
Takes a value and returns a function that returns that value. Always returns a new reference if the value is an object or array.
import { is, when, anyPass, clone } from 'ramda'
const stubValue = (value) => () => when(
anyPass([
is(Array),
is(Object),
]),
clone,
)(value)
@wesm87
wesm87 / _helpers.sh
Last active November 10, 2017 17:45
Git post-merge hook to auto-install dependencies
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
on_changed() {
echo "$changed_files" | grep --quiet "$1" && eval "$2" || return 0
}
@wesm87
wesm87 / react-router-4.0.0-alpha.5.d.ts
Created November 21, 2016 14:13
TypeScript definitions for React Router v4 Alpha
/**
* Custom typedef for React Router v4 (WIP).
*/
declare module 'react-router' {
export type Action = 'PUSH' | 'REPLACE' | 'POP';
export type Location = {
pathname: string,
search: string,
@wesm87
wesm87 / keybase.md
Created June 15, 2016 01:47
keybase.md

Keybase proof

I hereby claim:

  • I am wesm87 on github.
  • I am wesmoberly (https://keybase.io/wesmoberly) on keybase.
  • I have a public key ASBQQ0IGrQXbe52YuS4kOFcHTzdrCsdLGO4YlnghWSt0ego

To claim this, I am signing this object:

@wesm87
wesm87 / breakpoints.scss
Last active April 3, 2018 20:27
Responsive Breakpoints Using Sass Maps
// Breakpoints
$breakpoints: (
'sm': 480px,
'sm+': 640px,
'md': 768px,
'md+': 1024px,
'lg': 1280px,
'lg+': 1440px,
'xl': 1600px,
'xl+': 1920px,
@wesm87
wesm87 / Base_Collection.coffee
Last active November 10, 2017 17:53
WordPress + CoffeeScript + Backbone
# Root object
root = exports ? module.exports ? self ? this
# Replace `plugin_slug` below with whatever you used in `wp_localize_script()`.
# The `||= {}` at the end will assign an empty object to `root.plugin_slug` if it doesn't already exist.
app = root.plugin_slug ||= {}
# Dependencies
$ = root.jQuery ? root.$
_ = root._