Skip to content

Instantly share code, notes, and snippets.

View fzn0x's full-sized avatar
🌎
Makes international software.

fzn0x fzn0x

🌎
Makes international software.
View GitHub Profile
@fzn0x
fzn0x / readline.ts
Created April 20, 2024 22:21
Temporary solution for https://github.com/oven-sh/bun/issues/10403 Cannot exit all the processes when CTRL + C in readline, need to enter twice, or enter after CTRL + C.
import * as readline from "node:readline";
// TODO: remove code when https://github.com/oven-sh/bun/issues/10403 is fixed
if (process.stdin.isTTY) {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on("keypress", (str, key) => {
if (key.ctrl && key.name === "c") process.exit();
});
@fzn0x
fzn0x / index.html
Created April 19, 2024 12:58
Voice Recognition in Modern Browsers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
@fzn0x
fzn0x / proof.md
Created April 19, 2024 04:06
Identity Ownership Proof

aspe:keyoxide.org:RLQZXDQOTFSV55QFFVBYFWWW2Q

@fzn0x
fzn0x / sync.js
Last active April 16, 2024 09:45
Sync model with database (creating tables)
"use strict";
const { Sequelize } = require("sequelize");
const db = {};
const fs = require("fs");
const path = require("path");
const sequelize = new Sequelize("xxxx", "xxxx", "xxxx", {
host: "xxxx",
port: "xxxx",
@fzn0x
fzn0x / countries-with-flags.json
Created April 11, 2024 14:59
Find Flag Image with Currency Code
[
{
"code": "AED",
"name": "UAE Dirham",
"country": "United Arab Emirates",
"countryCode": "AE",
"flag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAG5SURBVHja7JdLihRBEEBfVqUU6rQNggiCFxA8gswFRNy49gAeQdx4G8HbuHDvRkRUnKxPZ2dGhous6Y9TtavPZmITtYggXsWPSKOqrCkFK8stgAFKoOr1kiKAt8CD76/f/KYYj//u7bPpU28Mn199eGiBLabg7uWLUePLp08mB/j66xvA1gKVSkK9J/29guuxNCZrVX60905qZlD0xvd5XbPvmN22uo+XCFDZXI2Idjt0txuk9TFM+ve7Yk9MAkAPIKSuI3XdoEMX/aQAd4qSfYpHAI0RbVt0FGA/KYAtyvMMaBTUObRpBh2a0E3cgspewkkJQkDqGm3bQfNPL9/PtIQ+cmjC5OqbTaj9qppRcglCAFej3h9H8P9xnBUgCtRNBllYDj0QmxbWAkgxggiktFjg60PosAeMJnQtAIkRq7poBlIfK5cgRBQdzYC1dtLgVVVRluUJgEQo7XH0RminlBDCKUDK99AIwByXs4gcb0JJafaFc7aCjTlktQBIqpiVAPIYas5AcXEx6LCRzaxjKAn4465GjZ1zs13GBngMPAceLbyFfwJfTP8m2PR6SfGAM7eP07UB/g0Aw73uXdMbeJMAAAAASUVORK5CYII="
},
{
"code": "AFN",
@fzn0x
fzn0x / mysql.js
Created March 13, 2024 18:57
My best practice for MySQL wrapper with App Engine support.
const mysql = require("mysql");
const util = require("util");
const dayjs = require("dayjs");
const sqlString = require("sqlstring");
let config = {
host: process.env.DB_HOST,
user: process.env.DB_USER,
port: process.env.DB_PORT || 3306,
database: process.env.DB_DATABASE,
@fzn0x
fzn0x / index.html
Created February 16, 2024 16:29
Lazy Asset Loading - fzn0x
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lazy Loading with Infinite Scroll</title>
<style>
#image-container {
column-count: 3;
column-gap: 10px;
@fzn0x
fzn0x / build.gradle
Created February 16, 2024 05:26
Gradle Configuration - Maven Configuration Comparison
plugins {
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '21'
repositories {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
visibility: hidden;
@fzn0x
fzn0x / structuredClone.js
Last active March 23, 2023 00:00
Asynchronous Structured Clone (Using The Structured Clone Algorithm) for Deep Copying
// postMessage is using the structured clone algorithm
function structuredClone(obj) {
return new Promise(resolve => {
const {port1, port2} = new MessageChannel();
port2.onmessage = ev => resolve(ev.data);
obj.y.x = "Now I can modify cyclic objects without ";
port1.postMessage(obj);
port1.close();
});
}