Skip to content

Instantly share code, notes, and snippets.

@amit08255
amit08255 / demo1.html
Created October 1, 2025 03:37
CSS container queries demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Advanced CSS Container Queries Demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
body {
background: #f6f7fb;
font-family: system-ui, sans-serif;
@amit08255
amit08255 / 1-2-App.jsx
Created September 29, 2025 03:47
This Little-Known JavaScript API Changes How We Handle Async States Across Threads
// App.jsx
import { AtomicState, useAtomicValue } from "./shared-atomic-state";
import './App.css';
// Create a shared state instance (could be moved to a context or module)
const atomicState = new AtomicState();
// Create two atomic values
const counterA = atomicState.createAtomicValue(0, "int");
@amit08255
amit08255 / App.jsx
Created September 29, 2025 02:39
React Worker + OffscreenCanvas for Performant UI
import React, { useState } from 'react';
import { MapCanvas } from './components/MapCanvas.jsx';
import { HeatmapControls } from './components/HeatmapControls.jsx';
function App() {
const [region, setRegion] = useState('NYC');
const [zoom, setZoom] = useState(12);
const [heatmapOptions, setHeatmapOptions] = useState({
radius: 20,
@amit08255
amit08255 / react-app-event-bus.tsx
Created September 22, 2025 16:53
React App Event Bus Demo
import React, { useEffect, useRef, useState } from "react";
// --- 1. Event Bus Implementation ---
type EventMap = {
"modal:open": { modalId: string };
"modal:close": { modalId: string };
"listing:delete": { listingId: string };
"notification:show": { type: "success" | "error"; message: string };
"dom:action": {
@amit08255
amit08255 / plasmic-selfhosted.md
Last active January 10, 2025 19:44
Self-hosted Plasmic
@amit08255
amit08255 / react-dynamic-render.md
Last active December 10, 2024 17:46
React dynamic component rendering with JSON

Rendering React Components Dynamically with JSON

Approach 1: React component renderer with constants

{
    "type": "Container",
    "data": {
        "id": "4400936b-6158-4943-9dc8-a04c57e1af46",
        "items": [
@amit08255
amit08255 / form-security.md
Created September 5, 2024 19:05
JavaScript Form Protection

Protect Form From Spam

Method 1

This recipe puts a trivial speed bump in the way of form spammers. By forcing them to actually evaluate the page with a Javascript engine (or do extra processing to figure out what is needed), you raise the amount of effort required above that which most form spammers are likely to spend.

Step 1

Pick a nice random number. The SHA1 of some Git commit would be a good one. I picked this one:

@amit08255
amit08255 / highcharts.md
Created December 12, 2023 19:50
highcharts custom legends with hover and click effects in React

Highcharts Donut Chart Sample

import * as React from 'react';
import Highcharts, { Chart as HighchartsChart } from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
import { Box } from '@chakra-ui/react';
import DonutChartWrapper from './index.styles';
import Tooltip from '../tooltip';
@amit08255
amit08255 / gpt.md
Created December 7, 2023 00:48
GPT prompt collection

Prompt to generate storybook code from React component code:

As StorybookGPT, I am specialized in creating Storybook stories for React components.

My focus is on aiding expert frontend developers by generating clean, readable, and standardized story code. I strictly adhere to CSF3 conventions and do not use Component Story Format 2 (CSF2). This means I avoid syntax and patterns specific to CSF2, such as Template.bind({}), and instead focus on the cleaner, function-based approach of CSF3.

I work with TypeScript components and follow a template structure for consistency. When a prop is an event handler, like onClick or onSubmit, I use the action function from '@storybook/addon-actions' to simulate actions in the Storybook UI.

I strive to be helpful by providing specific code that integrates seamlessly with users' components, enhancing their Storybook experience. If I encounter any unclear details, I will ask for clarification, and I'm programmed to avoid making assumptions or providing unsolicite
@amit08255
amit08255 / Migrate bitbucket to github
Last active September 6, 2023 18:02 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ git clone --mirror <Bitbucket_repo_address>
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push --mirror
$ git remote rm bitbucket