bash: Cryptocurrency Price From the Linux Terminal

#!/bin/bash
printf -v coin '%s' -1    
curl -X 'GET' 'https://api.coingecko.com/api/v3/simple/price?ids='"$1"'&vs_currencies=usd' \
  -H 'accept: application/json' 2> /dev/null | 
sed  's/.*usd"://' |   
sed 's/..$//' |        
sed 's/^/\$/'          
echo ""                

h/t Techstructive for the basic idea. I simplified their code by cutting out the I/O and putting the coin as a variable when calling the script, e.g. crypto.sh bitcoin, and formatting it by piping it through sed. Have I mentioned how much I love sed?

Tildeverse & Rawtext.club

I was checking out Lagrange, which is a web browser for the Project Gemini Internet protocol. The Gemini protocol is a text based, privacy focused communications protocol, and Lagrange renders the text beautifully.

But, during the course of checking it out, I was reminded of the Tildeverse. In short, tilde communities are playgrounds for people interested in multi-user *nix systems. It’s a kind of return to old *nix and BBS systems that you, if you are old enough, used to connect to with telnet or a modem, and features tools like IRC, which I haven’t used for years. There are a variety to choose from, e.g,, tilde.team, envs.net, tilde.club, ctrl-c.club, rw.rs, sdf.org, etc. Personally, I found the thinking behind rawtext.club in line with my attitudes about working from the command line, text, and the problems with social media. Their values include: off the web, DIY, resource minimalism, non-profit, and asynchronous. Here’s a bit from their social contract:

“People in democratic countries might be saying, “but don’t we have a government and legal system to protect us?”. In theory yes – but as history shows, these legal systems are often distorted to encourage those abuses. The corporations and wealthy individuals responsible are either good friends with governments, or hard at work “convincing” them. They are funding intense lobbying efforts to influence politicians, and entire media campaigns to erase public awareness of their work (or, similarly, to manufacture consent). The end result is that public service and regulations are being systematically dismantled and neutralized as an obstacle to reckless, short-sighted profiteering. The institutions that are nominally for the people, by the people, and designed to protect the people, turn out to be none of those, and we are being broken apart into a bickering sea of lonely individuals.”

https://rawtext.club/social-contract.html

You Don’t Need (To Complain About) Substack

“Our timing was nearly perfect—a mere two weeks after we wrote our joint essay, Substack had a huge controversy, and is now facing a backlash. Writers are thinking of jumping ship and looking for ideas for what to do next. I’ve been doing this without a net for a while, and I have a few thoughts on how it can be done.”

—Ernie Smith, “Newsletter, Untethered.” Tedium.co. March 19, 2021.

Basically, Ernie explains how to roll your own newsletter. If you don’t like Substack, Medium, or these other publishing platforms, you don’t have to use them. There are options, but many require technical expertise, which is what you are paying them not to learn so you can focus on writing.

Let me take a moment to comment, with the full understanding that no one cares what I think: The Substack “controversy” is nonsense. What they are doing is figuring out who could make money on their platform and removing the risk for these writers to try it out. I haven’t read up on who they made offers to, but is the world a more interesting place with Scott Alexander publishing Astral Codex Ten and Freddie deBoer being given a one year guarantee to build an audience on the platform and concentrate on writing? Probably. I don’t agree with the politics of either of these individuals. But, I do know that the modern media landscape doesn’t give them a platform, and it should. When we support a media landscape of diverse voices, it means you’re going to hear a lot of viewpoints you’re not going to like. That’s the price of a diverse landscape.

Of course, capitalism comes with incentives, and the incentives encourage extreme viewpoints. That’s what people will pay for.

If you want to promote conventional opinion, write mediocre poetry, share your hot tips on making money (or living your best life, nutrition advice or what not), then you get on a free tier of an online publishing platform. Or, if you are slightly more serious, you pay for the privilege and get a WordPress personal site or equivalent. And, if you are very good, relatable, extreme and/or lucky, Substack might approach you in a decade too. Good luck to you, if that’s what you want.

