Skip to content

Instantly share code, notes, and snippets.

@samet404
samet404 / snapScroll.js
Last active September 30, 2025 08:35
SnapScroll
!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))processPreload(e);new MutationObserver(e=>{for(const t of e)if("childList"===t.type)for(const e of t.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&processPreload(e)}).observe(document,{childList:!0,subtree:!0})}function processPreload(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();window.snapScroll=({container:e,offset:t,debug:n=!1,animateIn:o,animateOut:l,initialElemState:i})=>{const s=Array.from(e.children);((e,t)=>{if(e instanceof Array||!(e instanceof HTMLElement))throw new Error("Invalid container");if(0===t.length)throw new Error("No child elements fou
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry.js';
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
import dat from 'dat.gui';
import Stats from 'three/examples/jsm/libs/stats.module.js';
const createWorkerFromText = (workerCode: string) => {
// Create a blob from the code
@samet404
samet404 / DrawerComposable.kt
Created July 27, 2025 08:26
Drawer composable in Jetpack Compose and also can be used in Kotlin Multiplatform Projects
@Composable
fun Drawer(
isOpen: Boolean,
toggleDrawer: () -> Unit,
content: @Composable () -> Unit,
containerModifier: Modifier = Modifier,
) {
val screenSize = ScreenSize.collectAsStateWithLifecycle()
var isReallyOpen by remember { mutableStateOf(isOpen) }
var isContainerDisappearing by remember { mutableStateOf(false) }
@samet404
samet404 / onIO.ts
Created June 24, 2025 17:43
Type safe, tRPC like, socket.io on function in Typescript.
import { z, ZodSchema } from 'zod'
import type { AllSocketTypes } from '../types'
import { logErr } from './logErr'
/**
* onIO is a utility to handle on input from socket.io
*
* @example
* onIO().input(z.string()).on(io, 'connection', (input) => {
* console.log(input) // input is inferred as string
@samet404
samet404 / emitIO.ts
Created June 24, 2025 17:42
Type safe tRPC like, socket.io emit function in Typescript
import type { BroadcastOperator, Namespace, Server, Socket } from 'socket.io'
import { z, ZodSchema } from 'zod'
import { logErr } from '@/utils'
import type { AllSocketTypes } from '@/types'
/**
* emitIO is a utility to emit data to a socket.io client.
*
* @example
* emitIO().output(z.string())
@samet404
samet404 / ReorderableLazyColumn.kt
Last active June 7, 2025 18:14
Custom Jetpack Compose Lazy Column Composable that allows to drag items
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@samet404
samet404 / ReorderableColumn.kt
Last active June 22, 2025 18:51
Drag/Drop items inside Jetpack Compose Column Composable using ReorderableColumn.kt. Supports Kotlin Multiplatform.
package org.example.dragdrop
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@samet404
samet404 / CustomMultilineTextField.kt
Last active May 15, 2025 17:20
Custom multiline text field in Jetpack Composable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@samet404
samet404 / InPosition.kt
Created April 6, 2025 20:37
Jetpack Compose InPosition Composable allows to place content in spesific position.
package org.bloomy.project.core.composables
import androidx.compose.runtime.Composable
import androidx.compose.ui.layout.Layout
import org.bloomy.project.core.theme.ScreenSize
/**
* Composable that allows to place content in a specific position.
*/
@Composable
@samet404
samet404 / Fullscreen.kt
Created April 6, 2025 20:36
Custom Jetpack Compose Fullscreen composable allows to create a Box that overlays the whole screen
package org.bloomy.project.core.composables
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
/**