based.cooking

2021-07-28

Found my new favourite website. Some guy named Luke has become very angry at what he calls ‘soydevs’ and their recipe pages filled with trackers, ads, unwanted content, comment sections, bloat, login portals, popups, and megabytes upon megabytes of Javascript. As a result he set up a static site with very little styling, to open source the problem of collating online recipes. Contributions are made by GitHub pull requests. Love it. Will be contributing a chickpea curry soon. based.cooking

Site finished! Almost...

2020-06-07

I mean I still need to include a showcase of my undergraduate uni work and pay tribute to CTF somewhere in here… but hey no more template rubbish lying around!

pi.py

2020-06-02

My concern with attempting to keep something resembling a blog is that it will inevitably die due to neglect. The obvious solution is to have something simple that obliges me to make some small regular contribution, no less often than once a month. I’m going with programatically calculating . Once a month, always in a different way, always with a different language. This will start fairly trivially, though I envision it getting fun.

I’ll begin with Python, and one of the most intuitive methods of calculating : a basic monte-carlo estimate. The intuition is illustrated with the graphic above, draw a quarter circle of radius 1 inside a square of side length 1. Then start dropping points at random inside the square. The probability of a point falling inside the quarter circle is . Therefore if we drop a large number of points , we would expect points to fall within the circle, and to fall beyond it.

Given a point with coordinates on the unit square:

$$ \left\lfloor x^2+y^2 \right\rfloor = \begin{cases} 0\textrm{ if $p$ is inside the circle} \\ 1\textrm{ if $p$ is beyond the circle} \end{cases} $$

Therefore if we choose a large enough :

$$ \sum_{i=1}^n \left\lfloor x_i^2+y_i^2 \right\rfloor \approx n\left(1-\frac{\pi}{4}\right) $$

giving us an expression for of:

$$ \pi \approx 4-4\frac{\sum_{i=1}^n \left\lfloor x_i^2+y_i^2 \right\rfloor}{n} $$

Thanks to some nice vectorisation from numpy this can be written very succinctly:

from numpy import floor as f, random as r
n = 2**27
print(4-4*sum(f(r.random(n)**2+r.random(n)**2))/n)

This little block runs in 10 seconds or so on my laptop and consistently gives accurate to three decimal places. Not too shabby for the most simplistic method available.

Adversarial Security Models

2020-05-06

If my study of quantum cryptography has taught me anything, it’s that our threat modelling can never be too extreme.

404 Post

2020-05-02

For a time in ancient Athenian society the city was presided over by a figure called the Archon. The Archon would be democratically appointed, to hold the post for a year. Sometimes they were also known as the Eponymous Archon, since their names could be used to date the years, eg. 682, Creon.

After suffering defeat at the hand of oligarchic Sparta in the Peloponnesian War in the 5th century BCE, Athens was subjected to the rule of an oligarchy. A handful of men backed by Sparta, who came to be known as the Thirty Tyrants, took charge. The rule of the Tyrants was brutal, and brief. After less than a year in power they were deposed in a rebellion led by the exile Thrasybulus, and democracy was restored.

Later historians refer to the year 404 BCE, the year Athens was subdued and without a legitimate democratically appointed Archon, as “the Anarchy”. So given the chance to query them: “Who was the Archon in the year of the Thirty Tyrants?”, they could conceivably have replied:

“404, Archon not found”

This is a coincidence, but it brings a smile to my face to think of it as a great easter egg of the internet. Enough so that a duplicate of this post serves as the actual 404 page of this website.