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%'

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
<?php
# Nginx don't have PATH_INFO
if (!isset($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = substr($_SERVER["ORIG_SCRIPT_FILENAME"], strlen($_SERVER["SCRIPT_FILENAME"]));
}
$request = substr($_SERVER['PATH_INFO'], 1);
$file = $request;
$fp = @fopen($file, 'rb');
@rlittlefield
rlittlefield / gist:e7ee65ccf3f103fcc78d
Created August 21, 2014 16:35
Cesium JS - geometry age determines visibility behind low-opacity billboards
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var primitives = scene.primitives;
var old_col = new Cesium.PolylineCollection();
scene.primitives.add(old_col);
var billboards = primitives.add(new Cesium.BillboardCollection());
billboards.add({
image : '../images/Cesium_Logo_overlay.png',
@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:
@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'));