Skip to content

Instantly share code, notes, and snippets.

# External module imp
import RPi.GPIO as GPIO
import datetime
import time
init = False
GPIO.setmode(GPIO.BOARD) # Broadcom pin-numbering scheme
def get_last_watered():
<!DOCTYPE html>
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>PLANT HELPLINE</h1>
<h2>The date and time on the server is: {{ time }}</h2>
<h2> {{ text }} </h2>
<a href="/auto/water/ON"><button>Turn ON Auto Watering</button></a>
import water
if __name__ == "__main__":
water.auto_water()
@benrules2
benrules2 / Gravity.py
Last active November 14, 2023 16:39
Python N-Body Orbit Simulation
import math
import random
import matplotlib.pyplot as plot
from mpl_toolkits.mplot3d import Axes3D
class point:
def __init__(self, x,y,z):
self.x = x
self.y = y
@benrules2
benrules2 / orbits.py
Created February 10, 2017 23:19
Python RK4 orbits
import math
import random
import matplotlib.pyplot as plot
from mpl_toolkits.mplot3d import Axes3D
class point:
def __init__(self, x,y,z):
self.x = x
self.y = y
self.z = z
@benrules2
benrules2 / AnimateBilly.h
Last active October 13, 2022 06:43
Billy Bass
#include <AFMotor.h>
#define NUM_MOTORS 3
AF_DCMotor head(1, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor mouth(2, MOTOR12_1KHZ);
AF_DCMotor tail(3, MOTOR34_1KHZ);
void runMotorOnOff(AF_DCMotor motor, int aniDelay = 500){
motor.run(FORWARD);
@benrules2
benrules2 / README_UBC.md
Created October 14, 2021 20:42
UBC Animal Welfare Project Brief

UBC Animal Welfare Project - Using nest cameras to collect behavioural animal data

Currently, we are running ~ 10 nest cameras simultaneously to collect continuous behavioural data on cats in shelters. As Nest will not allow us to download our stored continuous video streams, we are pulling our data from the home.nest.com website by 1) making “clips” of individual hours to download and/or 2) creating time-lapse of 12-hour chunks to be later behaviourally coded. Both solutions involve a team member working full-time to pulling data manually from the website and having access to the continuous data would remove this need.

Modify this code so it dumps many videos to many video files, instead of just one to one (we have 10-12 nest cameras running @ once) Simplify the auth process so it can be started more easily without copy pasting from cookies in the browser networking inspection tabs. It is tricky to snoop through the cookies and find the data we need to get authenticated. Launch this as a service so it i

@benrules2
benrules2 / ThingShadow.ino
Last active April 3, 2021 22:19
Alexa Smart Home and Arduino Yun Smart Light Code
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
@benrules2
benrules2 / CoffeeRoasting.ino
Created February 20, 2021 21:09
Sketch to control a relay and thermocouple Coffee Roaster
#include "MAX31855.h"
const int doPin = 7;
const int csPin = 6;
const int clPin = 5;
const int relayPin = 13;
MAX31855 tc(clPin, csPin, doPin);
float getTemp() {
@benrules2
benrules2 / Gravity.py
Last active March 12, 2020 14:31
Python N-Body Orbital Simulation
import math
import random
import matplotlib.pyplot as plot
from mpl_toolkits.mplot3d import Axes3D
class point:
def __init__(self, x,y,z):
self.x = x
self.y = y
self.z = z