Skip to content

Instantly share code, notes, and snippets.

@htbkoo
htbkoo / latency.txt
Created September 6, 2025 15:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@htbkoo
htbkoo / .md
Created May 5, 2025 20:33 — forked from Gentoli/.md
IntelliJ AVD - The skin directory does not point to a valid skin.
@htbkoo
htbkoo / refactor.cs
Last active July 15, 2022 09:22
Some temporary workspace
using System;
using System.Collections.Generic;
namespace SomeNamespace
{
enum OperationType
{
}
@htbkoo
htbkoo / beautiful_idiomatic_python.md
Created June 3, 2022 12:16 — forked from 0x4D31/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@htbkoo
htbkoo / leader_election.py
Created May 21, 2022 16:56 — forked from tfrench/leader_election.py
etcd v3 leader election using Python
"""etcd3 Leader election."""
import sys
import time
from threading import Event
import etcd3
LEADER_KEY = '/leader'
LEASE_TTL = 5
SLEEP = 1
@htbkoo
htbkoo / disable-people-also-search-for-google.md
Created March 11, 2022 00:46 — forked from mmazzarolo/disable-people-also-search-for-google.md
Disabling "People also search for" box in Google search results

Disabling "People also search for" box in Google search results

😡😡😡

image

Option 1: Add a rule to hide the "People also search for" box by targeting its style.

If you're using uBlock origin, add one of the following custom CSS rules:

@htbkoo
htbkoo / markdown-details-collapsible.md
Created January 7, 2022 14:01 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@htbkoo
htbkoo / random.md
Created December 14, 2021 09:19 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@htbkoo
htbkoo / avl.c
Created October 24, 2021 09:23 — forked from tonious/avl.c
A quick AVL tree implementation in c.
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <assert.h>
struct avl_node_s {
@htbkoo
htbkoo / spike_gist_1.ipynb
Last active September 11, 2021 07:41
A spike to try creating code snippet using GitHub Gist
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.