Skip to content

Instantly share code, notes, and snippets.

@t3dotgg
t3dotgg / try-catch.ts
Last active May 6, 2025 15:35
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@sikanhe
sikanhe / ReactCompilerPlugin.ts
Last active May 3, 2025 13:11
React Compiler plugin for ESBuild
import { readFileSync } from "node:fs"
import * as babel from "@babel/core"
import BabelPluginReactCompiler from "babel-plugin-react-compiler"
import type { Plugin } from "esbuild"
import QuickLRU from "quick-lru"
export function ReactCompilerEsbuildPlugin({
filter,
sourceMaps,
runtimeModulePath,
@bdsqqq
bdsqqq / vesper-dark.json
Last active December 1, 2024 20:38
Vesper theme for zed.dev
{
"$schema": "https://zed.dev/schema/themes/v0.1.0.json",
"name": "Vesper",
"author": "Rauno Freiberg",
"themes": [
{
"name": "Vesper",
"appearance": "dark",
"style": {
"border": "#101010",
@rishi-raj-jain
rishi-raj-jain / index.ts
Last active December 12, 2024 14:25
Google OAuth 2.0 on the Edge with Hono and Cloudflare Workers
// Do enable nodejs_compat
// https://developers.cloudflare.com/workers/runtime-apis/nodejs/
import crypto from 'node:crypto'
import { Context, Hono } from 'hono'
const app = new Hono()
function generateJWT(payload, secret, expiresIn) {
const header = { alg: 'HS256', typ: 'JWT' }
const encodedHeader = base64UrlEncode(JSON.stringify(header))
@theatom06
theatom06 / README.md
Last active September 18, 2023 05:33
Naming Scheme in Js

Gandalf's JavaScript Naming Scheme

1. CamelCase:

  • Use camel case for variable and function names.
  • Example: myVariable, myFunction

2. PascalCase:

  • Use Pascal case for class and constructor names and modubles.
  • Example: MyClass, MyConstructor, MyModule
@b-nnett
b-nnett / boost.js
Created April 18, 2023 15:47
Arc ChatGPT Boost
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function fillQuery() {
question = window.location.search.split("=")[1].replace("+", " ").replace("%3F", "?").replace("%27", "'")
var input = document.getElementsByTagName("textarea")[0]
await sleep(1000); // Pause for 1 second
input.textContent = question
// input.innerText = question
@hackermondev
hackermondev / ClydeAI-Jailbreak.md
Last active January 26, 2025 06:49
Discord ClydeAI jailbreak
@zisra
zisra / index.js
Last active March 21, 2023 23:40
Parse date
import parseDate from './parseDate.js';
parseDate('1 minute'); // => 60000
parseDate('1 hour'); // => 3600000
parseDate('Not a date'); // => Error: Invalid format
/*
* Usage: count {unit}
* Units:
* s, second, seconds, sec
@monokee
monokee / define-component.js
Last active December 7, 2024 17:07
Tiny customElement wrapper that enables scalable web component architecture. Define custom elements with a configuration object that separates markup from css and javascript. Uses a slotted light DOM (no shadow DOM) to allow for powerful component extension, composition and easier styling with external stylesheets and global css variables. Expor…
/**
* Tiny customElement wrapper that enables scalable web component architecture.
* Define custom elements with a configuration object that separates markup from css and javascript.
* Uses a slotted light DOM (no shadow DOM) to allow for powerful component extension,
* composition and easier styling with external stylesheets and global css variables.
* Exports a component class that can be imported and explicitly used to be picked up by module bundlers.
* See comments for examples and GNU license below.
*/
export function defineComponent(name, config) {