Skip to content

Instantly share code, notes, and snippets.

name description tools model color
web-research-specialist
Use this agent for ALL web searches.
WebFetch, WebSearch
inherit
cyan

You are an elite technical research specialist with expertise in finding authoritative, accurate technical information through strategic web searches. Your core mission is to conduct searches like an experienced developer would - targeted, efficient, and focused on official sources.

@marcospgp
marcospgp / Dialog.tsx
Created October 9, 2025 20:01
react baseUI dialog manager
import { Dialog as D } from "@base-ui-components/react/dialog";
import { type ComponentType, type ReactNode, useEffect, useState } from "react";
import { Button } from "./Button";
import { Form, Input } from "./forms";
export type DialogAction = {
label: string;
action?: () => void | Promise<void>;
danger?: boolean;
};
@marcospgp
marcospgp / Dialog.tsx
Created September 22, 2025 13:07
BaseUI dialog manager implementation
import { Dialog as D } from "@base-ui-components/react/dialog";
import {
type ComponentProps,
type ReactNode,
createContext,
useEffect,
useRef,
useState,
} from "react";
import { Button } from "./Button";
import { useCallback, useState } from "react";
import { useAsyncEffect } from "./useAsyncEffect";
/**
* Hook factory to create hooks for storage models.
* The resulting hook allows components to use stored objects in their state.
*
* Feel free to copy and paste this documentation comment into the resulting
* hook function (replace "something" with the collection name):
*
@marcospgp
marcospgp / gist:1cb3b77488a7f616cd06b6c4a082ed6e
Created April 21, 2025 13:13
text input with animated underline in tailwind
<div className="relative">
<input
type="text"
ref={inputRef}
placeholder="flaborger the shenonions..."
className="peer relative z-10 focus:outline-none"
size={24}
/>
{/* Animated underline */}
<span
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcospgp
marcospgp / Hash.cs
Last active May 10, 2022 21:41
FNV 1a Hash in C# for use with Unity
using System;
using System.Text;
using UnityEngine;
/// <summary>
/// An implementation of the Fowler–Noll–Vo 1a hash
/// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash
/// http://www.isthe.com/chongo/tech/comp/fnv/index.html
/// </summary>
namespace MarcosPereira.Terrain {
@marcospgp
marcospgp / SafeTask.cs
Last active July 31, 2025 16:19
Cancel async tasks in Unity upon exiting play mode
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
namespace UnityUtilities
{
/// <summary>
/// A replacement for `Task.Run()` that cancels tasks when entering or
/// exiting play mode in the Unity editor (which doesn't happen by default).
@marcospgp
marcospgp / FloatingOrigin.cs
Last active September 16, 2025 03:12
A floating origin script for Unity.
// Based on script found at http://wiki.unity3d.com/index.php/Floating_Origin
// on 2021-05-13, modified substantially - mostly to accomodate multiplayer,
// by introducing threshold and offset values.
using UnityEngine;
public class FloatingOrigin : MonoBehaviour {
public static FloatingOrigin Instance;
// Largest value allowed for the main camera's X or Z coordinate before that
@marcospgp
marcospgp / JellyCube.cs
Created December 4, 2020 23:09
Unity C# script that jellifies a cube.
using System.Linq;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
public class Jellify : MonoBehaviour {
[SerializeField]
[Tooltip("The object's resistance to outside forces. Default value is 10.")]
[Range(1f, 1000f)]
private float stiffness = 10f;