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 / 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;
@daragao
daragao / readDatadirLeveDB.js
Last active Jun 7, 2017
playing around to check how to read a levelDB
View readDatadirLeveDB.js
const level = require('level');
const levelup = require('levelup');
const RLP = require('rlp');
const Trie = require('merkle-patricia-tree')
const DATADIR_PATH = '../../simple_geth_launcher/data_node1';
/*
const nodeDb = level('/home/da/.ethereum/geth/nodes');
const nodeDataArr = [];
@daragao
daragao / luckyGuessGenKey.sh
Created Jun 7, 2017
(Useless crazy :D ) Bash script that keeps generating keys and saves the key if that Ethereum account has ether
View luckyGuessGenKey.sh
#!/bin/bash
COUNTER=0
trap '{ echo "Hey, you pressed Ctrl-C. Loop Counter: $COUNTER Time to quit." ; exit 1; }' INT
#./go-ethereum/build/bin/geth --bootnodes enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303 --rpc
#Libs used for keccak-256sum
#https://github.com/maandree/libkeccak.git
You can’t perform that action at this time.