Skip to content

Instantly share code, notes, and snippets.

View TomHumphries's full-sized avatar

Tom TomHumphries

View GitHub Profile
@TomHumphries
TomHumphries / HttpCodes.ts
Created November 16, 2022 09:08
HTTP Codes
export const HttpCodes = {
continue: 100,
switchingProtocols: 101,
earlyHints: 103,
ok: 200,
created: 201,
accepted: 202,
nonAuthoritativeInformation: 203,
noContent: 204,
@TomHumphries
TomHumphries / phonetic_alphabet.txt
Created November 2, 2022 10:15
Phonetic Alphabet
Alpha
Bravo
Charlie
Delta
Echo
Foxtrot
Golf
Hotel
India
Juliet
@TomHumphries
TomHumphries / readme.md
Created January 31, 2022 16:15
Saving RTSP Camera Streams with FFmpeg

Saving RTSP Streams from Tapo C310 Cameras with FFmpeg

The full FFmpeg command to copy-paste:

ffmpeg -hide_banner -y -loglevel error -rtsp_transport tcp -use_wallclock_as_timestamps 1 -i rtsp://username:[email protected]:554/stream1 -vcodec copy -acodec copy -f segment -reset_timestamps 1 -segment_time 900 -segment_format mkv -segment_atclocktime 1 -strftime 1 %Y%m%dT%H%M%S.mkv

The input stream URL is for a Tapo C310 camera with the RTSP username and password "username" and "password".

I've put a fair bit of experimentation into the settings in this command. I've included the what and whys below, as well as a camera recommendation for RTSP.

@TomHumphries
TomHumphries / script.split_csv.js
Created September 3, 2021 14:39
Split a CSV a file >> RAM into smaller CSV files
/**
* TO BE USED AS A node SCRIPT:
* node script.split_csv.js csv_filepath MB_per_file stop_after_count
*
* Smaller files will be created in the directory of the filepath
* Each file contains the header from the main file
*/
const path = require('path');
const fs = require('fs');
async function ReadCSVFile(filepath) {
let lines = (await fs.promises.readFile(filepath))
.toString()
.split(/\r?\n/) // split into lines
.filter(x => x != ''); // remove empty lines
let items = [];
let header = lines.shift();
const headerCells = header.split(',');
for (let iL = 0; iL < lines.length; iL++) {
const cells = lines[iL].split(',');
@TomHumphries
TomHumphries / make-csv-backpressure.js
Last active December 16, 2020 08:07
Node.js random-walk timeseries CSV generation script
/**
* Arguments:
* START DATE
* END DATE
* SECONDS BETWEEN POINTS
* NUMBER OF SIGNALS (csv columns)
*
* Example use for 1 month of 60-second-reolution data with 100 columns
* node make-csv-backpressure.js 2020-01-01 2020-02-01 60 100
*/
@TomHumphries
TomHumphries / demo.service
Created February 3, 2020 15:03
Installing an auto-start Node.js service on a Raspberry Pi
# https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/
# https://medium.com/@simon_prickett/writing-a-systemd-service-in-node-js-on-raspberry-pi-be88d9bc2e8d
# WorkingDirectory=
# This is the path to the node.js server files.
# If you don't add this in it will start the node server but try to look for files the server needs in the wrong folder.
# This means you just get an error.
# User=root
# Personal experience - sometimes a service has file read/write access with User=pi, but sometimes not.