Skip to content

Instantly share code, notes, and snippets.

@axelbdt
axelbdt / crop_pdf_python.md
Created January 19, 2024 17:39
Crop a PDF with Python and PyPDF2
from PyPDF2 import PdfWriter, PdfReader

reader = PdfReader('Elixir in Action.pdf')
writer = PdfWriter()

A4_WIDTH = 7.36
A4_HEIGHT = 9.23

page = reader.pages[0]
@axelbdt
axelbdt / dashboard.clj
Created December 16, 2023 15:17 — forked from jacobobryant/dashboard.clj
Internal dashboard code being used in yakread.com
(ns com.yakread.report.dashboards
(:require [com.biffweb :as biff]
[clojure.string :as str]
[cheshire.core :as cheshire]))
(defn debug [x]
[:pre (with-out-str (biff/pprint x))])
;; slight modification of clojure.core/distinct
(defn distinct-by
@axelbdt
axelbdt / install_asdf_with_nix.md
Created April 11, 2023 14:10
How to Install asdf with Nix Home-manager

How to Install asdf with Nix Home-manager

  1. First, add asdf to the Nix configuration with the package named asdf-vm. Add the following line to your configuration.nix file:

    environment.systemPackages = with pkgs; [
      asdf-vm
    ];
@axelbdt
axelbdt / zero-to-catlab.md
Last active March 3, 2023 15:42
Zero to Catlab with Julia
@axelbdt
axelbdt / bqn-keyboard-layout-gnome.md
Last active November 19, 2022 16:33
How to set up BQN keyboard layout on GNOME

How to set up BQN keyboard layout on GNOME

Download the XKB configuration for bqn here, and place it whith the other layouts:

curl https://raw.githubusercontent.com/mlochbaum/BQN/master/editors/bqn
cp bqn /usr/share/X11/xkb/symbols/

Add an entry for BQN in evdev.xml

@axelbdt
axelbdt / django-postgresql-15.md
Last active April 26, 2024 08:03
# Django and PostgreSQL 15, the rules have changed

Django and PostgreSQL 15, the rules have changed

Postgres 15 is just out, and while there is a lot to love about this new release, you're in for a surprise if you try to set it up with Django following tutorials like this one.

The reason is stated in the release announcement:

Remove PUBLIC creation permission on the public schema (Noah Misch) The new default is one of the secure schema usage patterns that Section 5.9.6 has recommended...

Provided your web app doesn't access your database as a superuser (it shouldn't) and uses a dedicated user, it is not allowed to use the public schema anymore. You have to create one for this specific user, and the next section will