Skip to content

Instantly share code, notes, and snippets.

View jasny's full-sized avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / lto-tx-csv
Last active October 12, 2022 01:27
LTO get transactions of address as CSV
#!/bin/bash
ADDRESS="$1"
TOTAL=$(curl -s -I "https://nodes.lto.network/index/transactions/addresses/$ADDRESS" | grep x-total | awk '{printf "%d",$2}')
seq -w 00000 100 $TOTAL | xargs -P 10 -I'{}' curl -s "https://nodes.lto.network/index/transactions/addresses/$ADDRESS?limit=100&offset={}" -o "$ADDRESS.{}.json"
jq -s add $ADDRESS.*.json > "$ADDRESS.json"
rm $ADDRESS.*.json
@jasny
jasny / build-packagexml.php
Last active July 24, 2022 16:56
Build package.xml for PECL extensions
<?php
/**
* Generate package.xml for pecl extensions.
* Works for new and existing extensions.
*
* Add it to `Makefile.frag`
* package.xml: php_$(PHP_PECL_EXTENSION).h
* $(PHP_EXECUTABLE) build-packagexml.php
*
@jasny
jasny / update-lto.sh
Last active July 4, 2022 21:23
Update LTO Network public node as deb
#!/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 / lto-transfer-all
Last active May 27, 2022 10:52
Transfer full LTO node balance to own wallet
#!/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 09:56
Get balances and rewards
#!/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 April 30, 2022 22:50
Create missing resized images for Fiestainfo
#!/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 April 29, 2022 17:49
Get balances of all accounts from all 3 LTO bootstrap nodes
#!/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 / CMakeList.txt
Created October 7, 2019 01:21
CMake configuration for php-src
cmake_minimum_required(VERSION 3.8)
project(php C)
# 32bit or 64bit
set(BITNESS 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
endif()
# Global definitions
@jasny
jasny / find_seed.py
Last active April 5, 2022 19:32
Recover LTO seed from known words
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 / icu-config
Created May 26, 2020 01:34
ICU 66.1 for Ubuntu 20.04
#!/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.
#******************************************************************************