Skip to content

Instantly share code, notes, and snippets.

View chafreaky's full-sized avatar
👋

chafreaky chafreaky

👋
View GitHub Profile
@chafreaky
chafreaky / validateJWT.js
Created February 5, 2022 22:59
Validate a JWT token in DeSo (BitClout) against a Public Key
const jsonwebtoken = require('jsonwebtoken');
const bs58check = require('bs58check');
const EC = require('elliptic').ec;
const ec = new EC('secp256k1');
const KeyEncoder = require('key-encoder').default;
/**
* Thank you to https://github.com/mattetre/bitclout-jwt-validate/blob/main/index.js
* @param {String} publicKey
* @param {String} jwt
@chafreaky
chafreaky / signTxn.js
Created October 31, 2021 21:06
DESO - Sign a transaction in nodejs given a seedHex and a txnHex
// Do `npm i elliptic sha256` before hand
const EC = require('elliptic').ec;
const sha256 = require('sha256');
function seedHexToPrivateKey(seedHex) {
const ec = new EC('secp256k1');
return ec.keyFromPrivate(seedHex);
}
@chafreaky
chafreaky / merge_csv.py
Last active May 2, 2017 11:31
Scans for all zipped files within a directory (recursively), opens archives and reads the csv files inside the archives. Append all csv files into a single one named 'output.csv'. Useful for creating a single file from thousands of different csv files. Skips headers.
import os
import fnmatch
import zipfile
import StringIO
import csv
print('Scanning for files ...')
count = 0
for r, d, f in os.walk(os.path.dirname(os.path.abspath(__file__))):
for fn in fnmatch.filter(f, '*.zip'):