Skip to content

Instantly share code, notes, and snippets.

@afoster
afoster / readme.md
Created January 8, 2025 00:36
Brother P-touch PT-P710BT

Get ptouch-print

git clone https://git.familie-radermacher.ch/linux/ptouch-print.git
cd ptouch-print

Check its README

cat README

@afoster
afoster / gist:9f19bf516d81e1915f88d50de8f1e80b
Last active March 29, 2024 03:38
Linux I/O performance on 2013 Mac Pro
# Credit https://lewisinthelandofmachines.tumblr.com/post/662138111279644672/ubuntu-2004-on-2013-trashcan-mac-pro-61
# Improves I/O throughput and latency on an old trashcan Mac Pro under Debian 12
#
# /etc/hdparm.conf
/dev/sda {
write_cache = off
}
/*
* Star Micronics
*
* CUPS Filter
*
* [ Linux ]
* compile cmd: gcc -Wl,-rpath,/usr/lib -Wall -fPIC -O2 -o rastertostar rastertostar.c -lcupsimage -lcups
* compile requires cups-devel-1.1.19-13.i386.rpm (version not neccessarily important?)
* find cups-devel location here: http://rpmfind.net/linux/rpm2html/search.php?query=cups-devel&submit=Search+...&system=&arch=
*
@afoster
afoster / nginx-rewrites.conf
Created November 1, 2019 02:04
Bitbucket to Gitlab nginx redirects
# If you migrate your repos from Bitbucket to Gitlab
# Here are some nginx rewrites to redirect common routes to their Gitlab equivalent
#
# Probably in a `location / {}`:
# File URLs, e.g. https://bitbucket.example.com/projects/XYZ/repos/xyz-repo/browse/app/Http/Controllers/HomeController.php
rewrite ^/projects/([^\/]*)/repos/([^\/]*)/browse/(.*) https://gitlab.example.com/$1/$2/blob/master/$3;
# Commit URLs, e.g. https://bitbucket.example.com/projects/XYZ/repos/xyz-repo/commits/afd8adac26d8f77e40aad19e2e8584aae1abcca2
rewrite ^/projects/([^\/]*)/repos/([^\/]*)/commits/([a-f0-9]+) https://gitlab.example.com/$1/$2/commit/$3;
@afoster
afoster / mysql-5.7-rollback.md
Last active June 21, 2018 03:35
Homebrew MySQL 8.0.11 roll back to 5.7

MySQL 8.0.11 from Homebrew lunched my local database

The MySQL 5.7.22 to 8.0.11 upgrade contains some serious non-backwards-compatible changes (among them authentication - from mysql_native_password to caching_sha2_password by default) and, in my case, could not migrate or upgrade some tables due to a "error in fixing SE data" error discussed at https://bugs.mysql.com/bug.php?id=87229.

I tried dropping unneeded databases that contained those problematic tables and got to the point where mysqld was happy to run, but all my databases seemed to disappear despite being present on disk, mysql_upgrade failed to run with "Error occurred: Cannot setup server variables." and mysqld 5.7 now segfaulted on startup presumably due to changes in the database files.

I restored /usr/local/var/mysql from backup and installed MySQL 5.7 again.

@afoster
afoster / whois2csv.rb
Created June 8, 2018 07:53
whois2csv.rb
# Read domain names from a CSV file, output another containing results of some WHOIS database lookups.
#
# requires whois, whois-parser gems
require 'rubygems'
require 'optparse'
require 'whois'
require 'whois-parser'
require 'csv'
@afoster
afoster / faxstats.rb
Created June 8, 2018 07:38
Extract stats from a HylaFAX xferfaxlog to CSV
require 'csv'
# usage: ruby faxstats.rb /path/to/xferfaxlog
#
# A quick and nasty script to parse a HylaFAX xferfaxlog file and print
# a human-readable report of the number of faxes received, grouped by
# destination number, totalled by day. Specify the date range of interest
# in the script by setting from_date and to_date.
tsv = File.read(ARGV[0])
@afoster
afoster / functions.php
Last active February 27, 2020 02:16
Example pipe-encapsulated tag replace for Wordpress content
<?php
// Copy the following snippet into your active theme's functions.php file
// After updating the placeholder phone, email and company name values.
function replace_system_tag($text) {
$replace = array(
'|PHONE|' => '(02) 9555 5555',
'|STAFFEMAIL|' => sprintf('<a href="mailto:%1$s">%1$s</a>', 'test@example.com'),
'|LEVEL|' => 'ACME Pty Ltd',
@afoster
afoster / settings.json
Created February 23, 2017 02:51
vscode config for dot/graphviz output on save
// First, install the emeraldwalk.RunOnSave extension.
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.dot$",
"cmd": "dot -Tpng -o \"${file}\".png \"${file}\""
}
]
}

Keybase proof

I hereby claim:

  • I am afoster on github.
  • I am anfo (https://keybase.io/anfo) on keybase.
  • I have a public key whose fingerprint is 3623 7565 D499 7295 DBCF 2E6C 008C A185 1971 65BB

To claim this, I am signing this object: