Skip to content

Instantly share code, notes, and snippets.

@vipertechofficial
vipertechofficial / fastest-rgba-hsla-hex-conversion.js
Created April 30, 2022 19:23
Fastest RGBA, HSLA, and HEX color conversion, formatting and blending (mix) in JavaScript developed for the pixa.pics project.
_format_color = (color) => { // Supports #fff (short rgb), #fff0 (short rgba), #e2e2e2 (full rgb) and #e2e2e2ff (full rgba)
const hex = color || "#00000000";
const hex_length = hex.length;
if(hex_length === 9) {
return hex;
} else if (hex_length === 7) {
@vipertechofficial
vipertechofficial / cloudflare-worker-deepai.js
Last active February 24, 2022 00:43
Cloudflare worker for Deepai API
function base64Encode (buf) {
let string = '';
(new Uint8Array(buf)).forEach(
(byte) => { string += String.fromCharCode(byte) }
)
return btoa(string)
}
function base64Decode (string) {
string = atob(string);
exports.bitcoin = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'bc',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4,
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,