Skip to content

Instantly share code, notes, and snippets.

@pasqualevitiello
pasqualevitiello / sidebar.tsx
Last active July 2, 2025 09:19
Stripe-Style Collapse/Expand Toggle
"use client"
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, VariantProps } from "class-variance-authority"
import { PanelLeftIcon } from "lucide-react"
import { cn } from "@/lib/utils"
import { useIsMobile } from "@/hooks/use-mobile"
import { Button } from "@/components/ui/button"
@DeluxeOwl
DeluxeOwl / parsing-operators.md
Created June 23, 2025 05:27
An algorithm for parsing with user-defined mixfix operators, precedences, and contexts

original: https://www.reddit.com/r/ProgrammingLanguages/comments/1lgcbhe/an_algorithm_for_parsing_with_userdefined_mixfix/?share_id=sScCkD2vAveIZeCurtMw1

This post is meant as a long-overdue reply to u/PitifulTheme411's question on this topic. The length is unfortunate, but I wanted to be sure that I was explaining the algorithm in detail so that it could be reproduced.

An ad-hoc parser for user-defined mixfix operators in contexts

This algorithm supports defining mixfix operators with different parsing behavior based on context: possible contexts include expressions, patterns, types, and top-level declarations. A total order of precedence is assumed, but is not required. This algorithm also does not correspond to any formalism that I am aware of, so it's going to be the only thing that can parse your files if you use it.

Declarations of syntax within the file being parsed are not supported: they're relatively easy to analyze and provide IDE support for (both the file with the definitions and the file b

@hirbod
hirbod / tus-file-reader.tsx
Created May 24, 2025 18:41
TUS FileUpload Class using next generation expo-file-system/next for fast chunked uploads with contant RAM by fair CPU usage
import { File, type FileHandle } from 'expo-file-system/next'
interface FileInput {
uri: string
}
export default class TusFileReader {
async openFile({ uri }: FileInput) {
const handle = new File(uri)
if (!handle.exists || !handle.size) throw new Error(`File ${uri} not found`)
// useful links:
// custom easing by Lochie (x.com/lochieaxon): https://www.easing.dev
// motion-primitives by Ibelick (x.com/Ibelick): https://motion-primitives.com/docs
// The Magic of Clip Path article by Emil Kowalski (x.com/emilkowalski_): https://emilkowal.ski/ui/the-magic-of-clip-path
// we use same transition for every element to make it look consistent
const transition: Transition = {
duration: 2.5,
// custom easing from https://www.easing.dev
ease: [0.175, 0.885, 0.32, 1],
@guilhermerodz
guilhermerodz / settings.json
Last active February 26, 2025 19:44
Tailwind Styled Utility inspired by styled-components and emotion
// .vscode/settings.json
{
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cn\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
["styled\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
],
}
@hirbod
hirbod / BarTest.tsx
Last active February 16, 2025 17:12
Reanimated CSS 4 Search Bar Header Replica (hacked together quick and dirty, no support!)
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { useCallback, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react'
import { ActivityIndicator, Keyboard, Platform, Text, View, TextInput, useWindowDimensions } from 'react-native'
import Animated from 'react-native-reanimated'
const SearchBar = () => {
const inset = useSafeAreaInsets()
const [isFocused, toggle] = useReducer((s) => !s, false)
const ref = useRef<View>(null)
const rect = useRef({ width: 0, height: 0, x: 0, y: 0 })
@jphsd
jphsd / interprocess.md
Last active October 13, 2024 16:46
Interprocess channels in Go by using named pipes

How to use channels across different processes in Go

A couple of code samples to show how a named pipe can be used to extend Go's channel paradigm for use between different processes running on a system.

  • interprocess1.go details a single byte channel.
  • interprocess2.go details a channel that passes slices of bytes.

Note that opening a write channel will return two channels -

@AndrasKovacs
AndrasKovacs / TwoStageRegion.md
Last active July 2, 2025 18:11
Lightweight region memory management in a two-stage language
@7etsuo
7etsuo / lambda.c
Created September 8, 2024 09:43
lambdas in C
/** Lambdas in C. Compile with GCC!
* ███ ▄████████ ███ ▄████████ ███ █▄ ▄██████▄
*▀█████████▄ ███ ███ ▀█████████▄ ███ ███ ███ ███ ███ ███
* ▀███▀▀██ ███ █▀ ▀███▀▀██ ███ █▀ ███ ███ ███ ███
* ███ ▀ ▄███▄▄▄ ███ ▀ ███ ███ ███ ███ ███
* ███ ▀▀███▀▀▀ ███ ▀███████████ ███ ███ ███ ███
* ███ ███ █▄ ███ ███ ███ ███ ███ ███
* ███ ███ ███ ███ ▄█ ███ ███ ███ ███ ███
* ▄████▀ ██████████ ▄████▀ ▄████████▀ ████████▀ ▀██████▀
*
import React, { useCallback, useState } from "react";
const EnvironmentVariables = () => {
const [variables, setVariables] = useState([{ key: '', value: '' }]);
const handleInputChange = useCallback((index, field, value) => {
setVariables((prevVariables) => {
const newVariables = [...prevVariables];
newVariables[index][field] = value;
return newVariables;