Monday, August 10, 2009

Addiction

Probably the best piece of hardware that I got my hands on recently was the Nokia E71. With it came the knowledge of the Symbian OS (S60), and the revelation that behind its quite non-sexy UI there's a Unix-ish openness to it. Then came the downfall: I installed FreeCell on the damn thing :P.

Not wanting to ruin the keyboard and joystick with action gaming (I need _some_ type of game to play while waiting in line for stuff) like I did with my last phone, I opted for a strategy game. Which became a minor (uh?) addiction. So minor that today I was only mildly inclined to search the interwebs for a freakin' FreeCell solver to convince myself that my current game was unsolvable. Aha! It wasn't :( Anyway at least that humbled me a bit, allowed me to cheat (to save time!) and presented me with some new build environments (ccmake anyone?). The project I'm talking about is Freecell Solver, and here's the game I needed help with (just to save time!):


QD 7H QH 3C KH 2C 8S
8C 5H AH 5D AD JH KC
5C 5S 9C 4D QC 8H 6D
AC 3D 7D KS JS 7S JC
10D 10H 10S 3S KD 9H
4S 9S 4H 8D 6H 2H
10C QS 6S 6C 4C JD
3H 2D 2S 7C 9D AS


Try something like fc-solve -m -snx < <filename> to solve it. If you need to save even more time than I did ;) here's the solution:


8h 3a 4b 43 a3 4c 4d 41 4a 4h
74 a7 18 1h 1a 1h b1 12 1b c1
85 4c b4 58 4b d4 14 7d 7h 71
78 c7 1c b1 c1 5b 75 b7 75 27v3
2c 2h 2b 2h 6h b8 2b 25 b1 15
3b 32 31 c3 b2 6c 26 32v2 3b 13
d1 63 1d a1 21 d2 36 3a 3d b3
36 3h c3 63 2b a2 62 6c 6a c6
32 3c d3 63 6d b6 68 c6 3b 3c
b3 6b c6 3c a3 85 3a b3 23 6b
d6 c6 58 26 36 3d a3 85 3c b3
23 c2 58 2a d2 63 2b 51 5c 5d
52 53 d2 c2 1d 1h 5c 57 c2 65
54 82 8h 8h 8h 8h 3h 2h 3h 2h
3h 2h 3h 2h 3h 2h 2h 4h 2h 4h
2h 4h 2h 4h 2h 4h 2h 4h ah dh
bh 1h 3h 1h 3h 1h 1h 7h 1h 7h
1h 7h 1h 7h

This game is solveable.
Total number of states checked is 9510.
This scan generated 9606 states.


BTW is it just me or is the board layout for fc-solve in CxL notation instead of LxC notation? I keep having to turn my head 90 degrees to make sense of it. And then I can't read the codes :P.

Wednesday, July 15, 2009

Fans drive me crazy

No, not that type of fan. The Canonical folks updated the Ubuntu 9.04 kernels and now my Aspire One started blowing its fan all the time again. After a bit of tinketing in ~/tmp and /etc/modules I remembered that the acerhdf module is _not_ included, so has to be reinstalled every time a new kernel shows up. So grab that and sudo make install.

xrandr to the rescue

Just got a new Samsung 22" 1080p monitor and plugged it into an Acer Aspire One. I have 3 OSes in this machine, so decided to configure all 3 for the new monitor. Windows XP did a decent job at setting it up (there's an "Advanced" tab in the video preferences that has lots of cool options -- video card specific). MacOS X 10.5.5 was even better, it came up with a bogus config but as soon as I pulled the new monitors plug, it reverted to the main netbook screen and recognized the new monitor after plugging it back in. All very easy.

Unfortunately Ubuntu 9.04 was not as friendly. Although Xorg did recognize all valid modelines at boot, for whatever reason the intel driver refused to show any of the higher ones. The same thing happened when I configured other monitors in the past, but I forgot what I had done to fix it, and didn't want to hard code the xorg.conf file because I will be using different external monitors on a regular basis.

Anyway the solution is quite simple. Just force xrandr to recognize the modeline you want (xrandr --newmode and copy/paste the modeline from Xorg.0.log, then xrandr --addmode). Now go to the display preferences and your shinny new display mode will be available. Logout and login and all is done. Yay!

Thursday, May 7, 2009

Swim on boot

I've got my Nokia E71 syncing with Google (contacts, calendar) and Ovi (those and more). As you probably know the S60 platform doesn't sync by itself on a regular basis so most people use Swim for that task. According to the Swim page it should run at boot time but on my E71 it doesn't seem to. I use Powerboot to run a few apps at boot time, but couldn't find the Swim process by name to add it. Turns out that ("use the source, Luke!") it's called SyncServer.

Friday, April 3, 2009

Alexa cleaning up interfaces

Now that Alexa's thumbnails are no longer supported via AWS (breaking their own site for a while :P) it seems that they decided to also revamp their remaining services and do so cleaning up. This broke a script of mine used to fetch per-country stats. It's a simple change, the UrlInfo call with RankByCountry now returns a Code property in the XML instead of the old code property (note the case change). So if you're using HPricot (like I am), you'll use a line like:

(h/"aws:country[@Code='#{countryCode}']"/"aws:rank").innerHTML.sub(/\s*$/, '')


to filter out the resulting rank.

Monday, August 11, 2008

jdresolve on GitHub

I'm trying to force myself to switch to Git from Subversion for my current projects. The safest way to do it seems to be using an older project as a guinea pig :) So I just pushed jdresolve over to GitHub. I'll scavenge for the uncommitted patches and the unanswered emails regarding jdresolve and will commit to the Git repository soon (enough).

Sunday, July 27, 2008

Google geocoding charset encoding currently broken

Update (2008-09-09): Google seems to have finally fixed this.

About 2 weeks ago I started seeing weird characters when geocoding addresses via Google using the YM4R gem. The addresses are outside the US and so contain plenty of accented characters that used to be properly encoded in UTF8. Although Google's XML claims to return UTF8, it currently doesn't, sending what looks like ISO-8859-1 encoded characters in some fields instead. This is more than likely a problem with their outsourced partners not having properly setup UTF8 environments and updating GIS information using local encodings.

I search for the issue and found if mentioned in ep's blog. He ended up seeing the same error message:

#<REXML::ParseException: Missing end tag for 'DependentLocalityName' (got "DependentLocality")

That'll usually result in a nice 500 error in your Rails app (if that's what you use) because it raises an exception.

His solution (forcing further charset translations to occur) worked quite well, except that I had to mention the origin charset in my case. So instead of calling to_utf8 plainly, I pass it the charset with to_utf8('iso-8859-1'). This is a very ugly hack in all so I hope that Google fixes the issue soon. I personally didn't report the bug 'cause I never got any feedback from any information I ever sent their way or any requests that I've made in the past.