Skip to content

Instantly share code, notes, and snippets.

View elundmark's full-sized avatar
💭
I may be slow to respond.

elundmark

💭
I may be slow to respond.
View GitHub Profile
@elundmark
elundmark / generate_killer_sudoku_cheatsheet.py
Last active May 11, 2023 11:42
Generate cheatsheet for killer sudoku
#!/usr/bin/python3
"""
Generate cheatsheet of possible combinations of numbers in killer sudoku cells
"""
from itertools import chain, combinations
import sys
def powerset(iterable):
"""https://stackoverflow.com/questions/464864/"""
s = list(iterable) # allows duplicate elements
@elundmark
elundmark / test_stdin.sh
Last active October 13, 2022 16:11
Using the test command with STDIN
#!/usr/bin/env bash
set +H
# Using STDIN, check LINES of FILES and use the test command to filter by EXPRESSION
# Supports all EXPRESSIONS that test does.
# fn | test_stdin -f \! -d -L -s \! -ot FILEARG
# Use '!' to negate results. -ef, -ot, -nt will be read as "LINE -nt FILEARG"
if [[ $# -eq 0 ]] ; then
# An omitted EXPRESSION defaults to false (see manpage for test)
@elundmark
elundmark / animated-pixel.html
Created May 24, 2022 05:53
Test Monitor FPS in Browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test Monitor FPS in Browser</title>
<style>
html {
background-color: #000;
@elundmark
elundmark / crop.sh
Created October 5, 2021 05:53
Slice image into grid, by width of number
#!/usr/bin/env bash
# Crop image using the CSS method top-right-bottom-left
# Uses get_tmp_hash.py
declare -i e_c=1 img_w=0 img_h=0 i=0 x=0 c_t=0 c_r=0 c_b=0 c_l=0 arglen=0 form_w=0 form_h=0 form_x=0 form_y=0 gui_input=0
declare -a args=() im_cmd=()
declare img mime_type jpeg_re='jpe?g' jpeg_quality tmp_file num_re='^[0-9]+$' output_name
parse_gui_args(){
@elundmark
elundmark / monitor_audio-cable_change.sh
Last active April 26, 2021 11:48
Monitor audio-cable In or Out
#!/usr/bin/env bash
# NOTE! This script checks card 1, yours may be different
declare -i CARD=1
if amixer -c "$CARD" contents | grep -A2 'Headphone' | grep -q 'values=on'
then
mkdir /tmp/.audio-cable-connected &>/dev/null
fi
@elundmark
elundmark / embed_cover_in_audio.sh
Created September 9, 2020 15:56
Script to embed images in audio files using tageditor cli and chafa!
#!/usr/bin/env bash
declare tageditor=/home/user/bin/tageditor-latest-x86_64.AppImage
if ! command -v chafa &>/dev/null || [[ ! -x "$tageditor" ]] ; then
echo "Missing programs"
exit 1
fi
declare -a args=() error_files=()
@elundmark
elundmark / jump_between_app_windows_i3.py
Last active September 21, 2020 11:29
i3wm: Switch between same program windows
#!/usr/bin/env python3
"""
i3wm Python Script: Jump fwd/backward N positions in app windows sharing the
same 'class'
Download: https://gist.github.com/elundmark/f1f5cdee35a6305af23b62847ae79386
Updated: 2020-09-21 13:28:54
"""
import sys
import json
import subprocess
@elundmark
elundmark / generate_list.sh
Last active May 16, 2020 08:27
Copy Emoji from Rofi List (plus how-to generate a full list)
#!/usr/bin/env bash
# curl 'https://unicode.org/Public/emoji/13.0/emoji-test.txt' > Public_emoji_13.0_emoji-test.txt
declare title_re='^# (sub)?group[: ]+(.+)'
declare e_line_re='^([0-9A-Z]+ )+[ ]+;[ ]*(fully-qualified|unqualified|minimally-qualified|qualified|component)[ ]+#[ ]*(.+)[ ]+(E[0-9.]+)[ ]+(.+)$'
declare work_dir
work_dir="$(dirname "$(realpath "$0")")"
while read -r; do
@elundmark
elundmark / mms.py
Last active February 13, 2020 04:33
Magic Media Sorter - Sort your media correctly! (Tested in: Python v3.8+ on Linux)
#!/usr/bin/env python3.8
"""Magic Media Sorter - Sort your media correctly!"""
import argparse
import operator
import sys
import re
def main(imported=None, importedList=None):
"""main function"""
@elundmark
elundmark / Screenshot.md
Last active December 27, 2019 13:24
Show the next 2 days calcurse meetings in i3blocks (i3bar) (Nerd Font must be installed)

preview