Skip to content

Instantly share code, notes, and snippets.

@cryptoskillz
cryptoskillz / imageupload.js
Last active April 9, 2023 16:17
how to use a custom image uploader in any rich text image editor.
//overide the image handler, this is using quill but it will work with any richtext editor.
var toolbar = quill.getModule('toolbar');
toolbar.addHandler('image', showImageUI);
let saveToServer = (file) => {
//get the data
const fd = new FormData();
fd.append('image', file);
//send it ot the server
const xhr = new XMLHttpRequest();
@cryptoskillz
cryptoskillz / email.js
Last active January 14, 2023 09:47
uising Cloudflare workers and postmarkapp to send outbound email
/**
STEPS
sign up for a postmark account here
https://postmarkapp.com/
verify an email. I used email cloudflare email routing to make this easy
//import swan.
const swan = require('@swan-bitcoin/xpub-lib');
export async function onRequestGet(context) {
//build the paramaters
const {
request, // same as existing Worker API
env, // same as existing Worker API
params, // if filename includes [id] or [[path]]
waitUntil, // same as ctx.waitUntil in existing Worker API
@cryptoskillz
cryptoskillz / bitcoinjsgenerateaddress
Last active April 22, 2022 17:46
generate a Bitcoin address from a xpub using bitcoinJs
//test data
//xpub converted from electrum using https://jlopp.github.io/xpub-converter/
const xpub =
'xpub67yMUMbr2gAnBgnYvXcbJq8iUBe54Ev2dbUYKGN8jGY21AHJFeR7mnZqhbUNze4UbpRE9S1fWvmFCsFN4EvU1rWdqegW7dzoa7vZmYCLAAy';
//xpub from electrum https://www.poof.io/help/wallet/electrum
const zpub = "zpub6mdt5gwgL3FjtHAnbFBqj1Kip7vxwUu2TpWyt49uVHHn7MukkxkF1ut7k1PYzTNKR6eqePCnSFULySUVVdkVcKsqaL5MHTdn7a3rYdSEc2K";
//different xpubs for testing taking from https://github.com/peli-pro/coldcard_address_generator/blob/master/coldcard_address_generator_node.js
const xpub_44h_0h_0h = 'xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj';
const xpub_49h_0h_0h = 'xpub6C6nQwHaWbSrzs5tZ1q7m5R9cPK9eYpNMFesiXsYrgc1P8bvLLAet9JfHjYXKjToD8cBRswJXXbbFpXgwsswVPAZzKMa1jUp2kVkGVUaJa7';
const xpub_84h_0h_0h = 'xpub6CatWdiZiodmUeTDp8LT5or8nmbKNcuyvz7WyksVFkKB4RHwCD3XyuvPEbvqAQY3rAPshWcMLoP2fMFMKHPJ4ZeZXYVUhLv1VMrjPC7PW6V';
@cryptoskillz
cryptoskillz / gist:98b8e7090b7cc8d51531bb9dcfe7654a
Created December 5, 2021 16:48
Tips on how to use a KV namespace with Cloudflare Pages
This gist aims to show you how to use KV datastore using Cloudflare pages. The reason I created this quick guide is it took
me almost 2 weeks to get it working, mainly because it is very new and the documentation is not up fully fleshed out yet
https://developers.cloudflare.com/workers/runtime-apis/kv
https://developers.cloudflare.com/pages/platform/functions
https://blog.cloudflare.com/wrangler-v2-beta/
Steps:
Install wrangler 2
@cryptoskillz
cryptoskillz / gist:ce0ab074d625755abf6bc87891c20d32
Created June 22, 2021 09:42
Fetch the files using the Strapi API so we they can be used in our eleventy static site without having to call back to the API.
IN THE ELEVENTY API FILE
const superagent = require('superagent');
let env = require('./env')
//this function gets some date from and API which can be used in the data processing, for simpluicty stakes it is connection to our auctions endpoint so you can see
//it in action
@cryptoskillz
cryptoskillz / Strapi Image retervial
Created June 22, 2021 05:27
Our frontend websites are simple flat HTML files created in a JAM stack fashion we recently moved Strapi as our back end CMS and it saves assets images in an uploads directory. We wanted to be able to render these images out of content blocks and repurpose them in our static sites without having to call the API each time
//API Data preprocessing can happen here
const superagent = require('superagent');
let env = require('./env')
//this function gets some date from and API which can be used in the data processing, for simpluicty stakes it is connection to our auctions endpoint so you can see
//it in action