Skip to content

Instantly share code, notes, and snippets.

View mattboehm's full-sized avatar

Matthew Boehm mattboehm

View GitHub Profile
//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)}
<!-- 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.-->
#!/usr/bin/env bash
if [ "$#" -ne 2 ]
then
echo "move a directory to a new location.
While normally, git mv old-dir new-dir should work, let's say you do that and then try to merge in another branch where someone's added new files to old-dir.
these files will stay in old-dir, and we need a way to merge their (arbitrarily deeply nested) contents into new-dir. This script uses cp -r to merge the contents,
followed by git add/rm. When you do git status, it should now show that all those files have been moved.
Warning: script will add the whole target directory, including uncommitted changes on files that existed before it ran."
echo "usage: $0 <old-dir> <new-dir>"
function! SplitRegex()
    tabnew
    setlocal buftype=nofile bufhidden=hide noswapfile
    let numlines=len(@")
    execute "normal! V".numlines."pggjl"
    let tmp=@z
    let @z="hv0r wlv$r j"
    execute "normal! ".(numlines-2)."@z"
    let @z=tmp
    execute "normal! gglv$r\<space>"
@mattboehm
mattboehm / tetris_dense.py
Created April 13, 2014 16:59
Pycon 2014 Thumbtack solution ("dense" version)
import sys, re #thumbtack pycon tetris challenge. "dense" solution by @mattboehm
def shift_down(col):#shift piece down 1 space
loc = "".join(col[::-1])
space = loc.find("#") - 1
return col if loc == -2 else list(loc[:space] + loc[space+1:] + ".")[::-1]
def top_row_blank(board):#check if the top row has only .
return all(tile == "." for tile in board[0])
def find_piece(board):#Replace the X's for the piece with #
board, marked_board = board[:], []
while top_row_blank(board):#skip top blank rows
@mattboehm
mattboehm / gist:9977950
Created April 4, 2014 16:15
A mini-plugin to cycle through diffs of unstaged git changes by file (requires fugitive)
nnoremap <silent> <leader>gm :tab split<CR>:Glistmod<CR>
nnoremap <silent> <c-s-j> :call g:DiffNextLoc()<CR>
nnoremap <silent> <c-s-k> :call g:DiffPrevLoc()<CR>
command! Glistmod only | call g:ListModified() | Gdiff
function! g:ListModified()
let old_makeprg=&makeprg
let old_errorformat=&errorformat
let &makeprg = "git ls-files -m"
let &errorformat="%f"
@mattboehm
mattboehm / gist:7456743
Last active December 28, 2015 06:28
Tmux aliases
#tl: list sessions
alias tl='tmux ls'
#tn <name>: create a session named <name>
alias tn='tmux -2 new -s'
#ta <name>: attach to a session named <name>
alias ta='tmux -2 attach -t'
@mattboehm
mattboehm / gist:7109927
Last active January 6, 2024 07:25
Highlighting lines in vim
"with your cursor on a line or a block selected, type `:HL`
"to remove, on each line call :sign unplace
highlight HL ctermbg=darkgray
sign define hl linehl=HL
let s:highlightLineSignId = 74000
function! g:HighlightLine()
execute 'sign place' s:highlightLineSignId 'line='.line(".") 'name=hl' 'file='.expand("%")
let s:highlightLineSignId += 1
endfunction
command! HL call g:HighlightLine()
@mattboehm
mattboehm / marks.vim
Created March 15, 2013 01:35
Notes from my February NoVA Vim presentation on marks, jumps and registers. Mostly just a list of suggested :help sections to read.
"These lines map a hotkey that allow you to easily execute the current line or
"selection by hitting F9. It's a cheesy hack that made demoing while reading
"through this more simple.
"
"This is also why commands start with colons. Normally colons would be
"unnecessary if trying to execute these in your vimrc.
:nnoremap <F9> "ayy@a
:vnoremap <F9> "ay@a
"Marks {{{
@mattboehm
mattboehm / merge.vim
Created December 12, 2012 21:19
Crappy Vim "mail merge"
"I recorded a macro of the command. These are the keystrokes I hit to do one line
"To do all lines, I recorded the macro in register q (starting on the first line of names.csv)
"then did 2@q to repeat macro twice more.
"This assumes the template is in the same dir and is very brittle
"You should use a templating engine like genshi for non-trivial templating, but just wanted to show that this is possible
"Creates $email.html file for each email address.
0"ayt,f,l"by$:new^M;read template.html^M:%s;\$EMAIL;^Ra;g^M:s;$NAME;^Rb;g^M:w! ^Ra.html^M:bd^Mj