Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile
@magnetikonline
magnetikonline / README.md
Last active October 20, 2025 10:11
Install VirtualBox 7.0/6.1/6.0/5.2/5.1 guest additions on Ubuntu server guest.

Install VirtualBox guest additions onto Ubuntu server guests

Note

The following steps have been successfully tested with Ubuntu guests of:

  • 24.04LTS
  • 22.04LTS
  • 18.04LTS
  • 16.04LTS
@magnetikonline
magnetikonline / README.md
Last active October 11, 2025 10:28
Enable LDAP over SSL (LDAPS) for Microsoft Active Directory servers.

Enable LDAP over SSL (LDAPS) for Microsoft Active Directory servers

Tip

Microsoft active directory servers by default provide LDAP connections over unencrypted connections (boo!).

The steps below will create a new self signed certificate appropriate for use with and thus enabling LDAPS for an AD server. Of course the "self-signed" portion of this guide can be swapped out with a real vendor purchased certificate if required.

Steps have been tested successfully with Windows Server 2012R2, but should work with Windows Server 2008 without modification. Requires a working OpenSSL install (ideally Linux/OSX) and (obviously) a Windows Active Directory server.

@magnetikonline
magnetikonline / README.md
Last active April 29, 2024 23:45
PowerShell execute command (.exe) with arguments safely (e.g. with spaces).

PowerShell execute command with arguments safely

In my opinion this is the best way for executing external commands from PowerShell with arguments in a safe manner - via the use of an array to hold the arguments.

Consider this one a PowerShell gem to keep in the toolbox.

Note

The example below makes use of EchoArgs.exe - a small utility that simply echoes back arguments passed to it. Utility is part of the PowerShell Community Extensions, or the exe alone can be downloaded at https://ss64.com/ps/EchoArgs.exe.

Example

@magnetikonline
magnetikonline / README.md
Last active September 12, 2018 20:48
PowerShell example to copy local files recursively to target server share with orphan cleanup.

PowerShell copy local files recursively to target server

A PowerShell script which provides the following:

  • Mount remote/target server share with given username/password credentials.
  • Copy all $SourcePath files to target share ($TargetServer / $TargetShare) recursively.
  • Finally, clean up all orphaned directories/files from target share.

Usage example

./remotecopy.ps1 `
	-SourcePath "." `
@magnetikonline
magnetikonline / README.md
Last active September 24, 2024 23:18
PowerShell Import-Module with .ps1 quirk.

PowerShell Import-Module with .ps1 quirk

Well, not so much a quirk - but an interesting anti-pattern I found in some (poor quality) PowerShell. Documenting the "how and why" so I can refer to it again if needed!

Example

@magnetikonline
magnetikonline / README.md
Last active June 21, 2023 00:24
FLAC -> MP3 VBR with ffmpeg

FLAC -> MP3 VBR with ffmpeg

Convert source FLAC files in a directory to MP3 VBR (around 220-260 kbps).

#!/bin/bash -e

FLAC_SRC_DIR="/path/to/flac/files"
@magnetikonline
magnetikonline / README.md
Last active April 17, 2023 11:49
Kodi media player - update video database file paths.

Kodi media player - update video database file paths

  • The Kodi databases are all SQLite3 based.
  • For Linux, the video database will be located at: ~/.kodi/userdata/Database/MyVideosXX.db, where XX is the version number. You will most likely want the highest number available for edit.

Install SQLite CLI tools, open database

$ sudo apt-get install libsqlite3-dev sqlite3
$ sqlite3 MyVideosXX.db
@magnetikonline
magnetikonline / README.md
Last active May 1, 2023 04:43
Python AWS CloudTrail parser class.

Python AWS CloudTrail parser

Python parser class for CloudTrail event archives, previously dumped to an S3 bucket. Class provides an iterator which will:

  • Scan a given directory for archive files matching the required pattern.
  • Decompress each archive in memory.
  • Parse JSON payload and return each event in turn.

Parser contained in cloudtrailparser.py, with timezone.py used as a simple datetime.tzinfo concrete class implement to provide UTC timezone.

@magnetikonline
magnetikonline / README.md
Created July 5, 2016 01:46
SSL certificate - compare modulus of certificate vs. private key for equality.

SSL certificate - compare certificate vs. private key

Or to put it another way...

Does this certificate I have actually work with this private key I have?

Where server.crt is your certificate and server.key is your private key:

$ certMod=$(openssl x509 -text -noout -modulus -in server.crt | grep "Modulus=") && \
	keyMod=$(openssl rsa -text -noout -modulus -in server.key | grep "Modulus=") && \
	[[ $certMod == $keyMod ]] && echo "Equal"
@magnetikonline
magnetikonline / example.py
Last active July 4, 2016 00:54
Fun with Python datetime timezones.
#!/usr/bin/env python
from datetime import datetime
import timezone
def main():
my_time = datetime(
year = 2016,
month = 1,