Philip Marlowe: Product of a Hard-Boiled Time

From “Murder, My Sweet“:

My feet hurt, and my mind felt like a plumber’s handkerchief. The office bottle hadn’t sparked me up, so I’d taken out my little black book and decided to go grouse hunting.

via Philip Marlowe: Product of a Hard-Boiled Time : NPR.

I’m pretty sure my mind has felt like a plumber’s handkerchief on occasion too. In fact, it may feel like that right now…

Migrating from Blogger to WordPress

Ok, here’s my third exciting post on my Blogger to WordPress migration. After failing miserably with my attempt to migrate from Blogger to Drupal, I wasn’t sure what to expect from the WordPress Blogger import tool.

Drupal’s importer is a third-party module that hasn’t been updated recently. (There might be another one out there that I don’t know about, but I never found one.) It imports from an XML file that you export from Blogger. WordPress, on the other hand, uses Google’s API to connect to Blogger directly, and read all your posts. It pulls in posts, comments, and images. My old blog had about 1600 posts, and it pulled them all in, pretty quickly.

After importing, I used this guide to help me figure out how to set up my permalinks to (pretty much) match Bloggers, then run a PHP script to fix up the permalinks to exactly match Blogger’s. I also had Blogger putting a “.html” at the end of the post URLs. (I’m not sure if that was standard, or if that was an artifact from when I switched from Blogger’s FTP publishing, where I was actually creating HTML pages for each post.) So I had to create a rewrite rule in my .htaccess file to deal with that. Now that I’ve done that, I’m pretty sure most individual post URLs from the old blog will redirect correctly to the corresponding pages on the new blog.

In terms of the DNS stuff, I had to change Blogger to point to a new subdomain (“oldblog” in case you’re curious), so I could free up “blog.andrewhuey.com” for the new WordPress install. I hit a slight snag there, as I deleted the “blog” subdomain in 1&1, with the intention of letting the “click & build” install recreate it. But it turns out that deleting a subdomain in 1&1 can take a while, and the subdomain is basically locked while you’re waiting for it to happen. So I got an opportunity to run out for an iced coffee.

One other minor snag I hit involved DNS. I’ve had my router configured to use Google’s DNS servers for a while now. Well, Google didn’t quite want to let go of “blog.andrewhuey.com”, and got a bit confused about it, so I had to switch to using my ISP’s DNS servers, so I could actually reach the new blog. (Weirdly, it had worked fine for a while, then just stopped, and started returning errors. At first, I thought there was something wrong with the WordPress install, but then I found I could get to the blog on my phone.) At some point, I’ll switch back to Google DNS, or maybe OpenDNS.

I plan to write up at least one more post on my WordPress migration, covering themes and plugins. Maybe tomorrow.

Update: I spoke too soon!

I just figured out that the Blogger importer stripped out all JavaScript embeds in my posts, or at least certain ones. The end result of this is that all my GitHub Gists are missing. So any posts with source code now have no source code. So the most useful posts on my site are now kind of useless. Great!

Finding all the posts with Gists is proving to be a bit of a challenge too, since I can’t search for text within script tags via the Blogger interface, so I can’t just search for “gist.github.com” or anything obvious like that. But I think I’ve found most of them now.

Oh, and in WordPress, you can apparently reference a Gist simply by pasting the URL to the Gist in, and it gets magically expanded. Which is nice. (It looks like this is part of Jetpack, rather than core WP. And there are a bunch of other cool shortcodes you can use.)

But I’m also seeing now that my current WordPress theme isn’t the best for rendering Gists. But one thing at a time. Let’s try to get them all back in there first, shall we?

Setting up WordPress on 1&1

I just want to get down a few notes on setting up WordPress on 1&1, my web host. 1&1 has something called “click & build” that lets you do a quick setup of WordPress, or Drupal, or Joomla, or a bunch of other stuff. First, I should say that there’s no reason I couldn’t have done the setup manually — creating a MySQL database, then unzipping the WordPress files into a folder in my web space, and running the regular WordPress install. I’ve done that before, in other environments, and I don’t think it would have been hard to do with 1&1.

But I decided to try the click & build option. When you first go into that section in the 1&1 admin, you have options for three kinds of installs – basically an eval install, a “safe” install, and a “free” install. I skipped the eval install. I had heard that it wasn’t terribly useful, unless you just want to set up a simple temporary install that you’re going to tear down later. So I started with the “safe” option. In that option, 1&1 locks down a few things, and gives you a basic WordPress install that will (supposedly) be automatically kept up to date. Poking around a bit, I didn’t see anything too unusual about it. It includes a special WordPress module that, I guess, is used to handle the automatic updates. After messing with that for a little bit, I went back and converted it to a “free” install. This wasn’t too difficult, but it did involve moving the SQL data to a different database. (I guess it was in a shared database before.) So, with that done, I had an unlocked WordPress install that was pretty reasonable. I used that for testing, and still have it set up, but I decided to start fresh for my “production” install.

For the final install, I went straight to a new “free” install. With a new “free” install, you’re prompted for a lot of the same things that the normal WordPress installer prompts for, but it’s all done in the context of the 1&1 admin interface. Once you’ve answered all the questions, then 1&1 chugs away for a few minutes, and, at the end, you’ve got your WordPress install.

I think it worked out pretty well, and I have a reasonably standard and up-to-date WordPress install in place now. If you go out to Google and look for opinions on the 1&1 click & build experience, most of what you’ll find is pretty negative. Many of the posts I found on this were pretty old, though, so I’m guessing that 1&1 has improved the experience over time. And some of them were just expressing frustration with the “safe” install, in cases where that obviously wasn’t the right choice. The one fairly balanced, and fairly recent, review I found is here. A lot of what he writes doesn’t really apply to me, since I’m a long-time 1&1 customer, on a plan that’s probably not available to new users. So, as long as things keep working for me, there’s no compelling reason for me to switch to anyone else.

So that’s my long and exciting post about the experience of setting up WordPress on 1&1. Next up, I want to post some notes about my experience with the Blogger importer.

 

Hello from WordPress!

I’ve just switched my blog from Blogger to WordPress. I’ve been using Blogger since, oh, 2001, so switching to a new blogging platform is not something I’d do on a whim. I originally started thinking about moving to WordPress in 2010. Then, since I was doing so much work with Drupal, I started thinking about switching over to Drupal instead. But I could never get the Drupal Blogger import module to work right. I messed around with that for a while, put it aside, came back to it once or twice, and eventually gave up. I’m no longer doing any professional work in Drupal, and I’ve been stumbling across some WordPress stuff lately, so I decided to give WordPress a shot. I have done some work with WordPress at my last job, so I was already familiar with the basics, from an end-user perspective, and some of the internals, from a developer’s perspective. I’ve never messed with WP themes though, so that’s something I need to learn more about.

Well, I have the basics of this blog set up now, and it should be available at my usual address, blog.andrewhuey.com, so I’m going to post this now, and take a break. Later, I plan on writing up some more notes on WordPress setup, which I’m sure everyone will find very exciting. 🙂

 

Learning F#

I’ve been curious about F# for quite some time, and I recently decided to pick up a few books on it, and see if I could learn it. More generally, I wanted to learn more about functional programming. I thought about learning something like Haskell or Scala, but F# seemed like a good choice. I already know a good bit about the .NET Framework, and the CLR, so I wouldn’t be starting entirely from scratch, and I could stick with tools I already know (Visual Studio).

The three books I picked up are F# for C# Developers, Book of F#, and Programming F# 3.0.I bought them all from as DRM-free e-books from O’Reilly. (This was right before O’Reilly lost the license to sell Microsoft Press books, so the “F# for C#” book would no longer be available from them, if you were looking for it.) I haven’t started the “Programming F#” book yet, so I can’t say anything about it. But I have read a few chapters from each of the other two books.

“F# for C# Developers” is published by Microsoft Press. It’s reasonably well-written, but I haven’t really found it to be particularly engaging or interesting. Of the chapters I’ve read thus far, I’d say that it lives up to its name, in that it is oriented to folks with a good grounding in typical .NET development. I think it would make for a good reference book to keep at my desk, if I was doing some serious F# development at work, and needed to remember the difference between :> and :?>, for instance.

