$ curl -sSL https://gist.github.com/jaymecd/6887829/raw/bash_prompt | sudo tee /etc/bash_prompt
$ curl -sSL https://gist.github.com/jaymecd/6887829/raw/bash_alias | sudo tee /etc/bash_alias
$ curl -sSL https://gist.github.com/jaymecd/6887829/raw/bashrc | tee -a ~/.bashrc
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
from __future__ import annotations | |
import boto3 | |
from functools import lru_cache | |
import dataclasses as dc | |
import uuid | |
def _reconstruct_params(cls, params: dict) -> dict: | |
if not hasattr(cls, '__dc_field_names'): |
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
#!/user/bin/env bash | |
# run as ./relative_time 2021-05-06T20:37:59Z | |
relative_time() { | |
declare -r dt="$1" | |
declare ts_then ts_now retval | |
! { ts1=$(date +%s -d "${dt}"); retval=$?; } |
Based on https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html
Directive | Description |
---|---|
define variable define variable = define variable := define variable ::= define variable += define variable ?= endef |
Define multi-line variables. |
undefine variable |
Undefining variables. |
In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.
All the examples use demical types, except for the original value, which is automatically casted as a float.
To set the context of what we are working with, let's start with an original value.
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 python3 | |
import asyncio | |
from typing import List, Awaitable | |
async def slow_job(delay: int): | |
print(f"running slow_job with {delay}s delay ...") | |
await asyncio.sleep(delay) | |
print(f"slow_job with {delay}s delay is 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
package main | |
import ( | |
"context" | |
"errors" | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" |
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 bash | |
# | |
# Split single S3 Inventory manifest into sequential subsets. | |
# | |
# Usage: | |
# $ env INVENTORY_BUCKET=my-inventory INVENTORY_PATH=sample-name ./s3.batch.operations.manifest.split.sh | |
# | |
set -euo pipefail |
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
MAKEFLAGS += --warn-undefined-variables | |
SHELL := bash -o pipefail -c | |
.DEFAULT_GOAL := help | |
.PHONY: help all deps build | |
guardEnvVar = $(if $(value $(1)),,$(error env $(1) not defined)) | |
# Note: help extracts title from ## comment just above the target, builds target/title grid and prints it pretty. | |
## Show help |
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
# TEST WinRM connect | |
$targetHost = 'localhost' | |
$username = 'Administrator' | |
$password = 'PASSWORD' | |
$secret = ConvertTo-SecureString -String $password -AsPlainText -Force | |
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $secret | |
$option = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck |