Skip to content

Instantly share code, notes, and snippets.

import linecache
import re
import sys
from types import TracebackType
from typing import Any, Optional
PACKAGE_PATH_PATTERN = r'.*/lib/python.*/site-packages/.*'
class TracebackLogger:
@jftuga
jftuga / python_forelse.py
Created July 25, 2022 12:55
Python For Else Loop
# the else below should really have been named 'nobreak'
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(f"{n} = {x}*{int(n/x)}")
break
else: # only occurs when 'nobreak'
# loop fell through without finding a factor
print(f"{n} is a prime number")
@jftuga
jftuga / change_route53_dns_entry.sh
Last active May 1, 2022 21:09
Change or Insert a Route53 entry from the command line
#!/bin/bash
# change_route53_dns_entry.sh
# -John Taylor
# 2022-05-01
# Change or add a route53 DNS entry
# dependencies: the aws cli, jq
# a AWS profile that has IAM permissions for Route53 API calls
@jftuga
jftuga / certbot_install_ubuntu20+.md
Created April 24, 2022 20:22 — forked from bmatthewshea/certbot_pip_install-debian_ubuntu.md
Ubuntu 20 - CERTBOT without SNAP/SNAPD

CERTBOT - Install using Python PIP

Install Certbot using Python PIP (Package Installer for Python) without using SNAP, APT or SYSTEMD) (Debian/Ubuntu)

This guide will help you install LetsEncrypt / Certbot and a DNS plugin (certbot-dns-route53) using PIP under Debian/Ubuntu.

  • You should already be somewhat familiar with LetsEncrypt, Certbot and any plugin you might need.

  • This guide uses a DNS provider plugin (AWS Route53), but this is really about the install method - not plugins, or validation methods.

@jftuga
jftuga / ssm_parameter_store.py
Created April 22, 2022 14:31 — forked from nqbao/ssm_parameter_store.py
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@jftuga
jftuga / dataclass_example.py
Created March 24, 2022 02:02
Quick demo of how to use Python 3 dataclasses
r"""
dataclass_demo.py
-John Taylor
2022-03-23
A very quick demo of how to use Python 3 dataclasses.
Shows how to define a dict and a list for a dataclass.
"""
from dataclasses import dataclass, field
@jftuga
jftuga / git_config.md
Last active May 2, 2023 03:02
Git Config

Git Config

Merge strategy

git config --global pull.rebase false

Force LF instead of CRLF

  • git config --global core.autocrlf false
@jftuga
jftuga / creating_aws_lambda_layers_with_python_and_third_party_libraries.md
Last active April 25, 2023 22:34
creating aws lambda layers for python with third party libraries

creating aws lambda layers for python and third party libraries

python versions

  • Python 3.9: use Fedora 34
  • Python 3.10: use Fedora 35

example

# 'python' will be the top-level folder and underneath it, modules will be installed
pip install -t python paramiko
@jftuga
jftuga / build_and_install_visual_studio_extension_from_github_repo.md
Last active December 23, 2021 10:38
Build and Install Visual Studio extension from GitHub Repo

Build and Install Visual Studio extension from GitHub Repo

As root

  • Using Fedora 35
dnf install -y git npm
npm install -g vsce
npm install -g tsc
@jftuga
jftuga / default_gateway.go
Created December 6, 2021 21:18
How to get the default gateway IP address in go
package main
import (
"fmt"
"golang.org/x/net/route"
)
var defaultRoute = [4]byte{0, 0, 0, 0}
func main() {