Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@jftuga
jftuga / HaversinFormula.go
Created September 16, 2021 13:17 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@jftuga
jftuga / default_gateway.go
Created August 12, 2021 19:46 — forked from abimaelmartell/default_gateway.go
Get default gateway by parsing RIB information using the net/route package. BSD Only.
package main
import (
"fmt"
"golang.org/x/net/route"
)
var defaultRoute = [4]byte{0, 0, 0, 0}
func main() {
@jftuga
jftuga / *pycharm-setup-2020.3.2.md
Created June 18, 2021 20:07 — forked from rszeto/*pycharm-setup-2020.3.2.md
Setting up PyCharm project with remote interpreter

Setting up PyCharm project with remote interpreter

Setting up a remote interpreter on PyCharm is awfully unintuitive. I've pared it down to what I think is the minimal number of steps, and leaves the fewest number of deployment configurations and Python interpreters lying around. This is designed for my specific configuration (specifically PyTorch); adapt as needed.

Configuring default project (only do after installing PyCharm for the first time):

  1. (Optional) Add virtual environment path to excluded files
    1. From Welcome Page, go to Configure > Settings > Build, Execution, Deployment > Deployment > Options
    2. Add virtualenv path. For example, if you always have the project's virtualenv in .env, add ";.env" to the "Exclude items by name" field
@jftuga
jftuga / set_outer_border_for_range_xlsx.py
Created May 28, 2021 04:45 — forked from pankaj28843/set_outer_border_for_range_xlsx.py
A simple hack - set outer border for a range using xlsxwriter, a Python library
from __future__ import absolute_import
try:
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
@jftuga
jftuga / upsert.py
Created May 19, 2021 08:06 — forked from bhtucker/upsert.py
A demonstration of Postgres upserts in SQLAlchemy
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert: