Skip to content

Instantly share code, notes, and snippets.

View remvee's full-sized avatar

Remco van 't Veer remvee

  • 52°N, 5°E
View GitHub Profile
@remvee
remvee / md5.sql
Created September 21, 2020 09:47
MD5 sum a query result in PostgreSQL
SELECT md5(array_agg((t.*)::varchar)::varchar)
FROM (
SELECT users.*, departments.name FROM users INNER JOIN departments.id ON users.department_id
) as t;
@remvee
remvee / text.clj
Created July 30, 2020 15:32
Transliterate latin diacritics to ascii.
(let [trans {#"[ÁĂÂÄÀĀĄÅÃ]" "A"
#"[áăâäàāąåã]" "a"
#"Æ" "AE"
#"æ" "ae"
#"[ĆČÇĈĊ]" "C"
#"[ćčçĉċ]" "c"
#"[ĎĐ]" "D"
#"[ďđ]" "d"
#"[ÉĔĚÊËĖÈĒĘÐ]" "E"
#"[éĕěêëėèēęð]" "e"
@remvee
remvee / bsn.rb
Created February 5, 2020 11:20
Rails BSN (burgerservicenummer) validator
module BSN
# https://nl.wikipedia.org/wiki/Burgerservicenummer#11-proef
def valid?(val)
num = val.to_s.scan(/\d/).join.to_i
return false if num == 0
digits = ("%09d" % num).split(//).map(&:to_i).reverse
return false unless digits.size == 9
digits[0] = -digits[0]
@remvee
remvee / site.conf
Created October 7, 2019 08:16
Apache proxy HTTPS to HTTPS
<VirtualHost *:80>
ServerName app.example.com
RewriteEngine On
RewriteRule ^(.*)$ https://app.example.com$1 [L,R=301]
</VirtualHost>
<VirtualHost *:443>
ServerName app.example.com
SSLEngine on
@remvee
remvee / arch-linux-install
Last active April 6, 2020 13:02 — forked from binaerbaum/arch-linux-install
Minimal instructions for installing arch linux on an UEFI NVMe system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# This assumes a wifi only system...
@remvee
remvee / code.clj
Created December 12, 2018 19:33 — forked from skuro/forkme.md
Advent of Clojure solutions
(ns adv.code)
(defn lookup-seq [x i]
(lazy-seq (cons x (lookup-seq (+ i x) (inc i)))))
(defn lookup [x y]
(let [start (nth (lookup-seq 1 1) (dec y))]
(nth (lookup-seq start (inc y)) (dec x))))
(defn val-seq [v]
@remvee
remvee / Description.md
Created July 31, 2017 14:39 — forked from juanje/Description.md
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@remvee
remvee / keybase.md
Created August 17, 2016 05:18
keybase.md

Keybase proof

I hereby claim:

  • I am remvee on github.
  • I am rwv (https://keybase.io/rwv) on keybase.
  • I have a public key whose fingerprint is 7339 9648 1AC6 BAA8 B91D 9D58 1B46 31D4 12F6 0E29

To claim this, I am signing this object:

#!/bin/sh
#
# Monitor hotplug for my Thinkpad X240 / Arch Linux / AwesomeWM setup.
#
# Create /etc/udev/rules.d/99-monitor-hotplug.rules with following content:
#
# ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/home/me/bin/monitor-hotplug"
touch /tmp/monitor-hotplug.log
chmod a+w /tmp/monitor-hotplug.log
require 'net/http'
class GoogleMapsImage
class << self
attr_writer :api_key
def get(lat, long, options = {})
options = {width: 500, height: 500}.merge(options)
key = [lat, long, options]