Skip to content

Instantly share code, notes, and snippets.

View twopoint718's full-sized avatar
yo

Christopher Wilson twopoint718

yo
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@twopoint718
twopoint718 / read_jwt.rb
Created June 5, 2020 19:22
A script to decode a JSON Web Token given on standard input
#!/usr/bin/env ruby
require 'base64'
require 'json'
require 'openssl'
if ARGV.include?('-h') || ARGV.include?('--help')
puts <<~EOS
USAGE
@twopoint718
twopoint718 / bitfields.c
Created December 8, 2019 20:19
Bitfields in C
#include <stdio.h>
#include <stdint.h>
typedef struct {
uint8_t foo :4;
uint8_t :3;
uint8_t bar :1;
} foobar;
int main(int argc, char** argv) {
#!/bin/bash
set -e
APIKEY="YOUR-API-KEY-HERE"
trap onexit INT
function reset() {
echo 'Resetting status'
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token=${APIKEY}&profile=%7B%22status_text%22%3A%22%22%2C%22status_emoji%22%3A%22%22%7D" > /dev/null
@twopoint718
twopoint718 / database_files.sh
Created November 20, 2019 22:10
Script that returns all on-disk PostgreSQL database files for a given database.
#!/usr/local/bin/bash
set -e
if [ -z "$1" ]; then
echo "Must provide database name, e.g. 'my_database'"
exit 1
fi
db_dir=$(psql postgres -Atc "select (select setting from pg_settings where name = 'data_directory') || '/base/' || (select oid from pg_database where datname='$1')")
@twopoint718
twopoint718 / dsl.hs
Created August 22, 2019 00:40
Playing around with no-parameter typeclasses. These can pull values out of the "App" environment so that the `run` function can use them.
{-# LANGUAGE MultiParamTypeClasses, MonoLocalBinds #-}
import Control.Monad.Reader
class HasFoo where
foo :: App String
class HasBar where
bar :: String
@twopoint718
twopoint718 / tempfile.sh
Created August 1, 2019 16:38
Ephemeral Tempfile in bash
#!/bin/bash
set -Eeuo pipefail
# Create a tempfile, get writeable (4) and readable (5) file descriptors.
# Immediately remove the actual temfile, making it inaccessible to other
# processes. This script will hold onto the descriptors until it exits.
tmpfile=$(mktemp)
echo "created $tmpfile"
exec 5<"$tmpfile" 4>"$tmpfile"
None
createInforceReissue -> Open
Open&
cancel -> None
NBX
Valid
add change -> CheckingWithFlashUW
finalize -> REFLEXSubmitted
Invalid
Batch Open
1 closeout -> 2 Cash Drop In-Progress
2 Cash Drop In-Progress
next -> 3 Printing All-Debts Receipt
3 Printing All-Debts Receipt
next -> 3 Printing Total-Tendered Receipt
3 Printing Total-Tendered Receipt
print error -> Error
4 next -> 5 Check Listing Screen
5 Check Listing Screen
Order
Open
addItem -> AddingItem?
# Transient
AddingItem?
added -> Hold
Hold
addItem -> AddingItem?
reopen -> Open
tender -> ZeroBalance?