Skip navigation

Category Archives: Technical Problems

…encountering new errors along the way, as well.

chad@scheherazade:pydagogical$ python3 -m ai.ants
Ant 0 is a touring machine.
Traceback (most recent call last):
  File "/usr/lib/python3.5/", line 253, in choice
    i = self._randbelow(len(seq))
  File "/usr/lib/python3.5/", line 230, in _randbelow
    r = getrandbits(k)          # 0 <= r < 2**k
ValueError: number of bits must be greater than zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.5/", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/chad/kode/pydagogical/ai/", line 85, in <module>
  File "/home/chad/kode/pydagogical/ai/", line 57, in solve
  File "/home/chad/kode/pydagogical/ai/", line 41, in ant_tour
    next_city = self.get_random_next(self.antroutes[antno], current)
  File "/home/chad/kode/pydagogical/ai/", line 52, in get_random_next
    next_city = random.choice(choices[:int(len(choices) / 4)])
  File "/usr/lib/python3.5/", line 255, in choice
    raise IndexError('Cannot choose from an empty sequence')
IndexError: Cannot choose from an empty sequence

Exception during an exception? Wow.

I just got locked out of my Linux machine (details here) for reasons I am still trying to determine (see the link). I tried to recover my password but, unfortunately, all my most recent Live CDs I’ve left at work. All I have with me is an old Karmic installer, incidentally, the first Ubuntu I ever tried to install (and failed miserably more due to hubris and absence of mind—but that’s another story).

So from the Live CD, I was able to mount my Linux partition fine. Note that, I guess due to EFI and/or the tutorial I was following is just outdated, a mere sudo fdisk -l did not show me all my partitions; I had to use gparted (thankfully available with Karmic). But when I try to chroot, into my mounted partition, I get an exec format error which is apparently because my Karmic LiveCD is just 32-bit while the installation I am trying to salvage is 64-bit.

Thankfully, tinkering around with how Linux stores passwords, I got to reset my main account to have no password.

  1. Edit /etc/passwd. Look for your username in the first of the colon-delimited fields. A typical line in the this file looks like bin:x:2:2:bin:/bin:/bin/sh. The ‘x’ in the second field means that the password for this account is encrypted. Remove the x so the line corresponding to your user becomes similar to bin::2:2:bin:/bin:/bin/sh.
  2. Your actual password is stored in the /etc/shadow file. Open this file and, again, edit the line corresponding to your user to just have four colons after it like so: user::::.
  3. Reboot. You should now be able to log-in passwordless. Remember to reset your password at once.

Note that to get my system to boot from LiveCD I had to tweak my BIOS yet again. I had to set my boot mode to Legacy and, after doing the steps outlined above, had to switch back to UEFI and disable Secure Boot. Man is BIOS dealing becoming traditional for me!

Yay. I just defeated Miraak, making the Dragonborn DLC the first story arc I actually finished in Skyrim. I did not really intend to make it the first, it’s just that, Miraak’s theft of the souls of the dragons I slay has started to become a pain in the neck. So I decided to finally do him in.

However, I encountered a real show stopper of a bug along the way. I found a workaround to it myself, but one with which I’m not very pleased.

I haven’t found this bug described anywhere else so if anyone else encounters the bug, here goes…

Bug behavior: Upon dismounting Sahrotaar to face Miraak, the Dragonborn is instantly killed. Note that I dismount while Miraak is making his little welcome speech.

Dragonborn glows green and dies. No explanations whatsoever. What a way to finally face an arch-nemesis, keeling over to instant death.


  1. When the game prompts you to make a landing (e.g., in PC, the text “Press E to land” is displayed), do not land. Steer Sahrotaar to the Summit of Apocrypha and use the Bend Will shout once more. This will make Sahrotaar take ground without the Dragonborn dismounting.
  2. I’m not sure if you can order Sahrotaar to interrupt Miraak’s speech and just do battle but I sat through it.
  3. When the battle starts, you will have to battle while riding Sahrotaar. You can order him to attack Miraak, but not the other two dragons. Miraak behaves normally (i.e., keeps attacking you, the Dragonborn).
  4. Miraak still kills Sahrotaar last. When Sahrotaar is killed, the Dragonborn is automatically dismounted from him. Beware that, at this moment in the fight, the Dragonborn becomes very open for Miraak’s attack. Plan your actions well after this forced dismount. (This caught me by surprise but I was able to handle it with a well-timed consumption of a healing potion or two).
  5. Continue the battle. At this point, Miraak only needs to be weakened once more before Hermaeus Mora finally ends him.



  • My biggest annoyance with my workaround is in how it cut the battle with Miraak very short. Since, in the first three rounds, I’m ordering Sahrotaar to attack Miraak, Miraak was quickly weakened. I appreciate the leg-up but I really prepared to face Miraak: items, skills, tactic research, game plan preparation, the works. It sucks that I only get a single round out of four; Sahrotaar took the first three. And even the first three rounds did not last long as Sahrotaar was dealing damage way more than what my Dragonborn could’ve dealt.
  • As I noted in (3), the fight goes on even if you have not yet dismounted Sahrotaar. I’m not sure how Skyrim implements battles while dragon riding, but will it be possible for Sahrotaar to have died before his turn to heal Miraak? Judging by the wiki bugs list for this quest, in the event that Sahrotaar dies before healing Miraak, the quest may not complete.
  • Some experiments with my workaround would be interesting, but I haven’t got the proper save points to try it out. For one, would it be okay to dismount once the battle has started (and remedy my big annoyance described above)?

