Skip to content

Instantly share code, notes, and snippets.

View warmwaffles's full-sized avatar
🛠️
Code Wrestling

Matthew Johnston warmwaffles

🛠️
Code Wrestling
View GitHub Profile
#include <stdint.h>
uint64_t s[2];
uint64_t
xorshiftrng128(void)
{
uint64_t s1 = s[0];
uint64_t s0 = s[1];
uint64_t result = s0 + s1;
@warmwaffles
warmwaffles / defer.c
Created September 30, 2020 22:09 — forked from jart/defer.c
Go-like defer for C that works with most optimization flag combinations under GCC/Clang
#include "gc.h"
/**
* Adds destructor to garbage shadow stack.
*
* @param frame is passed automatically by wrapper macro
* @param fn takes one argument
* @param arg is passed to fn(arg)
* @return arg
*/
@warmwaffles
warmwaffles / convert.md
Last active October 17, 2020 01:05
Convert go-pro timelapse with ffmpeg

To compile all of the gopro timelapse images use the following command.

ffmpeg -r 6 \
  -f image2 \
  -pattern_type glob \
  -i '*.JPG' \
  -s 4000x3000 \
  -c:v mjpeg \
 -q:v 10 \
@warmwaffles
warmwaffles / organize.py
Created October 26, 2020 17:34
Organize GoPro Hero7 files.
"""
Works primarily only with GoPro Hero 7 at the moment.
GoPro has a really weird naming scheme and terrible pattern for timelapse and
videos. This tool helps move files into a usable / navigable directory.
"""
import argparse
import os
import re
# Some help text here
thing:
@echo boooo
# Show this help.
help:
@python make_help.py $(MAKEFILE_LIST)
@warmwaffles
warmwaffles / dotenv.fish
Created April 4, 2021 15:05
Loads a dotenv file definition into the current fish shell
function dotenv -a filePath -d 'exports all .env entries to global'
if not test -f $filePath
echo Error: file $filePath does not exist or can not be read
return
end
echo Parsing dotenv file $filePath
for entry in (cat $filePath | grep -v '^#' | grep -v '^$')
set entry = (string split -m 1 \= -- $entry)