Skip to content

Instantly share code, notes, and snippets.

View PetteriAimonen's full-sized avatar

Petteri Aimonen PetteriAimonen

View GitHub Profile
uint32_t prev_time = get_us_ticks();
uint32_t busy_time = 0;
uint32_t total_time = 0;
while(1)
{
uint32_t time_now = get_us_ticks();
uint32_t delta = time_now - prev_time;
prev_time = time_now;
@PetteriAimonen
PetteriAimonen / P2Pro.py
Created December 5, 2023 20:02
Infiray P2 Pro display application with locked scale
# P2Pro display application with locked scale
# Based on ideas from https://github.com/leswright1977/PyThermalCamera
import cv2
import numpy as np
import PIL.Image
import PIL.ImageDraw
import PIL.ImageFont
from matplotlib import font_manager
import functools
@PetteriAimonen
PetteriAimonen / gist:cca272814d8a5ec9e594a46bd370e843
Created December 13, 2022 07:39
Installing iceCube2 on Ubuntu 20.04
Just random commands from my log:
2021-12-13T09:33:38 /home/petteri/download: sudo cp /home/petteri/.steam/debian-installation/ubuntu12_32/steam-runtime/lib/i386-linux-gn
u/libpng12.so.0.46.0 /usr/lib32/
2021-12-13T09:33:41 /home/petteri/download: sudo ldconfig
2021-12-13T09:34:49 /home/petteri/download: ./iCEcube2setup_Dec_10_2020_2012
2021-12-13T09:42:40 /home/petteri/download: cp license.dat /work/icecube2/license0.dat
2021-12-13T09:44:46 /home/petteri/download: find /work/icecube2/ -type f -exec sed -i '1s/#\!\/bin\/sh/#\!\/bin\/bash/g' {} \;
2021-12-13T09:47:39 /home/petteri/download: sudo modprobe dummy
2021-12-13T09:50:42 /home/petteri/download: sudo ip link add eth0 type dummy
@PetteriAimonen
PetteriAimonen / combine.py
Created November 8, 2022 10:56
Python script to combine eclipse images
#!/usr/bin/env python3
# Usage: python combine.py SEatlas*.GIF
# Images from https://eclipse.gsfc.nasa.gov/SEatlas/SEatlas.html
import sys
from PIL import Image
import numpy as np
images = [Image.open(filename).convert('RGB') for filename in sys.argv[1:]]
@PetteriAimonen
PetteriAimonen / numerology.py
Created August 10, 2022 14:16
Python script to find numerological coincidences in bible verses
# Find numerological coincidences in bible verses
# https://skeptics.stackexchange.com/questions/53659/are-the-mathematical-constants-e-and-%cf%80-encoded-in-the-bible
import itertools
import functools
import math
import random
# Source data, in this case Genesis 1:1
words = [[400, 10, 300, 1, 200, 2], [1, 200, 2], [40, 10, 5, 30, 1], [400, 1], [40, 10, 40, 300, 5], [400, 1, 6], [90, 200, 1, 5]]
#!/usr/bin/python3
# Interpolate depth maps
from PIL import Image
import math
import random
contours = Image.open("contours.png")
contourspx = contours.load()
w, h = contours.size

Keybase proof

I hereby claim:

  • I am petteriaimonen on github.
  • I am jpa (https://keybase.io/jpa) on keybase.
  • I have a public key ASDMJhsa2oINfygbEdRO47UU2yytVjRxUXZK3OH70zMwQgo

To claim this, I am signing this object:

>>> class foobar: pass
...
>>> A = foobar()
>>> B = foobar()
>>> A.b = B
>>> B.a = A
>>> pickle.dumps(A)
"(i__main__\nfoobar\np0\n(dp1\nS'b'\np2\n(i__main__\nfoobar\np3\n(dp4\nS'a'\np5\ng0\nsbsb."
>>> newA = pickle.loads(pickle.dumps(A))
>>> newA.b