Given that I didn’t feel like I was really learning functional programming from that book, I decided to put it down and start reading “Book of F#”. For my purposes, this is turning out to be a better book. I’ve read the first four chapters so far, and I’m finding that I like the tone of it (including Doctor Who references!), and the general style. I’m finding the example code to be a bit more understandable and interesting than in the other book.

I’ve experimented a bit with re-doing some of the Project Euler problems in F#, as I’ve mentioned before, and I’ve found that to be a good exercise too. Oh, and I’ve solved through to problem 31 there, so I’ve managed to make some overall progress on Project Euler.

Spring Cleaning

I received a letter from my landlord this week notifying me that they would be coming through on Monday and spraying for bugs. The letter said that I should clear off my kitchen counters, and move everything out from the cabinets below the counters, and from under the bathroom sink. I only recall them sending out a notice like this once before, maybe seven or eight years ago. As far as I can tell, we don’t actually have a pest problem, but maybe there’s an issue elsewhere in the building.

Either way, I took this as an opportunity to do some spring cleaning this morning. In addition to throwing out a bunch of random stuff from the kitchen, I also decided to toss out a bunch of old computer books. I threw out maybe 30 or so books. I’ve done this before, and probably blogged about it, so I’m not sure if I’l be saying anything new here. But I wanted to take a break from cleaning and write up a blog post, so here we are.

I haven’t been buying a lot of hard-copy computer books lately, preferring DRM-free e-books instead. At my current job, I have exactly one hard-copy book at my desk. I also have three e-books on my computer that I refer to regularly. At my previous job, I kept maybe a half-dozen hard-copy books on my desk, and a few e-books. At the job before that, I had a whole bookshelf unit, probably six feet tall and three feet wide, full with books (and admittedly a large array of random knick-knacks), most of which I’d bought myself. I left quite a few of them behind when we went out of business, but I took a couple of boxes of them home; most of those went into the recycling dumpster today.

I’ve been buying most of my e-books from O’Reilly. Generally, I wait for them to have a good sale, as they did last week, on the Day Against DRM. Packt had a really good sale too, any book for $10. I ended up buying three books from Packt. They publish such a wide variety of stuff, I found myself with maybe 15 tabs open while I was shopping, looking at all the cool stuff I’d like to learn about. But I know, at this stage in my life, and with the speed that technology changes, that I’m not going to read 15 programming-related books before at least 12 of them are hopelessly out of date. So I settled on buying just three.

I should make a point of checking back in a year, and seeing how many of them I’ve actually read. But, hey, if I don’t read them, I’m only out $10 each and there’s nothing to drag out to the recycling bin!

F# on the Mac

I’ve been messing around with F# lately. It works fine in VS 2013 Express on my Windows 8 laptop, but I wanted to be able to play around with it on my Mac too. I have Xamarin Studio installed on the Mac, and I added the F# support to it, and that works OK. I wanted to be able to use FSI from the terminal too, though. That turns out to be pretty easy too, though it’s called “fsharpi” instead of “fsi” like it is on the PC.

base 36 conversion

I haven’t posted any code on here in a while, so here’s a quick little bit of code that might be useful to somebody. I had to write some code this week to do conversion from base 10 to base 36 and back, in Dynamics AX. So I just took some simple code from the Wikipedia article on base 36 and converted it to X++. Nothing fancy. The code below is all in a job, but I’ll probably put it in a utility class when I actually implement it.

