Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / json-deepmerge.py
Created January 19, 2023 16:23
JSON object merge tool.
#!/usr/bin/env python3
"""
JSON object merge tool.
Based on mergedeep and Python3 JSON Stream State Machine.
References:
https://github.com/clarketm/mergedeep
@jaytaylor
jaytaylor / ._README.md
Last active December 27, 2022 03:11
Python scripts to Remove, modify, or create a file without changing the modification time of the parent directory.

*_preserving_parent_mtime.py

Python programs to remove or modify files without changing the modification time of the parent directory.

Quick Install

curl -fSLO https://gist.github.com/jaytaylor/e2e0b53baf224f4e973b252370499de7/raw/bc175ba7008626ebc3f356c16f8240ebe578c5a0/rm_preserving_parent_mtime.py
curl -fSLO https://gist.github.com/jaytaylor/e2e0b53baf224f4e973b252370499de7/raw/bc175ba7008626ebc3f356c16f8240ebe578c5a0/mv_preserving_parent_mtime.py
chmod a+x rm_preserving_parent_mtime.py mv_preserving_parent_mtime.py
@jaytaylor
jaytaylor / python-postgres-insert-eopch-timestamp-without-timezone.md
Created November 22, 2021 16:55
How to insert a timestamp without timezone into postgres using Python

HOWTO: Insert a timestamp without timezone into postgres using Python

Background

I searched the net high and low but was unable to locate a definitive working example of how to take an epoch integer timestamp and insert it as a native postgres timestamp without timezone.

CREATE TABLE IF NOT EXISTS tz_test (
 stamp TIMESTAMP NOT NULL
@jaytaylor
jaytaylor / zstd.md
Last active January 11, 2022 18:04
How to use zstd for fast as hell compression

HOW TO: zstd

Why?

Way faster than bzip2, it's basically streaming compression with comparable compression levels.

Compress

tar -cvf - foo | zstd -f --no-progress -o foo.tar.zst
@jaytaylor
jaytaylor / install-go.sh
Last active November 15, 2021 21:53
Golang Linux installer configurator
#!/usr/bin/env bash
##
# @description Golang Linux installer.
#
# Example usage:
#
# VERSION=1.17.3 sudo -E bash install-go.sh
#
# @date 2021-02-18
@jaytaylor
jaytaylor / RichSQL.scala
Created March 12, 2020 20:59
Jay's RichSQL.scala from 2012
/*
* RichSQL.scala
*
* @note I originally found this at
* http://scala.sygneca.com/code/simplifying-jdbc. Since sourcing it I have
* made some improvements.
* -Jay T.
*/
import java.sql.ResultSet
@jaytaylor
jaytaylor / golang_linux_quick_install.md
Last active March 8, 2020 19:27
Golang Linux quick installer
cat > /tmp/install-go.sh << 'EOF'
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

if [ "${1:-}" = '-v' ]; then
 echo 'INFO: Verbose debug output enabled' 1&gt;&amp;2
@jaytaylor
jaytaylor / ._python_programming_snippets.md
Last active February 5, 2024 17:21
Jay's Python programming skeleton snippets quick reference
@jaytaylor
jaytaylor / multiline-mutator-v1.awk
Last active January 25, 2024 04:32
Multi-line search and inject new variable into helm templates.
#
# Multi-line search and inject new variable into helm templates.
#
# n.b. Works somewhat dynamically.
#
BEGIN {
insertion = "{{- include \"bots.k8s-envvars\" . | indent 8 }}"
expr_seq[0] = " +envFrom: *$"
expr_seq[1] = "^{prefix1}( )?- configMapRef: *$"
@jaytaylor
jaytaylor / ubuntu-18.04-web-server-init.sh
Created November 3, 2019 16:50
Common Ubuntu server setup for LAMP-ish configuration.
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ "$1" = '-v' ] ; then
set -o xtrace
shift
fi