Skip to content

Instantly share code, notes, and snippets.

Avatar
🎻
practicing

Raitis Veinbahs siers

🎻
practicing
View GitHub Profile
@siers
siers / .gitignore
Last active Oct 22, 2020
my megasec parsers
View .gitignore
dist
.stack-work
@siers
siers / downloadupdates.sh
Created Oct 4, 2016
The diff from a local fork of checkupdates that downloads latest packages so you can start upgrading on the minute's whim
View downloadupdates.sh
# diff /usr/bin/checkupdates ~/downloadupdates
107,108c107,108
< fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null
< pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
---
> pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null
> pacman -Suw --dbpath "$CHECKUPDATES_DB" --noconfirm
# crontab -l | grep downloadupdates
* * * * * ~root/downloadupdates
View mount-propagation-showcast.sh
#!/bin/bash
more="$@"
saved="$EUID"
if [ "$EUID" = "0" ]; then
echo "don't run as root"
exit
fi
@siers
siers / wait-while-idle.rb
Created Sep 8, 2016
Wait while xprintidle increases predictably thereby waiting until activity has been observed in the xorg
View wait-while-idle.rb
#!/usr/bin/env ruby
if %x{type xprintidle &> /dev/null; echo $?}.strip == '1'
raise 'xprintidle not found'
end
def idle
%x{xprintidle}.to_i
end
@siers
siers / print-all-synchronized-files.rb
Last active Jan 30, 2017
Print all files synchronized with syncthing.
View print-all-synchronized-files.rb
#!/usr/bin/env ruby
require 'json'
if ARGV.length == 0
puts "usage: $0 '?folder=$FOLDERID'"
exit
end
key = %x{grep -Po '(?<=<apikey>)[^<]+' ~/.config/syncthing/config.xml}.strip
@siers
siers / collect-times
Last active Dec 16, 2015
Vim startup time profiler
View collect-times
#!/bin/bash
while sleep 0.5; do vim --startuptime "$@" >(./startup-info) +qall; done
# usage: ./collect-times
# Running this will collect startup times in `times' directory.
# It will run it multiple times so that the averages start converging.
# Whenever you remove a plugin, it gets stored as a different version,
# which will be shown at 'watch ./watcher'.
@siers
siers / plot
Created Dec 11, 2015
Plot the active hours of an IRC channel based on your own logs.
View plot
#!/bin/sh
# usage: n=$(pwd); cd ~/.weechat/logs; cp $n/{plot,activity} .; ./plot *math.weechatlog
# Be aware that if your client's not receiving messages 24/7,
# some hours will not receive coverage or some might be underrepresented.
# Furthermore, using a bouncer with a long scrollback will create pikes.
! [ -z "$1" ] && (tail -n100000 "$1" | ./activity > data)
[ -e data ] && gnuplot -p -e \
@siers
siers / nap.rb
Last active Apr 30, 2017
a more natural alarm clock command line interface
View nap.rb
#!/usr/bin/env ruby
require 'time'
def die(str)
$stderr.puts str
exit
end
def usage
@siers
siers / demo
Created Jun 28, 2015
Extracts paragraphs to lines in files to allow generic operations be used
View demo
demo % cat file
1. Chox4ez9
Oov5iedeiF
ea7eapheeR
2. tu0ahTho
sheit5Kash
aiHiewae1i
3. Gau2Jesu
View git-stack-log.sh
#!/bin/sh
stashes() {
git stash list | sed "s/:.*//" | tr '\n' ' '
}
for s in $(stashes); do
git log -1 --format=short "$s" | cat
echo
git stash show -u "$s" | cat