Skip to content

Instantly share code, notes, and snippets.

@mkroman
mkroman / op-env.sh
Last active June 2, 2022 02:27
Prepare a shell environment with help from a 1Password vault
# Prepare a shell environment with help from a 1Password vault
#
# Prepares a shell environment by reading the `script` field from an item with
# the given NAME inside the `Environments` vault and then evaluating it in the
# current shell after injecting 1Password references.
#
# Usage:
#
# op-env <NAME>
#
@mkroman
mkroman / pupdiff
Created August 2, 2021 01:37
Simple script that fetches a page and extracts a css selector element and compares it with a cached version
#!/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.
#
… 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
#!/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__), '..')
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
#!/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"
### 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:
#!/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
{"_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"
#!/bin/sh
password_file=$1
container_file=$2
if [ $# -ne 2 ]; then
echo "Usage: $0 <password_file> <container_file>"
exit 1
fi