Skip to content

Instantly share code, notes, and snippets.

@cbsmith
cbsmith / random_selection.cpp
Last active March 17, 2026 17:48
Hopefully serves as a reference implementation on how to do random selection of an element from a container.
// -*- compile-command: "clang++ -ggdb -o random_selection -std=c++0x -stdlib=libc++ random_selection.cpp" -*-
//Reference implementation for doing random number selection from a container.
//Kept for posterity and because I made a surprising number of subtle mistakes on my first attempt.
#include <random>
#include <iterator>
template <typename RandomGenerator = std::default_random_engine>
struct random_selector
{
//On most platforms, you probably want to use std::random_device("/dev/urandom")()
@xkikeg
xkikeg / ddrescue_chart.py
Last active April 30, 2019 08:54
This script visualize the logfile of GNU ddrescue.
#!/usr/bin/python
import argparse
import sys
import math
import operator
import itertools
import Image, ImageDraw
# http://stackoverflow.com/questions/14423794/equivalent-of-haskell-scanl-in-python
@PhirePhly
PhirePhly / ISA.txt
Created March 26, 2012 20:42
Intro to the ISA bus by Mark Sokos
THE ISA AND PC/104 BUS
IBM, IBM/XT, IBM PC, and IBM PC AT are registered trademarks of
International Business Machines Corporation.
This file is designed to give a basic overview of the bus found in
most IBM clone computers, often referred to as the XT or AT bus. The
AT version of the bus is upwardly compatible, which means that cards