Skip to content

Instantly share code, notes, and snippets.

set ruler
set showcmd
set hlsearch
set incsearch
set ignorecase
set smartcase
set autoindent
filetype plugin indent on
let mapleader = ","
@betaveros
betaveros / zipmagic.py
Created May 17, 2015 10:19
magically fix (most of) this zip with corrupted filenames I got
import codecs
import os
import shutil
import zipfile
def magic(fname):
if type(fname) == unicode: return fname
assert type(fname) == str
return codecs.decode(fname, 'shift-jis', 'replace')
@betaveros
betaveros / underblank.sty
Created July 22, 2015 05:04
I wrote this in... December 2009? What the hell?
% underblank.sty: Blanks for tests and study guides and all that multiverse cr&p
% to get the answers, declare a command \underblankanswers to anything.
\ProvidesPackage{underblank}
\usepackage{ulem}
\usepackage{ifthen} % need 2 versions: w/, w/o answers
\normalem
\newlength{\answerwidth}
\newcommand{\emptyline}{\vspace{\baselineskip}}
\newcommand{\underblank}[2]{\settowidth{\answerwidth}{#1}\uline{\makebox[\answerwidth][c]{#2}}}
@betaveros
betaveros / digraph.py
Created December 4, 2015 00:49
sketchy sketchy digraphs
#!/usr/bin/env python
# nontrivial parts come from
# http://paste.pound-python.org/raw/6aCbTG3lKgCWdrRygkBG/
# tmux magic incantation:
# bind-key v command-prompt -p "Enter digraph:" "set-buffer \"%%\"; save-buffer /tmp/tmux-digraph-input; delete-buffer; if-shell 'digraph.py < /tmp/tmux-digraph-input > /tmp/tmux-digraph-output' 'load-buffer /tmp/tmux-digraph-output; paste-buffer -d; run-shell \"rm /tmp/tmux-digraph-output /tmp/tmux-digraph-input\"' 'display-message \"Error in digraph lookup\"'"
import logging
import os.path
import sys
import unicodedata

Keybase proof

I hereby claim:

  • I am betaveros on github.
  • I am betaveros (https://keybase.io/betaveros) on keybase.
  • I have a public key whose fingerprint is 9B4D 8695 1809 7390 1AC8 107E 58B4 4740 9AB4 540F

To claim this, I am signing this object:

(lambda main: main(0, 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10, main))(lambda _, license, chosen_word, guesses, scaffold, man, guesses_left, main_: main_(map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), license, chosen_word, guesses, scaffold, man, max((10 - len(guesses - set(chosen_word))), 0), main_) if not all(letter in guesses for letter in chosen_word) and guesses_left else __import__('sys').stdout.write('You ' + ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)] + '\nWord was ' + chosen_word + '\n'))
@betaveros
betaveros / .vimrc
Created May 21, 2016 00:58
the .vimrc MIT used at ICPC WF 2016; half of it was probably unnecessary, but it's probably not worth it to figure out which half
set nocp ai bs=2 cul hls ic is lbr list ls=2 mouse=a nu ru sc scs smd so=3 sw=4 ts=4
set lcs=tab:»\ ,trail:␣
filetype plugin indent on
syntax on
map <Space> i<Space><Esc>
map gA m'ggVG"+y''
@betaveros
betaveros / c.hs
Last active November 25, 2016 03:19
combinatorics!
import Control.Monad
import Data.List
-- Haskell comments look like this, lines that start with two hyphens.
{- You can also write range comments like this. -}
-- We did not write the type annotations (lines with ::) during class, and in
-- fact if you delete them Haskell will supply (more general) type signatures.
-- You can see what type Haskell thinks the things we've defined are by running
from __future__ import division, print_function
def partial_differences(xs):
return [x2 - x1 for (x1, x2) in zip(xs, xs[1:])]
def index_of_max(xs):
return max(enumerate(xs), key=lambda pair: pair[1])[0]
# given a list of floats, compute a tempo and a timestamp
def tempo(xs, max_beats):
@betaveros
betaveros / fn_minus.xml
Created January 9, 2017 15:45
Karabiner XML for mapping fn+- (fn-hyphen) to a legitimate minus sign, cobbled together from sone online sources I forget
<?xml version="1.0"?>
<root>
<item>
<name>Change fn+- to (minus sign)</name>
<appendix>You need to enable Unicode Hex Input and U.S. input sources.</appendix>
<identifier>private.fn_minus</identifier>
<autogen>__KeyToKey__
KeyCode::MINUS, ModifierFlag::FN,
<!-- change input source to Unicode -->