Skip to content

Instantly share code, notes, and snippets.

View omiq's full-sized avatar

Chris Garrett omiq

View GitHub Profile
@omiq
omiq / viewer.py
Created May 28, 2018 18:26
Basic Python image viewer
import os
from PIL import Image
import glob
import tkinter
from PIL import ImageTk
# process the interaction
def event_action(event):
print(repr(event))
@omiq
omiq / cpx-motors.py
Created May 30, 2018 18:27
Motors on CPX with Python
from busio import I2C
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.pwmout import PWMOut
from adafruit_motor import motor
import board
import time
# seesaw object
i2c = I2C(board.SCL, board.SDA)
seesaw = Seesaw(i2c)
@omiq
omiq / qt-example.py
Created May 31, 2018 18:16
example of Python PySide2 Qt viewing an image
import sys
from PySide2.QtWidgets import*
from PySide2.QtGui import*
from PySide2 import QtCore
# example event handler
def quit_app():
global application
print("Quit!")
@omiq
omiq / select.py
Created May 31, 2018 22:41
Example of selecting files in the filemanager of mac, windows and linux
import sys
import subprocess
def select_file(path):
if sys.platform == 'darwin':
subprocess.run(['open', '-R', path])
elif sys.platform == 'linux':
subprocess.run(['nautilus', path])
@omiq
omiq / recognise.py
Created June 8, 2018 20:04
Image recognition demo. Set filename as first parameter.
import sys
import numpy as np
from keras.preprocessing import image
from keras.applications import resnet50
# Load the Keras image database
model = resnet50.ResNet50()
# Load the picture as 224x224 (maximum size this model can cope with)
picture = image.load_img(sys.argv[1], target_size=(224, 224))
@omiq
omiq / mouse.py
Created June 9, 2018 22:03
emulate a mouse using the circuit playground express accelerometer and HID over USB
# for delay
import time
# for mouse emulation
from adafruit_hid.mouse import Mouse
# the cpx
import board
# buttons
@omiq
omiq / qt-viewer.py
Created June 11, 2018 21:51
Image viewer desktop app in python
import os
import glob
import sys
import subprocess
from PySide2.QtWidgets import*
from PySide2.QtGui import*
from PySide2 import QtCore, QtGui
# initialise variables
@omiq
omiq / steemmakers-bot.py
Created June 14, 2018 15:14
Discord "Welcome Bot"
import os
import discord
# discord client
client = discord.Client()
def process_message(message):
args = message.content.split(" ")
@omiq
omiq / geo_pic_pick.py
Created June 18, 2018 23:11
Get a Google map from photos using photo picker on iOS
import photos
import webbrowser
picked = photos.pick_asset()
print(dir(picked))
geo_loc = picked.location
lat = geo_loc['latitude']
long = geo_loc['longitude']
map_url = "comgooglemaps://www.google.com/maps/?q={},{}".format(lat,long)
print(map_url)
@omiq
omiq / python-scad.py
Created July 11, 2018 01:32
Load and modify an STL file and add text using Python
import os
from solid import *
from PIL import Image
def assembly(annotation=""):
a = import_stl("base.stl") + translate([5, -37, 10])(
linear_extrude(height=2, convexity=4)(
text(annotation,