Posted by & filed under Programming.

Quick little snippet needed while working on a web app that exports to an Excel worksheet. What I needed was a way to convert column numbers to the lettering that Excel uses. So, for example, column 27 would become AA.

Found a bulk of the solution at Stack Overflow. Logic wasn’t exactly what I was after and I needed it in PHP, but that post got me 99% of the way there.

function colByNumber($colNum) {
    $s = '';
    $colNum -= 1;
    do {
        $s = chr(ord('A') + ($colNum % 26)) . $s;
        $colNum /= 26;
    } while ((int)$colNum-- > 0);

    return $s;
}

Only note is that I was using one based indexing in my code, but zero based in this function. Easy enough to just subtract 1 from the column number before starting.

Posted by & filed under Random.

Yesterday was one of the stops for our official start to summer – picking up the small, inflatable pool that our daughter is going to be in for most of the next few months. Normally we just get one of the $20 inflatables that are big enough for her to sit and jump around in, but the one to the right caught our attention. For $45 at HEB we got one that’s about 2.5 feet deep and 10 feet in diameter.

It’s a Bestway, which probably isn’t the best brand. But it’s working so far. It’s short enough that it doesn’t need external bracing. The inflatable ring on top is enough to keep it together. Although I’m going off of what the box says since we’ve only had it up a little over 24 hours.

And while on the topic of time, the 10 minute setup time that’s on the box is way over optimistic. 10 minutes might be right for getting it together, but filling a 900 gallon pool with a water hose takes a long time. It’s one of those things I expected going in, but was really hard to explain to my daughter.

Overall though, for about 50 bucks an above ground pool this size with a filter was too much of a deal to pass up, even if it doesn’t hold up more than one summer.

Oddly, Amazon has the same pool for $130, so if you’re near an HEB that might be a better bet.

Posted by & filed under WordPress.

An unidentified error has occurred trying to list tags

Working on a plugin today, part of which includes a custom taxonomy, and came across a snag today.

Got the taxonomy added, along with the custom post type it was associated with. The meta box showed up just like it should. And I could type in items for the custom taxonomy and have them stick.

The snag was when I tried to type one in. The dropdown for auto complete would only show a 0. And clicking on the most used tags link would show “An unidentified error has occurred.”

Since this was the first time I’ve done anything with custom taxonomies, I was trying to make the fix way harder than it was.

The solution wound up being very easy. I just changed the priority on the add_action call that added my callback to admin_init to a lower number and it fixed it.

Posted by & filed under Programming.

Normally I just don’t worry about this since I’m usually building websites and HTML takes care of merging multiple spaces. But it comes up occasionally. And since it’s just a quick regex replace, it’s pretty quick to merge multiple spaces.

$x = preg_replace('/\s{2,}/m', ' ', "This     string   has     spaces");

Piece of cake.

It looks for any places that there is 2 or more spaces and replaces it with a single space.

Posted by & filed under Blogging, Programming.

Sitting here working on setting up a WordPress network and hit a snag. New sites have a giant “Welcome to your new WordPress site” message when someone logs in for the first time.

Now, I’m not against the message; and WordPress should definitely market where ever they can. But I’d like to be able to customize the layout a bit. Still plan on keeping links to WP and all of that, just want to add in some of my own welcome message.

Googling didn’t turn up anything except editing the core WordPress code which is a terrible idea. I don’t want to have to redo it every time WP upgrades. And it looks like there isn’t a hook or filter that can make it easy. So I had to make it ugly. Read more »

Posted by & filed under WordPress.

Had a thought while scrolling to the bottom of a WordPress post with 250+ comments. Does having the add new comment form at the bottom of a page that long lead to fewer comments? Really, who is going to scroll that far?

So I’m going to play around a bit here and move the comments form above existing comments. Guess we’ll see what happens.

And if you’ve tried the same thing and it worked, or didn’t, let me know.