Skip to content

Instantly share code, notes, and snippets.

View mattboehm's full-sized avatar

Matthew Boehm mattboehm

View GitHub Profile
@mattboehm
mattboehm / post-merge
Last active August 27, 2020 21:02 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
"A small script to measure typing speed
"Shows speed in bottom bar when you leave insert mode
"Run :messages to see all recent speeds
"This script was a hack thrown together in 10-15 minutes and has not been well tested yet.
function! s:insertEnterTypespeed()
let b:startTime = localtime()
endfunction
function! s:insertLeaveTypespeed()
let chars = strlen(@.)
if chars
#python3
from collections import defaultdict, Counter
import pprint as pp
DV_KEYS = [
"',.pyfgcrl",
"aoeuidhtns",
";qjkxbmwvz",
]
KEYS = [
"qwertyuiop",
def solve(d):
d2 = re.sub("!.", "", d)
d3 = re.sub("<[^>]*>", "", d2)
return len(d2) - len(d3) - 2*d2.count(">")
must be run on cell size of 16 bits or more with wrapping on inc and dec operations
>>>>>>
,[------------------------------------------------>>,] read input and convert ascii digits to data
data is loaded into an array with empty slots in between the data cells
get len
<<[while still on a number
>[-<<+>>]<<+< move len counter to the left and inc
]
@mattboehm
mattboehm / aoc_2017_1_1.bf
Created December 5, 2017 03:29
Advent of code 2017 day 1 part 1 in Brainfuck
must be run on cell size of 16 bits or more with wrapping on inc and dec operations
>>
,[------------------------------------------------>,] read input and convert ascii digits to data
copy the first digit to the end (to handle wrapping)
+ add 1 to the end space to mark it
[<]> goto first digit
[<+[>]<+[<]>>-] move to marked space and the space before first digit <[>+<-] >[>]<

Keybase proof

I hereby claim:

  • I am mattboehm on github.
  • I am mattboehm (https://keybase.io/mattboehm) on keybase.
  • I have a public key ASAG7HB6IlBoTjEkg1-4QQCJmvyilUvwJxGyCnq7PNElCgo

To claim this, I am signing this object:

"""See how many qwerty words are also dvorak words"""
from __future__ import print_function
import string
QWERTY = "][abcdefghijklmnopqrstuvwxyz"
DVORAK = "=/axje.uidchtnmbrl'poygk,qf;"
TRANS = string.maketrans(QWERTY, DVORAK)
def main():
with open("/usr/share/dict/words") as f:
words = frozenset((word.strip().lower() for word in f))
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> help(string)
>>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
//advent of code 2016 part 2; will give wrong answer if x/y/distance don't fit in a signed byte
// {x} {y} {tmp0=0} {tmp1=0} {dir = 0 to 3} {num}
// ^
//{tmp1}
, //read L/R
[
---------------------------------------------------------------------------- //subtract 76 to make L 0
[ //if it's not 0 (It was an R)
> //{tmp2(0)}
++ //{add 2 to dir}