Skip to content

Instantly share code, notes, and snippets.

jftuga / HaversinFormula.go
Created Sep 16, 2021 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
View HaversinFormula.go
// 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 / default_gateway.go
Created Aug 12, 2021 — forked from abimaelmartell/default_gateway.go
Get default gateway by parsing RIB information using the net/route package. BSD Only.
View default_gateway.go
package main
import (
var defaultRoute = [4]byte{0, 0, 0, 0}
func main() {
jftuga /
Created Jul 6, 2021
Terraform and ACM (AWS Certificate Manager)
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.48"
required_version = ">= 1.0.0"
jftuga /
Last active Jul 26, 2021
Terraform and EC2 Spot Instances
${T} init
${T} fmt
${T} validate
# to deploy:
${T} plan
jftuga /
Created Jun 25, 2021
reddit asyncpraw example
import asyncio
import asyncpraw
import sys
class AsPr:
def __init__(self, sr: str): = sr # subreddit
self.reddit = asyncpraw.Reddit(client_id=reddit_client_id, client_secret=reddit_client_secret,
jftuga / *
Created Jun 18, 2021 — forked from rszeto/*
Setting up PyCharm project with remote interpreter
View *

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 /
Created May 28, 2021 — forked from pankaj28843/
A simple hack - set outer border for a range using xlsxwriter, a Python library
from __future__ import absolute_import
import cStringIO as StringIO
except ImportError:
import StringIO
# Standard Library
import re
import string
jftuga /
Created May 24, 2021
Read the Chrome URL address bar with Python and Selenium
-John Taylor
Read the URL from the Chrome address bar using two different methods
Tested with Python 3/9/5 on Windows 10 v1809
import time
jftuga / all_remove_python_venv.ps1
Last active May 19, 2021
remove Python 3.9 Virtual Environment on Windows 10
View all_remove_python_venv.ps1
# this will remove:
# Python venv
# PyCharm .idea folder
rm -r -fo .\pyvenv.cfg,.\Include\,.\Scripts\,.\__pycache__\,.\.idea\
rm -r -fo .\Lib\
jftuga /
Created May 19, 2021 — forked from bhtucker/
A demonstration of Postgres upserts in SQLAlchemy
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
Initial upsert: