Skip to content

Instantly share code, notes, and snippets.

View arisris's full-sized avatar
👨‍🦱
Open to work

Aris Riswanto arisris

👨‍🦱
Open to work
View GitHub Profile
@arisris
arisris / status_command.py
Created August 4, 2025 00:45
Status command script for swaybar
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import json
import subprocess
import select
import os
import re
@arisris
arisris / hanko-auth.svelte
Last active May 18, 2025 03:52
Hanko auth provider for sveltekit, it use tailwindcss for styling
<script module lang="ts">
import { onMount, type Snippet } from "svelte";
import { register } from "@teamhanko/hanko-elements";
import type { StateName, Hanko, User } from "@teamhanko/hanko-elements";
import { PUBLIC_HANKO_API_URL } from "$env/static/public";
import { scale } from "svelte/transition";
import { goto } from "$app/navigation";
import { page } from "$app/state";
import { browser } from "$app/environment";
@arisris
arisris / flux.py
Created February 23, 2025 09:09
Flux image generator on modal
import modal
import asyncio
import io
import time
from typing import List
from pathlib import Path
PATH_ROOT = Path(__file__).parent
HF_HUB_CACHE = "/hf-hub-cache"
MODEL_ID = "black-forest-labs/FLUX.1-schnell"
@arisris
arisris / routes.tsx
Created August 22, 2024 23:25
Hono FS Router For Vite
import { type Env, type Handler } from "hono";
import type { HonoOptions } from "hono/hono-base";
import { Hono } from "hono/tiny";
import { type PropsWithChildren } from "hono/jsx";
import type {
BlankEnv,
BlankInput,
BlankSchema,
HandlerResponse,
Input,
@arisris
arisris / raw.js
Created August 16, 2024 09:27
astro viewtransition dark toggle script
!((storageKey, buttonId, darkTheme, lightTheme) => {
const getTheme = () => {
if (
typeof localStorage !== "undefined" &&
localStorage.getItem(storageKey)
) {
return localStorage.getItem(storageKey);
} else if (
window.matchMedia(`(prefers-color-scheme: ${darkTheme})`).matches
) {
@arisris
arisris / dev-server.ts
Created July 7, 2024 16:06
Vite plugin to develop fetch based web server like cloudflare workers & pages functions
import { type Connect, type Plugin } from "vite"
import { getRequestListener } from "@hono/node-server"
import { getPlatformProxy, type PlatformProxy } from "wrangler"
type HonoDevServerPlugin = {
entry?: string
export?: string
injectClientScript?: boolean
exclude?: RegExp[]
ignoreWatching?: RegExp[]
@arisris
arisris / server.js
Created July 4, 2024 23:59
Run Hono On Node.js 22
import { Hono } from "hono";
import { compress } from "hono/compress";
import { streamSSE } from "hono/streaming";
import { createServer } from "node:http";
const app = new Hono();
app.get("/", compress({ encoding: "gzip" }), (c) => {
return c.html("<h1>Hello, World!</h1>");
});
@arisris
arisris / dev-server.ts
Created June 15, 2024 06:29
fetch based dev server middleware for vite.
import { Connect, type Plugin } from "vite"
type DevSeverOptions = {
/** relative path to appDir without trailing slash */
appDir?: string;
}
export const getHeaders = (req: Connect.IncomingMessage) => {
const h = new Headers()
for (const [key, value] of Object.entries(req.headers)) {
@arisris
arisris / kysely-table-prefixed.ts
Created November 2, 2023 14:18
Simple Kysely Plugins to prefix table name
import {
type KyselyPlugin,
type PluginTransformQueryArgs,
type RootOperationNode,
type PluginTransformResultArgs,
type QueryResult,
type UnknownRow,
OperationNodeTransformer,
TableNode,
} from "kysely";
@arisris
arisris / README.md
Last active March 28, 2023 15:09
save: @auth/core implementation in fresh framework

how to use it?

To resolve dependencies defined by @auth/core First you need to modify ./import_map.json and add this scope

{
  "imports": {...},
  "scopes": {
 ...