Skip to content

Instantly share code, notes, and snippets.

View brianjychan's full-sized avatar
🌍

Brian Chan brianjychan

🌍
View GitHub Profile
@brianjychan
brianjychan / motion.ts
Created November 25, 2020 02:39
motion detection w Jimp, detection w google vision API
import vision from '@google-cloud/vision'
import Jimp from 'jimp';
import { unlinkSync } from 'fs';
const PHOTOS_DIR = './photos'
const MOTION_PERCENT_THRESHOLD = .005
// Maybe put this in some timed loop as imagse come in
@brianjychan
brianjychan / getTimeText.tsx
Last active March 29, 2020 04:46
Convert Firestore Timestamps to text format using javascript-time-ago. Works when Timestamps are retrieved both from client SDK or Cloud Functions. JS/ Typescript
import app from 'firebase/app'
import 'firebase/firestore'
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
// Add locale-specific relative date/time formatting rules.
TimeAgo.addLocale(en)