Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / ._README.md
Last active Nov 23, 2021
Python scripts to Remove, modify, or create a file without changing the modification time of the parent directory.
View ._README.md

*_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 Nov 22, 2021
How to insert a timestamp without timezone into postgres using Python
View python-postgres-insert-eopch-timestamp-without-timezone.md

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 Jan 11, 2022
How to use zstd for fast as hell compression
View zstd.md

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 Nov 15, 2021
Golang Linux installer configurator
View install-go.sh
#!/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 Mar 12, 2020
Jay's RichSQL.scala from 2012
View RichSQL.scala
/*
* 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 Mar 8, 2020
Golang Linux quick installer
View golang_linux_quick_install.md
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 Dec 21, 2020
Jay's Python programming skeleton snippets quick reference
View ._python_programming_snippets.md

Python programming skeleton snippets

Quick references to common and useful python best-practices programming snippets and boilerplate.

@jaytaylor
jaytaylor / multiline-mutator-v1.awk
Last active Jan 15, 2020
Multi-line search and inject new variable into helm templates.
View multiline-mutator-v1.awk
#
# 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 Nov 3, 2019
Common Ubuntu server setup for LAMP-ish configuration.
View ubuntu-18.04-web-server-init.sh
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ "$1" = '-v' ] ; then
set -o xtrace
shift
fi
@jaytaylor
jaytaylor / java-format-cleanup.sh
Created Oct 8, 2019
Perl-based Java codebase aesthetics format scrubber.
View java-format-cleanup.sh
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
for f in $(find . -name '*.java'); do
perl \
-0 \
-i \