Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Littlefield rlittlefield

View GitHub Profile
View postgres_queries_and_commands.sql
-- 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%'
View keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@rlittlefield
rlittlefield / gist:99e5ddd15a611fe62cea199e77fe99f4
Created Oct 14, 2016
ed25519.py with added scalarmultbase function to make it compatible with mininero
View gist:99e5ddd15a611fe62cea199e77fe99f4
# 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
View sc_reduce32.py
# 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]
View gist:d399b0464d4e89f5db9313df5818bd22

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
View gist:03a6ee07d1938b374073
<?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 Aug 21, 2014
Cesium JS - geometry age determines visibility behind low-opacity billboards
View gist:e7ee65ccf3f103fcc78d
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 Jul 27, 2017
Roll20: Dice expression checker
View gist:5545693
/*
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 Jul 8, 2016
Roll20 API - Highlight whichever token is currently up for initiative
View gist:5538171
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
Roll20 - Graphic/Token snapshot saving/loading for building your own macros
View Roll20TokenSnapshotAndClasses.js
/*
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: