Skip to content

Instantly share code, notes, and snippets.

@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)

CPUprofile on Sonic:

sudo -u sonic sonictool --datadir=/var/sonic/mainnet cli
> debug.cpuProfile("/tmp/cpuprofile1", 60) # capture for 60 seconds
> exit

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
@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
@thaarok
thaarok / metamask-mint.htm
Created October 18, 2021 20:15
Tool for minting (cloning) Artion tokens
<script src="//cdnjs.cloudflare.com/ajax/libs/web3/1.6.0/web3.min.js" integrity="sha512-+BhnLgfzIDDjssoEWHPmdgWRvbwIEdj0Xfiys7uSqfQWpMEOJ4ymJ88O6B1cB0j+4zjb5GhO+sb/kEicggvUQQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<h2>Mint token</h2>
Token contract (collection):</br>
<input type="text" id="contract" value="0x61af4d29f672e27a097291f72fc571304bc93521" style="width: 50em"></br>
Beneficiary (who obtains new tokens):</br>
<input type="text" id="beneficiary" value="0x83a6524be9213b1ce36bcc0dcefb5eb51d87ad10" style="width: 50em"></br>
async function sign() {
let web3 = new Web3(window.ethereum)
let accounts = await web3.eth.getAccounts();
let message = 'I am signing my one-time nonce: ABCDEF';
let signature = await web3.eth.personal.sign(message, accounts[0], '');
console.log('message', message);
console.log('account', accounts[0]);
console.log('signature', signature);
}
func reverseOrder(entities interface{}) {
entitiesVal := reflect.Indirect(reflect.ValueOf(entities))
for i, j := 0, entitiesVal.Len()-1; i < j; i, j = i+1, j-1 {
tmp := entitiesVal.Index(i).Interface()
entitiesVal.Index(i).Set(entitiesVal.Index(j))
entitiesVal.Index(j).Set(reflect.ValueOf(tmp))
}
}
func reverseOrder(entities interface{}) {