Skip to content

Instantly share code, notes, and snippets.

View bojidar-bg's full-sized avatar

Bojidar Marinov bojidar-bg

View GitHub Profile
@bojidar-bg
bojidar-bg / procedural-worm.py
Created July 25, 2024 09:34
Procedurally-animated worm in Python
# A simple program which shows a procedurally-animated worm that can be moved around by clicking on the screen.
# References: https://mcsp.wartburg.edu/zelle/python/graphics/graphics/graphref.html, https://tkdocs.com/shipman/index-2.html
from random import random
from math import sqrt
from graphics import * # https://mcsp.wartburg.edu/zelle/python/graphics.py
class FollowerCircle(Circle):
"""
@bojidar-bg
bojidar-bg / focus.py
Created July 1, 2024 18:25
Script enabling do-not-disturb mode for a random amount of time
#!/usr/bin/python
import sys
import argparse
import dbus
import random
import time
import signal
def seconds(s):
@bojidar-bg
bojidar-bg / layout-switcher.snip.sh
Created April 11, 2024 07:50
Change keyboard layout programatically and reload - kwin_wayland
# Go to Colemak
kwriteconfig6 --file kxkbrc --group Layout --key Model pc104awide
kwriteconfig6 --file kxkbrc --group Layout --key LayoutList us,bg
kwriteconfig6 --file kxkbrc --group Layout --key Options grp:alt_shift_toggle,grp:win_space_toggle,caps:backspace,lv3:ralt_switch_multikey,compose:menu
kwriteconfig6 --file kxkbrc --group Layout --key VariantList cmk_ed_dh,colemak_dh
dbus-send --session --type=signal --reply-timeout=100 --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig
# Back to QWERTY
@bojidar-bg
bojidar-bg / unsilence.sh
Last active March 15, 2024 14:33
Unsilence w/ MLT
#!/usr/bin/env bash
set -e
if [ "$#" -ne 4 ]; then
echo "Usage: $0 source-file silencedetect-args speedup-factor output-file"
echo " E.g.: $0 file.mkv n=-35dB:d=0.25 2.5 file.mlt"
exit 1;
fi
@bojidar-bg
bojidar-bg / Connection.i
Last active December 29, 2023 13:47
Virtual machine interaction net bootstrap for https://inet.run/playground/
require "./SymbolMap.i" // Diamond imports don't work
// import { List, null } from "./List.i"
// import { del, delOut, dup, dupOut } from "./Generic.i"
type Edge
type Connection
node pos(
edge: Edge,
@bojidar-bg
bojidar-bg / Bin.i
Last active September 23, 2023 19:10
Binary type with addition and multiplication for interaction nets, https://inet.run/playground/
// Example usage:
// let bsix = b0(b1(b1(bend())))
// let nseven = add1(add1(add1(add1(add1(add1(add1(zero())))))))
// let bseven = ntob(nseven)
// eval @inspect(bmul(bsix, bseven)) // -> takes 75 steps; doing the same with Nat mul takes 123 steps
// Type defitinion
type Bin
title Minilens
author bojidar-bg
homepage github.com/kobuge-games/minilens2
tween_length 0.3
again_interval 0.1
realtime_interval 0.4
level_select
runtime_metadata_twiddling
norepeat_action
@bojidar-bg
bojidar-bg / README.md
Created September 6, 2022 18:00
Trilium -> TiddlyWiki converter & Pandoc WikiText writer

Status: WIP

This is a quick and dirty script + pandoc lua filter I used to import notes from Trilium into TiddlyWiki.

Usage instructions:

  1. Export root note from Trilium as HTML files in a ZIP (enter protected mode to export protected notes too).
  2. Extract the ZIP file to a directory.
  3. Put process.sh and write-wikitext.lua in the root directory.
  4. Edit process.sh to match your exported root note name (change "root" and "transformed-root").
  5. Edit write-wikitext.lua (line 93 and perhaps 95) to match your TiddlyWiki name.
@bojidar-bg
bojidar-bg / ObjectParameterConstructorConverter.cs
Last active November 12, 2020 18:51
JsonConverter for System.Text.Json with support for immutable classes, fields, and polymorphic types
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
// Via https://gist.github.com/bojidar-bg/8124db51da853384bd03f3fa0ef71a35
public class ObjectParameterConstructorConverter : JsonConverterFactory
@bojidar-bg
bojidar-bg / boxit-solver.js
Created June 18, 2020 00:37
BOXit solver
// This file is made available under the GPLv3 LICENSE
// For more info, see https://www.gnu.org/licenses/gpl-3.0.html
// Based on ideas presented in https://hatnix.itch.io/boxit
function main() {
// HGrid format:
// All whitespace is ignored.
// Other characters represent tuples of color and symbol
// Colors are [w]hite/[r]ed, [b]lue, [g]reen, [o]range/[y]ellow, [p]urple/pink