Skip to content

Instantly share code, notes, and snippets.

View jasny's full-sized avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / ai-translate
Created October 8, 2024 19:20
Python script to translate a text using OpenAI GPT 4o-mini
#!/bin/env python
from openai import OpenAI
import sys
import os
import argparse
def translate_stdin_to_stdout(target_language, translate_lines=False, translate_po=False, instructions=""):
client = OpenAI()
@jasny
jasny / index.html
Created March 12, 2024 14:43
Ice Breaker (LangChain course)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ice Breaker</title>
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@chgibb/[email protected]/css/spinner/three-quarters.min.css">
</head>
<body>
<header>
#define public keys
let alicePubKey = base58'5AzfA9UfpWVYiwFwvdr77k6LWupSTGLb14b24oVdEpMM'
let bobPubKey = base58'2KwU4vzdgPmKyf7q354H9kSyX9NZjNiq4qbnH2wi2VDF'
let cooperPubKey = base58'GbrUeGaBfmyFJjSQb9Z8uTCej5GzjXfRDVGJGrmgt5cD'
#check whoever provided the valid proof
let aliceSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], alicePubKey ) || sigVerify(tx.bodyBytes, tx.proofs[1], alicePubKey )) then 1 else 0
let bobSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], bobPubKey ) || sigVerify(tx.bodyBytes, tx.proofs[1], bobPubKey )) then 1 else 0
let cooperSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey) || sigVerify(tx.bodyBytes, tx.proofs[1], cooperPubKey)) then 1 else 0
@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 / 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 / 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 / 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