// https://gist.github.com/andyhuey/5c2404b65939b5fccab8
static void AjhBase36Test(Args _args)
{
    // ajh 2014-05-07: 611.23
    // adapted from http://en.wikipedia.org/wiki/Base_36.
    // note: handles non-negative integers only.
    #define.NBASE(36)
    #define.CLIST("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")

    int64 base36_decode(str base36_input)
    {
        int64 result = 0;
        real pow = 0;
        int i, pos;
        str c;

        for (i = strLen(base36_input); i > 0; i--)
        {
            c = subStr(base36_input, i, 1);
            pos = strScan(#CLIST, c, 1, #NBASE) - 1;
            if (pos == -1)
                return pos;  // error
            result += pos * power(#NBASE, pow);
            pow++;
        }
        return result;
    }
    str base36_encode(int64 input_num)
    {
        int64 work_num = input_num;
        str result = "";
        int digitidx;
        str c;

        do {
            digitidx = int642int(work_num mod #NBASE);
            c = subStr(#CLIST, digitidx + 1, 1);
            result += c;
            work_num = work_num div #NBASE;
        } while (work_num > 0);
        return strReverse(result);
    }

    print base36_decode("");
    print base36_decode("0");
    print base36_decode("A"); // 10
    print base36_decode("7PS"); // 10,000
    print base36_decode("255S"); // 100,000
    print base36_decode("!@#$"); // error
    print base36_encode(0);
    print base36_encode(123);
    print base36_encode(10000);
    print base36_encode(100000);
    pause;
}

Streaming Music Services

In general, I’ve never been the kind of guy who likes to listen to music at work. And in most of my previous jobs, I really wouldn’t have been able to listen to music, since there were a lot of interruptions and interactions that would have prevented me from getting too far into anything before I’d have to take my headphones off to answer a call, or run over to a user’s desk, or whatever. But, in my current job, I’m doing a fair amount of “heads down” programming, with few interruptions. And I’m actually finding that some of the office noise distracts me enough that drowning it out with music allows me to be more productive.

For a while, I tried just listening to Coffeetivity. This was kind of helpful, but also kind of boring. I may give it another try at some point. I also tried focus@will. The idea here is kind of cool, but I’m not convinced it would make me more productive than listening to music of my own choosing. Again, I may give it another try at some point, maybe the next time they run a 50% off sale on a year’s subscription to their “premium” service. And, as I’ve mentioned previously on this blog, I was really in love with turntable.fm. Unfortunately, they shut down a while ago.

After messing around with all this stuff, I settled into a habit of listening to Pandora a lot. I set up some “stations” based on my favorite artists, and that worked out pretty well. About a year ago, I paid $36 to subscribe to Pandora One for a year, so I could get rid of the ads. That didn’t seem like a bad price, even though it really doesn’t buy you anything other than ad-free listening.

This past weekend, I got a notice that it was time to renew. (Normally, that would have happened automatically, but my credit card got stolen a while back and I had to replace it, so they couldn’t put through the charge on my old card.) I really wanted to just renew it for another whole year, but Pandora discontinued the annual plan a while back. So the $36/year (effectively $3/month) plan would become a $4/month plan with no annual billing option. I wasn’t sure if I wanted to go forward with that, so I basically just let the subscription lapse. Then, on Monday, when I looked again, I realized that I was no longer eligible for the $4/month “loyalty price,” and would have to go on the new $5/month plan. So I decided that was a but much, and I’d look around at other options.

For now, I’ve settled on Slacker. The ad-free version is $4/month, and it gets you a few things that you don’t get with Pandora. The one feature I really like, and I wish Pandora allowed, is the option to download stuff for offline listening. I can’t use my employer’s wifi to stream music to my phone at work, so I have to rely on my Verizon data connection. This generally works OK, but I can wind up getting pretty close to my data cap sometimes, and I think it drains the battery a lot more than listening from a local cache. So just being able to download a cache of stuff over my home wifi, before leaving for work, is useful.

I’m also finding that Slacker’s “curated” stations are interesting. I listened to “The Current” station today, and it was really good. I’m not sure how often the content on that station is refreshed, but I could see myself listening to that one quite a lot. So, overall, I’m finding Slacker to be just as good as Pandora, but with a few more bells and whistles. Over time, I’ll see how well it holds up — whether or not there are any glitches with the app, how often content is refreshed, and stuff like that. But I’m feeling pretty good about it.

a little more on digital comics

As a follow-up to my post earlier today, I spent some time today looking through my e-mail receipts for Comixology and Dark Horse Digital purchases, and made lists in Evernote for stuff I’ve read and stuff I haven’t read yet. First, let me say that I was surprised to see how much stuff I’ve bought, in both apps, but haven’t actually read yet. But now that I have decent lists to start from, I should be able to keep track of it all, going forward.