Skip to content

Instantly share code, notes, and snippets.

✌( ͡ᵔ ͜ʖ ͡ᵔ )✌

Max Ogden maxogden

✌( ͡ᵔ ͜ʖ ͡ᵔ )✌
Block or report user

Report or block maxogden

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
maxogden / index.js
Last active Feb 1, 2020
JavaScript Base-40 Class
View index.js
// based on
class B40 {
constructor() {
this.B16_CHARS = '0123456789abcdef'
this.B40_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz-_.+'
divmod(x, y) {
const div = x / y
const rem = x % y
View index.js
var fs = require('fs');
var Speaker = require('speaker'); // version 0.3.0
var OpenJTalk = require('node-openjtalk').OpenJTalk;
// pre-included HTS voice file
var fn_voice = OpenJTalk.voices.mei_normal;
// instantiate OpenJTalk with an HTS voice
var open_jtalk = new OpenJTalk({voice: fn_voice});
// synthesize a voice synchronously
maxogden / difflint
Last active Oct 25, 2019
Run eslint + prettier on only files that you've staged/commited on the current branch
View difflint
#!/usr/bin/env bash
# chmod +x this and save in your PATH. Assumes `eslint` + `prettier` are in your `devDependencies`
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
BASE=$(git merge-base master $BRANCH) # change master to whatever your trunk branch is
COMMITED=$(git diff --name-only $BASE $BRANCH)
STAGED=$(git diff --staged --name-only)
FILES=$(printf "$COMMITED\n$STAGED" | sort | uniq)
LINT="npx eslint --ignore-path=.prettierignore $FILES"
PRETTIER="npx prettier --list-different $FILES"
View index.js
const bip39 = require('bip39')
function twelveWords (missing) {
return `fold supreme boat absurd mango menu number brick ${missing} sun gold stone`
function loadWords () {
return `abandon
maxogden / index.js
Created May 24, 2019
ed25519 private and public keys to pem
View index.js
import { composePrivateKey, composePublicKey } from 'crypto-key-composer'
function privateToPem(privateKey) {
var decomposed = {
format: 'pkcs8-pem',
keyAlgorithm: { id: 'ed25519' },
keyData: {
seed: privateKey,
maxogden / index.js
Created May 24, 2019
slip-0010 hdkey ed25519 derivation from seed in javascript
View index.js
var ehdKey = require("@hawkingnetwork/ed25519-hd-key-rn")
var EdDSA = require('elliptic').eddsa
// test vector from
var seed = new Buffer('fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542', 'hex')
var ed25519 = new EdDSA('ed25519')
var derived = ehdKey.derivePath("m/0'/2147483647'", seed.toString('hex'))
var keys = ed25519.keyFromSecret(derived.key)
// expected test vector outputs
maxogden / index.js
Created May 17, 2019
secp256k1 encrypt/decrypt with bip32 keys
View index.js
var KeyEncoder = require('key-encoder')
var VirgilCrypto = require('virgil-crypto').VirgilCrypto
var HDKey = require('hdkey')
const secp256k1 = require('secp256k1')
var keyEncoder = new KeyEncoder('secp256k1')
var hdKey = HDKey.fromMasterSeed(Buffer.from(SEED, 'hex'))
var childKey = hdKey.derive(PATH)
maxogden /
Created Mar 27, 2019
upload large file to zenodo from command line (curl)
# in zenodo ui create a deposition. get the id
curl -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" "$DEPOSITION"
# get the bucket id from above
curl --progress-bar -o /dev/null --upload-file ./$FILE$BUCKET/$FILE?access_token=$TOKEN
maxogden / list.txt
Created Sep 17, 2018
yay installed packages arch xps 9370
View list.txt
alsa-firmware 1.0.29-2
alsa-oss 1.1.6-1
alsa-utils 1.1.6-1
android-file-transfer 3.4-1
arch-backup 0.8.11-2
arch-install-scripts 19-1
asoundconf 1:1.2-1
autoconf 2.69-4
automake 1.15.1-1
bind-tools 9.13.2-1
maxogden /
Last active Jun 29, 2018
compile gdal with poppler from miniconda
source ~/.bashrc
conda config --add channels conda-forge
conda install poppler
export IFOLDER="/mnt/bigdisk/miniconda2/include"
export LFOLDER="/mnt/bigdisk/miniconda2/lib"
./configure --with-python --with-poppler=/mnt/bigdisk/miniconda2 --with-spatialite --with-pg --with-curl
You can’t perform that action at this time.