Skip to content

Instantly share code, notes, and snippets.

@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 / address_bar.py
Created May 24, 2021 13:14
Read the Chrome URL address bar with Python and Selenium
r"""
address_bar.py
-John Taylor
May-24-2021
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
jftuga / all_remove_python_venv.ps1
Last active May 19, 2021 14:57
remove Python 3.9 Virtual Environment on Windows 10
# 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 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:
@jftuga
jftuga / sqlalchemy_upsert.py
Created May 19, 2021 08:05 — 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)
# 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 07:54 — forked from DmitryBe/app.py
SQLAlchemy quick start
# 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()
@jftuga
jftuga / github_project_list.md
Created May 16, 2021 20:02
GitHub Project List

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 April 20, 2021 15:52
comparing go date/time libraries
// 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 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 / less.md
Last active November 1, 2023 13:23
Using the LESS environment variable

set LESS environment variable to: -SXIFRs in your .bash_profile or .bashrc:

  • -S: chop lines, side scroll with left/right arrow keys
  • -X: leave contents on screen when less exits
  • -I: ignore case when searching with / or ?
  • -F: quit immediately when the entire file fits in one screen
  • -R: enable colored output
  • -s: squeeze blank lines into a single blank line

useful: