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 | |
set -euo pipefail | |
SERVERNAME=${1:-""} | |
PORT=${2:-443} | |
if [[ -z "${SERVERNAME}" ]]; then | |
printf "Usage:\n" | |
printf " sslcheck <servername>\n" | |
printf " sslcheck <servername> <port>\n" |
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 ProgressBar: | |
""" | |
A progress bar that's heavily inspired by click.ProgressBar. | |
Required imports: | |
import shutil | |
import sys | |
import time | |
import unicodedata |
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
import json | |
import urllib.parse | |
import urllib.request | |
def request( | |
url: str, | |
method: str | None = None, | |
data: dict | None = None, | |
query_params: dict | None = None, | |
raise_on_error: bool = True, |
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 | |
# -*- coding: utf-8 -*- | |
"""A script to print "ipsum" text from the Star Wars universe through Force Ipsum. | |
https://forcemipsum.com | |
""" | |
import argparse | |
import json | |
import sys | |
import urllib.request | |
from secrets import SystemRandom |
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 logging | |
import os | |
from pathlib import Path | |
SENSITIVE: list[str] = [] | |
TIMEZONE: str = "America/Denver" | |
# https://no-color.org/ | |
NO_COLOR: bool = os.getenv("NO_COLOR", "") != "" |
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 | |
# Quick and dirty setup for git and bash aliases. | |
[ ! -f ~/.git-aliases ] && cat <<-END > ~/.git-aliases | |
alias g='git' | |
alias gd='git diff' | |
alias gf='git fetch --all --prune' | |
alias gfpr='git fetch --all --prune && git pull --rebase' | |
alias gg='git log --graph --pretty=format:'\''%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative' | |
alias gh='cd "$(git rev-parse --show-toplevel)"' |
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
{ | |
// See https://go.microsoft.com/fwlink/?LinkId=733558 | |
// for the documentation about the tasks.json format | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "run file", | |
"type": "shell", | |
"command": "docker run --rm -it -v ${workspaceFolder}:/usr/src/app node:alpine /usr/src/app/${relativeFile}" | |
} |
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
function array_join() { | |
# Join an array with a a separator character. | |
# WARNING: This only works in bash. You should also pass the array by | |
# reference. Example: | |
# my_array=( "one" "two" "three") | |
# joined=$( array_join my_array "|") | |
local -n arr=$1 | |
local sep=${2:-" "} | |
printf -v result "%s${sep}" "${arr[@]}" |
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
# You can check to see if someone ran your script with `echo -n test | myscript.py`. | |
# In that case, there's no tty attached. If there _is_ an attached tty, then you | |
# can just prompt the user like normal. | |
import sys | |
def read_secret_key(): | |
if sys.stdin.isatty(): | |
return getpass("Enter the secret key: ") | |
else: | |
return sys.stdin.readline() |
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
def format_timespan(seconds: float) -> str: | |
"""Formats the number of seconds in h:m:s""" | |
hours, seconds = divmod(seconds, 3600) | |
minutes, seconds = divmod(seconds, 60) | |
return f"{hours:d}h:{minutes:02d}m:{seconds}s" |
NewerOlder