Skip to content

Instantly share code, notes, and snippets.

Avatar

Arun Babu Neelicattu abn

View GitHub Profile
@abn
abn / run-poetry-pull-request.sh
Last active Oct 8, 2020
Python Poetry: Run Pull Request Container
View run-poetry-pull-request.sh
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 Sep 14, 2020
Implicit casting from jsonb array to psql text array
View jsonb_array_to_text_array.sql
-- 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 Jun 25, 2020
Makefile: Using a custom bashrc file for default shell used by all targets
View Makefle
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 Oct 8, 2020
A slugify function for postgres
View slugify.postgres.sql
-- 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
@abn
abn / az-list-all-vhd.sh
Last active Jul 25, 2018
Azure: List all VHD blobs in all containers in all storage accounts of a specified resource group
View az-list-all-vhd.sh
#!/usr/bin/env bash
# This script lists all blobs in all containers in all storage accounts of a specified resource group
for storageAccount in `az storage account list -g ${1} | jq -r '.[] | .name'`; do
for containerName in `az storage container list --account-name ${storageAccount} | jq -r '.[] | .name'`; do
blobName=`az storage blob list -c ${containerName} --account-name ${storageAccount} | jq -r '.[] | .name'`
[[ ! -z "${blobName}" ]] && echo "${storageAccount}/${containerName}/${blobName}"
done
done
@abn
abn / install-jetbrains-toolbox.sh
Last active Sep 30, 2020
Install JetBrains Toolbox App
View install-jetbrains-toolbox.sh
#!/usr/bin/env bash
# Reference: https://github.com/nagygergo/jetbrains-toolbox-install/blob/master/jetbrains-toolbox.sh
# Note that we grep for linux here, if you are using this on mac/windows please see json output
TOOLBOX_URL=$(curl --silent 'https://data.services.jetbrains.com//products/releases?code=TBA&latest=true&type=release' \
-H 'Origin: https://www.jetbrains.com' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: en-US,en;q=0.8' \
-H 'Accept: application/json, text/javascript, */*; q=0.01' \
-H 'Referer: https://www.jetbrains.com/toolbox/download/' \
@abn
abn / bash-alias-unzipy.sh
Created Apr 22, 2018
An alias to unzip files when unzip command is unavailable, but python is.
View bash-alias-unzipy.sh
# usage: unzipy <source.zip> <dest dir>
alias unzipy="python -c \"import os, sys, zipfile; zipfile.ZipFile(sys.argv[1], 'r').extractall(sys.argv[2])\""
@abn
abn / Makefile
Last active Apr 19, 2018
An example makefile with embedded help messages and dynamic help targets
View Makefile
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
.PHONY: %/help
%/help: HELP_TARGET = $(subst /help,,$@)
%/help:
@make -C $(ROOT_DIR) help | grep -Pzo "$(HELP_TARGET)(/\w+)*:.*(\n\s+(.*)?)*\n"
### help: Displays this help message.
.PHONY: help
@abn
abn / ansible-letsencrypt-install-ca-certs.yaml
Created Apr 1, 2018
Install letsencrypt cross signed certs for Red Hat distros
View ansible-letsencrypt-install-ca-certs.yaml
---
# https://letsencrypt.org/certificates/
- hosts: all
tasks:
- name: install letsencrypt cross-signed x3
get_url:
url: https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt
dest: /etc/pki/ca-trust/source/anchors/lets-encrypt-x3-cross-signed.pem
register: x3
- name: install letsencrypt cross-signed x4
@abn
abn / azure-networkmanager-preserve-search-domain.yaml
Created Mar 31, 2018
Ensure default search domain is preserved when converting Azure VM network interface to be managed by NetworkManager
View azure-networkmanager-preserve-search-domain.yaml
- hosts: all
tasks:
- name: create custom fact directory
file:
path: /etc/ansible/facts.d
state: directory
- name: insert azure fact file
copy:
src: azure_resolv.fact
You can’t perform that action at this time.