Skip to content

Instantly share code, notes, and snippets.

View fzn0x's full-sized avatar
💻
Working from home

Fauzan fzn0x

💻
Working from home
View GitHub Profile
@fzn0x
fzn0x / QrCode.jsx
Created July 18, 2024 05:13
QrCode with Logo on Center
import { Box, Image } from "@chakra-ui/react";
import * as qrCode from "@zag-js/qr-code";
import { useMachine, normalizeProps } from "@zag-js/react";
import { useId } from "react";
// @ts-ignore-next-line
import YEYLogoChrome from "../../../assets/imgs/yey-logo-chrome-clear.png";
export default function QRCode() {
@fzn0x
fzn0x / bootloader.asm
Created July 12, 2024 23:29
Write my first OS - Hello World (part 1) - bootloader.asm
[ORG 0x7C00]
mov ah, 0x0E
mov al, 'H'
int 0x10
mov al, 'e'
int 0x10
mov al, 'l'
int 0x10
mov al, 'l'
@fzn0x
fzn0x / bitflip.js
Created July 12, 2024 19:41
Bit Flip - Bitnya ngeflip
function bitFlip(byte, bitPosition) {
// Membuat mask untuk bit flip
const mask = 1 << bitPosition;
return byte ^ mask;
}
function byteToBinaryString(byte) {
return byte.toString(2).padStart(8, "0");
}
wget https://gist.githubusercontent.com/ammarfaizi2/f55dbb7c918a660776c68c50319c7882/raw/1dd37e1fb96054b31f345381273e8a1702215002/ct.c;
gcc -O2 ct.c -o ct -lpthread;
./ct $(nproc);
2024-07-07-13-30-13_JyVhZy95.mp4
@fzn0x
fzn0x / app.module.ts
Created June 21, 2024 06:23
Generate Swagger from Nest Data Transfer Objects and Routes (@wait what?)
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module.js';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const config = new DocumentBuilder()
.setTitle('Minjem Buku Perpustakaan SMK TI Garuda Nusantara')
@fzn0x
fzn0x / hono_handler.ts
Created May 6, 2024 23:46
wip: dynamic handler types to enforce return value in Hono handlers
// Handler type when `next` is NOT provided and a response is expected
export type HandlerWithoutNext<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> =
(c: Context<E, P, I>) => R;
// Handler type when `next` is provided
export type HandlerWithNext<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> =
(c: Context<E, P, I>, next: Next) => void;
// Union type to combine both handler types
export type Handler<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> = HandlerWithoutNext<E, P, I, R> | HandlerWithNext<E, P, I, R>;
@fzn0x
fzn0x / package.json
Created May 4, 2024 00:01
vitest-bun-hono
{
"name": "vitest-bun-hono",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
@fzn0x
fzn0x / tsconfig.json
Created April 29, 2024 23:16
TSConfig for the Fullstack Kong
{
"include": [
"**/*.ts",
"**/*.tsx",
"**/.server/**/*.ts",
"**/.server/**/*.tsx",
"**/.client/**/*.ts",
"**/.client/**/*.tsx"
],
"compilerOptions": {
@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();
});