Skip to content

Instantly share code, notes, and snippets.

Avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / sha256-hmac.md
Last active Sep 9, 2022
Hashing examples in different languages
View sha256-hmac.md

Example inputs:

Variable Value
key the shared secret key here
message the message to hash here

Reference outputs for example inputs above:

| Type | Hash |

@jasny
jasny / linkify.php
Last active Sep 9, 2022
PHP function to turn all URLs in clickable links
View linkify.php
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @return string
*/
public function linkify($value, $protocols = array('http', 'mail'), array $attributes = array())
@jasny
jasny / mysql_splitdump.sh
Last active Jul 29, 2022
Split MySQL dump SQL file into one file per table or extract a single table
View mysql_splitdump.sh
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@jasny
jasny / build-packagexml.php
Last active Jul 24, 2022
Build package.xml for PECL extensions
View build-packagexml.php
<?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 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 / 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 / flip.js
Created Mar 27, 2014
Turn text upside down with JavaScript
View flip.js
//this script is based on coding by Reverse Fad http://www.revfad.com
function flip() {
var result = flipString(document.f.original.value.toLowerCase());
document.f.flipped.value = result;
}
function flipString(aString) {
var last = aString.length - 1;
var result = new Array(aString.length)
for (var i = last; i >= 0; --i) {
var c = aString.charAt(i)
@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\"