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
cmake_minimum_required(VERSION 3.20) | |
project(YOUR_PROJECT_NAME LANGUAGES CXX CUDA) | |
# you might want C++17 | |
set(CMAKE_CUDA_STANDARD 20) # C++20 | |
set(CMAKE_CUDA_STANDARD_REQUIRED ON) | |
set(CMAKE_CXX_EXTENSIONS OFF) | |
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # generate compile_commands.json |
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
# https://www.redhat.com/sysadmin/podman-inside-container | |
# https://fedoramagazine.org/podman-with-capabilities-on-fedora/ | |
# https://wiki.debian.org/CrossCompiling | |
# XXX need to run as root as debootstrap needs mknod privilege | |
sudo podman pull debian:stable-slim | |
sudo podman run -it --cap-add=all --privileged debian:stable-slim | |
# set -o vi | |
# cat >> /etc/apt/sources.list |
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
// g++ -lfmt exponential.cc -o exponential && ./exponential <lambda> | |
// | |
// Using lambda 0.3 | |
// 01: 1% 00189 - *** | |
// 02: 2% 00275 - ***** | |
// 03: 3% 00330 - ****** | |
// 04: 4% 00430 - ******** | |
// 05: 6% 00613 - ************ | |
// 06: 8% 00839 - **************** | |
// 07: 11% 01104 - ********************** |
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
# What if n nodes are assigned a random tick wait (of 1 to 10) | |
# to wait to become candidates when the previous leader is down? | |
# What is the chance of 2 candidates having the same random | |
# wait (birthday paradox) AND this wait to be the shortest wait. | |
# What's the amount of nodes with ~XX% chance of dueling candidates? | |
# Based on: | |
# https://codecalamity.com/the-birthday-paradox-the-proof-is-in-the-python/ | |
# | |
# For power distribution | |
# |
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
# What if n nodes are assigned a random tick wait (of 1 to 10) | |
# to wait to become candidates when the previous leader is down? | |
# What is the chance of 2 candidates having the same random | |
# wait (birthday paradox) AND this wait to be the shortest wait. | |
# What's the amount of nodes with ~90% chance of dueling candidates? | |
# Answer: 36ish | |
# Based on: | |
# https://codecalamity.com/the-birthday-paradox-the-proof-is-in-the-python/ | |
from random import randint | |
import matplotlib.pyplot as plt |
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
# What if n nodes are assigned a random tick wait (of 1 to 10) | |
# to wait to become candidates when the previous leader is down? | |
# What is the chance of 2 candidates having the same random | |
# wait (birthday paradox) AND this wait to be the shortest wait. | |
# What's the amount of nodes with ~90% chance of dueling candidates? | |
# Answer: 36ish | |
# Based on: | |
# https://codecalamity.com/the-birthday-paradox-the-proof-is-in-the-python/ | |
from random import randint | |
import matplotlib.pyplot as plt |
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
-- Note: example given is for SQLite but can be adapted to other SQL | |
-- This is a fast query to sample random rows | |
-- It gets a list of existing row identifiers (rowids), | |
-- materializes, sorts, and picks 10. | |
SELECT * FROM test | |
WHERE rowid IN | |
(SELECT rowid FROM test | |
ORDER BY random() LIMIT 10); |
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
from dtest import Tester, debug | |
from cassandra import ConsistencyLevel | |
class LWTExample(Tester): | |
def test_lwt(self): | |
cluster = self.cluster | |
cluster.populate(4) | |
cluster.start(wait_other_notice=True, wait_for_binary_proto=True) | |
node = cluster.nodelist()[0] | |
session = self.patient_cql_connection(node) |