Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Why do we need a status?

Tim Savage timsavage

😎
Why do we need a status?
View GitHub Profile
@timsavage
timsavage / Unifi-Video-Install.md
Last active Mar 23, 2022
Instructions to get a running install of Unifi Video
View Unifi-Video-Install.md

Setup Unifi-Video

Requirements

  • Debian 9
  • OpenJDK-8-jre 8u252
  • MongoDB 4.4

Install Debian 9 (Stretch)

Get the net-install image from Debian.org for your particular Hardware (usually AMD64)

@timsavage
timsavage / camera-on-air.py
Created Sep 10, 2021
Python script to monitor when a webcamera is activated on Linux
View camera-on-air.py
import shutil
import subprocess
import time
COMMANDS = [shutil.which("lsmod")]
MOD_NAME = b"uvcvideo"
def get_uvc_user_count() -> int:
"""
View PrimePY.py
# Python Prime Sieve
#
# MyFirstPython Program (tm) Dave Plummer 8/9/2018
#
# This is the main prime_sieve class. Call it with the number you wish as an upper limit, then
# call the runSieve method to do the calculation. printResults will dump the count to check validity.
#
# Updated 3/22/2021 for Dave's Garage episode comparing C++, C#, and Python
from sys import stdout # So I can print without an automatic python newline
@timsavage
timsavage / smart-sync.py
Last active Aug 25, 2020
Script for syncing static websites to S3.
View smart-sync.py
#! /usr/bin/env python3
"""
Script for syncing static websites to S3. Requires Python 3.6+
- Uses ETags to determine if a file has changed.
- Cleans up remote files.
- Sets public ACLs
- Supplies the correct content-type
- Uses GZip encoding for appropriate file types.
View keybase.md

Keybase proof

I hereby claim:

  • I am timsavage on github.
  • I am timsavage (https://keybase.io/timsavage) on keybase.
  • I have a public key whose fingerprint is B8B4 CB98 C8A8 4138 376E B77A AE89 3004 2ACF 1BA1

To claim this, I am signing this object:

@timsavage
timsavage / websocket_server.py
Last active Apr 29, 2022
Simple example of a websocket server with Tornado
View websocket_server.py
# While this code still works, I would recommend using Fast API for websockets in modern applications.
# See: https://fastapi.tiangolo.com/advanced/websockets/
# Note this is targeted at python 3
import tornado.web
import tornado.httpserver
import tornado.ioloop
import tornado.websocket
import tornado.options
@timsavage
timsavage / generate.py
Created Mar 14, 2016
Code Generation with Jinja
View generate.py
from jinja2 import Template, Environment
# The environment is used to configure the template engine
# See: http://jinja.pocoo.org/docs/dev/api/#jinja2.Environment
env = Environment(autoescape=False, optimized=False)
# Open your template and compile into a template object.
with open("template.txt", "r") as f:
template = env.from_string(f.read())
@timsavage
timsavage / __init__.py
Last active Nov 12, 2019
Customising Django Auth username length for Django 1.8+
View __init__.py
default_app_config = 'myapp.auth.apps.MyAuthAppConfig'