Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / java-format-cleanup.sh
Created October 8, 2019 17:10
Perl-based Java codebase aesthetics format scrubber.
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
for f in $(find . -name '*.java'); do
perl \
-0 \
-i \
@jaytaylor
jaytaylor / math.sh
Created August 8, 2019 21:33
Math functions from python as bash "builtins".
#!/usr/bin/env bash
##
#
# @author Jay E. Taylor <jay@jaytaylor.com>
#
# @description Math functions for bash!
#
##
@jaytaylor
jaytaylor / ._bash_shell_programming_snippets.md
Last active February 5, 2024 17:21
jaytaylor's Bash shell skeleton programming snippets quick reference

Bash shell skeleton programming snippets

Quick references to common and useful bash programming snippets and boilerplate.

@jaytaylor
jaytaylor / ._base64-url-shortener-poc.md
Last active December 16, 2022 10:39
URL shortener Base-62 encoder / decoder C++ Proof-of-Concept
@jaytaylor
jaytaylor / fix-helm-k8s-missing-priorityClass.md
Created June 28, 2019 18:32
Manual fix for missing priorityClass after helm upgrade

Problem Statement

I've been hitting cases where kubernetes cluster actions are blocked due to priorityClass being absent after a helm install --upgrade.

For example:

  Type     Reason        Age                  From                    Message
  ----     ------        ----                 ----                    -------
  Warning  FailedCreate  3m (x1405 over 11h)  statefulset-controller  create Pod elasticsearch-data-2 in StatefulSet elasticsearch-data failed error: pods "elasticsearch-data-2" is forbidden: no PriorityClass with name elasticsearch-data was found```
@jaytaylor
jaytaylor / dircnt-jay.c
Created June 10, 2019 18:28
Linux file and directory counter under one or more paths.
/**
* dircnt.c - a fast file-counting program.
*
* Written 2015-02-06 by Christopher Schultz as a programming demonstration
* for a StackOverflow answer:
* https://stackoverflow.com/questions/1427032/fast-linux-file-count-for-a-large-number-of-files/28368788#28368788
*
* This code is licensed under the Apache License 2.0. Please read the file
* LICENSE for more information.
*
@jaytaylor
jaytaylor / md5sum_multi_part.go
Last active June 3, 2019 22:26
High-performance multi-threaded MD5 hash calculator for multi-part file uploads to S3 / object storage.
package main
// Also see the Python version: https://gist.github.com/jaytaylor/76de9c99acbfac637e68f78809dbd27e
import (
"bytes"
"crypto/md5"
"encoding/base64"
"fmt"
"io"
@jaytaylor
jaytaylor / md5sum_multi_part.py
Last active June 3, 2019 22:26
MD5 hash calculator for multi-part file uploads to S3 / object storage.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
@author Jay E. Taylor <outtatime@gmail.com>
@date 2019-06-03
@description MD5 hash calculator for multi-part file uploads to S3 / object storage.
@jaytaylor
jaytaylor / k8s-delete-ns-resources.sh
Created March 4, 2019 22:43
Delete all resources from a Kubernetes namespace.
#!/usr/bin/env bash
#
# @author Jay Taylor [jaytaylor.com](https://jaytaylor.com)
#
# @date 2019-03-04
#
# Sometimes Kubernetes seems to get stuck and doesn't
# delete the contents of a namespace from my cluster after
# `kubectl delete namespace X` has been run.
@jaytaylor
jaytaylor / rm_preserving_parent_mtime.py
Last active December 27, 2022 03:10
Removes a file or directory while preserving the modification time (mtime) of the parent directory.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Removes a file or directory while preserving the modification time (mtime) of
the parent directory.
Pure-python implementation.
See also: