Skip to content

Instantly share code, notes, and snippets.

View omiq's full-sized avatar

Chris Garrett omiq

View GitHub Profile
@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 / discord-bot.py
Created February 18, 2018 20:22
Discord Bot
import discord
# discord client
client = discord.Client()
# create a new event
@client.event
async def on_ready():
@omiq
omiq / gpio.py
Created April 5, 2018 19:52
Basic Pi GPIO example
import RPi.GPIO as GPIO
import time
# Pi has (confusingly) two numbering schemes for pins
# usually you would choose based on what is printed on
# your dongles/pinout prints
GPIO.setmode(GPIO.BCM)
# H-Bridge pins
@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,
@omiq
omiq / usb_keyboard.py
Created July 20, 2018 02:21
Raspberry Pi USB keyboard emulator
import time
import RPi.GPIO as GPIO
# We are going to use the BCM numbering
GPIO.setmode(GPIO.BCM)
# Set pin 26 as input using pull up resistor
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
@omiq
omiq / shooter.py
Created April 4, 2018 17:43
In this demno of the Python Arcade library, I demonstrate moving backgrounds, sprites, sound effects (now working with zero lag!), and scoring.
import random
import arcade
import _thread
class Fireball(arcade.Sprite):
def update(self):
move_rate = 10
self.center_y += move_rate
@omiq
omiq / USB_Keyboard_Hello_Goodbye.ino
Created December 24, 2020 03:47
USB Macro Keyboard with Arduino Micro
/********************************************
USB Keyboard Hello World, Goodbye Zoom!
MakerHacks.com 12/2020
*********************************************/
// The library that does the magicx
#include "Keyboard.h"
// Right now our "keyboard" has one key
#define KEY_PIN 2
@omiq
omiq / vic-hello.ras
Created December 14, 2020 18:19
TRSE vic 20 hello world bounce
program MainProgram;
/*
Vic 20 8K Vic Bitmap Mode template
- can utilize up to 35K RAM under project settings
-------------------
Dev Note: Zero Page addresses have been defined in project settings
for the Vic 20 build.
@omiq
omiq / scan-network.py
Created August 28, 2018 21:26
Scan your local network for the host, IP and mac address, and detect Raspberry Pi
import sys
import nmap
import time
nm = nmap.PortScanner()
nm.scan('10.0.1.0/24', '22')
# clear screen
sys.stdout.write(u"\u001b[2J\u001b[0;0H")
sys.stdout.flush()
time.sleep(0.2)
@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