Skip to content

Instantly share code, notes, and snippets.

View khairul169's full-sized avatar
๐Ÿ€
Active

Khairul Hidayat khairul169

๐Ÿ€
Active
View GitHub Profile
@khairul169
khairul169 / bun-sqlite-persister.ts
Last active February 24, 2025 07:26
TinyBase Bun SQLite database persister
import { MergeableContent, MergeableStore } from "tinybase";
import { Database } from "bun:sqlite";
import { createCustomPersister, Persists } from "tinybase/persisters";
const TABLES = "_tables";
const escapeId = (str: string) => `${str.replace(/"/g, '""')}`;
const dbSchema = `
PRAGMA foreign_keys = ON;
@khairul169
khairul169 / SSH-Tunnel-Quick-Setup.md
Last active June 17, 2024 18:07
SSH Tunnel Quick Setup

Generate SSH Key

ssh-keygen -t ed25519 -C "khairul169"
cat .ssh/id_ed25519.pub

Add SSH Public Key to the server

ssh root@hostname
@khairul169
khairul169 / .sshtunnel.sh
Created March 14, 2024 09:45
AutoSSH Remote Tunnel
#!/bin/sh
# /root/.sshtunnel.sh
autossh -M 0 root@hostname -R 8023:localhost:22 -N -o "StrictHostKeyChecking no" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure yes"
@khairul169
khairul169 / ExampleUsage.tsx
Last active March 14, 2024 09:09
Custom Fetch/Mutation React Hooks
import React from "react";
import { useStore } from "zustand";
import { useFetch, useMutate } from "./useFetch";
import { authStore, logout } from "./authStore";
const App = () => {
const { accessToken } = useStore(authStore);
const login = useMutate("/login", {
onSuccess: (data) => {
@khairul169
khairul169 / MeshCustomMaterial.js
Created April 15, 2020 23:09 — forked from mattdesl/MeshCustomMaterial.js
Custom mesh standard material with glslify + ThreeJS r83dev
const glslify = require('glslify');
const path = require('path');
// This is the original source, we will copy + paste it for our own GLSL
// const vertexShader = THREE.ShaderChunk.meshphysical_vert;
// const fragmentShader = THREE.ShaderChunk.meshphysical_frag;
// Our custom shaders
const fragmentShader = glslify(path.resolve(__dirname, 'standard.frag'));
const vertexShader = glslify(path.resolve(__dirname, 'standard.vert'));
@khairul169
khairul169 / p2p.c
Created December 12, 2019 15:11 — forked from mpatraw/p2p.c
Simple P2P example using ENet.
/*
* p2p.c
*/
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <enet/enet.h>
shader_type spatial;
render_mode shadows_disabled;
uniform float rim = 0.25;
uniform float rim_tint = 0.5;
uniform sampler2D albedo : hint_albedo;
uniform float specular;
uniform float roughness = 1.0;
uniform bool disable_lighting = false;
uniform vec4 shadow_color : hint_color;
@khairul169
khairul169 / encode.sh
Created January 2, 2018 15:10
Encode video to small-sized MP4 video optimized for NontonAnime streaming application using FFMPEG & MP4Box
#!/bin/bash
PREVIEW_DIR="preview";
ENCODED_DIR="encoded";
PREVIEW_SCALE="-2:240";
mkdir -p "$PREVIEW_DIR";
mkdir -p "$ENCODED_DIR";
# Check arguments