Skip to content

Instantly share code, notes, and snippets.

@akomakom
akomakom / Readme Low Battery Warning Alert for Linux.md
Last active March 25, 2023 06:49
Play periodic sound when laptop battery is low, also when charger is plugged in/unplugged

Suitable for laptops that don't generate udev events when battery charge level changes (but do generate events when unplugged).

Uses MP3 files (use mine or make your own).
You can also change sound() to use a tone as in this example

Installation

  • Copy MP3 files to /usr/local/bin (or change the shell script)
  • Copy other files to the location specified at the top (change "CHANGE_TO_MY_USER" to the username you primarily use)
@akomakom
akomakom / doshutdown
Last active June 28, 2021 14:03
Plugin for apcupsd to prevent low battery shutdown when external DC source is connected
#!/usr/bin/env python
# Prevent shutdown when batteries are not really empty
# installed in /etc/apcupsd/ as 'doshutdown' and 'mainsback' (symlink)
import os
from sys import argv
from subprocess import check_output
from syslog import syslog
threshold=24.3 # If batteries are above this, don't shut down
@akomakom
akomakom / SemVer.groovy
Last active February 1, 2024 19:58 — forked from michaellihs/SemVer.groovy
Semantic Versioning class for Groovy
/**
* This evolved from pure SemVer to any-length version with optional -suffix
* accepts any of:
* 1
* 1.2
* 1.2.3
* 1.2.3.4 (etc, no limit)
* 1.2.3-SNAPSHOT
*
* bump() also accepts index values, eg -1 (last component), -2 (second from end), etc:
@akomakom
akomakom / README.md
Last active March 9, 2023 15:26
AWS Lambda function to kill forgotten instances, pure NodeJS

AWS Lambda function to kill old instances

A pure NodeJS function to kill select EC2 instances if they run longer than a defined period.

This is useful as a safety measure when using EC2 in CI and launching many instances.
A CI crash or user action could prevent proper cleanup, leaving expensive machines running forever (or until the next billing cycle when there is much screaming).

Instructions