Menu
: Happy Friendsgiving
Today I am celebrating my friends. I am not celebrating the genocide of millions of indigenous peoples, or the stealing, rape, and exploitation of the lands that had been their ancestral homes for millennia.
: Oh look, a cat!
I saw a cat on my morning walk. This is an excellent omen.
: dc, Desk Calculator
I love the Linux command line interface ( CLI ). It was one of the main reasons I switched to Linux ( but let's face it, even without Linux's command line, my utter hatred for all things Microsoft and Apple would have necessitated the change ). Also, I use a calculator several times a day. And Linux has many available calculators, both GUI and CLI; some, like Octave, offer both interfaces. Most of these calculators are powerful, feature-rich, and user friendly.
Then there is the venerable dc, short for desk calculator. dc is supposedly the oldest UNIX utility that is still available in UNIX-like operating systems, so old that the original incarnation was written in PDP-7 machine code. dc is powerful and feature-rich, to be sure, but user friendly? ХАХАХАХАХАХАХАХАХА! Of course, when I need a calculator, it is dc that I turn to.
Let me give you a quick example of a dc session. First I open a terminal, type:
dc
and hit <enter>, and I see:
_
That's all you get. An underscore cursor. Nothing else. Nada. The damn cursor doesn't even blink. At this point, you might be tempted to abandon the whole thing. No worries, all you have to do is type q and hit <enter>, and the program exits and dumps you back out to your shell.
But let's say you accept the challenge and want to continue. Let's start with something simple, like two plus three. At the dc cursor, type:
2 3 + p ( note the spaces; for now make sure you include them. )
and hit <enter> and you will see the answer, along with a fresh cursor to begin a new operation:
5_
We can safely assume that the answer to two plus three is five, as shown, but if you have doubts you can double check your work on another calculator.
So what the hell just happened? Let's break it down. dc uses reverse Polish notation ( RPN, also known as Łukasiewicz notation; yes, I am fun at parties ), which means the operands are entered first ( in this case, 2 3 ) followed by the operator ( in this case, + ). The p is the command to print the result.
So we can continue with some other operators: - is subtraction, * is multiplication, / is division; as above, hit <enter> after each expression:
2 3 - p-1
2 3 * p6
2 3 / p0
_
And here we see an important feature ( bug? ) of dc: by default, zero decimal places are shown by the p command, unless dc is instructed to show more. This is done by:
4 k
In this case, we are telling dc to display 4 decimal places; k being the command to assign decimal places. Once the places are assigned in a session, that will continue to be the default unless a new k command is used. So let's try the previous expression again, which can be easily accomplished by hitting the <up> key until the desired expression appears:
2 3 / p.6666
And here we see another important consideration: dc displays the desired number of decimal places, but doesn't round the result. So you may want to plan ahead, and assign more decimal places than you need, so the final result can be properly rounded.
So that is enough to get someone started and do simple calculations. I will post a follow-up with a little more history, and some more operators, like powers and square roots. We will also take a look at reusing results and talk a little about *shudder* the stack.
So we can end our session by typing q and hitting <enter> to return to the shell, and I'll see you next time.
: Blue and Pee-Wee
Once upon a time my mom had a cat named Blue. Blue was a tabby-Siamese mix. Blue was also a biter; if you got too close to her she would rip your head off. After much affection and patience, I finally got Blue to like me...and we formed a strong bond, the strongest I ever experienced with a cat. My mom used to get angry because when I was there Blue would ignore her and hang out with me during my visit. As all cats must, Blue died, after a life of being loved and pampered.
Fast forward many years, and my friend Ernie got a cat named Pee-Wee when a friend died and left him her cats. Pee-Wee was also a tabby-Siamese mix. Pee-Wee was also a biter; if you got too close to him he would rip your head off. After much affection and patience, I finally got Pee-Wee to like me...and we formed a strong bond, as strong as my bond with Blue. Alas, Pee-Wee also died, after a life of being loved and pampered.
Blue and Pee-Wee were so much alike that sometimes I thought Pee-Wee was Blue reborn, coming back to spend more time with me. That's ridiculous, right? Anyway, they will never be forgotten.
: Give Your CLI the Finger
Let's have some finger fun!
finger is a command on UNIX-like operating systems that returns information about the users that are logged into the system. Since I use the username buckyogi on my Linux system, I enter the terminal and type:
finger buckyogi
and hit <enter>:
As you can see, it shows my username first. If I had used my real name when I installed Linux, the Name field would show my real name, but since I echoed my username, it is shown again. It shows my home directory and the shell ( command line interface, or CLI ) I am using ( zsh FTW! ). Then it shows the time I logged on and my idle time, which in this case is the entire time I've been logged on.
Huh? I've been using my laptop almost the entire time I've been logged in, why does finger show I've been idle the entire time? finger measures the idle time in the console, which is Linux's native command line interface. If I had not installed a desktop environment ( GUI ) when I installed Linux, it would have booted into the console; this is how most network server installs of Linux work, no GUI, CLI only.
So even though I usually spend a good part of my day on the command line, I do so inside a terminal, which is a GUI application to access the shell, and its usage doesn't register in the console.
Then we see that I have messages turned off and no mail. mail is an internal mail system in UNIX-like operating systems to send emails to other users.
When I first used the finger command I was delighted to see the final line: No Plan. No shit, right? But we can create a plan by entering it in a hidden file named .plan that is saved to the user's home directory, which, as you can see from the above output, is /home/buckyogi.
So I created a .plan file and saved it, let's see what happens:
We can see that my plan is Nine from Outer Space ( IYKYK ). If you want to learn more than you ever wanted to know about the finger command do an online search for finger's man page.
What's a man page, you ask? That is a subject for another day.
: Hacking Shortwave
I love radio. Being a boomer, I grew up with radio and at a young age learned about underground and college radio, which eschewed all the Casey Kasem top 40 corporate crap in favor of stuff people might actually want to listen to. With the advent of the WWW era, which allowed one to listen to almost literally any radio station on the planet, my vistas expanded prodigiously and I was able to explore music on a whole new level.
I love the Shortwave Internet Radio application. It is a splendid Linux desktop application that allows me to organize my favorite stations and access them with a tap of the touchpad. It offers the ability to search and add stations via the excellent radio-browser service.
But I am a serious old-school boomer with serious OCD who prefers to do things myself. Good news! The Shortwave application allows one to add Internet radio stations manually, too (truth be told, that is why I use it as opposed to similar applications such as Tuner). The one thing Shortwave doesn't offer, though, is the ability to edit station information once the entry is entered.
The reason for this is that the radio-browser service was susceptible to vandalism, similar to Wikipedia. But what about weirdo boomers like me who don't use radio-browser, and wants the ability to edit station entries locally?
Huzzah! Shortwave stores its local data in an SQLite database called Shortwave.db (duh). On my system it is stored here:
~/.var/app/de.haeckerfelix.Shortwave/data/Shortwave/Shortwave.db
If you install Shortwave via Flatpak, the primary source for the software, this is probably where your copy is stored, too (of course, if you are an even bigger weirdo than me, feel free to build from source; the instructions are on the Shortwave site). Armed with this knowledge, it is a simple matter to use an SQLite application to edit the database (I use DB Browser for SQLite which is available in my distro's package manager, and should be available in yours, too).
What's the point? I don't know, I guess just that there is always a way to do what you can't with computers, if you try. Anyway, this little hack (kluge?) improved my enjoyment of an application I already loved.
: Despair
I cried Saturday, for the first time in decades.
: For Ester Only
Hi Ester. Happy Anniversary.