But, complaining how some company runs its business? Is Substack Amazon, Apple, Google, Facebook or Microsoft? Do we want to talk about the relative harms here and why quitting Substack for some other online publishing or newsletter platform is a relatively cost-free form of virtue signaling? Want to guess how many people will read and heed Ernie’s advice rather than join the platform of the moment? Fractions of a percent. In other words, the objections about Substack and the migrating to another service with the same incentives is the kind of nonsense that characterizes left activism and is why so much of it has very little impact on the real world beyond soothing a few consciences and signaling we are good people at very little cost.

Rolling your own has a serious cost, in time and effort. Giving up Facebook, or one of the other feudal internet companies, also has a significant cost. But, leaving Substack to go to Buttondown? Who you fooling?

For a better argument, see Ben Thompson.

Thanks to Ernie for suggesting a few editorial changes to make it clear that rolling your own is not cost-free nor is it virtual signaling. It is a great way to control your creative output and foster independence. The challenge for publishing ecosystems is getting the tools to the point that non-technical writers can take advantage of them.

bash: Number of Days Between Today and Some Future Date

#!/bin/bash                                                        
                                                                   
printf -v date '%(%Y-%m-%d)T\n' -1                                 
echo $(( ($(date -d $1 +%s) - $(date -d $date +%s)) / 86400 )) days

Above is a bash script to output the number of days between today and some future date. Copy it into a file, e.g., diffdate.sh, into a directory, e.g., ~/bin/scripts. Then, enter the directory you saved it to and type to make it executable:

$ chmod +x diffdate.sh

Then, check your .profile to make sure something like this in it:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then                             
  PATH="$HOME/bin:$PATH"
fi                                                                   

Then, run the script.

$ diffdate.sh 2021-06-01
70 days

I have to figure out the difference between today and some future date all the time for forecasting, and today was the day I finally bothered to figure out how to do it from the command line. I have to start thinking of ways to make shell scripts to do this little tasks that I go to the web for.

Fun With Fortune in Linux

Fortune provides a random quote or aphorism every time you open a terminal in Linux. I wanted to have a personalized fortune using zuihitsu quotes posted on this site come up whenever I opened a terminal. If you want to do something similar, here’s the procedure.

To check if you have it installed, simply type fortune into the terminal.

$ fortune 

This either returned a fortune or an error message. If you got an error message, then install fortune using the package manager for your system.

$ sudo apt install fortune-mod

Let’s create our own file of fortunes. I want to use my zuihitsu quotes I have posted on this site. This file is a text file that looks like so:

%
quote 1
%
quote 2
%
quote ...

There is a copy of the file available online.

If you have just a file with lines of quotes, this is easy to get into this format using emacs. Simply type: M-%, followed by c-q c-j Enter then c-q c-j % c-q c-j Enter. I like to check the replacements, so just keep hitting y to do the replacement and move on to the next one if it looks good. Save the file to the appropriate directory, which on Debian systems is /usr/share/games/fortunes, but can vary. For explanation purposes, we are going to assume the file was named zuihitsu with no file extension.

Note: If you are using the file above, just save it as a text file in your directory. Then, copy it to the appropriate system directory without a file extension.

Now, create a .dat file for the file you just made.

$ sudo strfile zuihitsu

Set the same permissions on the new files as the others in the directory. This just makes the files readable to groups and others.

$ sudo chmod o+r zuihitsu
$ sudo chmod g+r zuihitsu
$ sudo chmod o+r zuihitsu.dat
$ sudo chmod g+r zuihitsu.dat

Following the rest of the directory. I added a symbolic link.

$ sudo ln -s zuihitsu zuihitsu.u8

You should be able to test it now.

$ fortune zuihitsu

Assuming that worked. The final thing to do is to have your preferred shell call this when it runs. I use bash, so I added the command above to my bash_aliases file. From then on, it will pull a random quote from the zuihitsu file every time you bring up the terminal.

Bonus

Make a fortune come up automatically every time you login or open a new terminal by adding the following to .bashrc or .bash_aliases:

fortune zuihitsu 

Also, if you use mutt, you can add the following to your .muttrc file to have this fortune file generate a random signature for your emails:

set signature="fortune zuihitsu -s|"

The -s selects shorts quotes and the | pipes it to your email text.

Did you know the original fortune-mod fortune collection is available as a EPUB?