For the record, here’s the kind of battle I prepared for:

In contrast, I think my whole battle with Miraak did not even go beyond five minutes.

The First Dragonborn is dead. Long live the Last Dragonborn!

My laptop turned one-year old last Monday. What could be called remarkable for this gadget anniversary is the fact that I had legitimate cause to claim warranty in the allotted one-year period. It’s not a show-stopper defect that required servicing. It’s something minor though it’s one of those minor things that tend to be really annoying.

One day, the down arrow-key button just stopped working (or started over working depending on how you view the symptoms).

That day I noticed that Windows 8 automagically loaded even if I missed the 10-second period where GRUB asks you for a confirmation on the OS you want to load. I did not fuss too much about it since I was about to play Skyrim, and was going to boot into Windows 8 anyway. However, later that day, when I wanted to code and so had to boot into Linux, I noticed the automagic and started wondering.

In Linux, I noticed that the browser randomly scrolls down and scrolling up with anything (mouse wheel, scroll bar drag, page-up, up arrow key) had no effect as it just drags back down. Then I started switching workspaces via the Ctrl+Alt+Down key combo which just didn’t work.

This is where I started experimenting, starting with GRUB. With no further delay, I present you, the symptoms:

  • At GRUB, I noticed that the selection cursor automatically goes down to Windows 8 (the bottom-most option). From there, while in the 10-second grace period, you can still go up (by pressing `up`) but not down.
  • Inside Linux, I noticed that Ctrl+Alt+Left does not work as well.
  • Inside Windows, while in Notepad, the down button really does not work. All the other direction keys seem to be fine though.
  • Inside a terminal session in Linux, pressing `down` does not make your terminal command history go forward.

As I said, not really a show stopper. At vim, my text editor of choice, I’ve grown accustomed to using the h, jkl keys to navigate around my document; for everything else, I have a mouse with a scroll wheel. At bash, I seldom go through my command history via the up and down buttons anyway; I mostly use Ctrl+R (reverse search). As for workspace switching, I can still get to any workspace as long as up and right are still working and wrap-around behavior is enabled. But this defect just bugs my workflow, not to mention the annoying scroll down browser behavior told earlier.

As when this happened, the machine is still under warranty, I thought it prudent to claim it. Everything’s fine, save that I went to this year’s GDG Philippines DevFest without a laptop. I had to leave it with Acer for three weeks as they ordered a new keyboard. Those three weeks, I managed to sleep on time and devote time to my other hobbies.

I wonder what could’ve caused it though.

Now, I’m having another problem, still minor but perhaps less annoying. For some reason, USB mice are working very erratically with my laptop. At first I thought that the one I’m using just failed. I’ve been using it for less than over a year and it’s not any recognizable brand but one that has sentimental value; I wouldn’t want to let it go too easily.  But I just bought an A4 D530FX, saw that it works well with my computer at work but not with my laptop. I’m not sure if I should feel happy or sad that I seem to have established that my no-namer, sentimentally-important mouse is still fine1 but my laptop may be in for another maintenance check.

(In retrospect, I could’ve saved myself a few hundred pesos by plugging my sentimentally-important mouse to another computer—like the laptop my sister is using, or the old Windows XP desktop which we only keep for printing, or the beast I use at work—and check if its working fine there. Oh well, back-ups can still be considered an investment no?)

