Skip to content

Instantly share code, notes, and snippets.

View eschaefer's full-sized avatar

Eric Schaefer eschaefer

View GitHub Profile
@eschaefer
eschaefer / convert.sh
Created August 14, 2020 13:25
ffmpeg movie to gif
ffmpeg -i test.mov -vf "fps=15,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
@eschaefer
eschaefer / machine.js
Last active March 5, 2020 16:30
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@eschaefer
eschaefer / de-dupe.js
Last active March 31, 2019 13:56
Clean way of removing duplicates from an array
const duped = [1, 2, 3, 3, 3, 2, 1];
const deduped = [...new Set(duped)];
@eschaefer
eschaefer / general-components-codemod.js
Created March 29, 2019 12:35
Codemod to convert central general/index imports into tree-shakeable imports
/*
jscodeshift --parser=flow --extensions=js,jsx -t ./mod.js ~/Projects/frontend/app/*
*/
const GENERALS = {
AddToCartBtn: 'addToCartBtn/',
AddToLightbox: 'addToLightbox/',
AdManagerExportButton: 'adManagerExportButton/',
@eschaefer
eschaefer / reduce.re
Created February 27, 2019 18:27
ReasonML 2D array reduce or fold_left
let nestedArray = [|[|1, 1|], [|1, 2|], [|1, 3|]|];
let _ = nestedArray |> Array.fold_left(Array.append, [||]) |> Js.log;
/* [1,1,1,2,1,3] */
let _ = nestedArray |> Js.Array.reduce(Js.Array.concat, [||]) |> Js.log;
/* [1,3,1,2,1,1] */

Keybase proof

I hereby claim:

  • I am eschaefer on github.
  • I am eschaefer (https://keybase.io/eschaefer) on keybase.
  • I have a public key ASBbNCfGB9yehV7P_wkcXw09d5JhxGeUT_4GZVlmEZx-Nwo

To claim this, I am signing this object:

@eschaefer
eschaefer / linting.md
Last active June 2, 2017 13:56
Linting only staged JS files

Lint all staged .js and .jsx files

git diff --cached --diff-filter=ACMRTUXB --pretty='format:' --name-only | grep -E .jsx?\\?$ | xargs node_modules/eslint/bin/eslint.js --quiet --ext .jsx,.js

Lint all staged .scss files

git diff --name-only --staged --diff-filter=ACMRTUXB --relative | grep -E .scss\\?$ | xargs --no-run-if-empty node_modules/sass-lint/bin/sass-lint.js -v --max-warnings 0
find . -name "*.orig" -type f -delete
@eschaefer
eschaefer / .bash_profile
Created December 7, 2016 09:18
Git alias for purging old local branches no longer tracked remotely.
alias gitpurge='git branch --merged | grep -v "\*" | grep -Ev "(\*|master|develop|staging)" | xargs -n 1 git branch -d'
@eschaefer
eschaefer / Textarea.jsx
Created August 27, 2016 21:12
Textarea Auto Resize with React
const DEFAULT_HEIGHT = 20;
export default class Textarea extends React.Component {
constructor(props) {
super(props);
this.state = {
height: DEFAULT_HEIGHT,
value: "Don't get lost in the upside down",