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 /
Last active August 9, 2023 02:18
Nifty flask snippets
def _log_request():
'[access] %s %s %s %s %s %s "%s"',
flask.request.remote_user or '-',
briancline /
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

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

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 /
Created November 25, 2022 08:31 — forked from rbarrois/
Proper module for patching
# This code is in the public domain
# Author: Raphaël Barrois
from __future__ import print_function
import datetime
import mock
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) {
briancline / .pylintrc
Created June 6, 2022 17:51
Example pylintrc (mostly based off a few OpenStack projects' pylintrcs)
# generated-members=SymbolName
# C0111: Missing module docstring
# C0301: Line too long (pycodestyle checks this)
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 ( {
- text += " (" + + ')';
+ text = + ' (' + text + ')';
} else { // node, pool, storage
briancline /
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)
briancline /
Last active June 2, 2018 19:18
ubuntu-17.10: Fix resolver behavior for dhclient when systemd-resolved is disabled (fall back to resolvconf)

The problem

So systemd-resolved has bugs. Disabling and stopping systemd-resolved to escape these is the logical step, but a dhcp-managed system does gracefully not fall back to resolvconf-managed file even though dhclient still executes the hook for it. As a result, you're then left with a broken resolv.conf that never gets updated by dhclient.

The reason is the systemd-resolved hook in dhclient only checks to see whether it is executable, and not whether it is also enabled. As a result, it still overwrites the default make_resolv_conf shell function with systemd-resolved logic. Since the resolvconf hook is executed before the resolved hook, you either have to rename it to a name that sorts after resolved, or symlink it thusly; but this doesn't fix the bug.

This diff fixes the resolved hook to actually check for the enabled state of the service in addition to checking whether it is executable. Not the best sequence of steps -- better to check the binary's executable state first, then check whe