published by whitemice on Fri, 12/11/2020 - 08:41
JSON is a strange format [I'm not a fan]. Opening a large JSON file in many text editors is unfruitful when the file is one long line - they will burn CPU trying to line wrap the data.
JSON however can be easily linted on the command line, producing a more friendly file.
cat onelongline.json | python -m json.tool > linted.json
And the file linted.json is readable and friendlier with text editors.
published by whitemice on Thu, 12/10/2020 - 14:58
I have a postfix SMTP relay buried deep in a network behind proxy servers, all the infrastructure [sadly] is IPv4 only. This works, yet one ends up with many log messages like:
connect to smtp.office365.com[2603:1036:304:2857::2]:587: Network is unreachable
The server attempts if IPv6 result from the DNS lookup first. So let's make postfix use IPv4 only.
postconf -e inet_protocols=ipv4
That's it! No more "unreachable" log messages.
published by whitemice on Fri, 12/04/2020 - 08:21
I went to start my Windows XP virtual machine, after something like ~4 years. And it failed to start with an 0x80004005 error: "Could not find the VirtualBox Report Desktop Extension library." Hmmm, that's strange.
Turns out that the extensions loaded by the Windows XP VM uses the library libvncserver which was no longer installed on the host. Unfortunately the VirtualBox Extensions are not integrated into the distribution's package manager.
published by whitemice on Wed, 09/09/2020 - 14:06
Using lxml's etree to iteratively parse an XML document and I wanted to drop a specific element from the stream...
for event, element in etree.iterparse(self.rfile, events=("end",)):
if (event == 'end') and (element.tag == 'row'):
self.wfile.write(etree.tostring(element))
elif (event == 'end') and (element.tag == name_of_element_to_drop):
element.getparent().remove(element) # drop element
The secret sauce is: element.getparent().remove(element)
published by whitemice on Sun, 05/24/2020 - 14:52
Uh oh, in a default-ish GNOME install of openSUSE 15.1 there are a couple of unmatched / unclaimed dependencies. It appears Zoom Inc. did not try very hard when drafting the spec for their LINUX clients.
published by whitemice on Mon, 04/20/2020 - 13:21
In a few recent conversations I have become aware of an unawareness - an unawareness of the awesome that is gedit's best feature: External Tools. External Tools allow you to effortlessly link the power of the shell, Python, or whatever into an otherwise already excellent text editor yielding maximum awesome. External Tools, unlike some similar features in many IDEs is drop-dead simple to use - you do not need to go somewhere and edit files, etc...
published by whitemice on Mon, 11/25/2019 - 13:33
This is an update from "Uncoloring ls" which documents how to disable colored ls output on older systems which define that behavior in a profile.d script.
published by whitemice on Mon, 10/21/2019 - 09:36
In some effort to avoid time-zone drama, or perhaps due to fantasies of efficiency, some developer put a date-time field in a PostgreSQL database as an integer; specifically as a UNIX Time value. ¯\_(ツ)_/¯
How to present this as a normal date in a query result?
published by whitemice on Wed, 09/11/2019 - 11:09
Dates in databases are a tedious thing. Sometimes a time value is recorded as a timestamp, at other times - probably in most cases - it is recorded as a date. Yet it can be useful to perform date-time queries using a representation of time distinct from what is recorded in the table. For example a database which records timestamps, but I want to look-up records by date.
To this end PostgreSQL supports indexing a table by a cast of a field.
published by whitemice on Fri, 08/30/2019 - 15:36
The assignment of print queues to device URIs can be listed from a CUPS server using the "-v" option.
The following authenticates to the CUPS server cups.example.com as user adam and lists the queue and device URI relationships.
Pages