Skip to content

Instantly share code, notes, and snippets.

View developit's full-sized avatar
🦊
write, the codes

Jason Miller developit

🦊
write, the codes
View GitHub Profile
@RafalWilinski
RafalWilinski / claude-desktop-auto-allow-everything-mcp.js
Last active April 16, 2025 18:39
Auto-approve all MCP tool calls in Claude Desktop
// HOW TO INSTRUCTIONS
// 1. Open Claude Desktop
// 2. Go to Help -> Enable Developer Mode
// 3. Navigate Developer Tools window named "Developer Tools - https://claude.ai"
// 4. Go to "Console" tab
// 5. Type "allow pasting" and hit Enter
// 6. Paste this snippet and hit Enter
// From now on, all MCP calls will be auto-approved
@marvinhagemeister
marvinhagemeister / bind-plugin.ts
Last active December 16, 2024 14:38
Preact Signals `bind:value`
import { options } from "preact";
import { Signal } from "@preact/signals";
// Add `bind:value` to JSX types
declare global {
namespace preact.createElement.JSX {
interface HTMLAttributes {
"bind:value"?: Signal<string | string[] | number | undefined>;
}
}
import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
@surma
surma / .gitignore
Created February 1, 2023 15:48
Wasm GC
*.wasm
@WebReflection
WebReflection / esx.md
Last active October 6, 2024 12:35
Proposal: an ESX for JS implementation
import { hook, OptionsTypes } from './preact-options-helper.ts';

hook(OptionsTypes.RENDER, (old, vnode) => {
    let component = vnode.__c;
    if (component) {
        // do stuff with the component instance
    } else {
        console.log(vnode.props);
 }
@developit
developit / index.html
Last active July 25, 2023 12:44
bare-bones exhaust() vs ternary #jsbench #jsperf #jsbench #jsperf (https://jsbench.github.io/#ec47bed3cf0e424b78bdbc4d71cdd3a3) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>bare-bones exhaust() vs ternary #jsbench #jsperf #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@developit
developit / index.html
Last active July 25, 2023 12:44
exhaust() vs ternary #jsbench #jsperf (https://jsbench.github.io/#3b6dbcf299369a9916a06f2e338e74bb) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>exhaust() vs ternary #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>

preact-root-fragment: partial root rendering for Preact

This is a standalone Preact 10+ implementation of the deprecated replaceNode parameter from Preact 10.

It provides a way to render or hydrate a Preact tree using a subset of the children within the parent element passed to render():

<body>
  <div id="root">  ⬅ we pass this to render() as the parent DOM element...
@wonderful-panda
wonderful-panda / test.tsx
Last active December 6, 2021 22:32
difference behaviour between react and preact
/*
* With [email protected], Effect-A is triggered, then Effect-B is triggered. (expected)
* With [email protected], Effect-B is triggered, then Effect-A is triggered.
*
* `useLayoutEffect` is more appropriate for Effect-A, maybe.
*
* BTW, behaviours will be same if removing React.memo call (line.39)
*/
const EditorWrapper_: React.VFC<{