Let's say you need to parse and analyse some raw data, for example a log file, to generate a report.
An easy way to get started with this is to write some Python, Perl, Ruby or shell code to work on your file and print meaningful information about it.
To illustrate this article I am going to write a Python script to "analyze" the var/log/syslog
log file, whose entries look like this:
Apr 12 11:53:42 dozer org.kde.KScreen[6995]: kscreen.xrandr: #011Primary: false
Apr 12 11:53:42 dozer org.kde.KScreen[6995]: kscreen.xrandr: Output 68 : connected = false , enabled = false
Apr 12 11:53:43 dozer org.kde.KScreen[6995]: kscreen.xrandr: Emitting configChanged()
Apr 12 11:53:47 dozer dbus-daemon[991]: [system] Activating service name='org.kde.powerdevil.backlighthelper' requested by ':1.416652' (uid=1001 pid=7186 comm="/usr/lib/x86_64-linux-gnu/libexec/org_kde_powerdev" label="unconfined") (usi
Apr 12 11:53:47 dozer org.kde.powerdevil.backlighthelper: QDBusArgument: read from a write-only object
Apr 12 11:53:47 dozer org.kde.powerdevil.backlighthelper: message repeated 2 times: [ QDBusArgument: read from a write-only object]
Apr 12 11:53:47 dozer dbus-daemon[991]: [system] Successfully activated service 'org.kde.powerdevil.backlighthelper'
Apr 12 11:54:04 dozer kernel: [716525.975149] usb 3-2: USB disconnect, device number 64
Apr 12 11:54:04 dozer kernel: [716525.975156] usb 3-2.1: USB disconnect, device number 65
Apr 12 11:54:04 dozer kernel: [716526.040164] usb 3-2.3: USB disconnect, device number 66
Apr 12 11:54:04 dozer upowerd[1672]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0/0003:046D:C046.0025
Apr 12 11:54:04 dozer upowerd[1672]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0
Apr 12 11:54:04 dozer upowerd[1672]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1
Apr 12 11:54:04 dozer acpid: input device has been disconnected, fd 6
The script is going to take the log entries from stdin, iterate on the lines and produce a report on stdout.
The first thing to do is to parse the log file. Since we read the log from stdin, we can start with something like this:
import sys
def parse_line(line):
# TODO
def parse_log():
for line in sys.stdin.readlines():
entry = parse_line(line)
if entry:
yield entry
def main():
for entry in parse_log():
print(entry)
if __name__ == "__main__":
main()
I don't know about you, but when I work in a git repository for a long time, I tend to accumulate branches, which I need to clean up.
There are a number of tools to do this, but since I have been teaching myself Rust I thought it was a good topic for a first "real" program. So here is "Git Bonsai", a command-line tool to help you keep your git repository clean and tidy by:
For example, given a repository like this:
$ git log --all --oneline --graph
* f97c782 (HEAD -> master) Merging topic1
|\
| * f6bfa90 (topic1) Merging topic1-1
| |\
| | * 6943ed2 (topic1-1) Create topic1-1
| |/
| * 4ea41ff Create topic1
|/
| * eec4ebe (topic2) Create topic2
|/
* b8b1506 Init
$ git branch
* master
topic1
topic1-1
topic2
This article is part of a series on creating a Bluetooth speaker from an old vacuum tube radio and spare parts I had lying around in the house.
If you remember well, my first attempt at electronics for this Bluetooth speaker project was using an all-in-one Bluetooth + amplifier board. It did not go well, so I tried to use the guts of an existing Bluetooth speaker instead. That almost worked, but I experienced stability issues I was not able to solve :(
This article is about the third attempt: following the instructions from the Radio Workshop (which I mentioned at the end of part 3) to get a working Bluetooth + mono amplifier (hopefully).
I am happy to announce the release of Pixel Wheels 0.15.0, the first version of year 2020! This version could almost have been called 0.14.2 as it's mostly made of bug fixes. Take this as an hint that the game is almost feature complete... at least that is how I analyze it :)
What's in this new version, you ask?
This article is part of a series on creating a Bluetooth speaker from an old vacuum tube radio and spare parts I had lying around in the house.
So, while I was waiting for the components I ordered at the end of part 3 to arrive, I spent some time working on the "frontend": the front panel of the radio.
In case you forgot, this is what the original front panel looked like at the beginning:
After some work on the cabinet itself, the wood looked much better:
But the original radio had a cloth and a grille to hide the speaker, so there was more work to do on the front side.
This article is part of a series on creating a Bluetooth speaker from an old vacuum tube radio and spare parts I had lying around in the house.
So after the failure of part 2, I decided to try a seemingly safer approach: buy a small Bluetooth speaker, tear it down and use its guts to power my radio.
I bought a small portable Grundig GSB 710 Bluetooth speaker. It's a mono speaker, but since the radio I am working was also mono, as was common by the time it was created, it felt like a good fit. I checked it worked and started to tear it down:
This article is part of a series on creating a Bluetooth speaker from an old vacuum tube radio and spare parts I had lying around in the house.
As I explained in part 1, the electronics looked too old so I decided to replace it with a small Bluetooth audio amplifier board and two loud speakers.
I ordered a TPA3116D2-based Bluetooth amplifier from Nobsound and a pair of MTX TX450C, 4 Ohms loud speakers.
This article is the first of a series on creating a Bluetooth speaker from an old vacuum tube radio and spare parts I had lying around in the house.
At the time I am writing this, the speaker is not done yet, so there is still a chance that I never finish it... As you will see, the journey so far as not been straight, I hit a few roadblocks and changed my mind while working on this project.
Let's start with the reason I started this project. When we moved in our house, more than a decade ago, I found this old vacuum tube radio left around by the previous owner:
I have always wanted to make something out of it, but never took the time to do so, until last month.
Last week I released version 0.14.1 of Pixel Wheels (I am a bit late with the announcement, it has been a busy week).
I am happy to say this is the first release to include changes from other contributors, thanks to Tim Schumacher and Julien Bolard!
Here are the most important changes:
I participated again to Inktober, the yearly challenge where you draw and ink one drawing a day each day of October. The Inktober web site provides a "prompt list": a list of words for each day, which you can (but are not forced to) follow.
I followed it as it helps me come up with drawing ideas, and I also picked "cats" as a recurring theme, so all my drawings are filled with kittens. This makes them very Internet friendly, since as we all know, the Internet was created to share cat pictures, right?