Skip to content

Instantly share code, notes, and snippets.

View SmartFinn's full-sized avatar
🇺🇦

Serhii Yeremenko SmartFinn

🇺🇦
  • Ukraine
  • 20:50 (UTC +02:00)
View GitHub Profile
@SmartFinn
SmartFinn / ghcp.py
Created November 15, 2024 03:24
A command-line utility to copy a file into a GitHub repository using GitHub API
#!/usr/bin/env python
#
# Copyright (c) 2021 Sergei Eremenko (https://github.com/SmartFinn)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
@SmartFinn
SmartFinn / sign-kernel-longterm.sh
Created September 2, 2023 19:04
Automatically signing long term kernels with Machine Owner Key (MOK) using post-install script
#!/bin/bash
# file: /etc/kernel/postinst.d/sign-kernel-longterm
#
# Create signing keys:
#
# openssl req -new -x509 -newkey rsa:4096 \
# -keyout MOK.priv \
# -outform DER -out MOK.der \
# -nodes -days 36500 -subj "/CN=Descriptive Name/"
#
@SmartFinn
SmartFinn / createHtmlTemplate.js
Created November 8, 2022 15:28
create HTML template from Javascript
function createHtmlTemplate(html) {
const template = document.createElement('template');
template.innerHTML = html.trim();
return template.content.firstElementChild;
}
@SmartFinn
SmartFinn / journald_stats.sh
Created October 15, 2022 13:50
Collect journald stats for prometheus-node-exporter
#!/bin/bash
#
# Description: Expose metrics from journald.
#
# Author: Sergei Eremenko (https://github.com/SmartFinn)
echo '# HELP journald_disk_usage Disk usage of all journal files in bytes.'
echo '# TYPE journald_disk_usage counter'
if [ -d /run/log/journal ]; then
echo 'journald_disk_usage{storage="temprary"}' \
@SmartFinn
SmartFinn / test_ls_colors.sh
Created October 15, 2022 13:31
Simple script that creates various directories to test your $LS_COLORS setup
#!/usr/bin/env bash
# Simple script that creates various directories to test your $LS_COLORS setup
set -euo pipefail
mkdir -p test
cd test
# File
touch FILE
@SmartFinn
SmartFinn / sym2bind.sh
Last active October 11, 2022 06:40
Replace symlinks to mounted drive with bind mount
#!/usr/bin/env bash
#
# Copyright (c) 2021 Sergei Eremenko (https://github.com/SmartFinn)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
@SmartFinn
SmartFinn / group_by_age.awk
Created November 7, 2020 09:55
Скрипт групує відкриті дані по захворюваності на COVID-19 в Україні по віку
#!/usr/bin/awk -f
# Copyright (c) 2020 Sergei Eremenko (https://github.com/SmartFinn)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
@SmartFinn
SmartFinn / .rsyncignore
Last active January 6, 2023 15:20
[Makefile] Yet another wrapper for rsync
/Makefile
/.rsyncignore
@SmartFinn
SmartFinn / send_email_on_logged_in.rsc
Last active November 14, 2023 16:05
A script to send an email when a user logged in the MikroTik router #RouterOS #MikroTik
# This script sends an email when a new user logged in the router
#
# Required permissions:
#
# [x] read [x] write
# [x] policy [x] test
#
# written by Sergei Eremenko (https://github.com/SmartFinn)
:global TokensOfLoggedUsers
@SmartFinn
SmartFinn / gmail_label_to_telegram.gs
Last active May 27, 2020 09:09
Forward email marked with custom label to Telegram #google-script #gas
/**
Forward email marked with custom label to Telegram.
Sergei Eremenko (https://github.com/SmartFinn) © 2020
**/
// Custom trigger to run script every 1 min
function startCustomTrigger() {
ScriptApp.newTrigger('checkInbox').timeBased().everyMinutes(1).create()
}