Site Sponsors:
C++: A Tale of Three Loggers 
Just putting the finishing touches on a new training offering. Dedicated to GNU C++, by way of a bonus to my new students we decided to create a Namespace to share our modernization of our classic .ezlog logger.


The first logger to share with you is the LogWriter. Designed to be one of the "bonus" exercise in our GNU C++ Training, the LogWriter is short and a decidedly no-frills way to CREATE logging telemetry.


Demonstratively based upon LogWriter, next in the logging-line-up is EzLog. Evolving into a OS-integrated journaling facility worthy of rivaling it's own namesake, after spending years in the logging problem-domain I felt the need to overcome the present timezone-gap in the standard so as to support 80% of what most people care about in the "track my personal activities" problem domain: Namely, tagging a log entry happening in either our TimeLocal or TimeGlobal continuum.


Finally, in a polymorphic attempt to eliminate complexity, allow me to mention StatLog. Designed for those times when our AI needs to self-balance / recover from errors (etc) are ever on our minds, like many I often find the need to categorize my telemetries betwixt an enumerated set of classic messages

-to be a very "not bad" type of API obsession.

It can take any SME a ludicrously long time to design things to be so easy to understand & to use but ... and as always ...

Sharing is caring!


If mastering C/C++ is part of your professional horizon, then feel free to join the group so as to better monitor the migration of our plethora of "stdnoj" C++ Projects into our Modern C++ "era."

(i.e. Shameless, horrific pun ... intended!)

[ add comment ] ( 201 views )   |  permalink  |  related link
"Just Do It:" Graphical Command-Line Parameters for Python 3 
There seems to be a huge line between those who want to use console applications, and those who have the need for a GUI.

When using Python however, such lines need not exist: It can be easy to jump between the the Graphical & Textual Worlds!

from tkinter import *

# Mission: Create a way to query a user for command-line values.
# Mission statement implies the encapsulation of a GUI paradigm.
# Here is how to do so using tkinter under Python 3.

''' Prompter: Graphically get a dictionary of command-line strings from a user.
Dictionary result is empty when the `cancel` button has been pressed, else the results
will contain the tag-value pairing (i.e. Dictionary keys match the fields requested, to
get the user's response for each field.)
class Prompter:
def __init__(self):
self._dict = None
self._isOk = None

def _okay(self):
self._isOk = True

def _cancel(self):
self._isOk = False

def InputStrings(*fields, title="Input"):
self = Prompter() = Tk()

self._dict = dict()

if title:

row = 0
# zFields (A Label, plus an Entry, in a grid layout)
for ref in fields:
obj = Label(, text=str(ref))
obj.grid(row=row, column=0)

obj = Entry(, bd=5)
obj.grid(row=row, column=1)

row = row + 1

# zButtons (A Frame in the grid, plus the properly-centered pair of buttons)
bottom = Frame(
bottom.grid(row=row, columnspan=2)
btn = Button(bottom, text="Okay", command=self._okay)

btn = Button(bottom, text="Cancel", command=self._cancel)

# zCenter (Close enough to make no odds?)
width =
height =
x = width / 2 - ( / 2)
y = height / 2 - ( / 2)"+%d+%d" % (x, y))
results = dict()
if self._isOk is not True:
return results

for ref in self._dict.keys():
results[ref] = (self._dict[ref]).get()
return results

if __name__ == "__main__":
# Here is how we would use the Prompter from a Console Program:
results = Prompter.InputStrings("this", "isa", "test", title="Just Do It!")
if len(results) is 0:
print("Pressed Cancel - no values!")
print("Pressed Okay - got values!")
for ref in results:
print(ref, results[ref])

Taking time to review the test case, all one need do is to provide Prompter.InputStrings() with the queries. The title is optional.

Upon activation, Prompter.InputStrings() will create a reasonable-looking user interface, screen-center it & use it to query the user, then return a dictionary of the string response(s) provided.

When the user presses "cancel," the dictionary will be empty.

WIPI Results

Of course, one of the most annoying things about Dict()ionaries in this man's world is - at the time of this writing - the eccentric ordering of their key:value pairs.

Submitted for your perusal therefore, allow me to offer up Prompter.InputOrder() for your more predictable re-usages:

def InputOrder(*fields, title="Input"):
results = Prompter.InputStrings(*fields, title=title)
if len(results) is 0:
return [*zip([],[])]
data = []
for ref in fields:
results = zip(fields, data)
return [*results]

Designed to work exactly as Prompter.InputStrings() (sans the dict(), of course):

-Here be the test case:
    results = Prompter.InputOrder("this", "isa", "test", title="Just Do It!")
if len(results) is 0:
print("Pressed Cancel - no values!")
print("Pressed Okay - got values!")
for ref in results:
print(ref[0], ref[1])
-With the much more predictable, everything is WHERE-I-PUT-IT (W.I.P.I = 'wippy') 'list of lists' result paring:

[ add comment ] ( 263 views )   |  permalink  |  related link
Tagging Your MP# Files 
Command-line audiophiles of all descriptions surely know about ffmpeg - The de-facto way of managing allot more than MP3 files, ffmpeg ranks highly - even amongst the audacity set - for managing the ear-candy.

An avid consumer of every audio book I can afford (I get about 2 a year - Christmas & Father's day :) once ripped from the CDs most book-listeners feel that any random-play feature - as enjoyed by most of the planet - should be considered a form of torture.

Until so considered by a joint Geneva / UN-declaration, like many we simply *need* to combine all spoken-word tracks into a SINGLE album-file, or risk going 'radical ;-)

Tweakin' Tags

When it comes time to update the tags for our audio amalgamations, rather than using ffmpeg however, one will find the services of the taglib examples to be in high-demand. Namely, `tagreader` and `tagwriter`.

Designed to do precisely what their names imply, one can save hours by updating music meta-data in place.

Indeed, with a collection of over 60 unifile audiobooks to update, commands such as:

ffmpeg -i /MyMedia/AudioBooks/SW_05_02_21_The_Unifying_Force.mp3 -metadata title="SW_05_02_21_The_Unifying_Force" /MyMedia/biglist/SW_05_02_21_The_Unifying_Force.mp3
on a 1.2 GB file ... are simply evil!

The Recipe

Unlike using ffmpeg (sudo-installable,) using taglib's examples are - at the time of this telling - never for the faint-hearted.

For those who would like to use the aforementioned pair of tag-management console tools however, here are my notes:

# (1) You must install Gnu's C/C++
sudo apt-get install c++

# (2) You must install CMake
sudo apt-get install cmake

# (3) You mist install BOOST
sudo apt-get install libboost-all-dev

# (4) You must download, unpack, make & install taglib
cd /<wherever_unziped>/taglib-1.11.1
sudo make install

# (5) The examples folder under <wherever_unziped> will have the tagreader & tagwriter
-rwxr-xr-x 1 root root 1281440 Feb 24 04:31 tagreader
-rwxr-xr-x 1 root root 1287144 Feb 24 04:31 tagreader_c
-rw-rw-r-- 1 root root 2913 Oct 23 23:03 tagreader_c.c
-rw-rw-r-- 1 root root 3413 Oct 23 23:03 tagreader.cpp
-rwxr-xr-x 1 root root 1282016 Feb 24 04:31 tagwriter
-rw-rw-r-- 1 root root 5201 Oct 23 23:03 tagwriter.cpp

Caveat Python

Note: For those who would like to use `pip install pytaglib` under Python / PyPi, note that we came up with the above strategy rather than swimming thru the plethora of build problems. (*)

Not only will one need to install taglib anywize, but by simply building the examples (-DBUILD_EXAMPLES=ON, above) you'll already have what you need to manage your audio metadata without writing a single line of code:

Usage: tagwriter <fields> <files>

Where the valid fields are:
-t <title>
-a <artist>
-A <album>
-c <comment>
-g <genre>
-y <year>
-T <track>
-R <tagname> <tagvalue>
-I <tagname> <tagvalue>
-D <tagname>
And yes, FWIW the taglib heroes have my personal vote for surely what be the all-time best `example` program in the history of example-program-oscpacy. -Right down to that macho, got-my big-boy pants-on, C++ incarnation. ;-)

(*) Example of the `pip3 install pytaglib` woes:
fatal error: taglib/tstring.h: No such file or directory
is just the beginning of the problem - after getting past those, one will also see errors such as:
/usr/bin/ld: //usr/local/lib/libtag.a(tstring.cpp.o): relocation R_X86_64_32S against `_ZTVN6TagLib6StringE' can not be used when making a shared object; recompile with -fPIC
Is not life too short for thousands of developers to be fixing that type of nonsense ... in a PyPi Package?

[ add comment ] ( 254 views )   |  permalink  |  related link

<<First <Back | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Next> Last>>