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.
This is not part of the /updates directory, and IFTTT should send it to Twitter.
The last piece missing from the Blog Poster app is the ability to post directly to Twitter and eliminate the dependency on third-party services like dlvr.it and IFTTT. Shouldn't be too hard.
I just coded a small feature for the Blog Poster app (a Ruby script) that allows the user to choose between two different directories when posting a "raw" update that isn't meant for the /updates/
directory that IFTTT taps for explicit social posts (using the body text instead of the title for the post). When making a "raw" post, the user can now choose the /now
directory for timely posts that would be better with the traditional title-and-link style social posting that "normal" blog entries usually get when fed to social media accounts.
I'm not quite sure how I stumbled upon the Ruby Terminal Apps Toolkit, but the gems included can definitely speed your development of interactive Ruby apps on the command line.
I just coded a menu for my app, and these gems by Piotr Murach offer a lot of ways to do this easily and to solicit and process user input.
The next thing I'm looking at doing in my app is allowing users to open lines for editing in their text editor of choice, and these TTY gems definitely do that. I wasn't thinking that shelling out to an editor would be so hard (meaning that was something that Ruby can do with no gems), but maybe this is a better (or easier) way.
The "hard" part in allowing user editing in my app is that I am assembling files to upload from a series of variables, and I think I'll have to create temporary files for editing that only include the component being modified (i.e. title, text, link, filename) because my app knows how to turn variables into a file but not a file into a series of variables, though that is something I could code into it. (But I may not do this because I am thinking of going in another direction and not creating actual files on the system at all and using Ruby to stream the data via FTP.)
That's more detail without context about the app I'm working on than you need.
tl;dr: The Ruby Terminal Apps Toolkit can speed up development of command-line based apps. You can use single gems or the whole thing. It's up to you.
Since I installed the JDK instead of the JRE, I didn't know if automatic Java updates would come at all and would cover the development portion of the tools.
I got the update today, and as you can see from the image above of my Windows command line, all is updated.
I'm actually doing it. I'm writing a blog-posting program that will take an http link, extract the remote page's title and create a social-media-style blog post (title, body text and link) that can be easily uploaded to my flat-file blogging system's server.
The idea is to make it as easy to post a "social"-style update to my own blog as it is to post to Twitter (or Facebook or Google+).
(I use IFTTT -- and formerly dlvr.it -- to post these social entries on Twitter, but I could see this program taking over that task as well.)
Back to my application. I could have gone several different ways from a conceptual standpoint.
I could have done this idea as a web app, but in order to get the files to upload to the blog, I'd either have to write a server component on that side, or create a backend service -- with some measure of security -- to handle the upload (I'm using FTP, but it doesn't have to be that).
I thought about a desktop GUI. I want this to be a true cross-platform app. I seriously considered using the now-ancient Tk framework with Ruby. I less-seriously considered Java FX, though I did successfully hack together code to upload via FTP using Java. (At least it was a worthwhile programming exercise.) I could have gone with QT. Maybe I could have done the whole thing with QML.
I'm not ruling out any of these GUI solutions, but I needed to start coding, and the easiest, quickest thing for me to do (or so I thought) is a menu-driven console app. I could have gone with Java, JavaScript, Ruby, even Perl. I did tests of various components in three of those languages.
I'm writing the app for the console with an eye toward re-using the code in a future GUI app, and for that reason maybe I should have used JavaScript.
But I really wanted to use Ruby. I'm trying to grasp object-orientated programming, and there is a whole lot of web-based help for Ruby programmers that often acknowledges that there are beginners out there who need a helping hand.
And I really would love to eventually port this code to Tk, or even as a Sinatra or Rails app. I should want to do it in JavaScript. But Ruby is so friendly, and it's made for use in the console.
So I'm writing it in Ruby. And I have some 190 lines of code that do the following:
I have all of these features working, and while the app is very far from perfect, it is functional. The code isn't ready for public consumption -- it needs lots of cleanup before I publish it, and it's really meant more for Ode users and blogs that work in a similar way (files are uploaded to a server, from which the blog software renders them for the reader) than it is for flat-file systems such as Hugo, where a dedicated program builds the blog locally and sends files on their way, but the concepts and code used in this app can certainly be modified for that workflow -- and I'm not at all above doing that in the future.
Aside from adding more features, primarily the ability to edit elements instead of re-typing them (maybe by invoking the vi editor), I want to make the code more modular. Right how it's a huge procedural hack, and modularity (and object orientation) will make it cleaner and more flexible. That's the idea anyway.
Before that I need to clean up the configuration, which is all over the place.
Still, I wanted to make an app, I used the skills I had (and Googled and read plenty), and now I have something that works, however ugly it may look on the back end.
How to back up your /home directory in the Windows Subsystem for Linux without losing permissions before killing your old WSL and installing a new one from the Windows Store
The Windows Subsystem for Linux - which is no longer being referred to officially as "Bash on Windows" - has grown up.
You no longer need to put your Windows 10 system into Developer Mode to use the WSL.
And now there are three different WSLs: Ubuntu, openSUSE and SUSE Linux Enterprise Server. Fedora is supposed to be on the way, but I haven't heard anything about progress toward that happening in a long time.
According to Microsoft, you can copy your current Ubuntu files to /mnt/c/tmp/WSL-backup
, or a similar directory, and then use lxrun /install
from the Windows command line to remove the old WSL. Then you can install a new WSL and move your files back after that.
Fellow Redditors suggested that I create a tar archive of my files, stow it anywhere, and then unpack it in my new /home directory when I remove the old WSL and install the new one via the Windows Store.
The only thing keeping me from doing it is what always keeps me from switching Linux distros: The need to re-install all of my packages.
The other thing keeping me from making this move is that my laptop hasn't yet received the Windows 10 Fall Creators Update. To successfully install the new WSL, your Windows build needs to be 16215.0 or higher. According to my About Windows 10 page, I'm on 15063.674. So not only can I wait, unless I opt to get the updates early (and I'm sure there is a way to do this), I must wait. And honestly, that doesn't bother me one bit.
Update: (July 4, 2018): Here is my Independence Day update to these instructions. The "original" instructions should work fine, but the "new" ones are better:
Originally I created the tar
archive of my home directory in my home directory:
$ tar -zcvf steven.tar.gz /home/steven
$ cp steven.tar.gz /mnt/c/Users/steve/OneDrive/Documents/linux_backup/
And to open it up when your new WSL is set up, go to your home directory:
$ tar -zxvf /path/to/steven.tar.gz
Then you'll have a home directory within your home directory (i.e. for me /home/steven/steven
, and you can copy what you want from one to the other). It's better not to overwrite everything in your "new" Linux /home
directory because it might handle things in your dot files differently, and I can see conflicts arising from npm
modules, ruby
gems and whatever else you happened to install in the course of working in your Windows box's Linux side.
I'm not sure how much of a problem it is, but creating the tar
archive while in your home directory causes tar
to throw the following error:
tar: Removing leading `/' from member names
... (lots of output)
tar: Exiting with failure status due to previous errors
There are explanations of what this error message means on the Internet, but they didn't really help me understand it.
So I did things a different way. If you just want to know how to make the backup and restore it, start here:
First, on the Windows side, create a directory in which to hold this backup. I created one called linux_backup
in my OneDrive Documents directory.
Then go into your WSL, which will put you in your home
directory on the Linux side (which for me is /home/steven
).
From there, to avoid the error message I go up one directory and do the tar
operation from there. I use pwd
a couple of times to confirm where I am in the filesystem, and I use chown
to make sure the restored archive belongs to my Linux user and group.
Note: in all of these instructions, things after a $
are things you type at the command line. Lines that don't begin with a $
represent output in the terminal (and you don't have to type them).
Here is what my terminal session looks like:
$ pwd
/home/steven
$ cd ..
$ pwd
/home
$ sudo tar -zcvf steven.tar.gz steven
$ ls
steven steven.tar.gz
$ chown steven:steven steven.tar.gz
$ sudo cp steven.tar.gz /mnt/c/Users/steve/OneDrive/Documents/linux_backup/
Now you have your tar
archive on the Windows side.
After you set up your "new" WSL, you can copy the tar
archive from the Windows side into your new Linux /home
directory. As before, I use a couple of pwd
command to confirm where I am in the Linux filesystem. (And remember, use YOUR home directory and Windows path to your tar archive, not mine):
$ pwd
/home/steven
$ sudo cp /mnt/c/Users/steve/OneDrive/Documents/linux_backup/steven.tar.gz steven.tar.gz
$ sudo chown steven:steven steven.tar.gz
$ tar -zxvf steven.tar.gz
$ ls
steven
$ cd steven
$ pwd
/home/steven/steven
Now you have your "new" home directory at /home/steven
, and your "old" files at /home/steven/steven
. Copy what you want from old to new, and you should be ready to go.
Once you confirm that all your files are in there, you can blow away the old WSL and use your new one. And you should still have a copy of the tar
archive on your Windows filesystem if anything goes wrong.
Before going forward, it's a good idea to read up on how to make a tar.gz archive.
My question (and maybe yours): Why do this from the Ubuntu/WSL shell when you could just copy/paste from the Windows file manager, or why not just copy the files via the Ubuntu shell to the Windows portion of the disk?
Answer (and I did test this): In both cases, even when using Bash to do the recursive cp
of all the files, you lose your Linux file permissions. In my case, all of my rw-r--r--
files turned into rwxrwxrwx
, which is NOT what you (or I) want.
Update on 4/23/18: This entry was written last October but not published until now. It kind of got lost, and I just found and finished it. Though the new WSL is out, and you can now install Debian (which I would) or SUSE (probably not), I'm leaning toward sticking with Ubuntu because it's working so well, though I'm a longtime Debian fan and user (though not so much lately).
Whatever I do, I probably need to move to the "new" WSL, though I haven't done it yet. Everything is working, so it's hard to muster the motivation to mess with what until now has been a successful installation of Ubuntu in Windows 10.
Update on 7/4/18: The new instructions for making an archive of the /home
directory are more detailed and a little more roundabout. But they should work, and tar
won't throw any errors.
Also, I still haven't moved to a new WSL. The current Ubuntu WSL is still on 16.04 LTS, and that's the same version as my "old" WSL. When the Ubuntu WSL moves to 18.04 LTS, then it'll be time to make the change.