Skip to content

Instantly share code, notes, and snippets.

View senderista's full-sized avatar

Tobin Baker senderista

View GitHub Profile
@senderista
senderista / 64_entries_2_choices.py
Created February 17, 2024 03:04
simulates hashing into least loaded of 2 64-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher64EntriesTwoChoices:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 64_entries_1_choice.py
Created February 17, 2024 03:03
simulates hashing into 64-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher64EntriesOneChoice:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 32_entries_2_choices.py
Created February 17, 2024 03:03
simulates hashing into least loaded of 2 32-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher32EntriesTwoChoices:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 32_entries_1_choice.py
Created February 17, 2024 03:02
simulates hashing into 32-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher32EntriesOneChoice:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 16_entries_2_choices.py
Created February 17, 2024 03:01
simulates hashing into least loaded of 2 16-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher16EntriesTwoChoices:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 16_entries_1_choice.py
Created February 17, 2024 02:53
simulates hashing into 16-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher16EntriesOneChoice:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a word-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 8_entries_2_choices.py
Last active February 17, 2024 04:52
simulates hashing into least loaded of 2 8-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher8EntriesTwoChoices:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a byte-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / 8_entries_1_choice.py
Created February 17, 2024 02:45
simulates hashing into 8-cell bins
#!/usr/bin/env python3
import numpy
class BinHasher8EntriesOneChoice:
def __init__(self, size_exp: int) -> None:
# each bin is represented by a byte-size bitvector
self.size_exp: int = size_exp
@senderista
senderista / bank_account.cpp
Last active October 22, 2023 22:43
Simple example of atomic actions
#include "atomik.hpp"
void increment_balance(const char* account_name, int32 amount)
{
atomik::do_atomically(
[]() {
atomik::var<Account> account_var = atomik::get_var_by_key(account_name);
auto account = account_var.get();
account.balance += amount;
account_var.set(account);
#!/usr/local/bin/python3
import sys
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import warnings; warnings.filterwarnings(action='once')