This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |