Title photo
frugal technology, simple living and guerrilla large-appliance repair
Wed, 12 Oct 2016

One guy's Google interview prep can be everybody else's computer-science tutorial

One guy's Google interview prep can be everybody else's computer-science tutorial https://github.com/jwasham/google-interview-university

I am trying Shutter as my GNOME screenshot program

Since the GNOME screenshot program is very broken, at least in my installation of GNOME, I decided to try Shutter, the Linux screenshot program written in Perl and seemingly aimed at GNOME users.

Shutter has a lot of options, and so far I can get it to work.

Going back to the beginning, why is the GNOME screenshot program broken in my GNOME installation? I have no idea.

When I hit the print-screen key, nothing at all happens. If I bind it to alt-p, I get the "shutter" sound, and a PNGJPG image appears in my Photos folder. Even if I go into gconf settings to modify just about everything, calling the screenshot program from the keyboard produces the same resultwon't allow me to change the target directory.

But if I hit the super key (or mouse into the hot corner), then search for Screenshot and run it, I get the full GNOME Screenshot window to open, and it has all of my configuration options (JPG instead of PNG, choose my own directory/folder). Why can't I make this work from the keyboard -- from print-screen or any other keyboard shortcut?

I've dwelled on GNOME Screenshot enough. Now I'm going to see if Shutter can do what I need. Or I can just use Xfce, where the screenshot program works like it's supposed to -- with the print-screen key. Why is this so hard, GNOME people?

Update: After using Shutter once (I have it bound to alt-P), the icon sits in my upper panel. I can then take a screenshot by clicking the icon. Easy.

Speaking of panels in the panel-less GNOME (where not having things appears to be a "feature"), I do have a panel in the form of the TopIcons, Places Status Indicator and Applications Menu extensions. And yes, it is not a good thing that what many consider core funtionality can only be implemented through Extensions that aren't part of the GNOME 3 core.

More GNOME Extensions: I just added Frippery Panel Favorites to make the upper panel on my GNOME 3 desktop even more GNOME 2-like.

Thu, 06 Oct 2016

Converting WordPress posts to files for a static site

I'm exploring ways to take WordPress blogs and semi-automatically covert them into heaps of individual static files for use in blogging systems like Ode that take text files and convert them to HTML either on the fly or via a static-site engine.

I think it's going to take a combination of at least two existing tools plus some scripting on my part to take what those tools create and further process the files for Ode.

I tried two WordPress plugins that didn't work at all: WP Static HTML Output and Static Snapshot.

A third WordPress plugin, Really Static, did not look promising, and I didn't try it.

I tested the HTTrack Website Copier -- there's even a Fedora package for it -- and that pretty much downloaded the entire WordPress blog as a fully baked static site. But it didn't produce files or a file structure that is in any way compatible with any other blogging software.

Still, I think HTTrack will be valuable in terms of extracting the images from WordPress sites for use in other blogging systems.

I tried another method using wget (which HTTrack also uses) with a ton of command-line switches in a post titled Creating a static copy of a dynamic website.

In case the above site disappears, here is what you do:

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

-k : convert links to relative
-K : keep an original versions of files without the conversions made by wget
-E : rename html files to .html (if they don’t already have an htm(l) extension)
-r : recursive… of course we want to make a recursive copy
-l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
-p : download all necessary files for each page (css, js, images)
-N : Turn on time-stamping.
-F : When input is read from a file, force it to be treated as an HTML file.
-nH : By default, wget put files in a directory named after the site’s hostname. This will disabled creating of those hostname directories and put everything in the current directory.
–restrict-file-names=windows : may be useful if you want to copy the files to a Windows PC.

This is a cool exercise, and it pretty much produces what you get with HTTrack. Cool but not useful.

Along these lines but aiming for something that's actually useful, I could use wget and just target the images.

Here's where the good stuff stars

It's not all bad. I just tried a Ruby Gem called wp2middleman, which takes a copy of the XML that you export out of WordPress and turns it into individual static files (either HTML- or Markdown-formatted) with YAML-style title, date and tags.

