Skip to content

Instantly share code, notes, and snippets.

View WietseWind's full-sized avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / coolify-custom.md
Last active November 7, 2024 03:13
Coolify Tips
  • Install the Git webhook for Push to Deploy
  • Custom headers (!!) NEEDS [ ] STATIC to be DISABLED even if static, example: https://github.com/WietseWind/iPubXahau-Homepage
    • Make sure you have the nixpacks.toml and the .nix folder, the custom headers (nginx format) are in the .nix folder.
@WietseWind
WietseWind / index.mjs
Created September 18, 2024 10:40
Create Escrow in incrementing instalments
import fetch from 'node-fetch'
import { XrplDefinitions, derive, sign } from 'xrpl-accountlib'
const now = new Date()
const Server = 'https://xahau-test.net' // can be testnet, xahau-test.net / xahau.network
const secret = '{sender secret}' // can be RK secret
const Account = derive.familySeed(secret)
Account.address = '{sender account r-address}'
@WietseWind
WietseWind / prtg.js
Created August 2, 2024 00:07
Shelly 1 PM Mini Gen 3 - PRTG
// Access: http://{ip}/script/1/prtg
HTTPServer.registerEndpoint('prtg', function (request, response) {
response.headers = [
['content-type', 'application/json']
]
const em = Shelly.getComponentStatus('switch', 0)
const ip = Shelly.getComponentStatus('input', 0)
@WietseWind
WietseWind / prtg.js
Last active July 8, 2024 08:53
PRTG formatted JSON endpoint for "HTTP Data Advanced" sensor straight from Shelly
// Shelly: Scripts - create prtg.js with contents below - Start - Scripts main page: "Run on start"
// Call with (assuming the first script): http://{shellyip}/script/1/prtg
// PRTG: Import HTTP Data Advanced sensor.
HTTPServer.registerEndpoint('prtg', function (request, response) {
response.headers = [
['content-type', 'application/json']
]
const em = Shelly.getComponentStatus('em', 0)
@WietseWind
WietseWind / index.mjs
Created June 20, 2024 14:26
Calculate Balance Adjustment on Xahau
import fetch from 'node-fetch'
import { hookStateXLFtoBigNumber } from './xfl.mjs'
// Credits: https://github.com/tequdev/xahau-reward-claim/blob/main/src/app/ClaimReward.tsx
const account = 'rTeLeproT3BVgjWoYrDYpKbBLXPaVMkge'
const RPC_ENDPOINT = 'https://xahau.network'
const toUnixTimestamp = ts => ts + 946684800
@WietseWind
WietseWind / state.mjs
Created June 20, 2024 10:54
Xahau Voucher state
import { getPubKey, xflHexToString } from "./statelib.mjs";
const main = async () => {
console.log(getPubKey(process.argv[2]));
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
@WietseWind
WietseWind / index.mjs
Created June 9, 2024 22:16
DH secp256k1 nodejs
import { createECDH } from 'crypto'
import elliptic from 'elliptic'
import { deriveAddress } from 'ripple-keypairs'
const curve = 'secp256k1'
const secp256k1 = elliptic.ec(curve)
const bytesToHex = a => a.map(byteValue => ('0' + byteValue.toString(16)).slice(-2)).join('')
const getPublic = echdObj => bytesToHex(secp256k1.keyFromPrivate(echdObj.getPrivateKey()).getPublic().encodeCompressed())
@WietseWind
WietseWind / hook.ts
Last active June 4, 2024 13:19
Sample JS Hook - using @xahau/[email protected]
import {
enableEmit,
getState,
setState,
prepareEmit,
doEmit,
log,
AnyJson,
} from '@xahau/hooks'
@WietseWind
WietseWind / index.mjs
Created June 3, 2024 09:45
256 bits, ED25519 keypair & XRPL account using 10-face dice roll, numbers 0-9 (78 throws)
import accountlib from 'xrpl-accountlib'
import assert from 'assert'
const requiredBits = 256
const requiredThrows = Math.ceil(requiredBits / Math.log2(10))
// Adapted from validator keypair dice tool by RichardAH
// https://github.com/RichardAH/validator-keys-from-dice/blob/main/dice.js
// Random (BAD RANDOM! BAD BAD BAD RANDOM! DO NOT EVER USE THIS!! TESTING PURPOSES ONLY!)
@WietseWind
WietseWind / gen.mjs
Created June 3, 2024 09:29
XRPL Account Generator (ED25519) with 78x 10-face Dice roll
import accountlib from 'xrpl-accountlib'
import elliptic from 'elliptic'
import assert from 'assert'
const ec = new elliptic.eddsa('ed25519')
// Adapted from validator keypair dice tool by RichardAH
// https://github.com/RichardAH/validator-keys-from-dice/blob/main/dice.js
// Random (BAD RANDOM! BAD BAD BAD RANDOM! DO NOT EVER USE THIS!! TESTING PURPOSES ONLY!)
const dicerolls = Array(78).fill().map(r => Math.floor(Math.random() * 10))