Skip to content

Instantly share code, notes, and snippets.

View uzyn's full-sized avatar
🤟

U-Zyn Chua uzyn

🤟
View GitHub Profile
@uzyn
uzyn / watch-load.sh
Last active March 15, 2026 08:29
Watch server load and notify via ntfy.sh when load is low
#!/bin/bash
# ./watch-load.sh — run this on the server, it will notify you when load drops
# ./watch-load.sh <threshold>, e.g. ./watch-load.sh 1.2 to set threshold to 1.2. Default to 2.0
NTFY_TOPIC="<INSERT NTFY TOPIC>"
THRESHOLD="${1:-2.0}" # first arg, default 2.0; e.g. ./watch_load.sh 1.5
CHECK_INTERVAL=60 # seconds between checks
SUSTAINED_CYCLES=3 # must be low for N consecutive checks before alerting
low_count=0
echo "Watching load average... threshold: <$THRESHOLD for ${SUSTAINED_CYCLES} consecutive checks"
while true; do
@uzyn
uzyn / freeze-staking-montecarlo.js
Last active July 19, 2021 21:05
Freeze staking Monte Carlo simulation
// Monte carlo simulation of long term staking
// Nodes distribution, regular, 5y, 10y
const CYCLES = 100000; // Increase this to run more simulations
const NODES = [1000, 1000, 1000]; // regular, 5y, 10y
const TARGET = 0.0012; // 0.12% of guesses win
// const COINAGE_EVERY = [24, 9, 5]; // 6 hours, 2h15m, 1h15m
const COINAGE_EVERY = [24, 24, 24]; // consistent
const SUBNODES = [2, 3, 4];
0xA8aB1A2ABB29E4bb9c4aefd42AE26471932Df3c7
0x412719c518935f1ec662a2b4c48c8baef2143451
0xFB43E5a34d4080F2199589EbBd5850B65fCa07F0
0x0f34a3f6065f47273f137b9c4d387116ac707c29
@uzyn
uzyn / Library.js
Last active January 9, 2017 04:51
Which is the preferred or trendy method for JS at this moment?
/**
* Method A: OOP
*/
class Library {
constructor() {
this.books = this.loadBooks();
}
add(newBook) {
const Web3 = require('web3');
const web3 = new Web3(
new Web3.providers.HttpProvider(
'http://localhost:8545'
)
);
web3;
web3.eth;
web3.eth.accounts;
@uzyn
uzyn / SGDT.sol
Last active April 16, 2018 17:13
pragma solidity ^0.4.2;
contract SGDT {
/* Public variables of the token */
string public name = 'Singapore Dollar Token';
string public symbol = 'SGDT';
uint8 public decimals = 2;
uint public totalSupply = 0;
address public authority;
Verifying that +uzynchua is my blockchain ID. https://onename.com/uzynchua