Skip to content

Instantly share code, notes, and snippets.

@fcostin
fcostin / trash_can_state_machine_poc.ino
Last active September 1, 2020 12:28
hypothetical refactor of self-opening trash can state machine
// 2020/09/01 - this code is placed in the public domain.
//
// This is a hypothetical refactor of state machine code from
// ivanilves's fun self-opening trash can project.
//
// Ref: https://github.com/ivanilves/arduino-sketches/blob/d0e965ebae1b98fa23b833fed2e2e28b21ef8863/basurito/basurito.ino
//
// The code below is incomplete, has not been tested and will not work! it's a sketch of an idea.
//
// Rough principles of this refactor:
@fcostin
fcostin / git_trivia.sh
Created July 12, 2019 10:40
git_trivia.sh
#! /bin/bash
set -x -e
# In the beginning there was nothing, just hopes, dreams,
# a modest development budget.
mkdir -p demo
cd demo
git init .
@fcostin
fcostin / example_output.txt
Last active June 12, 2019 12:01
attempted formalisation and optimisation of Christopher Alexander-ish "arrange the related design elements into a bunch of (overlapping?) subsystems" problem
<<< optimiser debug gibberish >>>
0000044880 ACCEPT 105 --> 104 (('grow', frozenset({1, 2, 14, 18, 26, 27}), 13))
{frozenset({33, 3, 6, 7, 8, 9, 10, 11, 19, 29}), frozenset({1, 2, 18, 26, 27, 13, 14}), frozenset({1, 2, 3, 12, 13, 20, 22, 23}), frozenset({16, 17, 21, 24, 25, 31}), frozenset({5, 15, 28, 29, 30}), frozenset({32, 17, 18, 4, 15})}
transation: on iteration 44880 i accepted the proposed move from a state with loss 105 to a new state with loss 104 via the move (('grow', frozenset({1, 2, 14, 18, 26, 27}), 13)) resulting in a new state containing the groups
{frozenset({33, 3, 6, 7, 8, 9, 10, 11, 19, 29}), frozenset({1, 2, 18, 26, 27, 13, 14}), frozenset({1, 2, 3, 12, 13, 20, 22, 23}), frozenset({16, 17, 21, 24, 25, 31}), frozenset({5, 15, 28, 29, 30}), frozenset({32, 17, 18, 4, 15})}
<<< results >>>
@fcostin
fcostin / lds.py
Created October 16, 2017 08:20
simple demo low disrepancy sequence -- Halton sequence in 2d using bases (2, 3)
from itertools import izip
def decompose(b, n):
k = 0
while n:
r = n % b
q = (n-r)/b
yield (r, k)
k += 1
n = q
@fcostin
fcostin / TEST_nunit_foo.xml
Last active October 7, 2015 00:49
TEST_nunit_foo
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<!--example comment-->
<!--another example comments. TFS VSO is a wonderful and intuitive test collection and reporting tool. -->
<test-results name="C:\Program Files\NUnit 2.6\bin\tests\mock-assembly.dll" total="2" errors="0" failures="1" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2015-10-07" time="11:22:00">
<environment nunit-version="" clr-version="" os-version="Microsoft Windows NT 6.1.7600.0" platform="Any CPU" cwd="C:\Program Files\NUnit 2.6\bin" machine-name="CHARLIE-LAPTOP" user="charlie" user-domain="charlie-laptop" />
<culture-info current-culture="en-US" current-uiculture="en-US" />
<test-suite type="Assembly" name="FOO" executed="True" result="Failure" success="False" time="0.094" asserts="0">
<results>
@fcostin
fcostin / popmodel.py
Created June 25, 2015 04:11
a simple yet perhaps informative population model.
"""
a stupid population model
Simplifying assumptions:
assume everyone in each country behaves the same
everyone lives until their birth life expectancy
everyone has same number of kids [1]
uniform life expectancy (take geom average men and women) [2m 2f]
everyone pair-bonds into a couple and has kids
# HG changeset patch
# User Reuben Fletcher-Costin <reuben.fletcher-costin@biarri.com>
# Date 1409866198 -36000
# Fri Sep 05 07:29:58 2014 +1000
# Branch windows_support
# Node ID 88290ca7505a15b8f4a1fe1a4f94fafebd747d8e
# Parent 9051b4b72737edcd7b483716471c070c917c5fde
windows_support - use setuptools console_scripts entry point; combine wake.py and vulture into vulture.py
diff --git a/ez_setup.py b/ez_setup.py
@fcostin
fcostin / minty_skypes.txt
Created December 20, 2013 10:59
setting up skype for some old debian flavoured mint
this is the way to go:
https://wiki.debian.org/skype
it Just Worked.
to enable your mic, open `mate-volume-control` and ensure the input device is unmuted...
this is also interesting: it gives you a way to meddle with webcam brightness / contrast / sharpening filters:
@fcostin
fcostin / test_if_ridulous_inequality_chain_works_like_is_sorted.py
Created August 20, 2013 07:43
answers to things you never wanted to know
import numpy
import py.test
MIN_SIZE = 2 # you cant have an unsorted array of size 1 !
MAX_SIZE = 1000
def is_sorted(a):
sa = numpy.sort(a)
return numpy.all(sa == a)
// goal: typeDefinitions = {"FIDO" : {864 : ["SUPER_864"]}, "SPOT" : {432 : ["LUCKY_SPOT_432"], 576 : ["MERRY_SPOT_576"]}}
// works with g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
//
// g++ -Wall -Werror -pedantic -Wconversion --std=c++0x % && ./a.out
#include <vector>
#include <map>
#include <tuple>
#include <utility>