Skip to content

Instantly share code, notes, and snippets.

alias sed-get-between-comments='sed -n "/\/\//,/\/\//{/\/\//b;/\/\//b;p}"'
function sed-get-between-duplicate() {
sed -n '/'$1'/,/'$1'/{/'$1'/b;/'$1'/b;p}' $2
}
@salkin-mada
salkin-mada / TEENSY3_USB_DESCRIPTIONS.md
Last active May 11, 2021 00:34
You want Keyboard+Midi or Keyboard+Midi+Serial USB mode in platformio?
  • add these lines
    "USB_KEYBOARD_MIDI",
    "USB_KEYBOARD_MIDI_SERIAL",

to the BUILTIN_USB_FLAGS list in /home/$USER/.platformio/platforms/teensy/builder/frameworks/arduino.py

  • and add the following two elifs to /home/$USER/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_desc.h
#elif defined(USB_KEYBOARD_MIDI)
@salkin-mada
salkin-mada / fetch_computer_music_journals.sh
Created March 4, 2021 10:11
download all volumes of the computer music journal
#!/bin/bash
base_dir=computer_music_journals
download_count=0
mkdir -p $base_dir && cd $base_dir
for volume in {23..43}; do
mkdir -p "volume_$volume" && cd "volume_$volume"
for issue in {1..4}; do
if [[ $volume -eq 43 ]]
then
@salkin-mada
salkin-mada / gbs.sh
Last active February 28, 2021 14:05
fuzzy git branch switcher
function gbs() { sk --ansi -c 'git branch' --preview 'git branch --all' --bind 'enter:execute[git switch $(echo {} | sed "s/ //g" | sed "s/*//g")]+abort' }
@salkin-mada
salkin-mada / wif.sh
Last active December 1, 2020 03:27
skim iwctl func
function wif() {
local device=$(iwctl device list | awk '{print $1}' | rg w)
echo "using device: $device"
local cmd="iwctl station $device get-networks"
local pcmd="iwctl station $device show"
echo "scanning for networks"
iwctl station $device scan && iwctl station $device connect \
$(sk --ansi -c $cmd --preview $pcmd \
--bind 'enter:execute(echo {} | awk '"'"'{print $1}'"'"')+abort' \
--bind 'esc:execute(echo "user_closed_wif")+abort' \
@salkin-mada
salkin-mada / app_launcher_window_switcher.md
Last active January 1, 2024 07:27
fzf/skim app launcher + window switcher using kitty/alacritty

.

Here follows a simple example using sway. Scripts and locations can/should be modified for your needs and layout can be changed to whatever likings. export FZF / SKIM default envir vars can also change behavior in addition to local fzf/skim --flags during command or scripting will override defaults. Go nuts.

  • in sway/config
# Preferred application launcher
# fzf launcher
set $fzf_launcher kitty --config \"$HOME/.config/kitty/fzf-launcher.config\" --class fzf-launcher --detach
@salkin-mada
salkin-mada / skimcode.sh
Last active November 21, 2020 13:41
skim file content and edit with nvim
function skimcode() {
local cmd='rg -S -n --color=always "{}"'
local pcmd='export LINE_NR=$(echo {} | awk -F: '"'"'{print $2}'"'"') && echo {} | sed "s/:.*//" | xargs -d "\n" bat -f -H $LINE_NR'
sk --ansi -i -c $cmd --preview $pcmd \
--bind 'ctrl-e:execute[export LINE_NR=$(echo {} | awk -F: '"'"'{print $2}'"'"') && nvim +$LINE_NR $(echo {} | sed "s/:.*//")]' \
--bind 'enter:execute(echo {} | sed "s/:.*//")+abort'
}
alias skc='skimcode'
@salkin-mada
salkin-mada / plugins.lua
Created October 26, 2020 11:54
using packer.nvim
-- check if packer is installed (~/local/share/nvim/site/pack)
local packer_exists = pcall(vim.cmd, [[packadd packer.nvim]])
if not packer_exists then
if vim.fn.input("Hent packer.nvim? (y for yada)") ~= "y" then
return
end
local directory = string.format(
'%s/site/pack/packer/opt/',
@salkin-mada
salkin-mada / ssh-ify_repo.sh
Last active November 26, 2020 23:04
ssh-ify https clones
#!/usr/bin/zsh
server='github.com'
username='so-schön-ein-Benutzername'
repo_name=$(basename `git rev-parse --show-toplevel`)
old_origin=$(git remote -v | head -n 1 | awk '{print $2}')
echo "switching to ssh on repo $repo_name"
echo "old origin -> $old_origin"
echo "using -> @$server:$username/$repo_name.git"
@salkin-mada
salkin-mada / ûr″gə-nŏm′ĭks.scd
Created May 12, 2020 21:24
spwan ûr″gə-nŏm′ĭks
( // Spwan ûr″gə-nŏm′ĭks
fork{
s.volume_(-6);
Convenience.crawl(Platform.recordingsDir);
~ergo_bus = Bus.audio(s,2);
SynthDef('Zzzz', {
|
bufnum, out = 0, loop = 0, rate = 1, pan = 0, spread = 0.5, width = 2, amp = 0.5,
attack = 0.01, sustain = 0.5, release = 1.0, pos = 0,
gate = 1, cutoff = 22e3, res = 0.01, fgain = 1.0, ftype = 0, bass = 0.0