Skip to content

Instantly share code, notes, and snippets.

View offby1's full-sized avatar

Eric Hanchrow offby1

View GitHub Profile
@offby1
offby1 / invoice.py
Last active December 16, 2015 21:48 — forked from anonymous/invoice.py
import collections
itemData = collections.defaultdict(list)
print('Reading rows...')
for row in range(10, 19):
# Each row in the spreadsheet has data for one item.
item = sheet['A' + str(row)].value
itemData['item'].append(item)
description = sheet['C' + str(row)].value
@offby1
offby1 / parse.py
Last active November 11, 2015 18:14 — forked from ysinc88/readme.txt
Creating new lines from the commas inside quotes
import codecs
import csv
import sys
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
with open('sample.csv', encoding='utf-8') as inf:
r = csv.reader(inf)
for line in r:
print(line)
@offby1
offby1 / jinja.tmp
Last active October 28, 2015 21:05 — forked from anonymous/jinja.tmp
%{ for count in range(0, multis) -%}
%{{ count %}} & A & B & C & D\\ \hline
%{ set count = count + 1 -%}
%{ endfor -%}
%{{ multis %}} & X & X & X & X\\ \hline
;; There's something similar in vc-git.el: vc-git-grep. Naturally,
;; though, I prefer this :)
;; --perl-regexp seems to be the most flexible flavor; in particular,
;; it's the only one I know of that supports '\b' to mean "word
;; boundary". Unfortunately, not all gits have the requisite support;
;; for example, on OS X with homebrew, I had to pass "--with-pcre" to
;; "brew install git".
;; -I means don't search through binary files
On second thought, _don't_ read me.
I'm working on a feature!!
Some second work on that feature.
This is where we actually fix it.
mystring1 = "cat"
mystring2 = "doge"
cmds = ['test %s' % mystring1, 'test 2 %s' % mystring2]
for cmd in cmds:
print cmd
;; Worst. Feature. Evar.
(when (fboundp 'electric-indent-mode)
(electric-indent-mode 0))
(when (eq window-system 'ns)
(global-set-key (kbd "M-`") 'other-frame)
(defun set-appropriate-font (frame)
(interactive "i")
(setq frame (or frame (selected-frame)))
(cl-flet ((points (pix) (+ 20 (round (- pix 1440) 200 ))))
(set-frame-font
(format "Inconsolata-%s" (points (display-pixel-height)))
nil
(erc-mode-abbrev-table)
"ams" 6 "http://toroid.org/ams/git-website-howto"
"atm" 71 "at the moment"
"bas" 265 "/me backs away slowly"
"ce" 1 "/me cackles evilly"
"ct" 21 "/me clears throat"
"ddtt" 6 "Don't Do That, Then®"
"dli" 84 "/me dances like an idiot in the end zone"
"dtrt" 6 "Do The Right Thing™"
def sorted_alphanumerically(strings, key=None):
"""Sort alphabetically, except treat strings of digits as numbers.
If key is not None, it must return a string.
>>> sorted_alphanumerically(['r1', 'r10', 'r2'])
['r1', 'r2', 'r10']
>>> sorted_alphanumerically(['r1', 'R10', 'r2'])
['R10', 'r1', 'r2']
>>> sorted_alphanumerically(['r1', 'R10', 'r2'], key=str.lower)
['r1', 'r2', 'R10']