DaedTech

Stories about Software

By

Dell Keyboard Failure

The Symptoms

This is yet another entry of the “hope this saves someone time and aggravation” variety. I’m adding a new category called “Lessons Learned” that I’ll be tagging these with going forward.

So, I was playing Civilization V and I stepped away for a few minutes to find the screensaver on when I came back. I moved the mouse and nothing. Enter key and nothing. Ctrl-Alt-Delete, nothing. Several minutes of angrily mashing my keyboard and, not surprisingly, nothing. Given the graphics-heavy nature of Civ V, I assumed that my machine had crashed (this happens sometimes with Civ V), so I rebooted.

When I did that, I was greeted by the image above. So, I figured my wireless keyboard had run out of batteries and I went all the way down to the basement, grumbling, got new triple As and slapped them in. Rebooted, and keyboard failure. Tried a different USB port and keyboard failure. Tried my keyboard in another machine and success! Uh, oh. To the interwebs!

After googling around, I didn’t find any definitive solution. There were some scorched Earth suggestions, my favorite of which was “replace the motherboard”. There were some shotgun suggestions involving running without a CMOS battery, bending USB pins, switching the wireless receiver around from port to port, and various other procedural mumbo-jumbo that had probably coincidentally worked for someone somehow.

The Solution

I got lucky, though. The first scattershot step I took seemed the simplest, and it worked, so I know exactly what worked. I powered down and disconnected from power, and then popped a two pin jumper off of a three pin block on the motherboard for a few seconds and replaced it. Viola!

Appropriate disclaimers about unplugging and discharging capacitors and all that other stuff that I never remember to do but wouldn’t want somehow to be liable for you not doing it. But, that did the trick. Back up and running with no new keyboard, and certainly no new motherboard. Excuse to buy a new machine averted… (d’oh!)

By

Compiling XML! (Not really)

So, here’s another one filed in the “hope this saves someone some grief” category. I was cruising along with my home automation ‘droid app, setting my layouts and wiring up my button click handlers, when all of a sudden, I was getting weird build errors about. I couldn’t run or even build. When I tried to build, I got messages about different things being redefined in my main XML layout file. This was strange, since I hadn’t edited it directly, but was using the graphical layout tool.

As I inspected the errors more closely, I began to understand that there was apparently some rogue XML somewhere. A bug in Eclipse? With the Android SDK plugin? Had I been hacked by someone with a very strange set of motives? I opened up my layout folder and this is what I saw:

Wat?

