Skip to content

Instantly share code, notes, and snippets.

View Leask's full-sized avatar
🏠
Working from home

Sixia "Leask" Huang Leask

🏠
Working from home
View GitHub Profile
const { randomBytes } = require('crypto')
const secp256k1 = require('secp256k1')
// or require('secp256k1/elliptic')
// if you want to use pure js implementation in node
// generate message to sign
const msg = randomBytes(32)
// generate privKey
let privKey
{"lastUpload":"2020-01-10T14:41:13.416Z","extensionVersion":"v3.4.3"}
const { randomBytes } = require('crypto')
const secp256k1 = require('secp256k1')
const createKeccakHash = require('keccak')
const signToPubAddress = (msghash, sig) => {
// TODO: verify msghash and sig
const v = Number(sig.slice(128));
const sigObj = {r: sig.slice(0, 64), s: sig.slice(64, 128)};
const point = secp256k1.recoverPubKey(msghash, sigObj, v);
const pub = point.encode('hex');
@Leask
Leask / listening.sh
Created May 15, 2018 09:32
Get current listening on iTunes.
#!/bin/sh
# Flora Listening by LeaskH.com
initFlora() {
export PATH=~/Documents/.flora:$PATH
}
getLastListening() {
echo `cat /tmp/flora_listening 2> /dev/null`
}
@Leask
Leask / test.js
Created April 18, 2018 16:22
Simple Javascript speed testing
let a = [
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4],
];
let t1 = new Date().getTime();
@Leask
Leask / read.py
Created February 11, 2018 07:20
Demo for reading text as array in Python3.
array = [];
with open('test.txt', 'r') as f:
while True:
line = f.readline().strip()
if not line:
break
line = list(map(int, line.split(' ')))
array.append(line)
@Leask
Leask / client.js
Created August 23, 2017 15:10
Node socket demo
var net = require('net');
var HOST = '127.0.0.1';
var PORT = 8977;
var client = new net.Socket();
client.connect(PORT, HOST, function() {
console.log('connect');
client.write('data');
client.write('data');
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Leask
Leask / endless.js
Created June 13, 2017 04:16
Endless Scroll
var fakeAjax = function(url, success, fail) {
setTimeout(function() {
console.log('Done!!!');
success();
}, 1000);
};
var render = function() {
$('.cloud-Label ul.clearFix').append('<li>anything</li>');
};