Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / banxa-api-signature.mjs
Created Sep 29, 2022
Banxa API from NodeJS (signature)
View banxa-api-signature.mjs
import fetch from 'node-fetch'
import {createHmac} from 'crypto'
const endpoint = 'xxxxxx
const key = 'yyyyyy'
const secret = 'xxxxxxxx'
const banxaCall = async (path, body, method = 'GET') => {
const nonce = Math.round(new Date() / 1000)
@WietseWind
WietseWind / setup.sh
Last active Sep 7, 2022
xrpld monitor
View setup.sh
echo 'Install xrpld monitoring'
echo ''
echo 'Please provide some info, if you need to change this, you can do so later in /etc/crontab'
echo ''
echo 'Local host + port with xrpld websocket, e.g. "localhost:6006"'
read host
echo ''
@WietseWind
WietseWind / animated-gif-for-tydbit.mjs
Created Aug 27, 2022
Animated GIF based on multiple SVG frames (sharpjs) for Tydbit (in NodeJS)
View animated-gif-for-tydbit.mjs
import express from 'express'
import sharp from 'sharp'
import fetch from 'node-fetch'
import { Gif } from 'make-a-gif'
sharp.cache(false)
const app = express()
const port = 3000
@WietseWind
WietseWind / svg-to-gif-for-tydbit.mjs
Last active Aug 27, 2022
Tidbyt SVG to GIF with NodeJS
View svg-to-gif-for-tydbit.mjs
import express from 'express'
import sharp from 'sharp'
import fetch from 'node-fetch'
sharp.cache(false)
const app = express()
const port = 3000
const device = 'some-device-name-whatever-123'
@WietseWind
WietseWind / index.mjs
Last active Jul 4, 2022
Fun with Generator Functions. First backfill XRPL Ledgers, then keep up with current Ledgers closing, fall back to backfilling if needed to sync gaps.
View index.mjs
import { XrplClient } from 'xrpl-client'
const config = { backfillLedgers: 20, lastLedger: null }
const client = new XrplClient(['wss://xrplcluster.com'])
await client.ready()
config.lastLedger = client.getState().ledger.last - config.backfillLedgers
function getLedgerTransactions(ledger_index) {
return client.send({ command: 'ledger', transactions: true, expand: true, ledger_index })
@WietseWind
WietseWind / user-profile-script.js
Last active Jun 20, 2022
Xumm OAuth2 Sign In for Auth0, based on Developer Question: https://xumm.readme.io/discuss/62af82ada6faf1007c0e89f3
View user-profile-script.js
function(accessToken, ctx, callback) {
const url = "https://oauth2.xumm.app/userinfo";
request.get(
{ url, headers: { 'Authorization': 'Bearer ' + accessToken, } },
(err, resp, body) => {
if (err) {
return callback(err);
}
if (resp.statusCode !== 200) {
@WietseWind
WietseWind / pkce-implicit.html
Created May 26, 2022
Example OAuth2 client side (vanillaJS) example with Implicit PKCE flow
View pkce-implicit.html
<html>
<title>OAuth Authorization Code + PKCE in Vanilla JS</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!-- Credits: https://github.com/aaronpk/pkce-vanilla-js/blob/master/index.html -->
<script>
// Configure your application and authorization server details
var config = {
client_id: "<The Xumm App API key (public)>",
@WietseWind
WietseWind / build.sh
Created Apr 14, 2022
Hooks AssemblyScript V2
View build.sh
#!/bin/bash
rm ./module.wasm
rm ./module.wat
node assemblyscript/bin/asc \
-O3 \
--noAssert \
--runtime minimal \
--textFile ./module.wat \
View starter.c
/**
* This hook just accepts any transaction coming through it
*/
#include "hookapi.h"
int64_t cbak(int64_t reserved) {
return 0;
}
int64_t hook(int64_t reserved ) {
View blacklist.c
#include "hookapi.h"
/*
Blacklist signing keys ((( you should change these )))
r.deriveKeypair('sEd7CGWXiFPazNncZJsxD11h1sHJCtm')
{
privateKey: 'ED55D3A139AF8F069FE93BB943FE3A46BAF70EA61E0DD02192D4A532D8E87627F0',
publicKey: 'EDDC6D9E28CA0FE2D475FC021D226881666EA106FBD2222C8C2110368A49C9513C'
}
the public key is encoded below, you should change this
*/