Skip to content

Instantly share code, notes, and snippets.

@harrylincoln
harrylincoln / init.sh
Created June 3, 2022 16:36
Bash concurrent script
#!/bin/bash
python camera.py &
python prediction.py &
wait
@harrylincoln
harrylincoln / camera.py
Created June 3, 2022 16:34
Camera streaming script
import io
import picamera
import logging
import socketserver
from threading import Condition
from http import server
PAGE = """\
<html>
<head>
@harrylincoln
harrylincoln / prediction.py
Created June 3, 2022 16:33
Predict what baby needs
import time
import audioop
import pyaudio
from pushbullet import Pushbullet
import wave
from tflite_support.task import core
from tflite_support.task import processor
from tflite_support.task import audio
from datetime import datetime
@harrylincoln
harrylincoln / listen-and-notify.py
Last active June 2, 2022 17:24
Raspberry pi script to listen for baby cries and predict what might need
import time
import audioop
import pyaudio
from pushbullet import Pushbullet
import wave
from tflite_support.task import core
from tflite_support.task import processor
from tflite_support.task import audio
from datetime import datetime
@harrylincoln
harrylincoln / model.py
Last active June 2, 2022 16:44
Newborn cries audio classifier tensorflow train
import tensorflow as tf
import tflite_model_maker as mm
from tflite_support.task import core
from tflite_support.task import processor
from tflite_support.task import audio
from tflite_model_maker import audio_classifier
import os
import numpy as np
import matplotlib.pyplot as plt
@harrylincoln
harrylincoln / fake-bubz.js
Created September 25, 2019 10:13
fake bubz
var SURNAME = ["Abraham", "Allan", "Alsop", "Anderson", "Arnold", "Avery", "Bailey", "Baker", "Ball", "Bell", "Berry", "Black", "Blake", "Bond", "Bower", "Brown", "Buckland", "Burgess", "Butler", "Cameron", "Campbell", "Carr", "Chapman", "Churchill", "Clark", "Clarkson", "Coleman", "Cornish", "Davidson", "Davies", "Dickens", "Dowd", "Duncan", "Dyer", "Edmunds", "Ellison", "Ferguson", "Fisher", "Forsyth", "Fraser", "Gibson", "Gill", "Glover", "Graham", "Grant", "Gray", "Greene", "Hamilton", "Hardacre", "Harris", "Hart", "Hemmings", "Henderson", "Hill", "Hodges", "Howard", "Hudson", "Hughes", "Hunter", "Ince", "Jackson", "James", "Johnston", "Jones", "Kelly", "Kerr", "King", "Knox", "Lambert", "Langdon", "Lawrence", "Lee", "Lewis", "Lyman", "MacDonald", "Mackay", "Mackenzie", "MacLeod", "Manning", "Marshall", "Martin", "Mathis", "May", "McDonald", "McLean", "McGrath", "Metcalfe", "Miller", "Mills", "Mitchell", "Morgan", "Morrison", "Murray", "Nash", "Newman", "Nolan", "North", "Ogden", "Oliver", "Paige", "Parr"
@harrylincoln
harrylincoln / webpack.config.js
Created July 18, 2017 13:17
Monk, yeahhhhhh
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');
let prod = process.argv.indexOf('-p') !== -1;
let watchOption = process.argv.indexOf('--watch') !== -1;
module.exports = {
entry: ['./js/site.js'],
output: {
@harrylincoln
harrylincoln / routes.js
Created July 13, 2017 16:46
/api routes and the authentication handled by the brilliant express-firebase-middleware
...
router.use('/api', cors(), firebaseMiddleware.auth);
router.get('/api/hello', (req, res) => {
res.json({
message: `You're logged in as ${res.locals.user.email} with Firebase UID: ${res.locals.user.uid}`
});
});
...
@harrylincoln
harrylincoln / af.ts
Created July 13, 2017 16:34
Get a token ID so our BE knows you're legit
...
getTokenAndSendToAPI() {
this.afAuth.auth.currentUser.getToken().then(idToken => {
this.tokenID = idToken;
console.log('getTokenAndSendToAPI() idToken', this.tokenID);
let headersObj = new Headers();
headersObj.append('Authorization', 'Bearer ' + this.tokenID)
let options = new RequestOptions({ headers: headersObj });
@harrylincoln
harrylincoln / routes.js
Last active July 12, 2017 22:16
Express route for creating user via firebase admin
const express = require('express');
const router = express.Router();
const admin = require('firebase-admin');
const db = admin.database();
...
router.use('/create-user', (req, res) => {
console.log('createUser: req', req.body);
admin.auth().createUser({
email: req.body.emailAddress,
emailVerified: false,