Skip to content

Instantly share code, notes, and snippets.

View rlittlefield's full-sized avatar

Ryan Littlefield rlittlefield

View GitHub Profile
@rlittlefield
rlittlefield / gist:f5f4211ced01eb687211fcceafe75479
Created April 5, 2021 21:16
github actions bridge network for newly created image
BRIDGE_NETWORK_ID=$(docker network ls --filter=name=github_network_ --format="{{.ID}}")
docker run --network="$BRIDGE_NETWORK_ID" -i imagename dosomething
@rlittlefield
rlittlefield / postgres_queries_and_commands.sql
Created October 26, 2020 22:06 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@rlittlefield
rlittlefield / gist:5545693
Last active July 27, 2017 05:44
Roll20: Dice expression checker
/*
Copyright (c) 2013 J. Ryan Littlefield
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@rlittlefield
rlittlefield / gist:99e5ddd15a611fe62cea199e77fe99f4
Created October 14, 2016 16:25
ed25519.py with added scalarmultbase function to make it compatible with mininero
# Ed25519 digital signatures
# Based on http://ed25519.cr.yp.to/python/ed25519.py
# See also http://ed25519.cr.yp.to/software.html
# Adapted by Ron Garret
# Sped up considerably using coordinate transforms found on:
# http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
# Specifically add-2008-hwcd-4 and dbl-2008-hwcd
try: # pragma nocover
unicode
# This is an attempt to make a real version of sc_reduce32,
# to match exactly the behavior in in:
# https://github.com/monero-project/monero/blob/2846d0850d6e92d38c44eac9e6a4fca6b1545453/src/crypto/crypto-ops.c
def loadN(b, n, index):
base = 0;
result = 0
for i in range(n):
byte = b[index+i]

Symmetric Encryption

The only way to encrypt today is authenticated encryption, or "AEAD". ChaCha20-Poly1305 is faster in software than AES-GCM. AES-GCM will be faster than ChaCha20-Poly1305 with AES-NI. Poly1305 is also easier than GCM for library designers to implement safely. AES-GCM is the industry standard.

Use, in order of preference:

  1. The NaCl/libsodium default
@rlittlefield
rlittlefield / gist:5538171
Last active July 8, 2016 00:20
Roll20 API - Highlight whichever token is currently up for initiative
on('ready', function() {
jrl_initiative_timer = setInterval(function() {
var c = Campaign();
var pre_turnorder = c.get('turnorder');
if (!pre_turnorder) {
return;
}
try {
var turn_order = JSON.parse(c.get('turnorder'));
@rlittlefield
rlittlefield / Roll20TokenSnapshotAndClasses.js
Last active May 29, 2016 17:23
Roll20 - Graphic/Token snapshot saving/loading for building your own macros
/*
Copyright (c) 2013 J. Ryan Littlefield
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@rlittlefield
rlittlefield / gist:5493842
Last active December 16, 2015 20:39
Roll20 API: reveal command by class
var getByClasses = function(classes, criteria) {
var graphics = findObjs({
_pageid: Campaign().get("playerpageid"),
_type: "graphic",
});
var cclasses = {};
for (var i = 0, il = classes.length; i < il; i++) {
cclasses['.'+classes[i]] = true;
}