Skip to content

Instantly share code, notes, and snippets.

Sam Whited SamWhited

Block or report user

Report or block SamWhited

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SamWhited
SamWhited / precisTests.go
Last active Aug 12, 2019
Run the test vectors from the Python version of Precis against the Go version
View precisTests.go
// 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 / transactions.go
Last active Jun 3, 2018
Example of wrapping up database transactions with a closure.
View transactions.go
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 / fake_enums.md
Last active Jan 29, 2018
Experience report about attempting to ensure compile time correctness of values using the type system
View fake_enums.md

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 / .gitignore
Last active Aug 31, 2016
Jitsi Meet mod_token_auth ASAP test server
View .gitignore
testtoken
main
*.sw[op]
@SamWhited
SamWhited / .block
Last active Apr 25, 2016
Go bcrypt benchmarks
View .block
license: gpl-3.0
@SamWhited
SamWhited / keybase.md
Created Jun 28, 2015
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am SamWhited on github.
  • I am samwhited (https://keybase.io/samwhited) on keybase.
  • I have a public key whose fingerprint is 9761 51DE E472 01CE 4A85 9F70 5408 3AE1 04EA 7AD3

To claim this, I am signing this object:

@SamWhited
SamWhited / Makefile
Last active Aug 29, 2015
Print all cameras supported by the currently linked version of libraw
View Makefile
.PHONY: build
all: cameras
cameras: cameras.c
gcc -I/usr/include/libraw $< -o $@ -lraw
@SamWhited
SamWhited / thinklight.go
Created May 30, 2015
Turn on or off the ThinkLight (or keyboard backlight) on various ThinkPad laptops
View thinklight.go
package main
import (
"flag"
"log"
"os"
)
func btoi(n bool) byte {
if n {
@SamWhited
SamWhited / ciphers.md
Created Feb 2, 2015
Ciphers supported in Android (Conversations prefered order first, then system ciphers)
View ciphers.md

Android 4.4:

02-02 08:40:53.293    2514-2530/eu.siacs.conversations D/conversations﹕ Using
ciphers: [TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA,
SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA,
TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA,
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
@SamWhited
SamWhited / rawextract.py
Last active Dec 28, 2016
Extract metadata from Canon CR2 and Nikon NEF raw files
View rawextract.py
#!/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:
You can’t perform that action at this time.