Skip to content

Instantly share code, notes, and snippets.

View zmitton's full-sized avatar
🦎
removing code > adding code

Zac Mitton zmitton

🦎
removing code > adding code
  • New York
View GitHub Profile
class Post{
constructor(){
this.temp = Post.initTemp() // use large floating point number
this.updatedAt = Math.round(new Date() / 1000) //unix timestamp
//other init logic...
//save object
}
hotness(){
let timeInterval = Math.round(new Date() / 1000) - this.updatedAt // in seconds
return this.temp * 2**(-1 * timeInterval / Post.halfLife())
#!/usr/bin/env node
const axios = require('axios')
const chalk = require('chalk')
const program = require('commander')
const fs = require('fs')
const ethers = require('ethers')
const Web3 = require('web3')
const _ = require('lodash')
const _cliProgress = require('cli-progress')
var MPT = require('merkle-patricia-tree')
var levelup = require('levelup')
var leveldown = require('leveldown')
var Rpc = require('isomorphic-rpc')
var rpc = new Rpc('https://etc-parity.0xinfra.com')
var { toHex , toBuffer } = require('eth-util-lite')
var { Account } = require('eth-object')
var arrayToHex = (arr)=> {
/*
.load personal/eip161.js
*/
var { Account, Header, Log, Proof, Receipt, Transaction } = require('eth-object')
var rlp = require('rlp');
var lu = require('levelup')
var ld = require('leveldown')
var d = ld('/Users/zacharymitton/Library/Ethereum/classic/geth/chaindata')
var db = lu(d)
var sha3 = require('js-sha3').keccak_256
```
INFO [03-22|08:52:38.006] Imported new chain segment blocks=41 txs=102 mgas=7.152 elapsed=8.403s mgasps=0.851 number=2470930 hash=bf6e8a…13a55d age=2y5mo1w cache=0.00B
ERROR[03-22|08:52:38.018]
########## BAD BLOCK #########
Chain config: {ChainID: 61 Homestead: 1150000 DAO: 1920000 DAOSupport: false EIP150: 2500000 EIP155: 3000000 EIP158: <nil> Byzantium: <nil> Disposal: 5900000 Social: <nil> Ethersocial: <nil> ECIP1017: 5000000 EIP160: 3000000 ECIP1010PauseBlock: 3000000 ECIP1010Length: 2000000 Constantinople: <nil> ConstantinopleFix: <nil> Engine: ethash}
Number: 2470936
Hash: 0x9e4ea3f5fb542d1320dc67864ddf0e3bc09df2373a77787c4d5204fdad6ef03e
0: cumulative: 21000 gas: 21000 contract: 0x0000000000000000000000000000000000000000 status: 1 tx: 0x79171704f6257fa2fedb459dd3bb194161fc4f36f3c9a9897cc70689b946ee2b logs: [] bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
DEBUG[03-25|10:55:11.550] Sanitizing Go's GC trigger percent=50
INFO [03-25|10:55:11.551] Maximum peer count ETH=25 LES=0 total=25
DEBUG[03-25|10:55:11.552] FS scan times list=67.201µs set=2.916µs diff=2.954µs
TRACE[03-25|10:55:11.552] Started watching keystore folder path=/Users/zacharymitton/Library/Ethereum/classic/keystore
INFO [03-25|10:55:11.572] Starting peer-to-peer node instance=Geth/v1.8.23-stable/darwin-amd64/go1.11.2
INFO [03-25|10:55:11.572] Allocated trie memory caches clean=1024.00MiB dirty=0.00B
INFO [03-25|10:55:11.572] Allocated cache and file handles database=/Users/zacharymitton/Library/Ethereum/classic/geth/chaindata cache=1024.00MiB handles=12288
DEBUG[03-25|10:55:11.834] Trie cache stats after commit misses=0 unloads=0
INFO [03-25|10:55:11.875] Persisted trie from memory database nodes=12356 size=1.79MiB time=40.493368ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 li
// fs.writeFile('thing1',Buffer.from('34','hex'), (e,r,a)=>{console.log(e,r,a)})
/*
node
.load MMR.js
*/
class MMR extends Array{
constructor(){
super(0)
{ header:
Header [
<Buffer b8 bc 8e cf 1e ff f5 e7 43 2c 91 80 15 0b 3f 23 a2 8b 10 b8 bc 0d fb d4 da aa 1b f4 de 6a 49 23>,
<Buffer 1d cc 4d e8 de c7 5d 7a ab 85 b5 67 b6 cc d4 1a d3 12 45 1b 94 8a 74 13 f0 a1 42 fd 40 d4 93 47>,
<Buffer b2 93 0b 35 84 4a 23 0f 00 e5 14 31 ac ae 96 fe 54 3a 03 47>,
<Buffer ee 2b 43 48 50 12 8d 80 0a 53 bd e2 ac ab 9a 31 ce 2a 9b 9d d8 f3 1a 77 93 3a d6 f7 7c 87 1c 70>,
<Buffer 5b 6e 9d 7a 5c 9d 49 94 c6 52 90 6f a2 8b 2d 2a 9a 9e e7 b5 a4 69 ae a2 1b 95 72 6f 78 a1 2d 89>,
<Buffer 21 7b 48 6b 87 14 50 78 53 d2 fe ef 1b c9 89 b5 70 a7 66 f5 cb 43 da 9a 5f 64 14 f0 1f 06 41 da>,
<Buffer 03 48 18 c8 08 43 31 e1 00 a3 b0 c2 20 20 15 45 61 10 44 90 12 20 1c 14 04 02 a5 80 02 38 51 09 9a c0 22 51 a0 0b 5c 00 40 48 93 4a 12 4c 80 82 96 68 ... 206 more bytes>,
<Buffer 06 bd ea 95 c4 3b c6>,
{ header:
Header [
<Buffer 7a 27 da da 81 4b 88 1c fa a7 01 79 ca 57 70 b5 1e b2 f1 88 63 27 3a 7a 2f ca 5c 5d d7 db 5b 2b>,
<Buffer 1d cc 4d e8 de c7 5d 7a ab 85 b5 67 b6 cc d4 1a d3 12 45 1b 94 8a 74 13 f0 a1 42 fd 40 d4 93 47>,
<Buffer 96 33 81 49 e9 f6 c2 62 d4 cb 7a ee c1 cf 4c 65 20 79 a1 1c>,
<Buffer 40 c4 25 67 a5 1d 91 ad 71 e0 4e 7c f9 a7 22 d9 12 fb fa c5 81 b6 97 be b9 4b de cb cb 8a 5b 24>,
<Buffer 5e ed 79 0a e3 d1 e8 18 a7 34 b3 ab 53 8c f5 55 28 0f 91 74 4e 71 c9 db 29 d9 19 eb 1d 2e 7b 13>,
<Buffer c2 94 6f 15 8a 35 e9 f5 75 f4 7d 4c 58 5d ae 2b ea 62 17 a6 52 00 b0 49 3d 7d 2c 12 02 74 26 c8>,
<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 40 00 20 10 00 00 04 00 00 00 00 00 ... 206 more bytes>,
<Buffer 0a 01 69 64 08 97 4b>,
@zmitton
zmitton / ballot.sol
Created October 20, 2018 02:28
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.25+commit.59dbf8f1.js&optimize=true&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {