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
  • 06:49 (UTC +02:00)
  • LinkedIn in/antonfriberg
View GitHub Profile
@AntonFriberg
AntonFriberg / README.md
Last active January 14, 2022 11:33
Access parquet files from S3 using ClickHouse

Parquet files from s3 using ClickHouse

Accessing the prompt

Start the clickhouse-client and connect it to your ClickHouse Server.

$ clickhouse-client --host=<host> --port=<port> --user=<user> --password=<password>

You should be greated by the ClickHouse prompt

ClickHouse client version 21.12.3.32 (official build).
@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 / 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 / Dockerfile
Last active July 10, 2023 08:50
Simple docker cron sidecar container based on alpine image
FROM alpine:3.8
# Alpine comes with built in cron schedules
# min hour day month weekday command
# */15 * * * * run-parts /etc/periodic/15min
# 0 * * * * run-parts /etc/periodic/hourly
# 0 2 * * * run-parts /etc/periodic/daily
# 0 3 * * 6 run-parts /etc/periodic/weekly
# 0 5 1 * * run-parts /etc/periodic/monthly
@AntonFriberg
AntonFriberg / create_event_from_email.gs
Created July 14, 2023 15:24
Create Event from Booking Email using Google App Scripts
// What to add to the parsed ISO date to get it in correct timezone
TZ_POSTFIX = 'T00:00:00+02:00';
// Email subjects to look at
SUBJECT_NEW_BOOKING = 'New Booking - Some Service';
// Matches '2023-07-14 00:00 - 2023-07-14 00:00' like strings with groups for each date
DATE_RANGE_PATTERN = new RegExp('(\\d{4}-\\d{2}-\\d{2}) 00:00 - (\\d{4}-\\d{2}-\\d{2}) 00:00');
// Regex patterns to extract other content such as name, apartment, email
NAME_PATTERN = new RegExp('<td>Name:<\\/td>[\\n\\s]+<td>(.*)<\\/td>');
APARTMENT_PATTERN = new RegExp('<td>Apartment:<\\/td>[\\n\\s]+<td>(.*)<\\/td>');
EMAIL_PATTERN = new RegExp('<td>Email:<\\/td>[\\n\\s]+<td>(.*)<\\/td>');
@AntonFriberg
AntonFriberg / fonts.conf
Created May 28, 2020 17:00
Fix ugly Calibri, Cambria font rendering on Linux
<!-- Add this to your font configuration e.g ~/.config/fontconfig/fonts.conf -->
<!-- Note that this will disable all embedded bitmaps in fonts that use them -->
<!-- disable embedded bitmaps in fonts to fix Calibri, Cambria, etc. -->
<match target="font">
<edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>
</match>
@AntonFriberg
AntonFriberg / install-swerty-altgr-working.md
Last active October 17, 2023 15:39
Swerty Keyboard Layout with working Alt-Gr on Linux Debian 10

Background

The Swerty keyboard layout is created by Johan E. Gustafsson and hosted on http://johanegustafsson.net/projects/swerty/

Swerty is released under the MIT Licence.

Since I spend a lot of time getting the right alt-gr key to work I decided to share back my fixes.

Installation

@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 / 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