Skip to content

Instantly share code, notes, and snippets.

Python Namedtuple to Dict to JSON

I've patched this together from several different tutorials.

from collections import namedtuple
import json

dict_list = []

Bash for Times to Use with Remind

# Calculate number of minutes since start of day.
# Use this with output of `remind -s` to calculate
# task duration.

GENERIC_DATE=$(date +'%b %d %Z %Y') # Example output: "Feb 23 EST 2020"
START_OF_DAY_IN_SECONDS_SINCE_THE_EPOCH=$(date --date="$GENERIC_DATE" +'%s') # That date spec provides sste at midnight.
NOW_IN_SECONDS_SINCE_THE_EPOCH=$(date +'%s')

Notes for Sqlite Blog

  • Create a sqlite timestring with date:
date +'%Y-%m-%d %H:%M'
  • Read text file into a blob:
@trauber
trauber / README.md
Last active January 29, 2020 19:11

Timetrap TSV Formatter

Hacked from csv.rb.

module Timetrap
  module Formatters
    class Tsv
 attr_reader :output

Latest Awk for My Timetrap/Pandoc/LaTeX Invoicing System

Output is YAML for use as Pandoc metadata. The YAML contains LaTeX strings. \quad and \hphantom come in handy for spacing LaTeX item lists in the invoice template I'm using.

# Process tsv generated from timetrap.rb display output

Processing Timetrap Output for Invoicing

Process and Awk Draft

t display --format csv > tmp.csv
@trauber
trauber / jsonphotos.sh
Created July 25, 2019 19:47
Make a JSON List of Photos #json
# Use find and file to crawl for files with mime-type image/jpeg or image/png.
# Awk isolates file names.
# rjgpcom gets comments, if any.
# jo wraps everything up into json for jsongallery.
#
# https://jpmens.net/2016/03/05/a-shell-command-to-create-json-jo
# https://github.com/mariobox/jsongallery
@trauber
trauber / README.md
Last active July 17, 2019 12:51
#vcard #ex Remove Photos from Vcard with Ex

Remove Photos from Vcards

Good ole ex matches multiple lines very easily.

ex -n test.vcf +'g/PHOTO/,/^$/d' +wq
@trauber
trauber / README.md
Created July 17, 2019 12:40
#gs #pdf QandD Shrink a PDF with GS

QandDShrink a PDF with GS

I imagine mileage may vary on this but I was able to shrink a 15mb PDF to 2.5mb.


$ pdf2ps large.pdf large.ps

$ ps2pdf large.ps small.pdf
@trauber
trauber / blocknotesplitter.md
Last active July 10, 2019 12:57
#awk #markdown #firefox_addon