Use a for
loop to do something to every element in a list.
This file contains 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
class J: | |
""" | |
Sequence Join Format String Wrapper | |
>>> seq = ['a', 'b', 1, None] | |
>>> print(f"default: {J(seq)}" | |
default: 1,b,1,None | |
>>> print(f"custom-delimeter: {J(seq):/-}" | |
custom-delimiter: a/-b/-1/-None | |
""" |
This file contains 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
+ git --version | |
git version 2.30.1.602.g966e671106 | |
+ uname -a | |
Darwin otata 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,1 Darwin | |
+ rm -rf ./SK.local.git ./SK.remote.git | |
+ git clone --bare https://github.com/octocat/Spoon-Knife SK.remote.git | |
Cloning into bare repository 'SK.remote.git'... | |
warning: templates not found in /Users/rcoup/share/git-core/templates | |
remote: Enumerating objects: 16, done. |
This file contains 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 | |
""" | |
A script to query the Amazon Web Services usage reports programmatically. | |
Ideally this wouldn't exist, and Amazon would provide an API we can use | |
instead, but hey - that's life. | |
Basically takes your AWS account username and password, logs into the | |
website as you, and grabs the data out. Always gets the 'All Usage Types' |
This file contains 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
# with Hack from https://www.nerdfonts.com/ installed | |
function iterm2_print_user_vars() { | |
# kubernetes current cluster & namespace | |
CONTEXT="$(kubectl config current-context)" | |
if [ -n "$CONTEXT" ]; then | |
NAMESPACE="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CONTEXT}\")].context.namespace}")" | |
iterm2_set_user_var kubecontext "⎈ $CONTEXT:${NAMESPACE:-default}" | |
else | |
iterm2_set_user_var kubecontext "" |
This file contains 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
$ cflow -T --brief --main=git_revparse_single refs.c revparse.c | |
+-git_revparse_single() <int git_revparse_single (git_object **out, git_repository *repo, const char *spec) at revparse.c:854> | |
+-git_revparse_ext() <int git_revparse_ext (git_object **object_out, git_reference **reference_out, git_repository *repo, const char *spec) at revparse.c:828> | |
| +-revparse__ext() <int revparse__ext (git_object **object_out, git_reference **reference_out, size_t *identifier_len_out, git_repository *repo, const char *spec) at revparse.c:663> | |
| | +-assert() | |
| | +-ensure_base_rev_loaded() <int ensure_base_rev_loaded (git_object **object, git_reference **reference, const char *spec, size_t identifier_len, git_repository *repo, bool allow_empty_identifier) at revparse.c:610> | |
| | | +-object_from_reference() <int object_from_reference (git_object **object, git_reference *reference) at revparse.c:596> | |
| | | | +-git_reference_resolve() <int git_reference_resolve (git_reference **ref_out, const git_reference *ref) at ref |
This file contains 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 | |
""" | |
Loggly CLI interface - standalone (Just Python). Deals with paging results automatically so you can easily grab >2000 rows. | |
Run `loggly.py --help` to see usage information. | |
TODO: | |
* Support XML format results (ie. combining multiple pages of results together) | |
* Facet support |
This file contains 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
' Usage: strip-utf8-bom.vbs file.csv | |
' Notes: | |
' this isn't suitable for large files unless you have a lot of memory - ADODB.Stream reads the entire file into | |
' memory, then builds the output buffer in memory as well. #stupid | |
If WScript.Arguments.Count <> 1 Then | |
WScript.Echo "Usage: strip-utf8-bom.vbs file.csv" | |
WScript.Quit | |
End If |
This file contains 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
__kube_ps1() | |
{ | |
# Get current context | |
CONTEXT="$(kubectl config current-context)" | |
if [ -n "$CONTEXT" ]; then | |
NAMESPACE="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CONTEXT}\")].context.namespace}")" | |
echo "⎈ $CONTEXT:${NAMESPACE:-default}" | |
fi | |
} |