Skip to content

Instantly share code, notes, and snippets.

View maggiben's full-sized avatar

Benjamin maggiben

  • Frávega
  • Argentina
View GitHub Profile
@maggiben
maggiben / getNodeVersion.ts
Created January 3, 2022 02:01
Get Node Version
export function getNodeVersion(): { major: number; minor: number; patch: number } {
const version = process.version.match(/(\d+)\.(\d+)\.(\d+)/);
const [major, minor, patch] = ensureArray(version)
.slice(1)
.map((match) => parseInt(match as string, 10));
return {
major,
minor,
patch,
};
@maggiben
maggiben / toISO8601.js
Created May 1, 2023 03:47
To ISO8601 date string with locale offset
// Ardiono Date https://adafruit.github.io/RTClib/html/class_date_time.html#a50502a3a29409c6c2507638779df1a9d
let now = new Date();
// correct time zone offset for generating iso string
now.setMinutes(now.getMinutes() - now.getTimezoneOffset())
console.log(now.toISOString());
@maggiben
maggiben / service.md
Last active August 17, 2024 17:31
remove dark images systemd daemon

Dark image remover daemon

Intended to be used to clean timelapse pictures

Requirements

  1. Python 3
  2. OpenCV library (cv2)
  3. NumPy library (numpy)

Install python virtual env sudo apt install python3-venv

@maggiben
maggiben / base.sh
Last active July 31, 2024 15:51
Base sensor monitor
#!/bin/bash
# Get the size of /snapshots
SNAPSHOT_SIZE=$(du -hs /snapshots 2>/dev/null | awk '{print $1}')
SNAPSHOT_TOTAL=$(ls | grep *.jpg | wc -l 2>/dev/null)
echo "[snapshots]"
echo "size: $SNAPSHOT_SIZE"
echo "total: $SNAPSHOT_TOTAL"
# Get the available space on the root partition
@maggiben
maggiben / garden-guardian.md
Last active August 18, 2024 03:09
Remote Watering System Setup

Remote Watering System Setup

Requisites

  1. Raspberry PI Zero 2W (any PI should work ok)
  2. nodemcu-32s
  3. USB OTG Cable, Power Supply, etc...

Preparation

  1. Flash the OS into the SD card (32gb is plenty) (Config: Username, Wifi and SSH)
  2. Connect the i2c RTC module to the rpi