Skip to content

Instantly share code, notes, and snippets.

@oftenliu
oftenliu / extract-claude-code.mjs
Created April 1, 2026 09:06 — forked from sorrycc/extract-claude-code.mjs
Download Claude Code from npm and extract original TypeScript source from its source map. Usage: bun extract-claude-code.mjs [version]
#!/usr/bin/env bun
/**
* Download a specific version of Claude Code from npm,
* then extract the original TypeScript source from its source map.
*
* Usage:
* bun extract-claude-code.mjs [version]
*
* Example:
@oftenliu
oftenliu / extract-sourcemap.mjs
Created April 1, 2026 09:05 — forked from sorrycc/extract-sourcemap.mjs
Extract original source code from JavaScript .map (source map) files. Reads sourcesContent, skips node_modules, reconstructs the original file tree.
#!/usr/bin/env node
/**
* Extract original source code from a JavaScript source map file.
*
* Usage:
* node extract-sourcemap.mjs <path-to-.map-file> [output-dir]
*
* Example:
* node extract-sourcemap.mjs cli.js.map ./src-extracted
@oftenliu
oftenliu / testRegex.js
Created August 18, 2024 01:45
Regex for chunking by using all semantic cues
// Updated: Aug. 15, 2024
// Run: node testRegex.js testText.txt
// Used in https://jina.ai/tokenizer
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;