Skip to content

Instantly share code, notes, and snippets.

View udovichenko's full-sized avatar
👾

Dmitry Udovichenko udovichenko

👾
View GitHub Profile
@udovichenko
udovichenko / Makefile
Created May 16, 2024 21:47
Makefile template with help suggestions and checking environment ability for each command
.ONESHELL:
$(VERBOSE).SILENT:
SHELL := /bin/bash
CYAN := \033[0;36m
NC := \033[0m
.DEFAULT_GOAL := help
help:
grep -E '^[a-zA-Z_-]+:[ \t]+.*?# .*$$' $(MAKEFILE_LIST) | sort | awk -F ':.*?# ' '{printf " ${CYAN}%-24s${NC}\t%s\n", $$1, $$2}'
<?php
return [
'a5',
'a4',
'tablet_9.7',
'laptop_13',
'laptop_15',
'buckwheat',
];
@udovichenko
udovichenko / ssh-config-sort.js
Last active May 8, 2023 14:52
Script for sorting ~/.ssh/config by host alphabetically
#!/usr/bin/env node
const fs = require('fs')
const os = require('os')
const readline = require('readline')
const home = `${os.homedir()}`
const configFile = `${home}/.ssh/config`
const lines = fs.readFileSync(configFile, 'utf-8').split('\n')
@udovichenko
udovichenko / youtube_clean_watch_later_videos.js
Last active March 11, 2023 19:41 — forked from qoomon/youtube_clean_watch_later_videos.js
Clean YouTube Watch Later Videos with Limit and Random Delay
(async function() {
const REMOVE_BUTTON_TEXT = 'Remove from Watch later'
// de-DE: const REMOVE_BUTTON_TEXT = 'Aus "Später ansehen" entfernen'
// pt-BR: const REMOVE_BUTTON_TEXT = 'Remover de Assistir mais tarde'
// swe-SE: const REMOVE_BUTTON_TEXT = 'Ta bort från Titta senare'
// zh-Hans-CN: const REMOVE_BUTTON_TEXT = '从稍后观看中移除'
// ru-RU: const REMOVE_BUTTON_TEXT = 'Удалить из плейлиста "Смотреть позже"'
const playlistName = document.querySelector('#title a').text
@udovichenko
udovichenko / .bashrc
Last active December 11, 2022 00:47
Task runner (Makefile Replacement). Pure bash (shell) functions based tasks. Autocomplete (completion) for both bash and zsh
_task() {
TASKS=$(./tasks.sh ls-func)
local -a LIST=()
while IFS='' read -r line; do LIST+=("$line"); done < <(compgen -W "$TASKS")
}
complete -F _task task
@udovichenko
udovichenko / Makefile
Last active December 11, 2022 00:33
Makefile: dynamically create targets from array
TARGETS = func1 func2 func3
$(TARGETS): %:
./funcs.sh $*
@udovichenko
udovichenko / svg2ico.sh
Created November 14, 2022 21:27 — forked from azam/svg2ico.sh
Convert SVG to ICO using ImageMagick, with transparent background and multi-size icons
convert -density 256x256 -background transparent favicon.svg -define icon:auto-resize -colors 256 favicon.ico
@udovichenko
udovichenko / ffmpeg-web-video-guide.md
Created October 31, 2022 13:10 — forked from jaydenseric/ffmpeg-web-video-guide.md
A quick guide to using FFmpeg to create cross-device web videos.

Video conversion with FFmpeg

Install

On mac:

  1. Download the latest release.
  2. Extract the binary and place it in /usr/local/bin.

Command basics

@udovichenko
udovichenko / new-wireguard-peer.sh
Last active October 16, 2022 13:28 — forked from robinlandstrom/new-wireguard-peer.sh
Script to automatically add configration for a new peer to a wireguard server. It will then print a QR code to the console that can be used to add the config to the Android or OS X wireguard client.
#!/bin/bash
readonly INTERFACE="wg0"
# Generate peer keys
readonly PRIVATE_KEY=$(wg genkey)
readonly PUBLIC_KEY=$(echo ${PRIVATE_KEY} | wg pubkey)
readonly PRESHARED_KEY=$(wg genpsk)
readonly IP=$(curl ifconfig.so)
@udovichenko
udovichenko / .env
Last active September 18, 2022 17:50
Server with Docker setup
USERNAME=
DOMAIN=