Skip to content

Instantly share code, notes, and snippets.

Duarte Aragão daragao

Block or report user

Report or block daragao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@daragao
daragao / parse_timeline_history.py
Created Nov 11, 2019
Parses history location from https://takeout.google.com/ (useful to check where you have been in the last few years)
View parse_timeline_history.py
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 Aug 9, 2019
script to generate Ethereum private key, public key, and address
View generateEthereumKey.sh
#!/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 Nov 8, 2018
Gold mine proble hackerrank
View goldmine.py
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 Oct 25, 2018
Bash script to start geth
View run_geth.sh
#!/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 Oct 11, 2018
Simple example on how to get accounts from state trie
View printStateAccounts.js
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)
@daragao
daragao / flow_test.go
Last active Oct 11, 2018
Simple flow test without using the abigen generated file (only using common transactions and the simulated blockchain)
View flow_test.go
package ionflow
import (
"bytes"
"context"
"math/big"
"regexp"
"strings"
"testing"
@daragao
daragao / nested_nodes_trie_example.go
Last active Jul 26, 2018
Example of a Patricia Trie with some value smaller than 32bytes wich results in nodes being nested inside each other
View nested_nodes_trie_example.go
package main
import (
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
@daragao
daragao / txRootExample.go
Last active Jul 3, 2018
Example of how a transaction root is created using the Ethereum Golang libraries
View txRootExample.go
package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethdb"
View xmobar_ticker_coinmarketcap.sh
#!/bin/bash
UP_SYMBOL=▲
DOWN_SYMBOL=▼
# BTC_SYMBOL="<fc=#FFFF00>฿</fc>"
BTC_SYMBOL="<fc=#FF9900><fn=1></fn></fc>"
#ETH_SYMBOL="<fc=#7777FF>Ξ</fc>"
ETH_SYMBOL="<fc=#7777FF><fn=1></fn></fc>"
@daragao
daragao / test.js
Last active Oct 11, 2018
Chat that we had today :)
View test.js
const printMatrix = (matrix) => matrix.forEach((line,j) => console.log('('+j+')',line));
// USES ALGORITHM THAT I DESCRIBED WHICH WAS WRONG!!!!
const countIslandsMyAlgorithm = (matrix) => {
const checkCounterMatrix = (counterMatrix,i,j) => {
if((i-1 >= 0) && (counterMatrix[i-1][j] !== 0)) return counterMatrix[i-1][j];
if((j-1 >= 0) && (counterMatrix[i][j-1] !== 0)) return counterMatrix[i][j-1];
// this 2 cases are never considered in any of the matrices, this causes issues
if((i+1 < matrix.length) && (matrix[i+1][j] !== 0)) return counterMatrix[i+1][j] = 0;
You can’t perform that action at this time.