Skip to content

Instantly share code, notes, and snippets.

View jvacek's full-sized avatar

Jonas Vacek jvacek

View GitHub Profile
@jvacek
jvacek / README.md
Created January 7, 2023 23:52
Homebridge Apple TV AirPlay Status Sensor

This setup will add a contact switch to show when your apple tv is playing music over airplay.

The config and script below will give you a contact switch which shows whether AirPlay Music is playing or not.

Follow the instructions for https://github.com/cristian5th/homebridge-appletv, and save your tokens separately from your script.

image

@jvacek
jvacek / README.md
Last active July 28, 2022 11:15
`aws-cli` easy 2FA authentication

This will help you set up two functions to manage your login status when using two-factor authentication with the aws-cli tool.

Of course, the auth tokens only live within the terminal session's environment, and are not persistent.

You will need to start a new terminal session after following the instructions.

Usage

When done, you can perform any aws tasks without authenticating, like below.

aws-login 123456
@jvacek
jvacek / Remove unused python imports on save in VSCode.md
Last active June 18, 2023 10:20
Remove unused python imports on save in VSCode

Auto-remove unused python imports in VSCode on save

I could not find a proper full configuration for this online, and I know I'll need this again in the future.

There are two ways to achieve this with some plugins; one via hitting the shell and doing an in-place replace, the other is by doing it with extensions configurable in vscode. Both should give you the same results.

Install VSCode extensions needed:

If running via bash:

@jvacek
jvacek / aws-mfa.sh
Last active September 7, 2021 14:16 — forked from mankins/aws-mfa.sh
aws mfa cli tool
#!/bin/bash
# From a user's MFA code, generate accesskey, secret, session token
#
# ENV inputs:
# AWS_CLI_INPUT = /path/to/token/config.json
# AWS_PROFILE = The Aws profile to use for aws commands
MFA_CODE=$1
if [ -z $MFA_CODE ]; then
@jvacek
jvacek / checkreboot.sh
Last active March 22, 2024 08:29
Check whether linux server needs reboot and return for how long has the reboot been necessary in PRTG's format
#!/bin/bash
#You can install and also update this script by running the follwoing command
# sudo curl https://gist.githubusercontent.com/jvacek/18aaf9858d8ab8016297bee5e71f59ef/raw/checkreboot.sh -L --create-dirs -o /var/prtg/scripts/checkreboot.sh; sudo chmod a+rx -R /var/prtg/
#Create a new sensor for your machine, select SSH script, and select checkreboot.sh from the script dropdown.
#The value returned is in seconds. 0 seconds means no file is present.
#The sensor will be set to warning when the file is present.
#If you want the sensor to go down when a reboot has been required for more than 24h, set the upper error limit of the valu channel on the sensor to 86400.