This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Switch to the window associated by the command, or start it | |
#{{{ Bash settings | |
# abort on nonzero exitstatus | |
set -o errexit | |
# abort on unbound variable | |
set -o nounset | |
# don't hide errors within pipes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These gists are in the process of being moved to https://brain.vandragt.com/books/code-snippets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#{{{ Bash settings | |
# abort on nonzero exitstatus | |
set -o errexit | |
# abort on unbound variable | |
set -o nounset | |
# don't hide errors within pipes | |
set -o pipefail | |
#}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#{{{ Bash settings | |
# abort on nonzero exitstatus | |
set -o errexit | |
# abort on unbound variable | |
set -o nounset | |
# don't hide errors within pipes | |
set -o pipefail | |
#}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#{{{ Bash settings | |
# abort on nonzero exitstatus | |
set -o errexit | |
# abort on unbound variable | |
set -o nounset | |
# don't hide errors within pipes | |
set -o pipefail | |
#}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# hideothers.sh | |
active_window_id=$(xdotool getactivewindow) | |
for window_id in $(xdotool search --onlyvisible ".*") | |
do | |
if [ $window_id != $active_window_id ] | |
then | |
wname=$(xdotool getwindowname $window_id) | |
if [ "$wname" != "" ] && [ "$wname" != "plank" ] && [ "$wname" != "io.elementary.wingpanel" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Replaces a file with a symlink, pointing to the path-preserving backup, unique per hostname. | |
version 2022-09-27 | |
""" | |
import os | |
import sys | |
import shutil | |
import socket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// won't be incremented | |
$a = [ | |
0, | |
0, | |
]; | |
// !! will be incremented !! | |
$b = [ | |
(object)['count' => 0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "byebug", "~> 11.1", :groups => [:development, :test] | |
gem "rss", "~> 0.2.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# v2021-12-24.1 | |
require 'sqlite3' | |
dbf = '/tmp/plan.db' | |
File.delete(dbf) if File.exists? dbf | |
db = SQLite3::Database.open dbf | |
db.results_as_hash = true | |
db.execute "CREATE VIRTUAL TABLE IF NOT EXISTS plan USING FTS5(contents,tokenize = porter)" | |
db.execute "INSERT INTO plan (contents) VALUES(?)", File.open(ARGV[0]).read |