Skip to content

Instantly share code, notes, and snippets.

View aquilax's full-sized avatar
💭
Fighting entropy

Evgeniy Vasilev aquilax

💭
Fighting entropy
View GitHub Profile
@aquilax
aquilax / Makefile
Last active February 28, 2024 15:50
Generate diagrams
# Define variables
SRCDIR := .
DOTFILES := $(shell find $(SRCDIR) -type f -name '*.dot')
PUMLFILES := $(shell find $(SRCDIR) -type f -name '*.puml')
MERMAIDFILES := $(shell find $(SRCDIR) -type f -name '*.mmd')
PNGFILES := $(DOTFILES:.dot=.png) $(PUMLFILES:.puml=.png) $(MERMAIDFILES:.mmd=.png)
DOT := dot
PLANTUML := java -jar plantuml-1.2023.4.jar
MERMAID := mmdc
@aquilax
aquilax / fixup-commits.sh
Created December 13, 2023 06:20
Script to auto-create fixup commits towards the first change in the branch
#!/bin/bash
set -e
# Function to create fixup commits for changed files
create_fixup_commits() {
target_branch="${1:-origin/develop}"
# Get the list of changed files
changed_files=$(git diff --name-only)
#!/usr/bin/env bash
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
# Define usage function
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-k|--keep] [--recursive] [--force] [--dry-run] INPUT_DIR [OUTPUT_DIR]
@aquilax
aquilax / viki-playback-speed.js
Last active March 13, 2023 10:55
Uses `<` and `>` to change the playback speed (defaults to 1.5x)
((_w) => {
const _d = _w.document;
if (!_d.querySelector('#speeder')) {
const getSpeed = s => s/10
let speed = 15;
let speedEl = document.createElement("span");
speedEl.id = 'speeder';
speedEl.innerText = ` ${getSpeed(speed)}x`;
_d.querySelector('#channel-link > span').appendChild(speedEl);
_d.querySelectorAll('video').forEach(v => v.playbackRate = getSpeed(speed));
@aquilax
aquilax / viki-sort-watchlist.js
Created April 21, 2022 16:47
Sort Viki watchlist by show rating
list = document.querySelector('.container > div:nth-child(2)'); [...list.children]
.sort((a,b)=>a.querySelector('.kngppJ').innerText<b.querySelector('.kngppJ').innerText?1:-1)
.forEach(node=>list.appendChild(node));
@aquilax
aquilax / builder.go
Last active December 31, 2021 18:13
Go builder pattern
// https://go.dev/play/p/JSWYXbjHBlM
package main
import "fmt"
type Fruit struct {
name string
color string
shape string
}
@aquilax
aquilax / recompose.go
Created December 31, 2021 09:37
Function composition with go
// https://go.dev/play/p/xmai9kPOwl3
// Function composition with go
// You can edit this code!
// Click here and start typing.
package main
func main() {
example()
}
@aquilax
aquilax / article_navigation.js
Created May 30, 2021 07:02
Inserts heading navigation for long documents
const datalist = document.createElement('datalist');
datalist.setAttribute('id', 'header-list');
Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6")).forEach(headerNode => {
const id = headerNode.id || headerNode.innerText.replace(/\W/g, '_') || Math.random();
headerNode.setAttribute('id', id);
const option = document.createElement('option');
option.setAttribute('value', headerNode.innerText);
option.dataset.target = id;
datalist.appendChild(option);
@aquilax
aquilax / index.html
Created May 15, 2021 14:19
Sort textarea unique
<a href="javascript:(function(){Array.from(document.querySelectorAll('textarea')).map(function(b){var a=document.createElement('div');var d=document.createElement('button');d.textContent='↑';d.addEventListener('click',function(f){f.preventDefault();b.value=Array.from(new Set(b.value.split('\n'))).sort().join('\n')});var c=document.createElement('button');c.textContent='↓';c.addEventListener('click',function(f){f.preventDefault();b.value=Array.from(new Set(b.value.split('\n'))).sort().reverse().join('\n')});a.appendChild(d);a.appendChild(c);b.parentNode.insertBefore(a,b)})})();">Sort textarea unique</a>