Skip to content

Instantly share code, notes, and snippets.

deno bench heap-bench.js
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
heap 9.6 µs 104,000 ( 8.7 µs … 172.2 µs) 9.2 µs 16.1 µs 18.9 µs
redundant sort and shift 1.3 ms 746.0 ( 1.3 ms … 1.5 ms) 1.3 ms 1.4 ms 1.5 ms
sort once and pop 26.9 µs 37,130 ( 25.5 µs … 160.7 µs) 26.6 µs 35.7 µs 42.1 µs
buckets 4.6 µs 219,000 ( 4.5 µs … 4.7 µs) 4.6 µs 4.7 µs 4.7 µs
import hashlib
import hmac
import json
import struct
import sys
def main():
if len(sys.argv) != 2:
print(f"Usage: python3 {sys.argv[0]} COURSES.jsonl\n", file=sys.stderr)
$ python --version
Python 3.6.0

$ python -m timeit -s 'import random; l = list(range(18))' 'random.choice(l)'
1000000 loops, best of 3: 0.591 usec per loop

$ python -m timeit -s 'd = {str(n): list(range(15)) for n in range(18)}' 'd["12"]'                     
10000000 loops, best of 3: 0.0224 usec per loop
import itertools
data = ['str', 'int', 'dex', 'con', 'wis', 'cha']
covered = frozenset([
# paladin
('wis', 'cha'), ('cha', 'str'), ('str', 'cha'), ('str', 'int'),
# barbarian
('str', 'dex'), ('str', 'con'), ('con', 'str'),
addDataset(id: string, content: string): Promise<InsightResponse> {
return new Promise(function (fulfill, reject) {
let zip = new JSZip();
let courseStringsPromises: Promise<string>[] = [];
if (id === "" || id === null) {
reject({"code": 400, "body": {"error": "invalid id"}});
}
if (content === "" || content === null) {
using System;
using System.Collections.Generic;
static class Application {
static void Main() {
var list = new List<int>();
for (int i = 0; i < 100; i++) {
Console.WriteLine("{0,5}/{1,5}", list.Count, list.Capacity);
list.Add(i);
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// most code is single-threaded
unsigned char* current_mem;
void* readA();
void* readB();
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
class ColorInterpolationApplication {
public static void Main() {
Application.Run(new ColorInterpolation());
}
}
alert("Don't blindly paste scripts into your console! Sheesh.");
@minitech
minitech / tail.c
Created September 10, 2013 14:27
The beginnings of an RSS reader or something in C.
#include <string.h>
#include <stdio.h>
#include <libpq-fe.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>