Skip to content

Instantly share code, notes, and snippets.

View siers's full-sized avatar
:octocat:

Raitis Veinbahs siers

:octocat:
View GitHub Profile
@siers
siers / ss-parse.rb
Created July 30, 2019 21:38
dumb, simple ss.com scraper for displaying notifications on diffs
#!/usr/bin/env ruby
script = <<-EOF
ccurl() {
curl -b cookie.txt -c cookie.txt "$@"
}
ccurl 'https://www.ss.com/lv/real-estate/flats/riga/agenskalns/filter/' -H 'authority: www.ss.com' -H 'cache-control: max-age=0' -H 'origin: https://www.ss.com' -H 'upgrade-insecure-requests: 1' -H 'content-type: application/x-www-form-urlencoded' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://www.ss.com/lv/real-estate/flats/riga/agenskalns/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' &> /dev/null || exit
ccurl 'https://www.ss.com/lv/real-estate/flats/riga/agenskalns/filter/fDgSeF4belI=.html' -H 'authority: www.ss.com' -H 'cache-control: max-age=0' -H 'origin: https://www.ss.com' -H 'upgrade-insecure-requests: 1' -H 'conte
@siers
siers / redecorate.py
Created July 17, 2018 10:56
recursive chown uid/guid mapping for migrating ownership to LDAP
#!/usr/bin/env python
# recursive chown uid/guid mapping for migrating files' owners to
# the new LDAP ids by matching users' duplicate names in /etc/passwd and
# treating the upper ones (from `getent passwd` list) as the real ones
# Created around January, 2017
# raitis.veinbahs.lv
# This file may be freely used, modified, copied and repurposed. Public domain.
#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides: dockercompose
# Required-Start: $docker
# Required-Stop: $docker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Docker Services
### END INIT INFO
@siers
siers / .gitignore
Last active October 22, 2020 20:53
my megasec parsers
dist
.stack-work
@siers
siers / downloadupdates.sh
Created October 4, 2016 14:36
The diff from a local fork of checkupdates that downloads latest packages so you can start upgrading on the minute's whim
# 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
@siers
siers / mount-propagation-showcast.sh
Last active June 3, 2017 16:39
Overlayfs example
#!/bin/bash
more="$@"
saved="$EUID"
if [ "$EUID" = "0" ]; then
echo "don't run as root"
exit
fi
@siers
siers / wait-while-idle.rb
Created September 8, 2016 10:39
Wait while xprintidle increases predictably thereby waiting until activity has been observed in the xorg
#!/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 January 30, 2017 16:11
Print all files synchronized with syncthing.
#!/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 December 16, 2015 12:15
Vim startup time profiler
#!/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 December 11, 2015 13:56
Plot the active hours of an IRC channel based on your own logs.
#!/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 \