Skip to content

Instantly share code, notes, and snippets.

// 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 March 24, 2025 14:55
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;
#include <stdio.h>
#include <stdlib.h>
#define da_append(xs, x) \
do { \
if ((xs)->count >= (xs)->capacity) { \
if ((xs)->capacity == 0) (xs)->capacity = 256; \
else (xs)->capacity *= 2; \
(xs)->items = realloc((xs)->items, (xs)->capacity*sizeof(*(xs)->items)); \
} \
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
// notifications.tsx
import * as Ariakit from "@ariakit/react";
interface Item extends Ariakit.NotificationStoreItem {
onUndo?: () => void;
}
export function useNotification() {
const notification = Ariakit.useNotificationContext();
if (!notification) {