Skip to content

Instantly share code, notes, and snippets.

@ali1234
ali1234 / switchingdemo.py
Created February 26, 2018 00:11
unicorn hat hd demos
import time, math, colorsys, random
from datetime import datetime, timedelta
from picamera import PiCamera
import numpy as np
import unicornhathd
unicornhathd.rotation(270)
#!/usr/bin/env python
import unicornhathd
import datetime
import numpy as np
print("""Unicorn HAT HD: Rainbow
OMG MY EYES.
Press Ctrl+C to exit!
@ali1234
ali1234 / devices.py
Last active March 4, 2018 19:54
Unified Graphics Library Yarrrrrrr
import subprocess, time, sys
import numpy as np
from PIL import Image
class GraphicsDeviceBase(object):
def __init__(self, buf, depth):
self.__buf = buf
@ali1234
ali1234 / clock.py
Created March 2, 2018 14:54
scroll phat hd clock
#!/usr/bin/env python
import time
import signal
import math
import scrollphathd
from envirophat import light, motion, weather
"""
@ali1234
ali1234 / life.py
Created March 11, 2018 01:04
PySDL2 Life Demo
import sys
import sdl2
import sdl2.ext
import numpy as np
class Life(object):
def __init__(self, height, width):
self.width = width
@ali1234
ali1234 / icon.py
Created April 25, 2018 20:46
Find the path Gtk loads an icon from.
#!/usr/bin/env python3
import sys
import pathlib
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
if __name__ == '__main__':
@ali1234
ali1234 / input.py
Last active December 24, 2022 00:54
Unbuffered, non-blocking stdin in Python
import fcntl
import termios
import sys
import os
import time
class NonBlockingInput(object):
def __enter__(self):
@ali1234
ali1234 / notify-when-done
Created October 15, 2018 13:36
Bash script to time a long running command and display a notification when it finishes.
#!/bin/bash
SECONDS=0
"$@"
e=$?
if [ $? -eq 0 ]; then
RESULT="Succeeded"
@ali1234
ali1234 / blender-script.py
Created October 29, 2018 01:52
A Python script which runs itself inside Blender upon being run from the command line. Passes through command line arguments.
#!/usr/bin/env python3
import sys
try:
import bpy
except ImportError:
print('Running myself inside Blender')
import subprocess
exit(subprocess.call(['blender', '--background', '--python', __file__, '--'] + sys.argv))

Keybase proof

I hereby claim:

  • I am ali1234 on github.
  • I am ali1234 (https://keybase.io/ali1234) on keybase.
  • I have a public key whose fingerprint is ADFD E886 043E 00DA F5ED 052C 4B13 38E2 0316 1411

To claim this, I am signing this object: