Skip to content

Instantly share code, notes, and snippets.

View dstebila's full-sized avatar

Douglas Stebila dstebila

View GitHub Profile
@dstebila
dstebila / ds_benchmark.h
Last active December 11, 2021 01:49
C macros for performance testing
/********************************************************************************************
* ds_benchmark.h: Macros for simple benchmarking of C code.
*
* See instructions for usage below.
* Software originally developed by Douglas Stebila.
* Most recent version at https://gist.github.com/dstebila/6980008ec98209ef6075
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
@dstebila
dstebila / keybase.md
Created January 12, 2015 23:07
Keybase proof

Keybase proof

I hereby claim:

  • I am dstebila on github.
  • I am dstebila (https://keybase.io/dstebila) on keybase.
  • I have a public key whose fingerprint is 2ADA 9B8D A02C 2977 D998 FFAA 35A2 F17C 7C8B 45E2

To claim this, I am signing this object:

@dstebila
dstebila / solarized.sh
Created December 31, 2014 01:28
Solarized colours as tcsh shell variables
#!/bin/tcsh
# Solarized colours (http://ethanschoonover.com/solarized) as tcsh shell variables
set solarized_base03 = "%{\033[1;30m%}"
set solarized_base02 = "%{\033[0;30m%}"
set solarized_base01 = "%{\033[1;32m%}"
set solarized_base00 = "%{\033[1;33m%}"
set solarized_base0 = "%{\033[1;34m%}"
set solarized_base1 = "%{\033[1;36m%}"
set solarized_base2 = "%{\033[0;37m%}"
@dstebila
dstebila / bin2hex.sh
Created October 21, 2014 18:10
Shell script to convert binary to hex
#!/bin/bash
# Read either the first argument or from stdin (http://stackoverflow.com/questions/6980090/bash-read-from-file-or-stdin)
cat "${1:-/dev/stdin}" | \
# Convert binary to hex using xxd in plain hexdump style
xxd -ps | \
# Put spaces between each pair of hex characters
sed -E 's/(..)/\1 /g' | \
# Merge lines
tr -d '\n'
@dstebila
dstebila / hex2bin.sh
Last active December 9, 2022 03:46
Shell script to convert hex file to binary, stripping out any comments
#!/bin/bash
# Read either the first argument or from stdin (http://stackoverflow.com/questions/6980090/bash-read-from-file-or-stdin)
cat "${1:-/dev/stdin}" | \
# Strip out comments starting with #
sed -E 's/#.*$//' | \
# Strip out comments starting with //
sed -E 's/\/\/.*$//' | \
# Strip out multi-line comments /* ... */
perl -0777 -pe 's{/\*.*?\*/}{}gs' | \