Skip to content

Instantly share code, notes, and snippets.

@robinkaty
robinkaty / soundfile.py
Last active September 14, 2023 22:03
portable_alert_sounds.py
import platform
def beephappy():
if platform.system() == "Windows":
import winsound
winsound.Beep(1998, 500)
elif platform.system() == "Darwin":
@robinkaty
robinkaty / warningcheck.pl
Created August 14, 2023 17:40
Check Timemachine Output for "0 bytes/sec" and insert error warning into stream/pipe
#!/usr/bin/env perl
use strict;
use warnings;
my $special_string = "0 bytes/sec";
sub process_text_pipe {
my @output;
while (<>) {
@robinkaty
robinkaty / edit_path.pl
Created August 7, 2023 05:12
Edit Path, show duplicate lines, print clean path
#!/usr/bin/perl
use strict;
use warnings;
use Env;
use File::Temp qw(tempfile);
use File::Basename;
sub edit_path_variable {
# Get the current PATH variable
@robinkaty
robinkaty / edit_path.py
Created August 7, 2023 04:51
Edit PATH Variable Strings or help find duplicates in path
import os
import tempfile
import subprocess
def edit_path_variable():
# Get the current PATH variable
current_path = os.environ.get('PATH', '')
paths_list = current_path.split(':')
# Display the current paths to the user
@robinkaty
robinkaty / searchallpath.pl
Last active August 7, 2023 04:20
SearchAllPath.pl
#!/usr/bin/perl
use strict;
use warnings;
sub find_file_in_path {
my ($filename) = @_;
my $count=0;
# Split the PATH environment variable into individual directories
@robinkaty
robinkaty / validate_known_hosts.pl
Last active August 6, 2023 19:15
Validate Known Hosts
#!/usr/bin/env perl
# perl script to validate entries in the known_hosts file
# by pinging or nslookup.
# tried several versions of perl modules for the ping and validate but they were
# very unreliable or requred root.
# the process uf using the shell seems to work reliably
# The output is written to ~/.ssh/new_known_hosts.
use strict;
use warnings;
@robinkaty
robinkaty / smbmounter.py
Last active October 4, 2023 23:13
smbmounter.py New version to support NFS mounts in addtion to SMB
#!/usr/bin/env python3
# Notes:
# if run from command line the mounts file will be the scriptname + .txt IE: smbMounter.py.txt
# if run from Platypus, the script name is always "script.txt" I need to find a way to
# make these to the same.
# Added mac sounds to the automount function
# Added a display box to cache messages created during the auto_mount and display them after
# the main grid is displayed.
# refactored some code in the mount and automount functions
# consolidated the mounting to mount_network_share
@robinkaty
robinkaty / newprune.sh
Last active June 19, 2023 03:22
script for managing timemachine backups over multiple destinations
#!/usr/bin/env perl
#use warnings;;
use Data::Dump qw(dump);
# assuming you have the backup disk connected & root privileges:
# get the latest backup to exclude from deletion
my $latest = `sudo tmutil latestbackup`;
# the 4th line after the last space from `tmutil destinationinfo` output
# contains the mount disk name
my $destination_info = `sudo tmutil destinationinfo`;
@robinkaty
robinkaty / mac-backup-script.sh
Last active August 5, 2023 18:11
Multi Destination Time Machine Backup
#!/bin/sh
(
exec 2>&1 ;
time (
set +e
echo "Start Time: `date`"
/usr/bin/tmutil destinationinfo
echo "===================================================="
/usr/bin/tmutil destinationinfo | grep "^ID" | cut -d ":" -f2 | while read destination
do
@robinkaty
robinkaty / mailapp.py
Last active June 12, 2023 23:41
Mailapp command line tool
#!/usr/bin/env Python3
#
# by Nathan Grigg http://nathangrigg.com
#
# Rob Granger
# change line #1 to use /usr/bin/env Python3
# change Popen to use UTF8 to fix the binary pipe errors.
# p = Popen(['/usr/bin/osascript'],stdin=PIPE,stdout=PIPE,encoding='utf-8')