Skip to content

Instantly share code, notes, and snippets.

@zillwc
zillwc / benchmark_gguf_mlx.py
Created May 23, 2025 23:06
Benchmark local GGUF and MLX models
import time
import requests
prompts = [
"Implement an LRU (Least Recently Used) cache in Python as a single .py file. It must support get and put operations in O(1) time complexity. Include test code at the bottom.",
"Write a complete single-file Python implementation of a multi-threaded producer-consumer system using threading and a shared queue. Include comments and a short main() function that demonstrates functionality.",
"Design and fully implement a rate limiter in Python that allows up to 100 requests per 10-second window per user. Use in-memory data structures and implement it in a single .py file with example usage.",
@zillwc
zillwc / masked-prompt.js
Created September 25, 2020 07:22
Module to prompt for masked input and test against predicates
const stdout = process.stdout;
const stdin = process.stdin;
module.exports = (specifiedPromptString = 'input', predicateFns = []) =>
new Promise((resolve, reject) => {
const prompt = specifiedPromptString.endsWith(': ') ? '' : specifiedPromptString + ': ';
const predicates = Array.isArray(predicateFns) ? predicateFns : [predicateFns];
stdout.write(prompt);
stdin.setRawMode(true);
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
int get_proxy_socket(void) {
int fd = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in bind_address;
@zillwc
zillwc / webcrypto_tests.js
Created April 17, 2020 11:00
Testing webcrypto functionality: encrypt, decrypt, wrapKey, unwrapKey, importKey, generateKey, and deriveKey
const KEY_OP_ALGO = 'AES-GCM';
const KEY_WRAPPING_ALGO = 'AES-KW';
const KEY_DERIVATION_ALGO = 'PBKDF2';
const encode = (t) => (new TextEncoder()).encode(t);
const decode = (t) => (new TextDecoder()).decode(t);
const bytesToArrayBuffer = (b) => new Uint8Array(b);
const areBuffersEqual = (buf1, buf2) => {
const a1 = bytesToArrayBuffer(buf1);
const a2 = bytesToArrayBuffer(buf2);
@zillwc
zillwc / md5_prefix_proof_of_work.go
Last active June 7, 2019 17:54
Computes proof of work for variable length md5 prefix match
/*
MD5 Prefix Proof of Work
Computes proof of work for variable length md5 prefix match
Charset: a-zA-Z
Usage:
$. go run md5_prefix_proof_of_work.go <MD5 Prefix>
Examples:
$ go run md5_prefix_proof_of_work.go af232 // mUOtbyGE
@zillwc
zillwc / syn_flood_alexa.py
Created July 18, 2017 06:34
Syn Flood Ethan's Alexa
#!/usr/bin/env python
import sys
import random
import logging
import threading
import multiprocessing
import scapy.all as scapy
logging.getLogger('scapy.runtime').setLevel(logging.ERROR)
@zillwc
zillwc / QRGen.py
Created July 18, 2017 06:12
Generates a QR code image based on highlighted words (intended to be used with Apple workflow as a service)
import sys
import subprocess
import tempfile
import urllib
text = sys.stdin.read()
chart_url_template = ('http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl={data}&chld=H|0')
chart_url = chart_url_template.format(data=urllib.quote(text))
public class FindDuplicateNumber {
public static int summationRes(int[] array, int len) {
for (int i = 0; i < len; i++) {
array[array[i] % len] += len;
if (array[array[i] % len] / len == 2)
return array[i] % len;
}
return -999;