Quick references to common and useful bash programming snippets and boilerplate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
for f in $(find . -name '*.java'); do | |
perl \ | |
-0 \ | |
-i \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## | |
# | |
# @author Jay E. Taylor <[email protected]> | |
# | |
# @description Math functions for bash! | |
# | |
## |
Author: Jay Taylor
Date: 2019-07-08
Purpose: Created as a C++ reference for SO: How do I create a URL shortener?.
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```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Also see the Python version: https://gist.github.com/jaytaylor/76de9c99acbfac637e68f78809dbd27e | |
import ( | |
"bytes" | |
"crypto/md5" | |
"encoding/base64" | |
"fmt" | |
"io" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
@author Jay E. Taylor <[email protected]> | |
@date 2019-06-03 | |
@description MD5 hash calculator for multi-part file uploads to S3 / object storage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |