Skip to content

Instantly share code, notes, and snippets.

Nathan Grigg nathangrigg

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am nathangrigg on github.
  • I am nathangrigg (https://keybase.io/nathangrigg) on keybase.
  • I have a public key ASAOB7SGlusGtRWA31uOinmVzQMjYMFtVfVOSHqSQxGv9Qo

To claim this, I am signing this object:

View taskpaper_pdf
#!/usr/local/bin/python3
"""Taskpaper to pdf using pandoc.
See http://leancrew.com/all-this/2015/06/putting-the-paper-in-taskpaper/
"""
import argparse
import contextlib
import re
import subprocess
import sys
View -
#!/usr/bin/env python
import argparse
import collections
import re
import sys
RE_INCLUDE = re.compile(r'^include\s+"([^\n"]+)"')
RE_ACCOUNT = re.compile(r'^\d{4,}-\d{2}-\d{2}\s+open\s+(\S+)')
def parse_file(fh, files, accounts):
View windows.html
<!DOCTYPE html>
<html>
<head>
<title>Journal Entries</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta charset="UTF-8" />
<style>
body {
width: 35em;
margin-left: auto;
View taskpaper_merge.py
#!/usr/local/bin/python3
"""Merge tasks into taskpaper file."""
import argparse
from collections import defaultdict, OrderedDict
import os
import re
# Note the leading space, which is required and which we consume.
# A trailing space is required unless we hit the end of line, but
View align-ledger.vim
" The :AlignLedger command adds spaces between an account and commodity so
" that the decimal points of the commodities all occur in the column specified
" by `g:ledger_separator_col`. If an amount has no decimal point, the imaginary
" decimal point to the right of the least significant digit will align.
"
" The command acts on a range, with the default being the current line. If the
" cursor happens to be inside that range and to the right of the account name,
" the cursor will be pushed to the right the appropriate amount, so that it
" remains on the same character.
"
@nathangrigg
nathangrigg / assign_page.rb
Created Nov 9, 2013
Jekyll plugin to assign a url to a variable and get access to the page object.
View assign_page.rb
# By Nathan Grigg
# Public domain
#
# The assign_page tag works like the assign tag, except it takes a url and
# returns a page or post object.
#
# Copy the file into Jekyll's _plugins folder
#
# Example:
#
@nathangrigg
nathangrigg / rmtex
Created Dec 6, 2012
Remove tex log files
View rmtex
#!/usr/local/bin/zsh
setopt local_options no_nomatch # suppress error message on nonmatching globs
USAGE='USAGE: rmtex [-r] [-f] [foo]
Argument:
[foo] file or folder
Options:
[-h] Show help and exit
@nathangrigg
nathangrigg / time_delta.rb
Created Sep 22, 2012
Jekyll plugin to calculate time between a post and the one before
View time_delta.rb
# By Nathan Grigg
# Public domain
#
# This tag takes two arguments: a post and the word "next" or "previous"
# It returns a phrase describing the difference in time
# e.g. "Five days later" or "One month ealier"
#
# Example:
#
# {% timedelta page previous %}
@nathangrigg
nathangrigg / postlist.rb
Created Sep 22, 2012
Jekyll plugin "postlist" to turn a list of URLs into an array of post objects
View postlist.rb
# By Nathan Grigg
# Public domain
#
# This block tag takes a list of post URLs, separated by newlines,
# and captures them to an array variable, which can be used later
# to loop on the listed posts.
#
# Copy the file into the _plugins folder
#
# Example:
You can’t perform that action at this time.