Skip to content

Instantly share code, notes, and snippets.

View inscapist's full-sized avatar

Felx inscapist

  • Penang, Malaysia
View GitHub Profile
@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 / .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 / 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 / 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 / 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 / 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:
@inscapist
inscapist / openssl.zsh
Last active October 20, 2022 02:28
Openssl helper functions (WIP)
# args:
# $1. server_name assuming SNI (eg. sub.domain.com)
# $2. endpoint (eg. IP_ADDR:8443 or sub.domain.com:443)
function tlscert-check() {
echo | \
openssl s_client -servername $1 -connect $2 2>/dev/null | \
openssl x509 -text -noout
}
function tlscert-list-kube() {
@inscapist
inscapist / p_np_np_complete.md
Last active September 16, 2022 03:23
P, NP, NP Complete (note to self)

Preamble

First, we can check the time needed to complete the following algorithm class:

  1. O(N) -> say it requires 1 second to process N=100
  2. O(N^3) -> 3 nested loops -> now requires N^3=1000000/100 * 1_second = 10000 seconds = ~ 3 hours
  3. O(2^N) -> N levels (binary tree) of computations -> 2^N = 1.26e+30 seconds
  4. O(n!) -> N levels (of increasing branches, 1x2x3x...xN) of computations -> 9.332622e+157 seconds

All about P

@inscapist
inscapist / xorg.conf
Created August 29, 2022 01:57
Xorg config for alienware x15 (Nvidia Prime Render Offload)
# https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-en-4/s1-x-server-configuration.html
Section "ServerLayout"
Identifier "layout"
Screen 0 "laptopscreen"
Option "AllowNVIDIAGPUScreens"
EndSection
Section "Device"
# Option "PrimaryGPU" "no"
# BusID "PCI:1:0:0"
@inscapist
inscapist / reinstall-grub.sh
Last active August 26, 2022 07:19
Reinstall broken bootloader (arch) - Grub2 UEFI
# in livedisk terminal:
# refer gparted for diskids (look for root and boot/esp)
# mount root
sudo mount /dev/nvme1n1p2 /mnt
# mount boot/esp
# refer `cat /mnt/etc/fstab` to ensure correct efi path
sudo mount /dev/nvme1n1p1 /mnt/boot/efi