Many of my traditional blog post live on this site, but a great majority of my social-style posts can be found on my much-busier microbloging site at updates.passthejoe.net. It's busier because my BlogPoster "microblogging" script generates short, Twitter-style posts from the Linux or Windows (or anywhere you can run Ruby with too many Gems) command line, uploads them to the web server and send them out on my Twitter and Mastodon feeds.
I used to post to this blog via scripts and Unix/Linux utilities (curl and Unison) that helped me mirror the files locally and on the server. Since this site recently moved hosts, none of that is set up. I'm just using SFTP and SSH to write posts and manage the site.
Disqus comments are not live just yet because I'm not sure about what I'm going to do for the domain on this site. I'll probably restore the old domain at first just to have some continuity, but for now I like using the "free" domain from this site's new host, NearlyFreeSpeech.net.
How to get a free static website with SSL from Gitlab https://rolodato.com/2018/01/14/static-websites-for-hackers.html
You don't have to use Jekyll. Gitlab provides a list of a bunch of other static-site-generators it supports, including Middleman, Octopress (which is really just Jekyll with extras), Hexo, Metalsmith, Hugo, Pelican and Nikola.
I have a couple of points in my BlogPoster Ruby script where an error can cause the program to end, and I have been at odds as to how to deal with it.
I had been looking at the various Ruby Gems that I am using for tips on how they might handle errors more gracefully and didn't gain any insight.
Turns out I was looking in the wrong place.
Today I took a few minutes to search for how Ruby handles errors and exceptions, and I found the begin ... rescue ... else methods. The Bastards Book of Ruby explains them very well.
I quickly wrote this little program to make sure it worked (it does). Though I'm in the middle of a method-based rewrite of the BlogPoster program, I might hack this into the old script to see if I can keep the program from stopping when the Nokogiri and Twitter Gems encounter problems (the former with unresolvable URLs, the latter with connectivity issues).
Here is my "test" of `begin ... rescue ... else:
#!/usr/bin/env ruby
# Handling potential errors in Ruby with begin/rescue/else
# The 'error' here is trying to divide by zero.
begin
1/0
rescue
puts "The expression 1/0 doesn\'t work"
else
puts "The expression 1/0 does work"
end
begin
1/1
rescue
puts "The expression 1/1 doesn\'t work"
else
puts "The expression 1/1 does work"
end
# Expected output:
#
# The expression 1/0 doesn't work
# The expression 1/1 does work
Update: I tried this with "real" code, and it works!
I just booted into a Fedora 27 live system on my HP Envy laptop with an HD screen, and already the fonts in Firefox look better than stock Debian, which is to be expected.
Just like with Debian, I'm astounded that everything works in Linux out of the box. This laptop is about nine months old, and I have been avoiding running Linux for that whole time, choosing to explore Windows 10 (which is not bad at all, in case you were wondering).
I'm very happy that Fedora (which I ran for pretty much the entire "run" of my old HP Pavilion g6 laptop, which is running F27 as we speak) is so good on what, for me is new hardware.
The improvement in font rendering on this HD screen (1920x1080) is enough for me to say that I could definitely make the switch from Windows 10 to Fedora. I'm not ready just yet, but it looks like I am able.
Maybe it's the new laptop talking, but GNOME 3 looks more polished and usable than ever. The first thing I did in the live environment (after pumping up my Firefox magnification to 140%) was installing GNOME Tweak Tool and changing to the Adiwata Dark Theme.
True for both Debian and Fedora: The laptop is running very cool, too.
Next up: A test of the new non-BIOS-bricking Ubuntu 17.10, where I hope the GNOME 3 experience will also be a good one.
I have been working steadily on the BlogPoster app, both tightening up the current "production" version and slowly coding the new "modular" version based on Ruby blocks.
Over the weekend I coded up a few blocks in what I hope will be a very atomized app in which all of the blocks do just about one thing and can be called upon in various combinations for different tasks.
Today I worked on the regexes for creating filenames based on post title. The hardest part is dealing with strange characters and website <title> text that contains lots of linefeeds. (Confession: This site did the same until I fixed it. Please don't put linefeeds in your <title>.)
I got rid of the extra linefeeds, but I was ending up with occasional doubled underscores (my go-to replacement character for the space between words). I came up (i.e. Googled and stole) the regex for "match two or more of this character," which in this case is __+, and I was off to the races. I also figured out that in HTML titles with extra lines, I was inadvertently adding an underscore to the beginning of a string, and I used ^_ to find that and kill it out. Regex is fun and profitable.
Hopefully I'll get back to working on the "new" version. I'm coding it slowly and deliberately because I don't want it to be a mess. Next version will be more object-oriented (i.e. will use classes) if I can figure that out. First we'll see how this version turns out,
One thing that bothers me about Twitter is that the 'like' symbol is a ❤ when it should be a 👍. I think a heart means "love," and a thumbs-up means "like." A heart is often too strong for "like," especially in the kind of things that come up on Twitter.
I'd even be open to "like" and "love" with 👍 and ❤, respectively.
I tried this, and it works: How to set file permissions from within Vim | Stack Overflow.
An example. In Vim's command mode:
:call setfperm("foo.txt","rw-r--r--")
It's probably easier to just do this in the Bash shell, but it can be done from within Vi/Vim.
In Bash (to make the files rw-r--r--):
chmod 644 foo.txt
I usually do all the .txt files in the directory (because I generally want text files to be 644, which is rw-r--r--):
chmod 644 *.txt
From Stack Overflow: How to leave white space on both sides of the page in HTML
I recently updated a 15-year-old IBM Thinkpad R32 laptop (Pentium 4, 1 GB RAM, 20 GB hard drive) to Lubuntu 16.04, and I set it up to run my Blog Poster script written in Ruby.
Since this is a Linux environment, I like to use the Ruby version that the system offers in its repositories, also installing as many Ruby gems as I can from those same repos (instead of using gem install from the console).
The Blog Poster app, which attempts to make it easy to create social and regular blog posts from the command line, uploading them to the blog and sending them directly to Twitter, is fairly simple. It uses two gems: Nokogiri to help pull the titles of web pages and Twitter to (you guessed it) send a post to Twitter.
On Windows I used gem install to get both of those gems, and I could do the same in Lubuntu. But I'm very comfortable with Linux package management, so I opted to install ruby (which, believe it or not, isn't in the Ubuntu/Lubuntu default install) as well as ruby-nokogiri and ruby-twitter, all from the Ubuntu repository.
It worked.
Curiously, the script's call to vim did not work. There is, theoretically, no vim in the Ubuntu/Lubuntu default. But there is vi. You can install vim, but I opted to stick with the vi default, and I modified the system call in my Ruby code to call vi instead of vim.
Also, copy-pasting into the terminal (LXTerminal is what I am using) via right-click works great (though ctrl-v does not work).
The Ruby script works great, and I did a few successful updates to my blog and Twitter feed with this very aged laptop.