Skip to content

Instantly share code, notes, and snippets.

@bockor
bockor / gist:81cf26bbd7ca5acb3e0f99b8f61c5c02
Last active August 31, 2026 07:57
A complete, dependency-free Python script (using only the standard library) that compares two SQLite databases.
"""
A complete, dependency-free Python script (using only the standard library)
that compares two SQLite databases.
It compares:
-----------
Tables: Tables added or removed.
Schemas: Columns added, removed, or if their data types changed.
Data: Rows inserted, deleted, or updated.
@bockor
bockor / gist:43eb29be4e28a9a1f419dcff52225d1f
Last active August 26, 2026 11:38
Using Regular epressions in Database Browser for SQLITE (DB4S)
Database Browser for SQLITE : https://sqlitebrowser.org/
Using REGEXP in the Data Filter Bar
------------------------------------
/^(?!mc\.)/ not beginning with mc.
/(?<!.int)$/ not ending with .int
/(10.5.135.49|10.5.135.50)/ OR function
@bockor
bockor / gist:ba6f15942182add36a576f22404cf506
Created August 16, 2026 07:25
Python sqlite3.Connection.row_factory
"""
Ref: https://zetcode.com/python/sqlite3-connection-row-factory/
See also: https://zetcode.com/python/sqlite3-row-keys/
"""
import sqlite3
from collections import namedtuple
@bockor
bockor / gist:08cbdd4c7e09ca3cc3eba49873fe4d5d
Last active August 2, 2026 14:23
find illegal unicode charaters in a csv file
Relevant unicode characters reference: https://www.unicode.org/charts/PDF/U2000.pdf
how to type an unicode character in Linux:
CTRL + Shift + U2014 Enter
how to type an unico character in Windoze: (not sure here !)
NumLock ON Alt Down 0151
file_with_illegal_characters.csv
--------------------------------
@bockor
bockor / gist:0774c689c4dfd3f7abac3275130a48b2
Created June 27, 2026 16:35
FIND NETWORK HIERARCHIES in SQLITE using Simple Recursion with Common Table Expressions ( CTE )
FIND NETWORK HIERARCHIES in SQLITE
using
Simple Recursion with Common Table Expressions ( CTE )
======================================================
Ref: https://www.youtube.com/watch?v=7GpyHedM4pw
Ref: https://douglaskline.blogspot.com/2016/06/simple-recursion-in-sql-with-common.html
Recursive CTE Principle:
@bockor
bockor / gist:ae17c54aa13409521d1a66859b4a63ad
Created June 21, 2026 14:52
operations with jq - Command-line JSON processor
# https://stackoverflow.com/questions/74400075/how-to-select-based-on-a-substring-in-jq
# https://jqlang.org/manual/#conditionals-and-comparisons
# https://play.jqlang.org/s/ovqQqRTfNE_Zxw0
# https://www.youtube.com/watch?v=YrVR09v78Dc
curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq -r '.[].commit.author | select (.email | contains(".us"))'
curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq '.[].commit.author | select (.email | contains("github") | not) '
curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq --arg n "github" '.[].commit.author | select (.email | contains($n)) '
@bockor
bockor / gist:d629d5717fb484e5724d501b0a828e69
Created May 17, 2026 14:20
Matching IPs to Subnets in Python in an Efficient Way // python // PyTricia
"""
PyTricia : Matching IPs to Subnets in Python in an Efficient Way
https://jmanteau.fr/posts/matching-ips-to-subnets-in-python-in-an-efficient-way/
https://github.com/jsommers/pytricia
https://www.youtube.com/watch?v=i5zP7iiw91Y ;
What is Python Pickle? A Beginner’s Guide to Data Serialization
@bockor
bockor / gist:d751e252c5bb459bd4c6fe6934a46818
Last active August 23, 2025 14:39
hosting-multiple-flask-apps-using-apache-mod_wsgi
# Inspiration ... where did I start ?:
# https://www.blopig.com/blog/2021/05/hosting-multiple-flask-apps-using-apache-mod_wsgi/
# https://www.rosehosting.com/blog/how-to-install-flask-on-ubuntu-22-04-with-apache-and-wsgi/?srsltid=AfmBOoqkm3GW5tXYBQywDTb_Y6SuLD0URVm9OC3uBqO4QhtSHpndMbz-
# https://stackoverflow.com/questions/29882579/run-multiple-independent-flask-apps-in-ubuntu
# https://serverfault.com/questions/357108/what-permissions-should-my-website-files-folders-have-on-a-linux-webserver
sudo apt install apache2 -y
sudo systemctl status apache2
sudo apt install libapache2-mod-wsgi-py3
apachectl -M | grep wsgi
@bockor
bockor / gist:8ade83eef84cbc57da84390525838d2f
Created July 2, 2025 11:51
SQLITE DATE - TIME - DATETIME notes
SQLITE DATE - TIME - DATETIME YOUTUBE TUT
https://www.youtube.com/watch?v=nJRvz5Rhrx0
# Insert DEFAULT timestamp "now" as INTEGER
# and unixepoch prior SQLITE 3.38 (2022-02-22).
####################################################
create table t1 (c1 TEXT, c2 INTEGER DEFAULT (strftime('%s', 'now')));
insert into t1(c1) values ('drink'),('eat');
@bockor
bockor / gist:f3b450244ca72330f97ca1ed72da18e5
Created June 14, 2025 08:52
python dictionary nested get
"""
The walrus operator “:=” is an operator used to evaluate, assign, and return value from a single statement in Python.
It was introduced in Python 3.8
"""
sss = {'color': 'red', 'size': 'l', 'clips': {'number': 6, 'material': 'metal'}}
if value := sss.get("clips", {}).get("number"):
print(f"Number of clips: {value}")
"""