You get the XML from the WordPress Dashboard (under Tools -- Export). Then you process that XML file with wp2middleman.

If you already have Ruby and Ruby Gems set up, getting the gem is as easy as:

gem install wp2middleman

Then you can produce a full filesystem with individually named files with:

wp2mm your_wordpress.xml

That gets you the files. Not the images. I'd use HTTrack or some similar tool to get those.

That I can work with. "All" I'd have to do is convert the YAML to Ode's title and Indexette date format, rewrite the image links to conform to whatever I have going on my Ode site and then convert the file suffixes from .html or .markdown to .txt.

I think I can do that.

Update: Getting the images from a WordPress blog with wget is easy. Stack Overflow has it: How do I use Wget to download all Images into a single Folder

There is enough info there to get them into a single folder, or into a directory/folder structure that could make it easier to call the images into your non-WP blog. I did both as a test:

wget -nd -r 2 -A jpg,jpeg,png,gif -e robots=off http://your-blog-here.com

wget -r -l 2 -A jpg,jpeg,png,gif -e robots=off http://your-blog-here.com

Wed, 05 Oct 2016

I bring the Blogger version of The CTRL Freak to Ode, plus a tally of what's left to move

It's low-hanging-fruit day. In my quest to archive all of my old blogs here in Ode, where I have everything on my server and in filesystem-level backups, I'm aiming to bring all of my "old" (and just plain old) blogs into this file-based Ode system that I host myself.

Today I did The CTRL Freak -- the Blogger version (there's also a WordPress version, the blog itself tells me).

It was only eight entries, I left at least one behind (because all it did was point to another blog entry), and there were no images. That made it a quick conversion, hence the low-hanging-fruit analogy.

I'm starting to get pre-2011 entries on this site. I'll expand the date links on the right when I get more vintage content on the site.

Here is what I have on Blogger:

2,000 Days in the Valley
142 posts to do

This Old Mac
61 posts to do

This Old PC
40 posts to do

My jazz guitar journey
48 posts to do

The CTRL freak
9 posts done

The status of my WordPress.com blogs is more complicated because there are backups in there from my company-owned WordPress.org sites as well as the Blogger sites mentioned above.

The WordPress.com sites are:

Steven Rosenberg
378 posts

Takectrl's Weblog (I think this is an old Click backup)
1,149 posts

The CTRL freak (WordPress version with maybe a few more entries)
27 posts

I also have:

Master and Server, which is a WordPress.org site on the devio.us OpenBSD server. It only has a few entries.
20 posts

And then there are my two big Daily News blogs that started their lives on Movable Type and which were converted to WordPress.org:

Click
1,950 posts

Come on Feel the Nuys
367 posts

Clearly these last two are going to either take a Herculean effort or some kind of scripting magic from me. I used to have access to the server and could grab the images in bulk, but I don't think I can do that any more. The hard parts of these kinds of "automatic" conversions are the internal links (WordPress uses absolute links, which are good for SEO but bad for portability) and images (and their URLs, also absolute links).

Today's mood (or mode): I could be programming, but I'm moving blog entries around instead ...

Tue, 04 Oct 2016

Blogging over the years: bringing it all together

After I started using self-hosted blogging software that wasn't WordPress in February 2011, I began with FlatPress and continued using it through October until I discovered and settled on Ode as the blogging software that best fit how I wanted to run my personal site.

As I write this post, it occurs to me that I've been running Ode just about five years.

It was always my intention to bring all of my past blog posts from Flatpress, WordPress and even Blogger to a single platform. I moved most of my Flatpress posts over some time ago but there were about a dozen or so entries from the early Flatpress months that never made it over. Over the past day and a half, I moved those entries into this Ode site.

I guess that means I can shut down the Flatpress site.

Migrating blog posts is hard. There's the formatting, the file naming (and organizing) and the images. There are ways of doing it automatically, and I might explore scripting the rest of it. But I'll probably just chip away at it manually, starting with my Blogger sites.

That's if I do it at all. The idea of having all of my blog entries in this Ode site, which means I'll have them in a local filesystem, too, is something I would like to do, but it is a lot of work.