Skip to content

Instantly share code, notes, and snippets.

View rlittlefield's full-sized avatar

Ryan Littlefield rlittlefield

View GitHub Profile
@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;
}
@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: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 / 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: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',
<?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');

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
# 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]
@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

Keybase proof

I hereby claim:

To claim this, I am signing this object: