Skip to content

Instantly share code, notes, and snippets.

@AO8
AO8 / pi_lapse.py
Created April 6, 2017 19:20
Timelapse photo with timestamp Python script for Raspberry Pi
from picamera import PiCamera, Color
from time import sleep
import datetime as dt
camera = PiCamera()
# 8 hour timeplase with image taken every 10 seconds
for i in range(2880):
camera.annotate_background = Color("black")
camera.annotate_text = dt.datetime.now().strftime("PiLapse %m-%d-%Y %H:%M:%S")
@AO8
AO8 / send_msg.py
Last active October 1, 2017 22:53
Send Gmail with Python
# Allow less secure apps to access your gmail account
import email
import smtplib
fromaddr = "[email protected]"
toaddr = "[email protected]"
msg = "Content of your email message."
username = "yourGmailAddress"
@AO8
AO8 / send_mms.py
Last active June 7, 2017 15:39
Send a text message from Gmail with Python
# allow less secure apps to access your Gmail at: https://support.google.com/accounts/answer/6010255?hl=en
# https://en.wikipedia.org/wiki/List_of_SMS_gateways
# [email protected] for AT&T
# [email protected] for Sprint
# [email protected] for T-Mobile
# [email protected] for Verizon
import smtplib
username = "[email protected]"
@AO8
AO8 / video.py
Created May 7, 2017 16:45
Record h264 timestamped video in Python with PiCamera
from picamera import PiCamera, Color
from time import sleep
import datetime as dt
camera = PiCamera()
camera.annotate_background = Color("black")
start = dt.datetime.now()
camera.start_recording("recording.h264")
while (dt.datetime.now() - start).seconds < 3600: # total seconds for length of recording
@AO8
AO8 / motiontxt.py
Last active May 12, 2017 15:12
Use a PIR sensor, Raspberry Pi, and PiCamera to detect motion, take a timestamped photo, then send a text message alert from Gmail with Python.
# Allow less secure apps to access your Gmail account
# https://en.wikipedia.org/wiki/List_of_SMS_gateways
# [email protected] for AT&T
# [email protected] for Sprint
# [email protected] for T-Mobile
# [email protected] for Verizon
from gpiozero import MotionSensor
@AO8
AO8 / motion_photo.py
Last active May 13, 2021 02:52
Use a PIR sensor, Raspberry PI, and PiCamera to detect motion, take a timestamped photo, then attach it and send from Gmail with Python.
# Allow less secure apps to access your Gmail account
from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
import smtplib
import os
@AO8
AO8 / send_img.py
Last active June 23, 2017 20:48
Take a timestamped photo with PiCamera, then attach and send from Gmail with Python
# Enable less secure apps in Gmail
import os
import smtplib
import email
import sys
import picamera
import time
from datetime import datetime
from email.mime.multipart import MIMEMultipart
@AO8
AO8 / motion_video_alert.py
Last active May 17, 2020 01:06
Use Python, a PIR sensor, Raspberry Pi, and PiCamera to detect motion, record h264 video with timestamp, convert to mp4, then email video as an attachment from Gmail
# allow less secure apps to access your Gmail at: https://support.google.com/accounts/answer/6010255?hl=en
# guide for setting up PiCamera at: https://www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/
# guide for connecting PIR sensor to Pi at: https://www.raspberrypi.org/learning/parent-detector/worksheet/
# requires your email password to run (line 56), obviously a security hazard so be careful.
from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
@AO8
AO8 / fizz_buzz.py
Created June 23, 2017 20:46
Simple FizzBuzz Python Solution
def fizz_buzz():
for num in range(1,101):
if num % 5 == 0 and num % 3 == 0:
print("FizzBuzz")
elif num % 3 == 0:
print("Fizz")
elif num % 5 == 0:
print("Buzz")
@AO8
AO8 / shakespeare_insults.csv
Last active December 6, 2017 17:03
"You sir, are a bawdy, milk-livered canker-blossom!" Randomly create Shakespearean insults just like this with this simple insult generator using Python and Tkinter. Corresponding CSV file included, modified from PDF at https://www.theatrefolk.com/free-resources.
artless base-court apple-john
bawdy bat-fowling baggage
beslubbering beef-witted barnacle
bootless beetle-headed bladder
churlish boil-brained boar-pig
cockered clapper-clawed bugbear
clouted clay-brained bum-bailey
craven common-kissing canker-blossom
currish crook-pated clack-dish
dankish dismal-dreaming clotpole