Skip to content

Instantly share code, notes, and snippets.

View abn's full-sized avatar

Arun Babu Neelicattu abn

View GitHub Profile
@abn
abn / fedora-install-jetbrains-toolbox.sh
Last active November 11, 2024 17:40
Install JetBrains Toolbox on Fedora
#!/bin/bash
set -e
set -o pipefail
sudo dnf install -y jq fuse fuse-libs
curl -sL \
$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' \
| jq -r '.TBA[0].downloads.linux.link') \
@abn
abn / cpython-patched-getfqdn.py
Created June 4, 2023 16:02
A patched version of socket.getfqdn() based on the patch provided in cpython#49254
import socket
# patched socket.getfqdn() - see https://github.com/python/cpython/issues/49254
def getfqdn(name=''):
"""Get fully qualified domain name from name.
An empty argument is interpreted as meaning the local host.
"""
name = name.strip()
if not name or name == '0.0.0.0':
name = socket.gethostname()
@abn
abn / console-logs-comment.md
Created June 1, 2022 11:00
Collapsible GitHub Markdown Block (console.log)
console.log

# insert log here

@abn
abn / nm-create-resolved-custom-port-dns-dispatcher.sh
Last active May 14, 2024 12:56
NetworkManager Dispatcher: Configure systemd-resolved DNS server with custom port on connection up event
# NetworkManager connection config does not like custom ports for DNS servers
# we work around this by using a dispatcher to configure this on up events
# change these to your desired configs
CONNECTION_ID=wg0
DNS_TARGET=10.10.0.1:5300
DNS_SEARCH_DOMAIN=~testing
cat > /etc/NetworkManager/dispatcher.d/99-${CONNECTION_ID}.sh <<EOF
#!/usr/bin/env bash
@abn
abn / fix-keychron-k1-fn.sh
Last active February 26, 2023 20:49
Fix keychron k1 function keys on Fedora
#!/usr/bin/env bash
FNMODE=0
# session fix
echo $FNMODE | sudo tee /sys/module/hid_apple/parameters/fnmode
# permanent fix
# https://ask.fedoraproject.org/t/getting-the-function-keys-to-work-properly-with-a-varmilo-keyboard/11297
echo "options hid_apple fnmode=$FNMODE" | sudo tee /etc/modprobe.d/hid_apple.conf
@abn
abn / jigsaw-outline-uninstall.sh
Last active October 9, 2024 07:01
Jigsaw Outline: Uninstall (purge) the persistent thing
#!/usr/bin/env bash
# this is not extensively tested, worked for personal use case.
# script is intentionally aggressive, use at your own peril :)
# reference: https://github.com/Jigsaw-Code/outline-client/issues/648
function uninstall-outline() {
set -x
sudo systemctl disable --now outline_proxy_controller
@abn
abn / run-poetry-pull-request.sh
Last active October 8, 2020 16:29
Python Poetry: Run Pull Request Container
PULL_ID=3147
PYTHON_VERSION=${PYTHON_VERSION:-3.8}
podman run --rm -i --entrypoint bash python:${PYTHON_VERSION} <<EOF
set -e
python -m pip install -q git+https://github.com/python-poetry/poetry.git@refs/pull/${PULL_ID}/head
python -m poetry new foobar
pushd foobar
sed -i /pytest/d pyproject.toml
python -m poetry add pycowsay
@abn
abn / jsonb_array_to_text_array.sql
Created September 14, 2020 21:27
Implicit casting from jsonb array to psql text array
-- https://stackoverflow.com/a/45244285
CREATE OR REPLACE FUNCTION public.jsonb_array_to_text_array(
JSONB
) RETURNS TEXT[] AS
$f$
SELECT array_agg(x::TEXT) FROM jsonb_array_elements($1) t(x);
$f$
LANGUAGE sql
IMMUTABLE;
@abn
abn / Makefle
Created June 25, 2020 22:23
Makefile: Using a custom bashrc file for default shell used by all targets
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
BASH_ENV := $(ROOT_DIR)/.bashrc
export BASH_ENV
SHELL := $(shell which bash) -e
@abn
abn / slugify.postgres.sql
Last active August 21, 2024 14:26
A slugify function for postgres
-- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88
-- https://www.postgresql.org/docs/9.6/unaccent.html
CREATE EXTENSION IF NOT EXISTS unaccent;
-- create the function in the public schema
CREATE OR REPLACE FUNCTION public.slugify(
v TEXT
) RETURNS TEXT
LANGUAGE plpgsql