Skip to content

Instantly share code, notes, and snippets.

@gagregrog
gagregrog / html.js
Last active October 28, 2020 22:39
Grab key value pairs of data cells for rows 1,3,4,5
const cheerio = require('cheerio');
const re = new RegExp('[1345]');
const parseHtml = (html) => {
const $ = cheerio.load(html);
const trs = $('#result-card > div > table > tbody > tr');
const results = [];
trs.each((trIdx, tr) => {
if (re.test(trIdx)) {
@gagregrog
gagregrog / request.js
Created October 27, 2020 19:35
Request UW COVID-19 Test Results
const fetch = require('node-fetch');
const { URLSearchParams } = require('url');
const METHOD = 'POST';
const URL = 'https://securelink.labmed.uw.edu/result';
const getTestResultsAsHtml = async ({ dob, barcode }) => {
if (!(dob && barcode)) {
throw new Error('dob and code are required');
}
@gagregrog
gagregrog / github_deploy_keys_with_pm2.md
Last active September 4, 2022 20:15
Using GitHub Deploy Keys with PM2

PM2, EC2, and Github

Set Up Deploy Key on Remote Server

  1. SSH into the target machine
  2. Make a deploy_keys folder and change into it
    1. mkdir ~/.ssh/deploy_keys
    2. cd ~/.ssh/deploy_keys
  3. Create a new key pair
  4. ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
@gagregrog
gagregrog / bad_bash_snippets.md
Last active January 10, 2020 19:36
Bad bash snippets that I'm liable to forget

bad bash snippets

mkmonths() {}

Create a folder for every month of the current year, or a provided year, in the current directory.

mkmonths () {
	y=$([ $# -eq 1 ] && echo "$1" || echo $(date +"%Y"))
	for i in {1..12}; do mkdir "$([ "$i" -gt 9 ] && echo "$i" || echo "0$i")-${y}"; done
}
@gagregrog
gagregrog / rtsp_stream.py
Last active April 10, 2024 04:02
View an RTSP stream in python with OpenCV
import cv2
import imutils
from imutils.video import VideoStream
# replace this with the url generated by the Wyze app
rtsp_url = "rtsp://<camera_name>:<some_uuid>@<some_ip>/live"
vs = VideoStream(rtsp_url).start()
while True:
@gagregrog
gagregrog / Using Github Deploy Key.md
Last active October 4, 2022 22:15 — forked from zhujunsan/Using Github Deploy Key.md
Using Github Deploy Key

What / Why

Deploy key is a SSH key set in your repo to grant client read-only (as well as r/w, if you want) access to your repo.

As the name says, its primary function is to be used in the deploy process, where only read access is needed. Therefore keep the repo safe from the attack, in case the server side is fallen.

How to

  1. Generate a ssh key

Raspbian Stretch with OpenCV 3.3 - Setup

Follow these steps to flash a pre-built Raspberry Pi image to an SD card. This image is established with everything documented in this original setup walkthrough. This install requires a MicroSD card with at least 32GB of storage. This will save you many hours of setup, specifically because you don't need to compile OpenCV from source.

Gather Required Components

  1. Raspberry Pi (Pi 3 or Pi Zero) and 32+GB MicroSD card.
    • Pi 3:
      • Ethernet Cable to plug in directly
      • Another computer (Mac)
  • If you don't have the ability to hook up ethernet, you will need the same peripherals as the Pi Zero.

Raspberry Pi - Clean Install

A great set of video resources can be found here. Most of this setup process comes from these videos. This setup process should work fine for either a Pi 3 or a Pi Zero, but the peripherals needed will change depending on which you are setting up. If you would like to skip this entire setup process, and instead flash a pre-built image to your card that includes all of the setup detailed here, as well as a copy of OpenCV 3.3 and python virtualenvironments, check out this walkthrough instead.

Installing the OS

  1. Download the newest version of Raspbian from The Raspberry Pi Org.
  2. Download a copy of The Unarchiver to extract the Raspbian img file.
  3. Download a copy of Pi Filler from [I