Skip to content

Instantly share code, notes, and snippets.

View mattboehm's full-sized avatar

Matthew Boehm mattboehm

View GitHub Profile
<!-- We were using FontAwesome for our icons, but then found that some clients have blocked the downloading of custom fonts.
To resolve this issue, we had to switch all our fonts to svgs instead.
Someone else has already converted FontAwesome to svgs/pngs, so we started with that repo ( https://github.com/CodeCharmLtd/Font-Awesome-SVG-PNG )
We decided to put our svgs in a sprite sheet and after a decent amount of trial and error, got things working.
Here's a code snippet; hope this helps!
More about this issue at https://github.com/FortAwesome/Font-Awesome/issues/3203
-->
<!-- SVG sprite sheet included once on the page.
It it hidden, but needs to be present so that other svgs can refer to these paths.-->
//Please excuse the horrible comments. Maybe when my head works again I'll clean this up. Tested at https://sange.fi/esoteric/brainfuck/impl/interp/i.html
// {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)}
//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}
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'
"""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))

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:

@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 <[>+<-] >[>]<
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
]
def solve(d):
d2 = re.sub("!.", "", d)
d3 = re.sub("<[^>]*>", "", d2)
return len(d2) - len(d3) - 2*d2.count(">")
#python3
from collections import defaultdict, Counter
import pprint as pp
DV_KEYS = [
"',.pyfgcrl",
"aoeuidhtns",
";qjkxbmwvz",
]
KEYS = [
"qwertyuiop",