Skip to content

Instantly share code, notes, and snippets.

@leehanchung
leehanchung / benfords_election.py
Created November 7, 2020 07:41
detecting election fraud using Benford's Law
##############################################################################
# Author: Han-chung Lee
# Date: 2020-11-6
#
# Detecting election fraud activity at Milwaukee County using Benford's Law
#
# Statistical detection of systematic election irregularities:
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3478593/
##############################################################################
@leehanchung
leehanchung / collisionLSH.py
Created August 18, 2021 20:05 — forked from unrealwill/collisionLSH.py
Proof of Concept : generating collisions on a neural perceptual hash
import tensorflow as tf #We need tensorflow 2.x
import numpy as np
#The hashlength in bits
hashLength = 256
def buildModel():
#we can set the seed to simulate the fact that this network is known and doesn't change between runs
#tf.random.set_seed(42)
model = tf.keras.Sequential()
@leehanchung
leehanchung / factors_gen.txt
Created April 5, 2024 04:01
yandex search features
This file has been truncated, but you can view the full file.
# Contains human-readable representation of NFactor::TCodeGenInput message (defined in factors_metadata.proto)
Group: [
"Datetime",
"Domain",
"RapidClicks",
"RegHostStatic",
"RegDocStatic",
"Regex",
"LinkBM25",
@leehanchung
leehanchung / .pre-commit-config.yaml
Created July 18, 2024 16:43
sample python pre-commit configuration
fail_fast: true
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
@leehanchung
leehanchung / cli.mjs
Last active May 11, 2025 16:11
formatted claude code cli.mjs
This file has been truncated, but you can view the full file.
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning --enable-source-maps
// Claude Code is a Beta product per Anthropic's Commercial Terms of Service.
// By using Claude Code, you agree that all code acceptance or rejection decisions you make,
// and the associated conversations in context, constitute Feedback under Anthropic's Commercial Terms,
// and may be used to improve Anthropic's products, including training models.
// You are responsible for reviewing any code suggestions before use.
// (c) Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service (https://www.anthropic.com/legal/commercial-terms).
@leehanchung
leehanchung / easter_egg.mjs
Created March 8, 2025 08:07
claude code sticker easter egg
var SE2 = 'Sends the user swag stickers with love from Anthropic.',
LE2 = `This tool should be used whenever a user expresses interest in receiving Anthropic or Claude stickers, swag, or merchandise. When triggered, it will display a shipping form for the user to enter their mailing address and contact details. Once submitted, Anthropic will process the request and ship stickers to the provided address.
Common trigger phrases to watch for:
- "Can I get some Anthropic stickers please?"
- "How do I get Anthropic swag?"
- "I'd love some Claude stickers"
- "Where can I get merchandise?"
- Any mention of wanting stickers or swag
@leehanchung
leehanchung / cli_ocaml.mjs
Created March 8, 2025 08:26
claude code ocaml syntax parsing
var FD2 = _((AQ3, HD2) => {
function M99(I) {
return {
name: 'OCaml',
aliases: ['ml'],
keywords: {
$pattern: '[a-z_]\\w*!?',
keyword:
'and as assert asr begin class constraint do done downto else end exception external for fun function functor if in include inherit! inherit initializer land lazy let lor lsl lsr lxor match method!|10 method mod module mutable new object of open! open or private rec sig struct then to try type val! val virtual when while with parser value',
built_in:
@leehanchung
leehanchung / system_prompts.mjs
Created March 8, 2025 08:33
claude code system prompts
function CQ2() {
return `You are ${w4}, Anthropic's official CLI for Claude.`
}
async function fR() {
return [
`You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
@leehanchung
leehanchung / scratchpad.mjs
Created March 8, 2025 08:42
claude code thinking scratchpad
async function Lu(I) {
if (await ug.isEnabled())
return (
s1('tengu_thinking', {
method: 'scratchpad',
tokenCount: '0',
messageId: QZ(I),
provider: c9 ? 'bedrock' : p9 ? 'vertex' : '1p',
}),
0
@leehanchung
leehanchung / claude_code_mcp.mjs
Last active March 8, 2025 09:08
claude code mcp implementation
async function OX9(I, G) {
let Z =
G.type === 'sse'
? new jN1(new URL(G.url))
: new MN1({
command: G.command,
args: G.args,
env: { ...process.env, ...G.env },
stderr: 'pipe',
}),