Skip to content

Instantly share code, notes, and snippets.

@Bas-Man
Bas-Man / cookie.css
Created July 15, 2020 13:36
HUGO Cookie Footer CSS
@Bas-Man
Bas-Man / cookie-notice.html
Created July 15, 2020 13:35
HUGO Cookie Footer HTML
@Bas-Man
Bas-Man / mock_sys.version_info.py
Created April 22, 2020 13:31
One method of mocking the values for sys.version_info.major/minor
def test_python2TooLow():
with mock.patch.object(sys, 'version_info') as v_info:
v_info.major = 2
v_info.minor = 7
assert helper.system.meetsMinSpecs(3, 0) == False
@Bas-Man
Bas-Man / JSONWithComplexPythonObjects.md
Last active May 11, 2020 11:33
return json string for complex python objects

Link found here

example usage in my case

def json():
  return json.dumps(self.__dict__,default=lambda o: o.__dict__,
                    ensure_ascii=False,indent=4)
@Bas-Man
Bas-Man / sleepwatcher.md
Created February 11, 2019 08:29
Run script on Mac OS on wake from lan event

Referenced from https://www.bernhard-baehr.de

use de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist from config folder follow instructions. Remember to chmod required files including the .wakeup in home directory.

@Bas-Man
Bas-Man / GetAllModules.txt
Last active February 6, 2019 13:03
Find all modules used in a Perl program
perl -MDevel::Modlist=options program.pl
@Bas-Man
Bas-Man / ShutDownServer.scpt
Created January 22, 2019 12:45
Mac Shutdown AppleScript
# Current under Dev
#Drobo Dashboard does not appear to respond to quit command.
# Drobo is the name of the drive to be unmounted. This should be changed to
# your own needs.
tell application "NordVPN" to quit
tell application "Plex Media Server" to quit
tell application "Dropbox" to quit
tell application "Drobo Dashboard" to quit
@Bas-Man
Bas-Man / startAfterMount.scpt
Created January 17, 2019 01:52
AppleScript to launch applications only after external drive has been mounted.
set diskIsMounted to false
repeat until diskIsMounted is true
delay 30
tell application "Finder"
if (disk "Drobo" exists) then
set diskIsMounted to true
end if
end tell
end repeat
@Bas-Man
Bas-Man / plexDatabaseBackupScript.sh
Last active March 26, 2021 23:38 — forked from shnhrrsn/plexDatabaseBackupScript.sh
Plex Media Server database backup script of Mac OS
#!/usr/bin/env bash
# Backup a Plex database.
# Author Scott Smereka
# Ubuntu
# Version 1.0
# Modified by Shaun Harrison
# Ubuntu
# Version 1.1
@Bas-Man
Bas-Man / TestCatchException.py
Created December 13, 2018 14:18
How to catch an OSError for invalid directory path or file in UnitTest in Python 3.x
def testValidatePathFile(self):
with self.assertRaises(OSError) as cm:
# self.handle.__ValidatePathFile()
self.handle = exceptman.ExceptionListManager(path="/tm")
err = cm.exception
self.assertEqual(str(err), "[Errno 2] No such file or directory: '/tm'")