Skip to content

Instantly share code, notes, and snippets.

View ashearer's full-sized avatar

Andrew Shearer ashearer

View GitHub Profile
@ashearer
ashearer / puzzle.py
Last active August 29, 2019 21:12
Alphametic puzzle brute force
#!python
from itertools import permutations
def num(format, vals):
return int("".join(str(vals[letter]) for letter in format))
letters = "eightrnwy "
def to_indices(word):
return [letters.find(letter) for letter in word]
@ashearer
ashearer / gist:745908
Created December 17, 2010 23:38
Vim key bindings for Mac to open a Terminal or Finder window pointed at the current file's parent
" Add to ~/.vimrc
" F5 opens a Terminal window with its current directory set to the current
" file's parent.
" [The command uses an extra CR at the end to get rid of the "Continue"
" prompt, since it will always run over a one-line status bar. :silent doesn't
" help when the command itself is too long for the status bar. Putting the
" command into a variable before executing may be another way to do it.
" Even better: in a function, save sc (showcmd), set nosc, run cmd, restore sc.]
map <F5> :!osascript -e 'tell app "Terminal" to activate do script with command "cd " & quoted form of "%:p:h"'<CR><CR>