Skip to content

Instantly share code, notes, and snippets.

@jftuga
jftuga / bufWrite.go
Created September 9, 2019 09:18
demonstrates how to either write to STDOUT or to a buffer in golang
// demonstrates how to either write to STDOUT or to a buffer
package main
import (
"bufio"
"fmt"
"os"
)
@jftuga
jftuga / python_decorator.py
Created March 7, 2023 02:56
Python Decorator
# source: https://www.pythontutorial.net/advanced-python/python-decorators/
def currency(fn):
def wrapper(*args, **kwargs):
result = fn(*args, **kwargs)
return f'${result}'
return wrapper
@currency
@jftuga
jftuga / create_boto3_tags.py
Created January 19, 2023 15:57
create boto3 tags from dict
import json
def create_boto3_tags(all_tags:dict) -> list:
boto3_tags = []
for tag in all_tags:
for key, val in tag.items():
boto3_tags.append({"Key": key, "Value": val})
return boto3_tags
@jftuga
jftuga / Compiling_Python_on_Debian_or_Raspberry_Pi.md
Last active December 23, 2022 10:09
Compiling Python 3.9 on Debian Buster or Raspberry Pi OS

Tested with Python 3.9.5 on Raspbian GNU/Linux 10 (buster)

https://www.python.org/downloads/source/

apt install -y libbz2-dev libffi-dev libffi-dev libgdbm-compat-dev libgdbm-dev liblzma-dev libncurses-dev \
    libncurses5-dev libnss3-dev libreadline-dev libsqlite3-dev libssl-dev uuid-dev zlib1g-dev
./configure --prefix=/opt
# edit Makefile to remove `-g -Wall`
@jftuga
jftuga / programming_languages_that_natively_support_128_bit_integers.md
Last active December 16, 2022 12:03
Programming languages that natively support 128 bit integers

what programming languages natively support 128 bit integers

2022-12-16

ChatGPT answer:

There are several programming languages that natively support 128-bit integers. Here is a list of some of them:

  • C and C++: C and C++ support 128-bit integers through the __int128 data type, which is defined in the <stdint.h> header file.
  • Java: Java supports 128-bit integers through the java.math.BigInteger class, which can represent integers of any size.
  • Python: Python supports 128-bit integers through the int data type, which can represent integers of any size.
@jftuga
jftuga / bash_strict_mode.md
Created November 28, 2022 13:19 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@jftuga
jftuga / Remove_PDF_Pages.ps1
Created February 21, 2020 00:52
Remove PDF Pages
<#
Remove_PDF_Pages
-John Taylor
Jan-7-2020
This is a simple, GUI frontend to pdfcpu.
https://github.com/pdfcpu/pdfcpu
The resulting PDF will have the filename appended with "--RemovedPages.pdf"
#>
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