Skip to content

Instantly share code, notes, and snippets.

View SamWhited's full-sized avatar

Sam Whited SamWhited

View GitHub Profile
@SamWhited
SamWhited / rawextract.py
Last active March 28, 2023 07:49
Extract metadata from Canon CR2 and Nikon NEF raw files
#!/usr/bin/env python
import sys
import os
from rawphoto.cr2 import Cr2
from rawphoto.nef import Nef
def print_entries(raw, ifd, level=1):
for name in ifd.entries:
@SamWhited
SamWhited / TimePreference.java
Created December 17, 2014 00:10
Time picker preference for Android
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TimePicker;
import java.text.DateFormat;
import java.util.Calendar;
@SamWhited
SamWhited / ejabberd.yml
Last active November 17, 2022 12:44
Example ejabberd config
### =======
### LOGGING
##
## loglevel: Verbosity of log files generated by ejabberd.
## 0: No ejabberd log at all (not recommended)
## 1: Critical
## 2: Error
## 3: Warning
## 4: Info
@SamWhited
SamWhited / transactions.go
Last active August 20, 2022 11:41
Example of wrapping up database transactions with a closure.
package transaction
import (
"context"
"database/sql"
)
// Exec creates a transaction and calls f.
// When it is finished, it cleans up the transaction. If an error occured it
// attempts to rollback, if not it commits.
@SamWhited
SamWhited / go.mod
Last active June 27, 2021 11:50
XEP Deps
module mellium.im/xepdeps
go 1.17
@SamWhited
SamWhited / fake_enums.md
Last active December 21, 2020 12:21
Experience report about attempting to ensure compile time correctness of values using the type system

Faking Enumeration Types with Consts and Unexported Types

What I Wanted to Do

While working on an implementation of the wire protocol from a network standard, I needed to implement an error response. These errors may come in one of several flavors which is encoded and sent along with the error:

  • Cancel
@SamWhited
SamWhited / Makefile
Last active November 17, 2019 19:30
Makefile for sheet music with LilyPond and LaTeX
SHELL = /bin/sh
.SUFFIXES:
.SILENT:
.PHONY: timidity clean
# If you want more output, change this.
REDIRECT = > /dev/null
SHEETMUSICDIR = Songs
AOBSHEETMUSICDIR = AOB/Songs
DRAFTSHEETMUSICDIR = Drafts/Songs
@SamWhited
SamWhited / precisTests.go
Last active August 12, 2019 19:52
Run the test vectors from the Python version of Precis against the Go version
// Command precisTests opens test/golden.json from the python version of Precis
// and attempts to run them against the Go version.
//
// Right now Python 3.7.4 appears to use Unicode Version 11.
// This means this program should be run with Go 1.13 to use the same version.
// This is gotip as of this gist.
//
// To install gotip try something like this:
//
// go get golang.org/dl/gotip
@SamWhited
SamWhited / hyperref.tex
Created April 23, 2012 18:42
The proper options for the hyperref LaTeX package
% Because I can never remember how to get rid of the borders on all systems...
\usepackage[pdfborder=0, bookmarks, colorlinks=false]{hyperref}
@SamWhited
SamWhited / qc.sh
Created June 6, 2012 20:38
Downloads Questionable Content (http://questionablecontent.net/)
#!/usr/bin/env bash
for i in $(eval echo {$1..$2})
do
curl "http://questionablecontent.net/comics/$i.png" > "QuestionableContent/$i.png"
done