Skip to content

Instantly share code, notes, and snippets.

Avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / lto-transfer-all
Last active May 27, 2022
Transfer full LTO node balance to own wallet
View lto-transfer-all
#!/bin/bash
if [ -z "$1" ]; then
echo "USAGE: $0 RECIPIENT" >&2
exit 1
fi
RECIPIENT="$1"
WALLET_ADDRESS=$(curl -sS http://localhost:6869/wallet/addresses | jq -r '[0]')
@jasny
jasny / lto-balance-vs-reward
Last active May 5, 2022
Get balances and rewards
View lto-balance-vs-reward
#!/bin/bash
ADDRESS=$1
MAX_HEIGHT=$(curl -sS http://testnet.lto.network/blocks/height | jq '.height')
MIN_HEIGHT=$((MAX_HEIGHT - 1999))
curl -sS "https://testnet.lto.network/addresses/balance/history/$ADDRESS" | jq -r '.[] | (.height|tostring) + "," + (.balance|tostring)' > balance.csv
BLOCKS=$(for ((HEIGHT=MIN_HEIGHT; HEIGHT<MAX_HEIGHT; HEIGHT=HEIGHT+100)); do curl -sS "http://testnet.lto.network/blocks/address/$ADDRESS/$HEIGHT/$((HEIGHT + 99))" | jq -r '.[].height'; done)
@jasny
jasny / fiestainfo-fix-images
Last active Apr 30, 2022
Create missing resized images for Fiestainfo
View fiestainfo-fix-images
#!/bin/bash
ALBUM=$1
mkdir -p "$ALBUM/original" "$ALBUM/new"
aws s3 ls "s3://fiestainfo-old-images/albums/$ALBUM/" | awk '{for(i=4; i<=NF; ++i) printf "%s ", $i; print ""}' | grep -v '.DS_Store' > "$ALBUM/list"
function resize_image {
IMAGE=$1
@jasny
jasny / lto-get-balances
Created Apr 29, 2022
Get balances of all accounts from all 3 LTO bootstrap nodes
View lto-get-balances
#!/bin/bash
if [ $# -gt 0 ]; then
HEIGHT=$1
CONFIG="
url = \"http://node-bs1.lto.network:6869/debug/stateAtHeight/$HEIGHT\"
output = \"balances-bs1.json\"
url = \"http://node-bs2.lto.network:6869/debug/stateAtHeight/$HEIGHT\"
output = \"balances-bs2.json\"
@jasny
jasny / find_seed.py
Last active Apr 5, 2022
Recover LTO seed from known words
View find_seed.py
from lto.accounts import AccountFactoryED25519
from itertools import permutations
address = "3JzSs25zWMomDHmw3jA3v9rpqqxxzmCAd9Hs"
words = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"]
factory = AccountFactoryED25519('L')
def find_insert_word():
print("Changing the position of each word")
@jasny
jasny / update-lto.sh
Last active Jul 4, 2022
Update LTO Network public node as deb
View update-lto.sh
#!/bin/bash
set -e
SERVICE="lto" # Change to "lto-testnet" for testnet
if [ -z "$1" ]; then
echo "USAGE $0 VERSION" >&2
exit 1
fi
@jasny
jasny / unit.php
Last active Jul 6, 2021
Idea for Unit PHP extension
View unit.php
<?php
$distance = new Meter(3);
$cm = $distance->in(Centimeter::class);
ecoh $distance; // 3m
echo $cm; // 300cm
$distance == Decimeter(30); // True
$distance === Decimeter(30); // False
@jasny
jasny / CrudClient.php
Last active Jul 14, 2020
Example of a CRUD controllers for new framework
View CrudClient.php
<?php
use Jasny\DB\Option\Functions as opts;
use Jasny\HttpAttributes\Request\Accept;
use Jasny\HttpAttributes\Request\ParsedBody;
use Jasny\HttpAttributes\Request\PathParam;
use Jasny\HttpAttributes\Response\ContentType;
use Jasny\HttpAttributes\Route\Delete;
use Jasny\HttpAttributes\Route\Get;
use Jasny\HttpAttributes\Route\Post;
@jasny
jasny / icu-config
Created May 26, 2020
ICU 66.1 for Ubuntu 20.04
View icu-config
#!/bin/sh
## -*-sh-*-
#set -x
# BEGIN of icu-config-top
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#******************************************************************************
# Copyright (C) 1999-2013, International Business Machines
# Corporation and others. All Rights Reserved.
#******************************************************************************
@jasny
jasny / comparison-gotchas.php
Last active May 24, 2020
PHP comparison gotchas
View comparison-gotchas.php
<?php
/**
* `a > b > c > a` should always result in false.
*/
function all_greater($a, $b, $c)
{
return ($a > $b) && ($b > $c) && ($c > $a);
}
// Fails due to type juggling.