After some googling around and experimentation, I discovered that this file is generated if you run with the Play icon and the XML file open as your selected window in the editor. Perhaps that’s something that Eclipse users are used to, but coming from a pretty solid couple of years of Visual Studio, this had me mystified. So, lesson learned. Don’t run if you have XML open in Eclipse (or anything else you don’t want slapped with a .out between filename and extension and apparently included in compilation.

Cheers 🙂

By

Scheduled Task Problems And Solutions in Windows 7

This is going here for my own sake as much as anything. I’ve been banging my head against a wall for a bit now, trying to figure out why I can’t get a scheduled task to run properly in Windows 7. Two things were going wrong. The first one was that I couldn’t get the start-in setting to work properly. This is neatly explained and addressed in this post.

Long story short, unlike everywhere else in Windows, the “start-in” text box randomly doesn’t demand or even support quotes around directory names with spaces in the paths. So, just remove the spaces.

Second issue I was having was that I was running a task to execute a program I had written that reads an XML config file to point it to files to use. One of these files was addressed by a mapped network drive. This worked fine when I ran the actual executable, but after a lot of bad noise and experimenting, I discovered that it wouldn’t work with the scheduled task. For the scheduled task, I had to use the UNC path to the file in my XML configuration file. I can only speculate that this has something to do with the scheduler not being tightly coupled enough to owning user to share network drives or something.

In the end, doesn’t matter. It’s kind of weird, but for anyone who finds themselves in that edge-case situation, try dealing with UNC exclusively.

By

Adding a Menu Placeholder in WordPress

How-To

In a bit of a reversal, I’m going to cut right to the chase and post my solution, followed by the back-story for those interested. I’m posting it right at the top because this would have saved me an hour or so had I stumbled across it last night, and I’m hoping it helps someone else later. So, without further to-do (points to anyone who can name the movie reference), here’s how to create a placeholder menu item in WordPress, without using the control panel’s menus (i.e. just the default menuing used by your theme).

The basic idea is that I wanted a menu at the top that had sub-menus, but without the menu item itself being clickable. The default in my theme (as well as twentyten and twentyeleven) is to have pages with no parent as menu-items and pages assigned a parent as sub-menu items. This is perfect, except for the fact that every menu item is a page, meaning that adding a page as the placeholder menu item forces me to add a navigable, empty page, which is kind of low rent from a design/UX perspective.

Here’s my solution to the problem. I created a file called “gohome.php” and added it to my theme folder. The file’s contents are simply:


Now, with this added, when I create or edit a page from the built in wordpress menu, I see the following options for template:

So, the interesting thing here is that wordpress picks up a page theme from a file by parsing its content for the commented line. I pieced this together from some blog and forum posts that I read (described in more detail below) and learned only through trial and error/deduction that WordPress picks up the fact that this is a page theme from the comment containing “Template Name” and the display name.

All this actually does is redirect the user to the home page if he or she happens to click on the menu item. It is perhaps not the most elegant possible solution (I would say that it would be more elegant to have the link not clickable in the first place), but it’s better than directing people to an empty, useless page and I like it better than another solution I found which was redirecting them to the first child. If clicking the menu item was a miss-click when going for first child this makes sense, but if not, I think this would be confusing.

Another alternative that I put into place was goback.php:




This uses javascript to effectively redirect the user to the last page he or she was on, instead of home. The “php code” here feels kind of weird, since the PHP serves only to house the necessary comment, but it works. I have both page themes in my arsenal now so that I can adopt whatever implementation I see fit. I’m leaning toward the “Go Back” theme since that seems a little closer to the actual desired effect – I’d rather the user click result in nothing than the user click result in going home (which will be jarring if not initiated from home page) or, worse, going to an empty page.

This is ultimately a hack. After all, I’m still actually creating a wordpress page and all that goes with it just to get the menu item. However, the page is empty and it does nothing but route the user elsewhere. This is the magic behind the hack.

So, use in good health – I hope someone finds this helpful. It’s not the most elegant solution in the world, but it’s one that clearly works within the confines of WordPress and doesn’t require modification beyond adding things to the theme. I prefer adding to the theme rather than modifying it, and I prefer either of those to modifying WordPress source, and this requires only adding to the theme. Furthermore, it doesn’t require using the WordPress menu structure, the motivation for which I’ll cover below.

My Quest For Sanity

Up until recently, I’ve had no need for a menu item place holder, as the only menu/sub-menu situation I had was one where clicking on the main menu item made sense. However, I’m in the process of prototyping a new menu layout for daedtech locally and the need to have a simple place holder came up. So, the first thing I did was follow the built-in menu-by-page paradigm, and that left me with the empty page. I looked in the wordpress control panel for a way to make the page non-navigable but this functionality is (understandably) not supported. I then tried making the page private, but I tried this half-heartedly, figuring it wouldn’t work. It didn’t.

So, I alighted to google to see what I could find. The first thing of note I found was in a lot of places, such as here, here, and here. WordPress has a built-in, customizable menu functionality. Great – problem solved!

Not So Fast

I could see how most people had solved this problem, and I followed suit. I diligently created a menu from the control panel using the pages that had previously been auto-menued by the theme. This took a while, and the API was intuitive if a little slow and cumbersome, but I finally had my menu structure in place. I saved it and viewed it on the actual site and saw that I had made a few mistakes. So, I went back in and modified a couple of things and saved again… only to get an error 500. I reloaded the page and tried again. 500. I closed my browser and tried again. 500. I restarted apache and tried again. 500. I tried other browsers. Yup, you guessed it… 500. Apparently, the menu structure save operation was passing too many post variables or some such thing.

Alright, time to take a break. I went and got some water and then decided to go back to google again. I read a few pages like this one and saw that the WordPress menu feature works great until you have about 24 menu items. Then glitchiness starts. As you increase it, the glitchiness becomes more apparent until, at 70 or so, there is nothing but glitchiness. I was closer to 24 than 70, but this apparent complete lack of scalability did not bode well for my future plans.

The general consensus in defenders of what was going on seemed to be “why would you want more than 20 menu items?” I view this kind of response as a non-starter and, in fact, a conversation ender, so I decided that if this was the prevailing attitude, I’d chalk the menu system up as worthless and seek another solution. I have to say that (1) I use WordPress and for free (2) the people from WordPress that I saw commenting on it did explain that this was an ongoing technical challenge that they plan to address in future releases. So, I’m not complaining at all – just a dispassionate assessment of the situation.

Back to the Drawing Board

At this point, I figured I’d exhausted my options for using the WordPress GUI and I started looking at plugins. These are so numerous and searching for them can be sort of exhausting, so I gave up on that. After a fruitless half hour or so of poking around, I stumbled on this blog post, by Bruce Header. He had borrowed a solution from here and linked to it.

Now, I was really onto something! This wasn’t really the behavior that I wanted, but it gave me two important pieces of information: this is how the page templates get incorporated and it’s possible to use your themed page to do a redirect. So, from there, I mustered my own solution of redirecting to home out of my limited knowledge of the WordPress codebase. Then, I created the place holder page as an empty page and set it to this new “Go Home” theme. I was finally in business.

Tweaking

After I got this setup, I realized while using it that the redirect to home was great if you started at home, but seemed a little weird if you hadn’t started at home. So, I debated how I’d want to handle this and concluded that a conceptual refresh (i.e. redirecting to the previous page) would be best, or at least desirable enough that I ought to include a template for that as well. From there, the javascript was really trivial. So, leaving the page empty and using the “Go Back” template creates a situation where the user navigates from X to Y, and Y simply deposits them right back at X. Short of eliminating all clickability, this is probably the best solution.

In the interest of non-clickability, this is the most promising thing I’ve found so far. However, it appears only to be for making the menu items non-clickable if you use the WordPress custom menu scheme and set the placeholder links to “#”. This isn’t actually possible when using pages, so the solution would require some modification here. I have no doubt that this is doable, but I don’t know if this rates high enough on my list at the moment to go poking through the theme and WordPress PHP until I can figure out how to do this. If I have some downtime, it might be interesting, and I’ll make another post about it if I do.

By

Belkin USB Dongle and Ubuntu

This is another one of those posts that’s more for my reference, but if anyone else finds it useful, so much the better…

So, a few years ago, I bought some Belkin wireless USB dongles (F5D7050 is the chipset, I believe). I’ve gotten these working with a few different Linux distros, but the one I most commonly use these days is Ubuntu. At the moment, I have two up and chugging along with different versions of Ubuntu, and they’ve been working long enough for me to forget all of the little annoyances in setting them up.

So, I recently blew away a Windows installation on another PC I have laying around and decided to put Ubuntu and Gmote server on it to take a stab at making it a media PC for hooking up to one of my TVs. I’m thinking of starting with a combination of Netflix/Hulu/Gmote and kind of going from there as the spirit moves me, tying things with my home automation and personal music/movie collection. But, I digress.

Point is, I got Ubuntu installed and configured to my satisfaction in my office with a cat5 connection. I figured, no problem, I’ll just poke around with ndiswrapper like I’ve done in the past. Well, it took me two hours to figure out what I was doing wrong, and I intend to document it here so that I’ll have a fighting chance of wasting less time the next time I have to do this.

I did remember enough that I got the part about using ndiswrapper right. That is, I had played around with the drivers that ship with Ubuntu, and none of them worked very well for these dongles. So ndiswrapper is the way to go. I also recalled that I had to pop the dongle CDs into my driver and pull the driver and the .inf file onto the machine locally to install with ndiswrapper. So I did this, found that there was no ndiswrapper, and remembered that I had to do a “sudo apt-get install ndiswrapper-utils”. Well, this also didn’t work. Apparently, there’s some new-fangled thing going on with ndiswrapper and the package manager, so I actually had to go through the package manager GUI to get this working, but it did, eventually.

I loaded it with “ndiswrapper -l rt73.inf” and thought I was up and running. (Of course, to complicate matters, I have two different CDs with two different sets of Belkin drivers, and I never thought to label the stupid dongles as to which went with which, so there was a bit of extra complication here.) But no dice. I picked through dmesg and some of the logs in /var/logs and saw a lot of cryptic driver messages. There’s nothing like “deauthenticating by local choice reason 3” or a message about the eeprom of the dongle to make you question your sanity.

Nevertheless, I could tell that I was tantalizingly close. The dongle’s light was blinking furiously, and I could see that it was actually connecting. This is no small miracle, given that my home network is non-broadcasting, encrypted with AES, static IP, and probably some other corner cases I’m forgetting. The problem was that it was also disconnecting–by “local choice,” apparently. I wasn’t sure who on Earth was making this choice, but I suppose that’s life.

As it turns out, the problem was that Ubuntu loads competing kernel modules for these drivers by default. At the end of the day, I needed to add the following to /etc/modprobe.d/blacklist:

# Added when rt73 module was installed
blacklist rt73usb
blacklist rt2570

And that sorted it out. I had spent the entire time racking my brain for what I wasn’t loading or configuring properly, and it didn’t dawn on me for those couple of hours what else might be loading. I’m still not entirely clear whose choice the local disconnection was, but I suppose, in the end, it doesn’t matter.

Also, for good measure, you’ll probably want to make sure ndiswrapper kernel module loads on boot. That can be accomplished simply by editing /etc/modules and adding “ndiswrapper” on its own line at the bottom of the file.

Cheers.