Category Archives: programming

Woofi and finding an access point

Wi-Fi Alliance logo

Image via Wikipedia

One of the main points of an app like woofi is to conserve battery life, so implementing features in a resource-conscious manner is paramount.

Of course, the biggest thing we do is make sure the WiFi radio is on for the smallest amount of time possible.  This brings us to the first trade off we have to juggle.  We can’t know for sure if we want the WiFi radio to be turned on without turning it on and checking for available access points.  If we turn on and then connect to an access point, all is good.  If we turn on and there is no access point to connect to we just wasted a bit of your battery life.

What we want to do is turn on the WiFi radio and then only stay on for the absolute shortest time possible.  The problem is this:  we don’t know what the shortest time possible is!  Some Android devices and some access points take longer than others.  If we only turn on WiFi for 5 seconds and then decide no access point is available, but your device and access point normally take 10 seconds to establish a connection we’ve failed the user.

Our solution to this is to pick a reasonable default time, and allow the user to increase it if they have a slow-to-connect access point.

Toggle Caps Lock with program.

Someone wanted a program to toggle the Caps Lock key on Windows. Here you go! Each time it’s run it just changes the state of the Caps Lock key.

Tip for asking questions on StackOverflow (or anywhere else).

Don’t say “urgent”, “deadline”, “QUICK”.

These are just people answering questions because they like to share knowledge.  Saying you need an answer quick sounds ungrateful, and doesn’t speed up getting an answer, and probably reduces your chances of getting a speedy answer.

The person who is going to give you the answer you need isn’t going to answer your question more quickly.  He’ll answer it when he sees your question.

 

Traildown is the new atd (aka, I’m slowly working on a new trailer downloader)

a very small trailer

Image via Wikipedia

The old atd was more limited than I wished and when Apple made changes on their end that caused it to break, I just didn’t have the heart to fix it.  I’ve recently picked up work on a new trailer downloader that I’m calling traildown (lowercase t because I’m crazy like that).

Traildown will fetch trailers from Apple and Yahoo.  Even if it doesn’t implement an exact replication of each feature of atd, I hope you’ll be able to do everything you could with atd and more!

I’m writing this project in Java instead of Python.  This isn’t because I think Java is better than Python, but because I’m currently learning Java and needed a project to work on.

You can find the source on github.

Android Application Development for Dummies

I’ve been working through the book Android Application Development for Dummies and noticed a little problem on page 182, paragraph 3 where it states:

At this point, you can install the Silent Mode Toggle application, long-press the home screen, and choose the Widgets category; now you should see the Silent Mode Toggle present.

The problem is that this isn’t true.  It’s not till the next page where you edit the AndroidManifest.xml file will you be able to see the widget.

Hopefully, this helps anyone getting frustrated trying to get the widget to show up!

On a related note, the author, Donn Felker, has been very responsive to emails about this issue.  He even offered to take the time to go through the code I’d already written.  I’ll definitely be looking for other books by him because of this.  Thanks Donn!

Soundswitch source on Github

If anyone is interested in hacking on the Soundswitch source, you can find it on GitHub.  Be sure to submit a pull request back to me if you make any changes!

Easier switching of sound devices in Windows with Soundswitch 3.0dev1.

I’ve got a beta-quality release of Soundswitch available now.

You can also peruse the source code.

The big changes for 3.0 are as follows:

  • Configure Source1 and Source2 via tray icon.
  • Select current active sound device from tray icon.
  • Single left click of tray icon switches between Source1 and Source2
  • Rewrites of core parts to reduce bugs and increase speed.

Please let me know about bugs.

Apple Trailer Downloader .2.2

New version of the Apple Trailer Downloader is now available.

This only includes a fix for one bug.

This bug was a failure to handle some Unicode strings and caused ATD to fail when encountering something like the ® character.  A recent trailer that caused ATD to fail was for “The Wolfman”.

Windows download here.

Source available here.

MySQL and Python 2.6 on Windows, Redux

As I noted before, getting a version of MySQLdb that works for Python 2.6 on Windows is an exercise in frustration.  Until now.

An anonymous commenter on the previous post pointed to a web page with instructions for compiling MySQLdb with Visual Studio.  This was quite the salvation to me as I have no experience with Visual Studio or really any sort of compiling on Windows at all.

The only thing lacking in those instructions is the bit about “vsvars32.bat”.  It says:

make sure “vsvars32.bat” exists in “C:\Program Files\Microsoft Visual Studio 8\Common7\Tools”

That’s the last mention of that file.  The problem is that you have to actually run that batch file prior to compiling.

The only other adjustments I had to make were to account for the fact that I’m using Visual Studio 2008 which has a different path than Visual Studio 2005.

All that resulted in my own Windows installer for MySQLdb for Python 2.6.  This was compiled on Windows 7 64-bit, I’m not sure how it’ll work on other operating systems, but if it doesn’t work for you make a comment and I’ll see if I can compile a version for your environment.

Download it here.