This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.bitcoin = { | |
messagePrefix: '\x18Bitcoin Signed Message:\n', | |
bech32: 'bc', | |
bip32: { | |
public: 0x0488b21e, | |
private: 0x0488ade4, | |
}, | |
pubKeyHash: 0x00, | |
scriptHash: 0x05, | |
wif: 0x80, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function base64Encode (buf) { | |
let string = ''; | |
(new Uint8Array(buf)).forEach( | |
(byte) => { string += String.fromCharCode(byte) } | |
) | |
return btoa(string) | |
} | |
function base64Decode (string) { | |
string = atob(string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_get_filters = () => { | |
return { | |
".1997": { | |
"a": Uint8ClampedArray.of(0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 39, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 146, 147, 148, 149, 150, 151, 152, 153, 153, 154, 155, 156, 157, 158, 159, 160, 160, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 188, 189, 190, 191, 192, 193, 193, 194, 195, 196, 197, 198, 199, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_get_pixels_palette_and_list_from_image_data = (image_data) => { | |
const image_data_data = image_data.data; | |
let new_pxl_colors = []; | |
let new_pxl_colors_set = new Set(); | |
let new_pxls = new Array(image_data.width * image_data.height); | |
for (let i = 0; i < image_data_data.length; i += 4) { | |
const color_hex = this._get_hex_color_from_rgba_values(image_data_data[index], image_data_data[index+1], image_data_data[index+2], image_data_data[index+3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CONST: | |
// imgd_data (you get img_data using a canvas, please get familiar with canvas) | |
// no_transparent (Boolean to know which file format to use) | |
// pxl_width (Simply width of the image) | |
// pxl_height (Simply height of the image) | |
// resize_width (Which size of width will it get at the end?) | |
try { // Can work in Web Worker so you can run it on a CPU thread different from the main one which doesn't freeze the UI | |
var imgd = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CLIENT-SIDE | |
function postJSON(url, payload, callback_function, content_type = "application/x-www-form-urlencoded") { | |
// This function is required because JSON is weird with some char | |
function clean_json_text(json_text) { | |
json_text = json_text.replace(/\\n/g, "\\n") | |
.replace(/\\'/g, "\\'") | |
.replace(/\\"/g, '\\"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The MIT License (MIT) | |
* | |
* Copyright (c) 2023 Affolter Matias | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The MIT License (MIT) | |
* | |
* Copyright (c) 2023 Affolter Matias | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The MIT License (MIT) | |
Copyright (c) 2023 Matias Affolter | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
OlderNewer