Skip to content

Instantly share code, notes, and snippets.

View jonwitts's full-sized avatar

Jon Witts jonwitts

View GitHub Profile
@jonwitts
jonwitts / studentPhotos.sql
Created June 25, 2020 11:47
SQL Query to extract the newest student photo file from the iSAMS database
-- SQL Script to get the latest student photos out of iSAMS
SELECT txtEmailAddress,
(SELECT TOP (1) txtPath FROM TblPupilManagementPictures
WHERE (txtSchoolID = TblPupilManagementPupils.txtSchoolID)
ORDER BY intOrder DESC) AS txtPupilPicturePath
FROM TblPupilManagementPupils
WHERE (intSystemStatus = '1') AND
((SELECT TOP (1) txtPath
FROM TblPupilManagementPictures AS TblPupilManagementPictures_1
WHERE (txtSchoolID = TblPupilManagementPupils.txtSchoolID)
# import the panda module - install https://pandas.pydata.org/docs/getting_started/install.html#installing-from-pypi
import pandas as pd
# read the webpage into python
url = r'https://en.wikipedia.org/wiki/FTSE_100_Index?fbclid=IwAR2V6kJA4d6mNqJaouVZ3ule6nuV4YS8tKtJutW98M_wmtQblHtcZOgmmVI'
tables = pd.read_html(url) # Returns list of all tables on page
ftse = (tables[2]) # the third table in the webpage (zero indexed lists in python)
print(ftse) # check we have the data
@jonwitts
jonwitts / files.sh
Last active June 28, 2019 08:40
exabytes19 files
#!/bin/bash
mkdir /home/pi/Documents/SpaceInvaders
mkdir /home/pi/Documents/SpaceInvaders/images
cd /home/pi/Documents/SpaceInvaders/images
wget https://github.com/jonwitts/PygameZero-Space/raw/master/images/alien.png
wget https://github.com/jonwitts/PygameZero-Space/raw/master/images/laser.png
wget https://github.com/jonwitts/PygameZero-Space/raw/master/images/rocket.png
cd /home/pi/mu_code/sounds
wget https://pygame-zero.readthedocs.io/en/stable/_static/eep.wav
@jonwitts
jonwitts / MC_BuildHouse.py
Created February 4, 2018 01:08
Building Houses in Minecraft Pi
# Connect to MineCraft
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
# Get our current position
x, y, z = mc.player.getPos()
# define our blocks we will be using
stone = 1
brick = 45
@jonwitts
jonwitts / robot-code.py
Created January 26, 2018 22:40
Code for the CamJamEduKit3 Robot controlled using the BlueDot Android app
#!/usr/bin/python3
from bluedot import BlueDot
from gpiozero import CamJamKitRobot, LED
from signal import pause
bd = BlueDot()
robot = CamJamKitRobot()
blue = LED(24)
red = LED(23)
@jonwitts
jonwitts / Enable-AutoResize.sh
Last active November 27, 2020 18:36
Re-enable automatic rootfs partition resizing for a Raspberry Pi image
sudo cp /boot/cmdline.txt /boot/cmdline.txt.orig
#add init=/usr/lib/raspi-config/init_resize.sh to end of cmdline.txt
##sudo wget -qO /boot/cmdline.txt https://github.com/RPi-Distro/pi-gen/raw/dev/stage1/00-boot-files/files/cmdline.txt
##wget -qO - https://github.com/RPi-Distro/pi-gen/raw/dev/stage2/01-sys-tweaks/00-patches/07-resize-init.diff | sudo patch -p3 -d /boot
sudo wget -qO /etc/init.d/resize2fs_once https://github.com/RPi-Distro/pi-gen/raw/dev/stage2/01-sys-tweaks/files/resize2fs_once
sudo chmod +x /etc/init.d/resize2fs_once
sudo systemctl enable resize2fs_once
@jonwitts
jonwitts / chromium-browser-proxy.desktop
Created September 6, 2017 08:59
chromium-browser-proxy.desktop - Auto Proxy for Raspberry Pi
[Desktop Entry]
Version=1.0
Name=Chromium Web Browser - Auto Proxy
Name[ast]=Restolador web Chromium
Name[bg]=Уеб четец Chromium
Name[bn]=ক্রোমিয়াম ওয়েব ব্রাউজার
Name[bs]=Chromium web preglednik
Name[ca]=Navegador web Chromium
Name[ca@valencia]=Navegador web Chromium
Name[da]=Chromium netbrowser
@jonwitts
jonwitts / shutDownPi.py
Last active August 15, 2017 20:26
A Python program to shutdown a Pi when button is held for 3 seconds
#!/usr/bin/python3
from gpiozero import Button, LED
from signal import pause
from time import sleep
from os import system
button = Button(21, hold_time=3)
led = LED(20)
def shutdown_pi():
@jonwitts
jonwitts / testLED.py
Last active April 16, 2017 20:17
Wearable LED string test
#!/usr/bin/python3
from gpiozero import LED
from time import sleep
from random import randint
led1 = LED(21)
led2 = LED(20)
led3 = LED(16)
led4 = LED(12)