Skip to content

Instantly share code, notes, and snippets.

View briancline's full-sized avatar

Brian Cline briancline

  • SoftLayer / IBM Cloud
  • Dallas, Texas
View GitHub Profile
@briancline
briancline / access_log.py
Last active August 9, 2023 02:18
Nifty flask snippets
@bp_one.before_request
@bp_two.before_request
def _log_request():
logger.info(
'[access] %s %s %s %s %s %s "%s"',
flask.request.remote_addr,
flask.request.remote_user or '-',
flask.request.scheme,
flask.request.environ.get('SERVER_PROTOCOL'),
flask.request.blueprint,
@briancline
briancline / 0readme.md
Last active February 2, 2023 22:10
patch for ffmpeg 5.1: allow use of `%t` in image2 output filenames to include video timestamp of the frame

ffmpeg patch: video timestamp in image2 output filenames (2022-10-27)

What it do

When extracting individual frames from a video file as image outputs, allows the use of %t in the output filename to be substituted at runtime with the timecode for each frame (for example 00.01.02.033).

Therefore an output filename of wtf_%t.jpg looks like wtf_00.11.22.333.jpg.

@briancline
briancline / 0-pvemanagerlib-fix-sorting.diff
Created December 8, 2021 01:46
Proxmox VE - Fix strange ID-based sorting to sort by VM/container names instead
--- /usr/share/pve-manager/js/pvemanagerlib.js 2021-11-24 11:32:51.000000000 -0600
+++ /usr/share/pve-manager/js/bc-pvemanagerlib.js 2021-11-29 15:44:54.070286236 -0600
@@ -3785,7 +3785,7 @@
if (Ext.isNumeric(info.vmid) && info.vmid > 0) {
text = String(info.vmid);
if (info.name) {
- text += " (" + info.name + ')';
+ text = info.name + ' (' + text + ')';
}
} else { // node, pool, storage
@briancline
briancline / postgres_queries_and_commands.sql
Created December 10, 2022 06:33 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@briancline
briancline / mock_datetime.py
Created November 25, 2022 08:31 — forked from rbarrois/mock_datetime.py
Proper module for patching datetime.datetime.now().
# This code is in the public domain
# Author: Raphaël Barrois
from __future__ import print_function
import datetime
import mock
@briancline
briancline / reasonable-corners.js
Last active October 29, 2022 07:05
Everyone please calm down with the gigantic fisher-price rounded corners on everything (especially you, Google)
_chill_factor = 0.25;
_chill_threshold = 5; // px
for (const el of document.querySelectorAll('*')) {
for (const _corner of ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft']) {
_prop = 'border' + _corner + 'Radius';
if (window.getComputedStyle(el)[_prop] !== '0px') {
_rad = parseInt(window.getComputedStyle(el)[_prop]);
if (isNaN(_rad) || _rad <= _chill_threshold) {
continue;
@briancline
briancline / .pylintrc
Created June 6, 2022 17:51
Example pylintrc (mostly based off a few OpenStack projects' pylintrcs)
[MASTER]
ignore=CVS,.git,.venv,.env,.env3,.tox,dist,doc,*egg,alembic
extension-pkg-whitelist=alembic
[TYPECHECK]
# generated-members=SymbolName
[MESSAGES CONTROL]
# C0111: Missing module docstring
# C0301: Line too long (pycodestyle checks this)
@briancline
briancline / swift-ecdeps-osx.sh
Last active December 8, 2021 02:03
Install Swift/PyECLib dependencies on OSX
#!/bin/bash
## swift-ecdeps-osx.sh
## https://gist.github.com/briancline/364d539e0e230b92adae
##
## This script is meant to be used on OSX as a quick and easy way to download,
## build, and install gf-complete, Jerasure, and liberasurecode to any prefix
## path you specify. These are typically what you may want if you're working
## with OpenStack Swift for a quick and dirty EC-friendly test run.
##
## The Xcode command line tools are required in order for this to work.
@briancline
briancline / app.py
Created March 24, 2021 21:47
Fix for nginx + flask
from werkzeug.middleware import proxy_fix
app = flask.Flask('thing')
app.wsgi_app = proxy_fix.ProxyFix(app.wsgi_app, x_proto=1, x_host=1)