Skip to content

Instantly share code, notes, and snippets.

@tcely
tcely / last_boot.py
Last active April 19, 2025 02:10
Getting Windows Last Boot Time in Python
#!/usr/bin/env python3
import datetime
import os
# import wmi
# https://github.com/tjguk/wmi
# https://github.com/tcely/wmi
class LastBoot:
@tcely
tcely / links.md
Last active April 4, 2025 13:46
Various links
@tcely
tcely / sum_files.py
Created April 2, 2025 09:50
Creating a sums file from the GitHub workflow
#!/usr/bin/env python3
import hashlib
import io
import os
import pathlib
import sys
def sum_file(hasher, file_path):
@tcely
tcely / README.md
Last active February 14, 2025 09:12
Useful GPG commands for GitHub

Using GitHub & GPG together

Fetching GPG keys

Any GitHub user account can contain GPG keys used for signed commits. To verify these signatures, your local gpg.program needs the public key.

To fetch them, just use a URL such as this: https://github.com/<ACCOUNT>.gpg

@tcely
tcely / url_decode.inc.sh
Last active December 17, 2024 01:48
sh url_decode
url_decode() {
local arg ;
if [ $# -gt 0 ]; then
for arg; do
printf -- '%s\n' "${arg}" ;
done | url_decode ;
else
check_printf ;
printf -- '%b\n' "$(sed -E -e 's/\+/ /g' -e 's/%([0-9a-fA-F]{2})/\\x\1/g')" ;
fi ;
@tcely
tcely / config
Created September 8, 2023 14:28
Turn on ssh-rsa for only the hosts that require that option
# Add this to the ~/.ssh/config file
#
Match Exec "ssh-rsa-needed.sh '%n' '%C' '%l' '%h' '%p' '%r'"
PubkeyAcceptedKeyTypes +ssh-rsa
@tcely
tcely / history.inc.sh
Last active August 24, 2023 20:33
Bash History Configuration
if [ "${BASH_VERSION-}" ]; then
# Local variables the functions depend upon
_bash_history_prefix=~/.local/history/bash
# {{{ Begining of the temporary functions block
_bash_history_get_today() {
date '+%Y/0%m/%d'
}
@tcely
tcely / Social_Media.md
Created December 18, 2022 23:04
Social Media Information
@tcely
tcely / simple-echo.function.sh
Created September 22, 2020 00:04
A simple echo using the shell printf for consistent behavior
#!/usr/bin/env sh
secho() {
_arg="${1}";
_fmt='%s';
_sentinel='--';
case "${_arg}" in
(-e|-en|-ne) _fmt='%b'; shift ;;
(-n|-En|-nE) shift ;;
@tcely
tcely / README.md
Last active June 26, 2019 00:21
AlpineLinux aports style decisions
  1. Shell (ash from busybox) variables are always quoted and use curly braces.

    "Optimize for the inexperience newcomers rather than the experience gurus." As explained in this post there are a few quirks when dealing with shell variables that do not use the curly braces. For example: $pkgver

    Instead of expecting new contributors to already know about all of the pitfalls involved with using that syntactic sugar, it is better to just always use the braces. Shell variables are quoted when assigned and used, when accessed they are quoted and surrounded by curly braces. For example: pkgname='bind' or pkgdesc="${pkgname} tools" and "${pkgname}"

The characters that do and do not extend the name of the variable are not a concern when the intention of what the variable name should be is made clear by using this explicit syntax. Users don't need to remember which of _, -, or . will change the variable name and lead to an empty value be