Skip to content

Instantly share code, notes, and snippets.

View dr2009's full-sized avatar
🐑
type-safe

dr2009 dr2009

🐑
type-safe
View GitHub Profile
@Xsir0
Xsir0 / patch-chrome-local-state.sh
Created January 29, 2026 15:03
Patch Chrome Local State for all local profiles: set is_glic_eligible=true (recursive), force variations_country=us, update variations_permanent_consistency_country. Auto backup + restart Chrome if needed.
#!/usr/bin/env bash
set -euo pipefail
need_cmd() { command -v "$1" >/dev/null 2>&1 || { echo "Missing: $1" >&2; exit 1; }; }
need_cmd jq
OS="$(uname -s)"
if [[ "$OS" != "Darwin" ]]; then
echo "This script is macOS-only (Darwin). Current: $OS" >&2
exit 1
@Kyle-Ye
Kyle-Ye / XcodeLLM.md
Last active September 19, 2025 01:31
Enable XcodeLLM for ChinaSKU Mac on macOS 15 Beta 1

Warning

The following guide need to disable SIP to work.

Please confirm the risk of disabling the SIP by yourself.

Another solution which does not require disabling SIP is currently under investigation.

Step 0

Reboot into Recovery OS + Disable SIP

@Temzasse
Temzasse / use-parsed-search-params.ts
Last active June 6, 2025 10:17
A utility hook to parse and type URL search params based on a configuration object. This hook is useful when you want to access URL search params in a typesafe way and with proper casting.
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
type ParseConfig = Record<
string,
| { type: "string"; defaultValue?: string }
| { type: "number"; defaultValue?: number }
| { parse: (value: URLSearchParams) => unknown }
>;

Idea: Flat file system for file-based routing

Personally I've never liked how tools like Remix or NextJS have mapped a nested file system to routes. Simple things like "I want to put this component in its own file" become annoying tasks.

I've always been a fan of "flatter" file systems, my files often look like this:

/App/
@sindresorhus
sindresorhus / esm-package.md
Last active March 16, 2026 04:38
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@developit
developit / *constant-locals-loader.md
Last active February 4, 2022 17:15
Inline Webpack CSS Modules classNames, reducing bundle size. https://npm.im/constant-locals-loader

constant-locals-loader for Webpack

This loader optimizes the output of mini-css-extract-plugin and/or css-loader, entirely removing the potentially large CSS classname mappings normally inlined into your bundle when using CSS Modules.

Run npm install constant-locals-loader, then make these changes in your Webpack config:

module.exports = {
 module: {
@jeremyben
jeremyben / ts-build-api.ts
Last active May 20, 2024 10:36
Typescript programmatic build with tsconfig.json (run with `ts-node -T`)
import * as path from 'path'
import ts from 'typescript'
function build(
override: {
compilerOptions?: ts.CompilerOptions
include?: string[]
exclude?: string[]
files?: string[]
extends?: string
@ruicky
ruicky / xima.py
Created April 30, 2019 03:19
喜马拉雅专辑批量下载脚本
import requests
import os, sys
import concurrent.futures
from itertools import repeat
class XimaScraper:
def __init__(self, album_no, page_num):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0'
}
@fnky
fnky / ANSI.md
Last active March 17, 2026 01:33
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@elijahmanor
elijahmanor / index-0-non-debounced.js
Last active August 6, 2025 13:41
React Debouncing Events
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {