Skip to content

Instantly share code, notes, and snippets.

View hilbix's full-sized avatar
🐢
I may be slow to respond.

Valentin Hilbig hilbix

🐢
I may be slow to respond.
View GitHub Profile
@hilbix
hilbix / installheadlessfirefoxonpi.sh
Created February 17, 2024 06:52 — forked from nestukh/installheadlessfirefoxonpi.sh
Install firefox-esr + geckodriver + selenium + python3 on raspberry pi 3 and above
#!/bin/bash
pypcks="python3-pip python3 python3-all-dev python3-dev libffi-dev libssl-dev librtmp-dev python-dev python3 python3-doc python3-tk python3-setuptools tix xvfb python-bluez python-gobject python-dbus python cython python-doc python-tk python-numpy python-scipy python-qt4 python3-pyqt5 python3-pyqt5.q* python3-qtpy python-pyqt5.q* python-lxml fontconfig python-demjson qt5-default libqt5webkit5-dev build-essential libudev-dev python-lxml libxml2-dev libxslt-dev libpq-dev python-pyside python-distlib python-pip python-setuptools" # python-examples python3-examples python-vte
allgoodpcks="ca-certificates virtualenv autotools-dev cdbs git expect libnss3-tools util-linux xvfb curl bridge-utils chromium-browser chromium-chromedriver firefox-esr"
sudo apt-get install --reinstall -y $pypcks $allgoodpcks
if [[ ! -f /usr/lib/chromium-browser/chromedriver ]]; then
sudo ln -s /usr/bin/chromedriver /usr/lib/chromium-browser/chromedriver
fi
@hilbix
hilbix / backup.sh
Created May 15, 2023 08:40
Borg Backup Script
#!/bin/bash
# vim: ft=bash
#
# borg init -enone `hostname -f`
STDOUT() { printf '%q' "$1"; printf ' %q' "${@:2}"; printf '\n'; }
STDERR() { local e=$?; STDOUT "$@" >&2; return $e; }
OOPS() { STDERR OOPS: "$@"; exit 23; }
x() { "$@"; STDERR exec $?: "$@"; }
o() { x "$@" || OOPS fail $?: "$@"; }
@hilbix
hilbix / deswappify.pl
Last active December 18, 2020 21:44 — forked from Someguy123/deswappify.pl
#!/usr/bin/perl
use strict;
use Fcntl qw(SEEK_SET);
sub deswappify {
my $pid = shift;
my $fh = undef;
my $start_addr;
// I recently saw http://davidwalsh.name/detect-native-function tweeted by
// @elijahmanor and was pretty jazzed about it. One of my favorite JS tricks is
// detecting native methods. Detecting native methods is handy because third
// party code can shim methods incorrectly as seen in past versions of
// Prototype.js, es5-shim, & modernizr, which can cause your code to behave in
// unexpected ways. This isn't a knock against those projects, shimming is really
// really hard to get right. Shimmed methods may also lack the performance
// benefits of their native counterparts. Lo-Dash, Dojo, Ember, & YUI,
// to name a few, detect native methods to avoid shims and rely on their own
// fallback paths, trusting their code over third-party.
@hilbix
hilbix / keybase.md
Last active October 27, 2020 20:20
keybase.io

Keybase proof

I hereby claim:

  • I am hilbix on github.
  • I am hilbix (https://keybase.io/hilbix) on keybase.
  • I have a public key ASCx_F6R2C8_UowExr0c1ZZ6Fp37u8N3Jb0EjAoUWYNoUQo

To claim this, I am signing this object:

@hilbix
hilbix / default.conf
Created February 3, 2020 12:40
NginX HTTP -> HTTPS redirection with LetsEncrypt
server {
server_tokens off;
server_name _;
listen 80 default_server;
listen [::]:80 default_server;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
access_log /var/log/nginx/access.log;
@hilbix
hilbix / fix-broken.sh
Last active July 12, 2019 22:08
Helper to fix broken "apt-get install -f", which might happen when upgrading from i386 to amd64
#!/bin/bash
#
# Public Domain
#
# If you follow https://wiki.debian.org/CrossGrading you might get stuck
# at the "apt-get install -f" step. Either you are doomed, or use this script here.
#
# Just run it to find out the troublesome :i386 packages.
# Then paste those packagenames to the script here to install the amd64 counterpart.
# Or press just return to run "apt-get install -f",
@hilbix
hilbix / update-yarn-key.sh
Created March 24, 2019 19:07
Safely update apt's yarn GPG key
#!/bin/bash
STDOUT() { local e=$?; printf '%q' "$1"; [ 1 -lt $# ] && printf ' %q' "${@:2}"; printf '\n'; return $e; }
STDERR() { STDOUT "$@" >&2; }
OOPS() { STDERR OOPS: "$@"; exit 23; }
x() { "$@"; }
o() { x "$@" || OOPS fail $?: "$@"; }
ID=72ECF46A56B4AD39C907BBB71646B01B86E50310
RING=/etc/apt/trusted.gpg.d/yarnpkg.gpg
@hilbix
hilbix / debug.inc
Created September 2, 2018 15:52
No-Brainer function to debug with `gdb` from shell level
# This function keeps IO redirection and commandline arguments
# when you want to debug some executable.
#
# Just type "debug" in front of the call:
# "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three)
# debug "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three)
#
# All you need is a /dev/tty
debug()
@hilbix
hilbix / googleauth.php
Last active July 8, 2018 09:02
PHP RFC4648-base32 to hex conversion for Google Authenticator
# $key = hex2bin(rfc4648tohex('AAAAAAAAAAAAAAAA')); # Your secret Auth-Key
# $token = googleauth($key, floor(time()/30));
function googleauth($key, $stamp)
{
$mac = hash_hmac('SHA1', substr(chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).pack('N', floor($stamp)),-8), $key, true);
$val = unpack('N', substr($mac, (ord(substr($mac, -1)) & 15), 4));
$val = $val[1]&0x7fffffff;
return substr("000000$val", -6);
}