Skip to content

Instantly share code, notes, and snippets.

@a6b8
a6b8 / findBrokenLinks.js
Last active February 8, 2022 08:01
Find Broken Links
@a6b8
a6b8 / (=^ェ^=)
Last active January 12, 2022 01:43
We couldn’t find that file to show.
@a6b8
a6b8 / (=ºェº=)
Last active January 11, 2022 11:41
We couldn’t find that file to show.
@a6b8
a6b8 / github_get_all_repos.rb
Created January 13, 2022 21:48
Github get all repos
require 'net/http'
require "active_support/core_ext/hash/indifferent_access"
def repos_all( github_user: )
all = []
expand = true
nr = 1
while( expand )
url = "https://api.github.com/users/#{github_user}/repos?page=#{nr}"
@a6b8
a6b8 / ethereum-blocktime-every-hour.json
Created January 16, 2022 16:17
Array of the corresponding ethereum block for every hours between 2017/06 to 2021/12.
This file has been truncated, but you can view the full file.
{
"meta": "This dataset contains the the corresponding ethereum block for every hours between 2017/06 to 2021/12.",
"data": [
{
"date": "2017-06-07T04:00:00Z",
"block": 3832764,
"timestamp": 1496808077
},
{
"date": "2017-06-07T05:00:00Z",
@a6b8
a6b8 / evmBlocknumberToDate.js
Last active January 4, 2023 17:43
Transform evm blocknumber to date
require( 'dotenv' ).config( { path: '../.env' } )
const EthDater = require( 'ethereum-block-by-date' )
const { ethers } = require( 'ethers' )
const moment = require( 'moment' )
const fs = require( 'fs' )
async function date() {
try {
let blocks = []
for( let i = from; i < to; i++ ) {
@a6b8
a6b8 / evmFetchAbiFromEtherscan.js
Last active March 22, 2022 22:07
Fetch contract abi from etherscan without an api key.
const fs = require( 'fs' )
const axios = require( 'axios' )
const ethers = require( 'ethers' )
const keccak256 = require( 'keccak256' )
function humanReadable( { humanReadable, solidity } ) {
const result = humanReadable
.map( a => {
const struct = {
@a6b8
a6b8 / evmDecodeTopics.js
Last active April 28, 2022 12:08
Function for decoding Event logs and converting Big Numbers to String.
const ethers = require( 'ethers' )
function decodeTopics( { abi, data, topics } ) {
const iface = new ethers.utils.Interface( abi )
const parsed = iface.parseLog( { data, topics } )
const values = {}
Object.keys( parsed['args'] )
.filter( key => !Number.isInteger( parseInt( key ) ) )
@a6b8
a6b8 / evmFindBlockExplorer.js
Last active March 26, 2022 22:44
find the right block explorer for evm layer 1 and 2 networks.
function addExplorer( { cmd, config } ) {
const id = `${cmd['network']['blockchain']}_${cmd['network']['chain']}`
const template = config[ id ]
const explorer = {}
Object.keys( template ).forEach( type => {
Object.keys( cmd['vars'] ).forEach( ( v, index ) => {
if( index === 0 ) {
explorer[ type ] = config[ id ][ type ]
}
@a6b8
a6b8 / waitForVariableChange.js
Last active April 4, 2022 19:00
Listener Class to detect variable condition changes. Usefull for async data streams.
const Wait = class Wait {
constructor() {}
init( { debug=false, max_retries=10, sleep } ) {
this.condition = false
this.debug = debug
this.retries = null
this.max_retries = max_retries
this.sleep = sleep