Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@mplewis
mplewis / alt.rb
Created January 8, 2018 18:49
Generate alternating-hand words for easy typing. Dictionary: https://github.com/dwyl/english-words. ruby alt.rb < ~/Downloads/words.txt > alternating.txt; gshuf -n 50 < alternating.txt
KEYS_ON_LEFT_HAND = 'qwertasdfgzxcv'
def alternating?(iterable)
return true if iterable.count < 2
return false if !!iterable[0] == !!iterable[1]
alternating? iterable.drop 1
end
def key_on_left_hand(word)
word.downcase.chars.map { |l| KEYS_ON_LEFT_HAND.include? l }

The Life and Death of People and Software

  • Sandi Metz: You're Insufficiently Persuasive
    How do you get people to do what you want? Why do we fight with people when we all want the same thing?

  • Chad Fowler: Growing Old
    No one will remember your code when you die. Then, what will your legacy be? How do we leave a dent in our fellow humans?

Dope Shell Stuff

These are my favorite tools for making my terminal a nice place to work.

  • bat: cat, but with pretty syntax highlighting, git, and diff support
  • chezmoi: Sync your dotfiles using a Git repo
  • diff-so-fancy: better-looking diffs for modern terminals
  • exa: ls, but pretty by default
  • Fantasque Sans Mono: A lovely monospace font with ligatures and a friendly shape
  • fasd: navigate between project directories really quickly
@mplewis
mplewis / sickgif.sh
Last active November 10, 2017 21:58
Turn screencasts into high-quality gifs with FFmpeg
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
set -x
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
# Default settings work great for screencasts. For video from an actual camera, set MOTION=1.
MOTION=${MOTION:-}
NOT PLANNED ON A WHIM STIR FRY
And you couldn't bring eggs because you motorcycled to the store
PRE-PREP:
1. Go to Asian grocery with no recipe in mind and assorted leftovers
2. Buy what looks colorful and good
3. Get home and find carrots in crisper
PREP:
Pre-cook pork
@mplewis
mplewis / breaker.rb
Created February 27, 2017 20:41
Basic circuit breaker in Ruby
class Breaker
def initialize(threshold, debug = false)
@active = true
@fails = 0
@threshold = threshold
@debug = debug
@on_trip = nil
end
def on_trip(&block)
$ 1 0.000005 1.8479586061009856 50 5 43
v 240 352 240 208 0 0 40 5 0 0 0.5
s 400 288 400 352 0 0 false
d 320 288 400 288 1 0.001
d 480 288 400 288 1 0.805904783
r 320 288 320 208 0 100000
w 400 352 320 352 0
w 320 352 240 352 0
w 240 208 320 208 0
w 400 352 480 352 0