Skip to content

Instantly share code, notes, and snippets.

View flockonus's full-sized avatar
🏯

Fabiano flockonus

🏯
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[
{
"inputs": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
0xE50E7A437D07DBE748BC2DA92019048810DE21E0 N/A mock0
0x80B27341D4218B757AB60D041DDDEC3F5738FD0A N/A mock1
0x53A4ED85795FEF056A588771F23F0CDADD75B27B N/A mock2
0x63D3F4C5D5077292CD965C1E667FFF5FCF2C3BC8 N/A mock3
0x48ACF0979B69734B9F7CEC01A70B110EA21845F6 N/A mock4
0xE0F70DBF8F326DACFAD31611579ABE896C5B911F N/A mock5
0xB2E492456C4443F480D797B377D18EEE0109FB73 N/A mock6
0x9F6EA389417EFBC73E7869878121A5EE9BB335E9 N/A mock7
0x8509232EECF789B9E1F8BCEDC4FBD8A8220FE795 N/A mock8
0xF2A4D9BEE944F95799A79C1169F17E0536E89450 N/A mock9
d = {
"data": {
"points": {
"1367193600": {
"v": [
144.5399932861328,
0,
1603768864.5,
1,
11095675.5153929
//https://tools.ietf.org/id/draft-msporny-base58-01.html
// N=10, search space = 4e17
// N=18, search space = 5e31
function rand58(length) {
const base = ('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').split('')
return Array.call(null, length).fill(0).map(() => base[Math.floor(Math.random() * 1e9) % base.length]).join('')
}
@flockonus
flockonus / Promise.all.js
Last active October 1, 2018 21:45
Example of concurrency using Javascript promises + await
const sleep = (seconds) => {
return new Promise((accept) =>
setTimeout(accept, seconds * 1000, `slept ${seconds}`),
);
};
async function execParallel() {
console.log(new Date(), 'starting');
// promises will execute concurrently, so that execution time = slowest one (not the sum)
const out = await Promise.all([sleep(5), sleep(5), sleep(5)]);
@flockonus
flockonus / objects.go
Created September 6, 2018 21:48
Storing MANY structs in memory in Go
package main
import (
"log"
"time"
)
type Kitty struct {
id uint
owner string
@flockonus
flockonus / q1-process-till-done.py
Created August 28, 2018 23:25
threading experiments in python 3.7
from threading import Thread
from queue import Queue
import time
num_worker_threads = 1
print("start", time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
def task(item):
print("IN", item)
/// @dev given a number get a slice of any bits, at certain offset
/// @param _n a number to be sliced
/// @param _nbits how many bits long is the new number
/// @param _offset how many bits to skip
function _sliceNumber(uint256 _n, uint256 _nbits, uint256 _offset) private pure returns (uint256) {
// mask is made by shifting left an offset number of times
uint256 mask = uint256((2**_nbits) - 1) << _offset;
// AND n with mask, and trim to max of _nbits bits
return uint256((_n & mask) >> _offset);
}
@flockonus
flockonus / randomStr.js
Last active March 27, 2018 18:30
Random 8-length string JS
// Really fast way to create 8 bytes random string =~ 1e12 possibilities
Math.round(Math.random() * 1e13).toString(32).substr(-8,8)