Skip to content

Instantly share code, notes, and snippets.

@o3bvv
o3bvv / create-task_delete-old-service-logs.ps1
Last active August 24, 2020 17:01
Deleting old log files on Windows periodically (see https://serverfault.com/a/1031301/252212)
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$LogsDirPath,
[Parameter(Position=1)]
[int]$LogsFileMaxN = 31,
@o3bvv
o3bvv / example.sh
Created December 9, 2020 09:15
N most recently created files in a directory
find . -type f -printf "%T@ %TFT%TT %p\n" | sort -nr | head
@o3bvv
o3bvv / install-python.sh
Last active March 2, 2021 11:01
Installing Python from sources
#!/usr/bin/bash
CC=x86_64-linux-gnu-gcc
CFLAGS=-g -fstack-protector-strong -Wformat -Werror=format-security
LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2
CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2
configure --enable-optimizations --with-ensurepip=install --enable-shared --prefix=/usr/local/ --enable-loadable-sqlite-extensions --with-dbmliborder=bdb:gdbm --with-computed-gotos --with-system-expat --with-system-ffi
make # -j 4
make altinstall
@o3bvv
o3bvv / run.sh
Last active May 8, 2021 06:22
Delete old kernels from Ubuntu
#!/bin/sh
# 1. List old versions by:
# 1.1. Listing all "initrd.img-*" files in "/boot" (ls -1), ex: "/boot/initrd.img-5.8.0-44-generic"
# 1.2. Excluding current LOADED version (grep -v), ex: "5.8.0-50-generic"
# 1.3. Extracting version part from listed filenames (awk), ex: "5.8.0-44"
# 2. Purge kernel packages per each version, with confirmation prompt (configmation is enabled by default)
for v in $(ls -1 /boot/initrd.img-* | grep -v `uname -r` | awk -F'-' '{ print $2 "-" $3 }'); do \
sudo apt-get --purge remove \
linux-image-$v-generic \
@o3bvv
o3bvv / build-cache-for-existing.sh
Last active January 8, 2022 00:19
youtube-dl playlist
#!/usr/bin/env sh
for n in *.mp3
do if [[ "$n" =~ -[-_0-9a-zA-Z]{11}.mp3$ ]]
then echo "youtube ${n: -15: 11}" >> downloaded.txt
fi
done
@o3bvv
o3bvv / help-ukraine-stop-russia.md
Last active March 29, 2022 18:35
How YOU can help Ukraine right NOW

Help Ukraine! Stop Russia!

About

This document is a collection of links 🔗 people all over the world 🌐 can use to help Ukraine 🇺🇦 and Ukrainians to stand in the war started by Russian Federation (RF).

The list is deliberately made in a simplistic text-based version, so you can copy it, save, make a screenshot, print, etc and share it in case access to it is lost for any reason.

What YOU can do ⚡️:

@o3bvv
o3bvv / .rsync-exclude
Last active July 22, 2022 06:51
Exclude items for rsync
.DS_Store
.tox
.pytest_cache
.egg-info
__pycache__
.vscode
.idea
Icon\r
Icon$\r
Icon?
@o3bvv
o3bvv / post.py
Last active August 30, 2023 05:17
Export Apple Photos with meta sidecars
import datetime
import json
import os
from pathlib import Path
from typing import Callable
from osxphotos import ExportResults
from osxphotos import PhotoInfo