Skip to content

Instantly share code, notes, and snippets.

View AntonFriberg's full-sized avatar
🕹️
Automating database migrations

Anton Friberg AntonFriberg

🕹️
Automating database migrations
  • Axis Communications
  • Lund, Sweden
  • 09:51 (UTC +02:00)
  • LinkedIn in/antonfriberg
View GitHub Profile
@AntonFriberg
AntonFriberg / pyproject.after.toml
Last active April 7, 2020 14:30
bug report pyproject.toml
[tool.poetry]
name = "application"
version = "1.0"
description = "An application."
authors = ["Anton Friberg <anton.friberg@example.com>"]
readme = "README.md"
[tool.poetry.scripts]
# Allow default command line entrypoint https://stackoverflow.com/a/55065934
etl = "etl.__main__:cli"
@AntonFriberg
AntonFriberg / respect_xorg_conf.md
Created March 11, 2020 14:06 — forked from JonasAlfredsson/respect_xorg_conf.md
Make Cinnamon/Gnome respect the /etc/X11/xorg.conf file instead of ~/.config/displays.xml

Make Cinnamon/Gnome/Mate Respect xorg.conf

By default the Cinnamon/Gnome/Mate desktop environment loads its own display configuration from the file ~/.config/monitors.xml instead of using the settings defined in /etc/X11/xorg.conf. This can be a little bit annoying if you are using the nvidia-settings program to configure your displays (which will use xorg.conf), since anything entered there will be overridden by monitors.xml every reboot.

By doing the following changes we will disable the "Display Manager" in

@AntonFriberg
AntonFriberg / test_partition_extract.py
Created December 4, 2019 12:15
S3 partition extraction in Python
import re
regex = r"(year|month|day|hour)=(\d+)"
test_str = "s3://bucket/datalake/year=2019/month=12/day=02/hour=06"
matches = re.finditer(regex, test_str)
partition = {match.group(1): int(match.group(2)) for match in matches}
print(partition)
# {'year': 2019, 'month': 12, 'day': 2, 'hour': 6}
@AntonFriberg
AntonFriberg / parse_key_value_pairs.py
Last active October 18, 2023 15:20
Extract key value pairs from string with quotes in Python 3
"""Extract key value pairs in Python 3 using shlex and regex."""
import re
import shlex
def regex_kv_pairs(text, item_sep=r"\s", value_sep="="):
"""
Parse key-value pairs from a shell-like text with regex.
This approach is ~ 25 times faster than the shlex approach.
@AntonFriberg
AntonFriberg / about:config
Created May 10, 2019 13:11
Fix Firefox right-click menu with i3 Window Manager
ui.context_menus.after_mouseup=true
@AntonFriberg
AntonFriberg / README.md
Created May 3, 2019 15:08
Polybar install on Debian Stretch

Polybar install on Debian Stretch

Install dependencies including libxcb-composite0-dev which is sometimes not mentioned.

$ sudo apt-get install cmake cmake-data libcairo2-dev libxcb1-dev libxcb-ewmh-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-randr0-dev libxcb-util0-dev libxcb-xkb-dev pkg-config python-xcbgen xcb-proto libxcb-xrm-dev i3-wm libasound2-dev libmpdclient-dev libiw-dev libcurl4-openssl-dev libpulse-dev libxcb-composite0-dev

Clone the official [Polybar repository].

@AntonFriberg
AntonFriberg / start_info.sh
Last active May 22, 2023 21:36
Two Chrome Kiosk Screens Autodeployed on Debian Gnome
#!/bin/bash
APP1=https://google.com
APP1NAME=Google
APP2=https://bing.com
APP2NAME=Bing
# Set correct display to launch the windows over ssh connection
export DISPLAY=:0
# Fixes autologin errors under gnome
@AntonFriberg
AntonFriberg / eduroam.sh
Created September 6, 2018 09:40
Connect to eduroam on Lund University with NetworkManager
nmcli con add \
type wifi \
con-name "eduroam"
ifname "wlp4s0" \ # Your wifi interface
ssid "eduroam" \
wifi-sec.key-mgmt "wpa-eap" \
802-1x.identity "<YOUR-STUDENT-ID>@lu.se" \ # May also use another university identification
802-1x.password "<YOUR-PASSWORD" \
802-1x.system-ca-certs "yes" \
802-1x.domain-suffix-match "radius.lu.se" \
@AntonFriberg
AntonFriberg / asian_characters.md
Last active February 7, 2024 18:40
Asian Characters ArchLinux

In order to get Asian Characters to render properly on ArchLinux you need to install a font which supports them. Even if you cannot read any of the characters I find it useful to have them installed to get wikipedia articles on geographical locations to render properly.

In order to cover most of Asia I installed the following fonts:

  • adobe-source-han-serif-cn-fonts
  • adobe-source-han-serif-jp-fonts
  • adobe-source-han-serif-kr-fonts
@AntonFriberg
AntonFriberg / deploy_minikube.sh
Last active August 1, 2018 13:10
Minikube install using kvm2 behind coorporate proxy on Debian stretch
#!/bin/sh
set -e
KUBECTL_VERSION="v1.11.1"
MINIKUBE_VERSION="v0.28.2"
echo "Installing kubectl $KUBECTL_VERSION and minikube $MINIKUBE_VERSION"
echo "Setting proxy settings including minikube ip range"
export no_proxy=localhost,127.0.0.1,192.168.0.0/16,.internaldomain.biz
export NO_PROXY=$no_proxy