Skip to content

Instantly share code, notes, and snippets.

@Egregius
Egregius / createramdiskatboot.command
Created September 9, 2020 09:30
Use RAM disk for macOS caches and logs
#!/bin/bash
while [ ! -d /Volumes ]
do
echo "waiting..."
sleep 0.5
done
if [ ! -d /Volumes/RamDisk ]; then
echo "creating ramdisk..."
sleep 0.5
diskutil partitionDisk $(hdiutil attach -nomount ram://$((2048*16000))) 1 GPTFormat APFS 'RamDisk' '100%'
@Egregius
Egregius / com.user.SSDsmart.plist
Created September 5, 2020 07:35
smartctl data to MySQL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.SSDsmart</string>
<key>ProgramArguments</key>
<array>
<string>/Users/guy/OneDrive/MyApps/readsmart.sh</string>
@Egregius
Egregius / snapshots.sh
Created February 15, 2020 20:39
Synology btrfs snapshots when needed.
#!/bin/sh
NOW=$(date +"%Y-%m-%d")
BPATH=/volume1/Guy/log
RUNLOG=/volume1/Guy/log/$NOW.txt
NAME="Guy"
echo ------------------- START SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
SOURCE="/volume1/$NAME"
LAST=$(find $SOURCE -type d -name '#snapshot' -prune -o -type d -name 'log' -prune -o -type f -printf '%T@\n' | sort -n | tail -1 | cut -f1- -d" ")
PREV=$(cat "$BPATH/timestamp_$NAME.txt")
@Egregius
Egregius / .htaccess
Created February 8, 2020 05:14
ifttt applet skipped fix
Header unset Upgrade
@Egregius
Egregius / storetemps.php
Last active April 26, 2021 11:00
Store temperature data from Domoticz in mySQL for historical analyses
<?php
define('sqlserver','127.0.0.1');
define('sqluser','domotica');
define('sqlpassword','domotica');
define('sqldatabase','domotica');
define('updatedatabase',true);//Set to false once the database is created, set to true to add devices
define('domoticzip','127.0.0.1');
define('domoticzport','8080');
define('numberofhours',1);//Defines how many hours of detailed data is updated in _day table. Set to a high number for initial run.
define('numberofdays',1);//Defindes how many days of min,avg and max is updated in _month table. Set to a high number for initial run.

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

JSON = (loadfile '/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua')()
base64 = loadfile('/volume1/@appstore/domoticz/var/scripts/lua/ee5_base64.lua')()
enc_devicechanged = base64.encode(JSON:encode(devicechanged))
enc_otherdevices = base64.encode(JSON:encode(otherdevices))
enc_otherdevices_idx = base64.encode(JSON:encode(otherdevices_idx))
enc_otherdevices_lastupdate = base64.encode(JSON:encode(otherdevices_lastupdate))
enc_otherdevices_svalues = base64.encode(JSON:encode(otherdevices_svalues))
os.execute( '/volume1/web/secure/pass2php.php "device" "' ..enc_devicechanged.. '" "' ..enc_otherdevices.. '" "' ..enc_otherdevices_idx.. '" "' ..enc_otherdevices_lastupdate.. '" "' ..enc_otherdevices_svalues.. '" &')
commandArray = {}
return commandArray