Skip to content

Instantly share code, notes, and snippets.

@mkroman
mkroman / pupdiff
Created Aug 2, 2021
Simple script that fetches a page and extracts a css selector element and compares it with a cached version
View pupdiff
#!/usr/bin/env bash
#
# This is a simple script that fetches the page from a given url and extracts a
# specific element using a CSS selector and compares it with the last invocation
# of this command with the same arguments.
#
# Some requests might not actually be HTML, but pup will parse it as HTML as if
# it had a body regardless, so one can still use the "body" css selector for
# non-html files.
#
View gist:188b9253ed35bcd3d6c7d00fc43f4882
… tons of calls
prlimit64(0, RLIMIT_AS, {rlim_cur=150000000, rlim_max=307200*1024}, NULL) = 0
futex(0x7f5171126048, FUTEX_WAKE_PRIVATE, 2147483647) = 0
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
statx(AT_FDCWD, ".", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
statx(AT_FDCWD, "servers", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
statx(AT_FDCWD, "servers", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
openat(AT_FDCWD, "servers", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(3, "", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_EMPTY_PATH) = 0
View generate_compile_commands.py
#!/usr/bin/env python
# This scripts generates and makes changes to `compile_commands.json` in order
# to make it work with coc-clangd without throwing a fit
import os
import json
import shlex
import subprocess
project_root = os.path.join(os.path.dirname(__file__), '..')
View digest-sha256-file-vs-system-sha256sum.rb
mk@… ~/Projects/Sandbox % cat digest-sha256-file-vs-system-sha256sum.rb
#!/usr/bin/env ruby
require 'tempfile'
require 'digest/sha2'
require 'benchmark/ips'
file = Tempfile.new 'testfile'
file.write 'a' * 1024 * 1024 * 2
View upgrade-bittorrent.sh
#!/usr/bin/env bash
# Downloads, compiles and installs qBittorrent.
# The qBittorrent version to download
version=$1
# The libtorrent-rasterbar version to download
lt_version="1.1.11"
# ./configure arguments for qBittorrent
configure_args="--disable-gui"
View gist:982126772859ef8572143e0f536bae9b
### Keybase proof
I hereby claim:
* I am mkroman on github.
* I am mkn (https://keybase.io/mkn) on keybase.
* I have a public key ASCrhe5_SFps_vD4R2FymT1GO4FaLiem42hHRIyuPtDFGgo
To claim this, I am signing this object:
View Install docker on Debian Stretch.sh
#!/bin/bash
sudo apt-get remove docker docker-engine docker.io
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
View kino-danske-film-paa-vej.json
{"_id":"kino-danske-film-paa-vej","startUrl":"http://www.kino.dk/film-paa-vej?genre=20","selectors":[{"parentSelectors":["_root","pagination"],"type":"SelectorElement","multiple":false,"id":"movies-list","selector":"ul.movies-list","delay":""},{"parentSelectors":["movies-list"],"type":"SelectorElement","multiple":true,"id":"movie-parent","selector":"li.grid3","delay":""},{"parentSelectors":["movie-parent"],"type":"SelectorImage","multiple":false,"id":"image","selector":"img.imagecache","downloadImage":false,"delay":""},{"parentSelectors":["movie-parent"],"type":"SelectorLink","multiple":false,"id":"title","selector":"h2 a","delay":""},{"parentSelectors":["movie-parent"],"type":"SelectorText","multiple":false,"id":"one-liner","selector":"div.movie-list-one-liner","regex":"","delay":""},{"parentSelectors":["movie-parent"],"type":"SelectorText","multiple":false,"id":"premiere-date","selector":"div.movies-list-inner-wrap div:nth-of-type(2)","regex":"","delay":""},{"parentSelectors":["_root"],"type":"SelectorLink"
View recover-veracrypt.sh
#!/bin/sh
password_file=$1
container_file=$2
if [ $# -ne 2 ]; then
echo "Usage: $0 <password_file> <container_file>"
exit 1
fi
View folketal-2016.csv
year city men women
2016 København 292245 299236
2016 Frederiksberg 49374 55107
2016 Dragør 6927 7215
2016 Tårnby 21168 21692
2016 Albertslund 13927 13953
2016 Ballerup 23601 24623
2016 Brøndby 17333 17989
2016 Gentofte 35748 39602
2016 Gladsaxe 33533 34381