Skip to content

Instantly share code, notes, and snippets.

View abn's full-sized avatar

Arun Babu Neelicattu abn

View GitHub Profile
@abn
abn / logstash.service
Last active November 30, 2022 13:17
logstash systemd service file
[Unit]
Description=Logstash
Documentation=https://www.elastic.co/products/logstash
After=network.target
ConditionPathExists=/etc/logstash.conf
[Service]
ExecStart=/opt/logstash/bin/logstash agent -f /etc/logstash.conf
[Install]
@abn
abn / Jenkinsfile
Created November 28, 2017 23:06
Jenkinsfile: OpenShift podTemplate example
// this currently is restricted on OpenShift Online, however is possible on OSD/OCP clusters
// we create a dotnet builder pod using the provided jenkins slave image for executing dotnet commands in
podTemplate(
label: 'dotnet-build-pod', cloud: 'openshift',
containers: [
containerTemplate(
name: 'dotnet-build-pod', image: 'registry.access.redhat.com/dotnet/dotnet-20-jenkins-slave-rhel7:latest'
)
]) {
node('dotnet-build-pod-x') {
@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 / rpm-build-workflow.md
Last active May 18, 2022 05:04
RPM build and hosting workflow using github, travis-ci and copr

RPM Build Flow

This document details a simple RPM build flow pattern used to build and host RPM artifacts for open source projects. The below is a visual summary of this flow.

In order to achieve this multiple tools and services are used. The services and their purpose in the flow is as listed below.

Service Purpose
GitHub As is the most common use for GitHub, it holds the build source code. In this case we hold only the spec files and related source files. All other sources, including project binaries/sources are retrieved at build time.
@abn
abn / convert-raw-to-vmdk.sh
Last active April 30, 2021 19:06
Convert all xz compressed raw images in current directory to vmdk and xz compress them.
find ./ -type f -name "*.raw.xz" \
-exec echo "Uncompressing {} ..." \; \
-exec unxz --keep {} \; \
-exec bash -c \
'for file do
INPUT_IMG=${file/.xz/}
OUTPUT_IMG=${file/raw.xz/vmdk}
echo "Converting to vmdk: ${INPUT_IMG}";
qemu-img convert -f raw -O vmdk ${INPUT_IMG} ${OUTPUT_IMG};
echo "Compressing ...";
@abn
abn / python-flask-task-async.py
Last active February 18, 2021 12:29
A module to facilitate dispatch of asynchronous tasks in a Flask App. This was designed to work standalone in an embedded fashion without dependencies like flask-celery, redis etc. This is not meant to be a reliable means to execute tasks, just a quick and easy solution for most needs.
"""
An asynchronous task manager.
This is a simple implementation for background task handing. No guarentees are
provided for task execution.
This was developed in the course of the work don for the victims project and
that version is available at
https://github.com/victims/victims-web/blob/master/src/victims_web/handlers/task.py
@abn
abn / keycloak-fetch-token-postman-pre-request.js
Created October 12, 2017 13:02
A postman pre-request script to fetch a valid token from Red Hat SSO (Keycloak) and set it to a template variable to use in request headers.
// modify these configurations to work with your environment
var server = "https://sso.example.com";
var realm = "realm";
var resource = "client";
var username = "username";
var password = "url encoded password";
var url = `${server}/auth/realms/${realm}/protocol/openid-connect/token`;
var data = `grant_type=password&client_id=${resource}&username=${username}&password=${password}`;
@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