It’s not a big problem as the touchpad is still working fine. What suffers is my Skyrim. Damn. :(

With that all said, I’m still pretty pleased with my laptop. Though I, as part of being a “wise consumer”, do check out reviews of products before buying them (especially when I buy uber-new products, like what I did with my XPeria Z), I do not place that much value in them. It seems to me that most reviews today come from people who have just used the product concerned for a test drive, just in time to write a blog post about it (and get their paycheck). Well, I’m buying things not to use them for a test drive but for a pretty long time. I’d actually like to see my purchases as investments.

After a year, I think I’m in a position to make a short review of my laptop no? Quoting from this blog’s “About” page as of this writing:

Unit Model: Acer Aspire V3
Processor: Intel Core i5 (2.5GHz) with Turbo Boost up to 3.1GHz.
GPU: NVIDIA GeForce GT 630M with 2GB dedicated VRAM
Operating Systems: Linux Ubuntu 12.04 LTS (Precise Pangolin) and Windows 8

So well, the pros: I think it looks really sleek. It’s no MacBook, but I find the design really aesthetically pleasing. It is not as light as I would’ve wanted (when I bought this, it was due to an emergency; it was still quite out of spending schedule) but I’ve no issues with weight since, unlike when I was in undergrad, my laptop mostly sits on my desk at home now. Plus points for having the order of the Ctrl, Fn, and Super2 keys in the same order as my previous one.

The specs may not be top-notch but it is sufficient for games (SkyrimCiv V, KingsRoad, anyone?) and the side projects I’m doing. I find that Windows 8 really plays nice with it, though it is not a touchscreen model. Though I think it must be said that I’m way more pleased with Windows 8 than your average Lifehacker commenter.

And yes, there are cons: one of my very first issues with it is that it doesn’t have any indicator if I’ve my Caps Lock on. It may not be a big issue for most users but it does bug me: imagine getting your web passwords wrong only to find out that you’ve accidentally hit Caps Lock on. There’s also this weird bug it has on Google Chrome where GC suddenly hangs for no apparent reason. It happens for both Windows and Linux but Linux does not seem to be able to recover. I’ve checked the logs, reported, and Googled about this bug but I don’t find much. I guess it’s an architecture-level issue, then? I’ve switched to Chromium in an attempt to isolate the problem further but to no avail.


So, hey, a keep-alive. Between me not being able to keep my New Year’s Resolution (at least the part that tells me to write about my experiments here) and some other problems, personal and/or technical, I’ve been going through lately it feels refreshing to be actually writing in casual English instead of code.

See you around! ~Chad

  1. Though you may say that this needs further testing, I noticed that it works quite well in Linux but really annoyingly erratic in Windows. So yes, sentimental value and all it must be still fine. []
  2. The one with a Windows logo printed on it. []

Ever since I got my new laptop and upgraded to Ubuntu 12.04, I noticed that my WiFi has been very unsteady to the point that for anything greater than 100MB, my most reliable download method would be via torrent, unless the server I’m downloading from supports resuming downloads, which is never. That’s a shame since not everything > 100MB can be found in P2P networks. I also noticed that Ubuntu 12.04 oftentimes took ages to connect to our WiFi network upon start-up. This isn’t the case with 10.04 and Windows 8. Unfortunately, the last time I felt this frustrated with WiFi connection upon start-up was with Windows Vista.

At first I thought it is an issue with our router which is around 3-4 years old—a suspicion I got pretty confident with upon checking my ping and traceroute logs. My pings averaged at around hundreds of milliseconds, sometimes even up to 800ms, while the normal was only at around 50ms to 60ms. Traceroute, on the other hand, times out intermittently and, noticeably, on the first hop towards our router (

I got a replacement for our router around a month ago and, to my disappointment, the problem persisted. My ping and traceroute returned to normal but the WiFi remained choppy while connected and initial connection upon start-up still took ages. I’ve been searching for a solution for this problem but every solution I come across seem to be very hardware specific (check those network cards, geeks) and involved building some low-level modules. For what it’s worth, it seems that this problem boils down to a conflict among the wireless drivers that come with 12.04.

Then somewhere, in my searches, I encountered a post in Ubuntu Forums which looked like a general solution to the problem I am having. This, as the command suggests, installs a backport of wireless drivers into your machine:

sudo apt-get install linux-backports-modules-cw-3.3-precise-generic

Now, my Ubuntu 12.04 instantly connects to our WiFi upon start-up, just like my old 10.04 installation.

The WiFi still cuts though, something which I’ve pinpointed to be a fault of the router (or, maybe, how I’m positioned with respect to the router): I noticed that my XPeria Z, stationed on the same desk, also gets disconnected. For what it’s worth, reestablishing connection is now faster since I backported my drivers.