Skip to content

Instantly share code, notes, and snippets.

@jftuga
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
jftuga / upsert.py
Created May 19, 2021 — forked from bhtucker/upsert.py
A demonstration of Postgres upserts in SQLAlchemy
View upsert.py
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert:
@jftuga
jftuga / sqlalchemy_upsert.py
Created May 19, 2021 — forked from malexer/sqlalchemy_upsert.py
Modelling UPSERT in SQLAlchemy (well actually it is not upsert but speed improvement is significant in comparison with simple session.merge)
View sqlalchemy_upsert.py
# Note: it is a copy of great answer by "mgoldwasser" from Stackoverflow
# Check the original answer here: http://stackoverflow.com/a/26018934/1032439
# Imagine that post1, post5, and post1000 are posts objects with ids 1, 5 and 1000 respectively
# The goal is to "upsert" these posts.
# we initialize a dict which maps id to the post object
my_new_posts = {1: post1, 5: post5, 1000: post1000}
for each in posts.query.filter(posts.id.in_(my_new_posts.keys())).all():
@jftuga
jftuga / app.py
Created May 19, 2021 — forked from DmitryBe/app.py
SQLAlchemy quick start
View app.py
# http://bytefish.de/blog/first_steps_with_sqlalchemy/
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from datetime import datetime, timedelta
from sqlalchemy import Table, Column, Integer, String, DateTime, ForeignKey
from sqlalchemy.orm import relationship, backref
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
View github_project_list.md

https://github.com/jftuga/sqs_clipboard - Use AWS SQS as a clipboard to copy and paste across different systems and platforms

https://github.com/jftuga/gofwd - A cross-platform TCP port forwarder with Duo 2FA and Geo-IP integration

https://github.com/jftuga/spotprice - Quickly get AWS spot instance pricing

https://github.com/jftuga/ipinfo - Return IP address info including geographic location and distance when given IP address, email address, host name or URL

https://github.com/jftuga/photo_id_resizer - Resize photo ID images using face recognition technology

@jftuga
jftuga / compare_dt_libs.go
Last active Apr 20, 2021
comparing go date/time libraries
View compare_dt_libs.go
// compare_dt_libs.go
// comparing go date/time libraries
package main
import (
"fmt"
"github.com/btubbs/datetime"
"github.com/jinzhu/now"
@jftuga
jftuga / Compiling_Python_on_Debian_or_Raspberry_Pi.md
Last active Jun 18, 2021
Compiling Python 3.9 on Debian Buster or Raspberry Pi OS
View Compiling_Python_on_Debian_or_Raspberry_Pi.md

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 / less.md
Last active Jun 2, 2021
Using the LESS environment variable
View less.md

set LESS environment variable to: -SXIFR

  • -S: chop lines, side scroll with left/right arrow keys
  • -X: leave contents on screen when less exits
  • -I: ignore case
  • -F: quit immediately when the entire file fits in one screen
  • -R: enable colored output

useful:

@jftuga
jftuga / bounded.go
Created Feb 14, 2021
Go Concurrency Patterns: Pipelines and cancellation
View bounded.go
// Copied from: https://blog.golang.org/pipelines/bounded.go
package main
import (
"crypto/md5"
"errors"
"fmt"
"io/ioutil"
"os"