Skip to content

Instantly share code, notes, and snippets.

View goedel-gang's full-sized avatar

Izaak van Dongen goedel-gang

  • United Kingdom
View GitHub Profile
@goedel-gang
goedel-gang / .gitignore
Last active February 11, 2020 15:49
Order sequences
odseq.txt
def draw_square(cx, cy, r, l, theta):
pushMatrix()
quarter_turns, theta = divmod(theta, HALF_PI)
translate(cx, cy)
rotate(quarter_turns * HALF_PI)
critical_theta = atan(l * 1.0 / (2 * r + l))
if theta <= critical_theta:
x = r + l / 2.0
y = (r + l / 2.0) * tan(theta)
elif theta >= HALF_PI - critical_theta:
@goedel-gang
goedel-gang / save_integers.py
Created January 12, 2020 20:53
Saving integers
some_data = [
(1, 2, 3),
(4, 5, 6),
(7, 8, 9),
(100, 255, 0)]
def dump_data(data, filename):
with open(filename, "w") as data_file:
for tup in data:
print(" ".join(map(str, tup)), file=data_file)
# TODO: this still doesn't quite account correctly for the case where you have a
# small exponent, which doesn't quite catch the periodic part of the
# powers
# e.g. the powers of 5 mod 10^5 go
# [1, 5, 25, 125, 625, 3125, ..., 40625] (...3125)
# so the power tower [5, 2] mod 10^5 wil incorrectly be stated as 65625.
def last_digit_of_power_tower(tower, base=10):
"""
Find the last digit of a power tower in some base (ie reduce a power tower
#!/bin/bash
# https://unix.stackexchange.com/a/527714/347199
mkfifo mypipe
trap 'rm -f mypipe' EXIT
printf '%d\n%d\n' 0 1 >mypipe &
python3 -c '
.PHONY: bash
SHELL = bash
APPARIX_ENV = APPARIXRC=$(CURDIR)/apparixrc APPARIXEXPAND=$(CURDIR)/apparixexpand
BASH_ENV = INPUTRC=inputrc
all: bash
apparixrc:
$(APPARIX_ENV) bash -c "source bourne-apparish; apparix-init"
@goedel-gang
goedel-gang / bytes_hs.hs
Last active May 12, 2019 18:07
Transpose Beamer
import Data.List
import qualified Data.ByteString.Char8 as B
main :: IO ()
main = do
stdin <- B.getContents
B.putStrLn $ (B.intercalate (B.pack "\n")
. map (B.intercalate (B.pack "\t"))
. transpose . map (B.split '\t')
. B.split '\n') stdin
@goedel-gang
goedel-gang / Makefile
Last active April 30, 2019 16:33
Transposition
# because I want to time things
SHELL=bash
.PHONY: clean run destroy gist all
.FORCE:
DATAGEN_PYTHON = pypy3 # python3
TRANSPOSE_PYTHON = python3
@goedel-gang
goedel-gang / 2019
Last active February 1, 2019 11:05
2019
Making the integers from 0-99 using the digits (2, 0, 1, 9) and various
mathematical operators, including the binary operators:
- addition
- subtraction
- multiplication
- division
- exponentiation
the unary operators:
- factorial
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
.........ccccccccccccccccccccccccccc::;;,''................................................................................................................
.........ooooooooooooooooooooooooooooooooooooolc:,.........................................................................................................
.........oooooooooooooooooooooooooooooooooooooooooool:,.................................