Skip to content

Instantly share code, notes, and snippets.

View cHemingway's full-sized avatar

Chris Hemingway cHemingway

View GitHub Profile
@cHemingway
cHemingway / example.c
Last active August 29, 2015 14:01
netprot_header_read
#include "netprot_header.h"
/* Psuedo-C for how to use this function */
/* One pointer to a netprot_header_stat per channel*/
struct netprot_header_stat *channel_header_stat[N_CHANNELS] = {NULL, NULL, NULL, NULL, /* ...More... */ NULL}
/* Capture Loop */
while (capturing) {
char chunk[MAXCHUNKLEN];
@cHemingway
cHemingway / minspritz.c
Created December 28, 2015 18:20
Spritz cipher implemented in one C file. Untested alpha code.
/*
* minspritz: A portable implementation of the Spritz cypher in C.
* Currently untested alpha code, not to be considered for any serious use.
* Written for leigibility over speed.
*
* Based on pseudocode in:
* "Spritz—a spongy RC4-like stream cipher and hash function" Rivest, Schuldt
* https://people.csail.mit.edu/rivest/pubs/RS14.pdf
*
* Copyright Chris Hemingway 2015
@cHemingway
cHemingway / unlucky_horses.ipynb
Last active September 21, 2018 15:49
Find out how many racehorses per year are born on a friday the 13th
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
INFO: Initializing raylib (v1.5.0)
INFO: Trying to enable MSAA x4
INFO: Display device initialized successfully
INFO: Display size: 1366 x 768
INFO: Render size: 800 x 450
INFO: Screen size: 800 x 450
INFO: Viewport offsets: 0, 0
INFO: OpenGL 3.3 Core profile supported
INFO: GPU: Vendor: Intel Inc.
INFO: GPU: Renderer: Intel HD Graphics 5000 OpenGL Engine
#! /usr/bin/env python2
"""oscillo.py: Port of windytan's oscillo.pl to python.
Requires Sox (for resampling), PIL/Pillow, and Numpy
Original script: https://gist.github.com/windytan/5276653
"""
import argparse
import subprocess
import struct
@cHemingway
cHemingway / flac_convert.sh
Last active June 20, 2019 20:04
Convert all wav files in a directory into flac
#!/bin/bash
# Script to covert all wav files to flac in parallel folder structure
# Chris Hemingway 2019, MIT License
#
# For VCTK corpus, but could easily be used with others
# Requires GNU parallel, please ensure you cite this in your research as they request
INDIR="wav48"
OUTDIR="flac48" # Presumes on same level as INDIR
set -e #Exit on first error
echo "Creating directory $OUTDIR"
@cHemingway
cHemingway / flac_check.sh
Last active January 2, 2022 18:30
Check output of flac_convert.sh
#!/bin/bash
# Script to check if flac_convert did it correctly
# Compares MD5 of audio stream using ffmpeg
# Chris Hemingway 2019, MIT License
#
# Requires GNU parallel, please ensure you cite this in your research as they request
function compare_audio {
hash1=$(ffmpeg -hide_banner -i "$1" -map 0:a -f md5 - 2>/dev/null)
hash2=$(ffmpeg -hide_banner -i "$2" -map 0:a -f md5 - 2>/dev/null)
# echo "$1=$hash1 $2=$hash2" # uncomment to see md5 of each file
@cHemingway
cHemingway / led_flash
Created June 21, 2019 08:56
Put this under /etc/watchdog.d, make it executable, and it will be ran by the watchdog automatically
#!/bin/bash
# Chris Hemingway 2019
# Script to flash LED every time watchdog runs, using kernel transient led trigger support
# Path to your LED device here
LED=/sys/devices/platform/leds/leds/orangepi:red:status
if ! [[ -f /tmp/watchdog_led_begun ]] ; then #Run setup only once
echo transient > $LED/trigger
echo 500 > $LED/duration
@cHemingway
cHemingway / watercooler_light.sh
Last active June 24, 2019 11:30
Turns Kraken X61 LED off on system suspend
#!/bin/bash
# Script to turn Kraken X61 light off on suspend
# Chris Hemingway 2019, MIT License
# Place under /lib/systemd/system-sleep/ on Debian/Ubuntu
# See https://blog.christophersmart.com/2016/05/11/running-scripts-before-and-after-suspend-with-systemd/
# Uses levctl, must be installed globally $ sudo -H pip3 install --upgrade leviathan pyusb
if [ "${1}" == "pre" ]; then
# Turn fan off
levctl -s 40 -m off -q

Keybase proof

I hereby claim:

  • I am chemingway on github.
  • I am chemingway (https://keybase.io/chemingway) on keybase.
  • I have a public key whose fingerprint is 54B7 26B3 DF30 D6C6 0325 AE07 D50F CC6B A89A 82B0

To claim this, I am signing this object: