Skip to content

Instantly share code, notes, and snippets.

View inscapist's full-sized avatar

Felx inscapist

  • Penang, Malaysia
View GitHub Profile
@inscapist
inscapist / .xinitrc
Last active April 22, 2024 21:20
Nvidia and Xorg on Void Linux
xset r rate 250 60
setxkbmap -option caps:escape
xbacklight -set 10
# paired with `Xft.dpi: 144`
export GDK_DPI_SCALE=1.4
if [ -z "${XDG_RUNTIME_DIR}" ]; then
export XDG_RUNTIME_DIR=/tmp/${USER}-runtime-dir
if [ ! -d "${XDG_RUNTIME_DIR}" ]; then
@inscapist
inscapist / docker-compose.yml
Last active April 10, 2024 11:32
Pi-Hole + unbound + tailnet search domain (Void linux)
#version: "3"
# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
network_mode: "host"
# For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
environment:
@inscapist
inscapist / flake-direnv.md
Last active December 13, 2023 00:05
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

@inscapist
inscapist / trigger.sql
Created May 2, 2023 08:38
Postgres trigger for all table changes (inserts, updates)
CREATE TABLE audit_log (
id SERIAL PRIMARY KEY,
schema_name TEXT NOT NULL,
table_name TEXT NOT NULL,
operation CHAR(1) NOT NULL,
new_data JSONB,
old_data JSONB,
changed_at TIMESTAMP NOT NULL,
changed_by TEXT
);
@inscapist
inscapist / qrgen.nim
Created July 12, 2023 15:19
QR code generator using Nim
import QRgen
import QRgen/renderer
import pkg/[pixie]
import os
# Create a new QR code
let qr = newQR("https://github.com/aruZeta/QRgen", ecLevel=qrECH)
# Generate the QR code
@inscapist
inscapist / keybindings.md
Last active June 11, 2023 14:08
VSCode omni-navigation with ctrl-hjkl (window navigation), ctrl-n/p (list navigation), cmd-hjkl (tab navigation)
[
  // ===================================================
  // window navigation
  {
    "key": "ctrl+h",
    "command": "workbench.action.navigateLeft"
  },
  {
    "key": "ctrl+l",
@inscapist
inscapist / .gitlab-ci.yaml
Created July 25, 2018 13:47
docker in docker
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- release
variables:
CONTAINER_IMAGE: registry.anuary.com/$CI_PROJECT_PATH
DOCKER_DRIVER: overlay2
@inscapist
inscapist / ANSI.md
Created November 3, 2022 14:46 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@inscapist
inscapist / tailwind.cljs
Last active November 15, 2022 00:36
ChakraUI inspired tailwind *layouts*, in reagent/hiccup
(ns myapp.tailwind
(:require
[clojure.spec.alpha :as s]
[clojure.string :as str]
[vl.config :as config]))
(s/def ::class (s/or :string string? :vector vector?))
(s/def ::cs sequential?) ;; shorthand for classes
(s/def ::dim #{:screen :fill :h :vh :w :vw})
(s/def ::position #{:x-center :y-center :center}) ;; position utils for relative elements
@inscapist
inscapist / fixpoint.nix
Created October 21, 2022 14:53
Fixpoint
{ lib, ... }:
rec {
# Compute the fixed point of the given function `f`, which is usually an
# attribute set that expects its final, non-recursive representation as an
# argument:
#
# f = self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; }
#
# Nix evaluates this recursion until all references to `self` have been
# resolved. At that point, the final result is returned and `f x = x` holds: