Skip to content

Instantly share code, notes, and snippets.

#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
class Message {
};
class Receiver {
public:
virtual ~Receiver() { }
virtual void receive(Message *msg) = 0;
@ejrh
ejrh / chocolate-bread.txt
Created December 18, 2016 09:47
Grandma's chocolate bread
04/09/2013
2 cups of flour, sifted with:
1/2 teaspoon salt
1 heaped tablespoon cocoa
1 level teaspoon baking powder
1 level tspn soda
Put in blender 1 cup dates (check for stones),
WITH RECURSIVE t AS
(
SELECT id, '{}'::int[] AS parents, 0 AS level
FROM z_msg WHERE in_reply_to IS NULL
UNION ALL
SELECT c.id, parents || c.in_reply_to, level+1
FROM t JOIN z_msg AS s c ON t.id = c.in_reply_to
),
t2 AS
@ejrh
ejrh / busplan.py
Last active November 24, 2021 01:15
import itertools
import math
import random
import time
DEPENDENCIES = {
'wires': {'copper'},
'green circuits': {'iron', 'wires'},
'red circuits': {'plastic', 'wires', 'green circuits'},
@ejrh
ejrh / bloat.sql
Last active May 4, 2023 05:22
PostgreSQL bloat report
with v as (select version() as ver),
constants(relkind, block_size, header_size, max_align, fill_factor, nonleaf_fill_factor, page_overhead, row_overhead) as (
values (
'r',
current_setting('block_size'),
CASE WHEN SUBSTRING((select ver from v),12,3) IN ('8.0','8.1','8.2') then 28 else 24 end,
CASE WHEN (select ver from v) ~ 'mingw32|64' THEN 8 ELSE 4 end,
1.0,
null,
32,
@ejrh
ejrh / soma.py
Created May 25, 2023 22:54
Python to generate pieces of Soma cube puzzle (WIP)
DIMENSIONS = 2
SCALE = 3
OUTER_SCALE = SCALE + 2
STEPS = tuple(OUTER_SCALE**x for x in reversed(range(DIMENSIONS)))
def generate_all_cells():
def do_slice(offset, depth):
if depth == DIMENSIONS - 1:
for i in range(1, SCALE + 1):
yield offset + i
@ejrh
ejrh / words.txt
Created May 25, 2023 22:56
Python to find sequence of words from long to short, removing 1 letter each time
# From http://www.mieliestronk.com/wordlist.html
aardvark
aardwolf
aaron
aback
abacus
abaft
abalone
abandon
abandoned