Skip to content

Instantly share code, notes, and snippets.

@benrules2
benrules2 / README_UBC.md
Created Oct 14, 2021
UBC Animal Welfare Project Brief
View README_UBC.md

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 / CoffeeRoasting.ino
Created Feb 20, 2021
Sketch to control a relay and thermocouple Coffee Roaster
View CoffeeRoasting.ino
#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() {
View AnimateBilly.h
#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 / AudioDiagnostic.ino
Created Jan 24, 2019
Billy Bass Audio Diagnostic
View AudioDiagnostic.ino
int sensorPin = A0; // select the input pin for the audio signal input
int ledPin = 13;
void setup() {
// declare the ledPin as an OUTPUT and sensorPin as input
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin(9600); // open the serial port at 9600 bps:
}
@benrules2
benrules2 / MotorDiagnostic.ino
Created Jan 24, 2019
Billy Bass Motor Diagnostic
View MotorDiagnostic.ino
#include <AFMotor.h>
#define NUM_MOTORS 3
AF_DCMotor head(1, MOTOR12_1KHZ);
AF_DCMotor mouth(2, MOTOR12_1KHZ);
AF_DCMotor tail(3, MOTOR34_1KHZ);
AF_DCMotor motors[NUM_MOTORS] = {head, mouth, tail};
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
View shift_youtube.py
import sys
alphabet = ["a", "b", "c", "d","e","f","g","h", "i", "j",
"k", "l", "m", "n","o","p", "q", "r","s", "t",
"u", "v", "w", "x", "y", "z"]
class ShiftCipher:
def __init__(self, N = 13):
self.cipher_alphabet = alphabet[N:]
self.cipher_alphabet.extend(alphabet[0:N])
View shift.py
class ShiftCipher:
def __init__(self, N = 13):
self.original_alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w","x","y","z"]
self.cipher_alphabet = self.original_alphabet[N:]
self.cipher_alphabet.extend(self.original_alphabet[0:N])
def encrypt_message(self, message):
encrypted = ""
#lowercase the message as alphabets are lowercase
@benrules2
benrules2 / shift_3.py
Last active Sep 27, 2018
Shift Cipher
View shift_3.py
class ShiftCipher:
[...]
import sys
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Not enough arguments, please provide e/d followed by the message")
N = 13
cipher = ShiftCipher(N)
@benrules2
benrules2 / shift_2.py
Last active Sep 27, 2018
Shift Cipher
View shift_2.py
class ShiftCipher:
def __init__(self, N = 13):
[...]
def encrypt_message(self, message):
encrypted = ""
#lowercase the message as alphabets are lowercase
message = message.lower()
for letter in message:
if self.original_alphabet.count(letter) > 0:
@benrules2
benrules2 / shift_1.py
Last active Sep 27, 2018
Shift Cipher
View shift_1.py
class ShiftCipher:
def __init__(self, N = 13):
self.original_alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w","x","y","z"]
self.cipher_alphabet = self.original_alphabet[N:]
self.cipher_alphabet.extend(self.original_alphabet[0:N])