Skip to content

Instantly share code, notes, and snippets.

package genesis
// go-gzip, no hashing elapsed=49.274027963s
// pgzip.NewReaderN(reader, 1024, 100*1024) , no hashing, elapsed=1m13.959573387s
import (
"archive/tar"
"crypto/sha256"
"encoding/hex"
"fmt"
adb shell
pm list packages -f
# xiaomi calendar
pm disable-user --user 0 com.xiaomi.calendar
# aplikační trezor
pm disable-user --user 0 com.mi.android.globalminusscreen
# čistič
@thaarok
thaarok / ethereum-keystore-load.go
Last active April 25, 2023 18:35
Reading ethereum JSON keystore to obtain PrivateKey object.
package driver
import (
"crypto/ecdsa"
"github.com/gochain/gochain/v4/accounts/keystore"
"os"
"testing"
)
const PrivateKeyStore = "~/.opera/fakenet-1/keystore/UTC--2023-04-25T07-50-08.017708542Z--239fa"
@thaarok
thaarok / comparison.py
Last active December 23, 2022 06:22
TeamCity-aggregator
#!/bin/python3
import os
import re
import collections
configs = set()
buildNumbers = set()
totalTimeTable = collections.defaultdict(dict)
buildTxsTable = collections.defaultdict(dict)
txsPerSecTable = collections.defaultdict(dict)
func TestGoHashSerialization(t *testing.T) {
hasher := sha256.New()
hasher.Write([]byte{0x2})
bytes, err := hasher.(encoding.BinaryMarshaler).MarshalBinary()
if err != nil {
t.Fatalf("%s", err)
}
hasher2 := sha256.New()
err = hasher2.(encoding.BinaryUnmarshaler).UnmarshalBinary(bytes)

Replacing go-ethereum/lachesis-base with custom branch for development:

go mod edit -replace github.com/ethereum/go-ethereum=github.com/hkalina/go-ethereum@86abe1a01dc15bb3282628cc39eb7b451e6c1113
go mod edit -replace github.com/Fantom-foundation/lachesis-base=github.com/hkalina/lachesis-base@01569740d42de172b09866c8bb45e9aabd8b0235
GOPRIVATE=github.com/Fantom-foundation go mod tidy

Running Opera with websocket:

build/opera --genesis /media/sda2/opera/testnet.g --ipcpath /home/jkalina/.opera/opera.ipc \
@thaarok
thaarok / php-csv-parse-detect-encoding-separator.php
Created April 4, 2022 21:25
Magic functions to detect encoding and separator of CSV file and parsing it
<?php
function parseCsv($file) {
$content = file_get_contents($file);
if (!$content) {
throw Exception('Unable to read the CSV file');
}
$encoding = detectEncoding($content);
$content = iconv($encoding, 'UTF-8//TRANSLIT', $content);

Prometheus installation

sudo apt install prometheus prometheus-node-exporter
tee /etc/ufw/applications.d/prometheus <<EOF
[Prometheus]
title=Prometheus UI
description=Prometheus monitoring web UI.
ports=9090/tcp
EOF
@thaarok
thaarok / mint-token.py
Created October 19, 2021 07:56
Script to mint Artion tokens on Fantom network.
#!/bin/python3
from web3 import Web3
import getpass
w3 = Web3(Web3.HTTPProvider('https://rpc.fantom.network/'))
myAccount = '0x83A6524Be9213B1Ce36bCc0DCEfb5eb51D87aD10'
contractAddr = '0x61aF4D29f672E27a097291F72fc571304BC93521'
tokenUri = 'https://artion10.mypinata.cloud/ipfs/QmPo8sQz4Lj9rVp71yaoTWCxZzS2vpPFmYEAaD1aph3RQu'
tokensAmount = 2