Skip to content

Instantly share code, notes, and snippets.

View daragao's full-sized avatar

Duarte Aragão daragao

View GitHub Profile
@daragao
daragao / Chainlink Price feeds.ipynb
Last active August 1, 2021 15:41
Study about Chainlink in and outflows
@daragao
daragao / singleFileAPI3.js
Created March 3, 2021 17:08
API3 Airnode contracts make a request and fulfill it
const hre = require("hardhat");
async function main() {
const signers = await hre.ethers.getSigners();
const owner = signers[0];
const Airnode = await hre.ethers.getContractFactory("Airnode", owner);
const Convenience = await hre.ethers.getContractFactory("Convenience", owner);
@daragao
daragao / printEvent.js
Created March 2, 2021 23:40
Simple Web3 script to print events
const Web3 = require('web3')
const BN = require('bn.js')
const Big = require('big.js')
// what is a wad https://makerdao.com/purple/#sec-3-1
const wadToEth = (value) => {
return (new Big(value)).div((new BN(10)).pow(new BN(18)))
}
const printEvent = (web3, eventType) => (event) => {
@daragao
daragao / refreshTouchbar.sh
Created January 15, 2021 12:53
Everytime the Esc disappears from the touchbar :)
#!/bin/bash
sudo pkill TouchBarServer; sudo killall ControlStrip
@daragao
daragao / slackspammer.sh
Last active January 29, 2020 13:49
Slack Spammer
#!/bin/bash
# need curl and jq installed
# go to https://api.slack.com/apps and create an app
# add OAuth permissions:
# calls:write
# channels:join
# channels:manage
# channels:read
@daragao
daragao / parse_timeline_history.py
Created November 11, 2019 00:13
Parses history location from https://takeout.google.com/ (useful to check where you have been in the last few years)
import json
from datetime import datetime
import reverse_geocoder as rg
location_history = None
json_filename = 'timeline_history/Location History/Location History.json'
print('Loading: %s' % json_filename)
with open(json_filename, 'r') as f:
location_history = json.load(f)
@daragao
daragao / generateEthereumKey.sh
Created August 9, 2019 11:02
script to generate Ethereum private key, public key, and address
#!/bin/bash
#Libs used for keccak-256sum
#https://github.com/maandree/libkeccak.git
#https://github.com/maandree/argparser.git
#https://github.com/maandree/sha3sum.git
# Generate the private and public keys
KEY="$(openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout 2> /dev/null)"
echo "$KEY"
@daragao
daragao / goldmine.py
Created November 8, 2018 18:35
Gold mine proble hackerrank
def mining(k, mines):
n = len(mines)
#create matrix
matrix = []
for i in range(n):
row = []
distance_i = mines[i][0]
weight_i = mines[i][1]
for j in range(n):
distance_j = mines[j][0]
@daragao
daragao / run_geth.sh
Created October 25, 2018 17:29
Bash script to start geth
#!/bin/bash
#-x
NODE_NUMBER=$1
REMAINING_ARGS=${@:2}
re_number=^-?[0-9]+$
if ! [[ $NODE_NUMBER =~ $re_number ]]; then
echo "First argument needs to be a number!"
exit 1
@daragao
daragao / printStateAccounts.js
Last active October 11, 2018 22:37
Simple example on how to get accounts from state trie
const level = require('level')
const rlp = require('rlp')
const chaindatadirectory = './data_node_0/geth/chaindata'
const TX_ROOT_HASH = '146d436eb3af4eeaf1f421d86a8994ef9f6e3670393837e9141f7f44b00e01cf'
const STATE_ROOT_HASH = '0c773fdbbe314cbeb0908d1b4949b39d1edca0653efee339882679538fce3318'
level(chaindatadirectory, { keyEncoding: 'utf8', valueEncoding: 'binary'}, async (err, db) => {
if(err) {
console.log('ERROR: ',err)