Skip to content

Instantly share code, notes, and snippets.

View zeth's full-sized avatar

Zeth zeth

View GitHub Profile
#!/usr/bin/python3
"""The once and future King."""
import math
import sys
print (
chr(int(sys.version[0])**3*3+3*3)
+ sys.exit.__doc__[0].lower()
@zeth
zeth / error.py
Created September 25, 2015 19:51
Running kevent example on the RPi2
pi@raspberrypi ~/kiventproject/kivent/examples/1_empty_kivent_app $ python main.py
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_15-09-25_21.txt
[INFO ] [Kivy ] v1.9.1-dev
[INFO ] [Python ] v2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3]
[INFO ] [Factory ] 177 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] OpenGL version <OpenGL ES 2.0>
[INFO ] [GL ] OpenGL vendor <Broadcom>
@zeth
zeth / gardenspy.py
Last active January 15, 2016 23:20
World's simpliest CCTV system
#/usr/bin/python
"""Spy system written in 60 seconds(ish)."""
import picamera
from datetime import datetime
from time import sleep
DELAY = 60
@zeth
zeth / mkvcard.py
Created February 22, 2017 13:48
Example of how to Make a Vcard qrcode using the qrcode module
#!/usr/bin/python3
# By Zeth
# Website http://zeth.net
# Twitter: zeth0
"""Make a Vcard qrcode using the qrcode module."""
import qrcode
FILENAME = "output.png"
@zeth
zeth / logo.py
Created July 3, 2017 22:30
Quick Python Logo, in Python
#!/usr/bin/python3
"""Quick Hand written Python version of (generated) bash I saw at
https://twitter.com/dmpayton/status/881986444947935232
By Zeth, Public Domain.
"""
IMAGE = ("e1 e1 x19 b6 x15 e1 x18 b1 x1 b6 "
"x14 e1 x18 b8 x14 e1 x23 b3 x14 e1 x15 b11 x1 y2 x11 e1 x14 b12 x1 "
"y3 x10 e1 x14 b12 x1 y3 x10 e1 x14 b3 x10 y3 x10 e1 x14 b3 x1 y12 "
@zeth
zeth / teamaker1.py
Last active May 19, 2019 12:03
Simple example of a class, pre-type hints era
"""Simple class example."""
class TeaMaker:
"""
A robot that makes tea.
Args:
boiler (Boiler): Something that can heat water
dispencer (Dispencer): Something that can give teabags
@zeth
zeth / teamaker2.py
Last active May 19, 2019 12:05
Example of using Python Type Hints
"""Type hint example"""
class TeaMaker:
"""
A robot that makes tea.
"""
def __init__(self,
boiler: Boiler,
@zeth
zeth / teamaker0.py
Last active May 19, 2019 12:49
Some stub classes
class Boiler:
"""Water heating."""
def heat_water(self):
"""Heats water."""
pass
class Dispenser:
"""Gives out objects."""
@zeth
zeth / teamaker3.py
Last active May 19, 2019 12:15
Dataclass example
"""Simple dataclass example"""
from dataclasses import dataclass
@dataclass
class TeaMaker:
"""
A robot that makes tea.
"""
@zeth
zeth / teamaker4.py
Last active May 19, 2019 14:31
Simple stub subclasses
"""Some dispenser subclasses."""
class Caddy(Dispenser):
def dispense(self):
"""Gives an object at home."""
pass
class SpacePouch(Dispenser):
def dispense(self):