Monday, November 7, 2011

Displaying ANSI Escape Sequences in Windows

I installed Busybox on my Samsung Galaxy S II to enjoy the Swiss Army Knife of Embedded Linux. When I want to look at my phone SD card content, I often use adb if the phone is connected with my laptop. So I typed the following command at Windows command prompt:

adb shell ls /sdcard

What I got is somehow scary as shown below (only first line is shown):

←[1;34mAndroid←[0m ←[1;34mTitaniumBackup←[0m

After a while, I realized that what is shown is actually ANSI escape codes. The ls command provided by Busybox is actually showing color codes by default.

So what shall I do? I know option --color=never can suppress ANSI escape sequences but I don't like typing such long keystrokes. On the other hand, getting useful information out of those ANSI codes is very difficult. My first reaction is trying to see whether Windows shell can show those ANSI codes. I remember my old friend DOS can display ANSI codes, so a modern Windows 7 should be able to do so. But I cannot find relevant configuration in Properties dialog of command prompt. After reading Wikipedia page on ANSI escape codes, I found the following sentence Console windows in all versions of Windows do not support ANSI escape sequences at all. Therefore the only solution is to find some console replacements which can show ANSI codes.

I do found some by Googling. But before trying one, I asked myself why I should install one software for just such a trivial task? I suddenly thought: how about Emacs shell? Maybe Emacs folks have already solved this issue? So I fired up Emacs, typed M-x shell, and typed adb shell ls /sdcard in Emacs shell. Bingo! All ANSI color codes are correctly shown, just as in an Linux box when typing ls --color.

Ubiquitous Emacs to the rescue again.

Saturday, September 10, 2011

Mobilizing All Forces

Recently I played a corresponding game at chess.com. It is one of the games I played in 16th Chess.com Tournament. It is an interesting demo on how Black can attack the King sides in King's Indian Defense. Below is the PGN and an embedded PDF analyzing the game.

[Event "16th Chess.com Tournament (1801-2000) - Round 1"]
[Site "Chess.com"]
[Date "2011.09.01"]
[White "ismail231"]
[Black "whily"]
[Result "0-1"]
[WhiteElo "1810"]
[BlackElo "1873"]
[TimeControl "1 in 3 days"]
[Termination "whily won by resignation"]

1.d4 Nf6 2.c4 g6 3.Nc3 Bg7 4.Nf3 O-O 5.e4 d6 6.Be2 e5 7.O-O Nc6 8.d5
Ne7 9.b4 Nh5 10.Re1 f5 11.Ng5 Nf6 12.f3 Kh8 13.Be3 Bh6 14.Nf7+ Rxf7
15.Bxh6 f4 16.Rf1 Neg8 17.Bg5 h6 18.Bh4 g5 19.Bf2 Rg7 20.c5 g4 21.fxg4
Nxg4 22.Kh1 Qg5 23.Bf3 N8f6 24.Qe2 Nxf2+ 25.Rxf2 Bg4 26.Nb5 Bxf3
27.gxf3 Rag8 28.h3 Nh5 29.Qc2 Qg3 0-1
alt : 2011-09-01-ismail231-vs-whily-kid.pdf

Friday, August 26, 2011

The Power of Two Bishops

Recently I played a corresponding game at chess.com. It is one of the games I played in a Semi Slav thematic tournament. At the end of the game, my two bishops completely dominates the board. Below is the PGN and an embedded PDF analyzing the game.

[Event "12th Chess.com Thematic Tournament - Semi Slav (1801-2000) - Round 1"]
[Site "Chess.com"]
[Date "2011.08.01"]
[White "BennyNevis"]
[Black "whily"]
[Result "0-1"]
[WhiteElo "1768"]
[BlackElo "1876"]
[TimeControl "1 in 3 days"]
[Termination "whily won by resignation"]

1.d4 d5 2.c4 e6 3.Nc3 Nf6 4.Nf3 c6 {Thematic Game - This is the starting position.} 
 5.e3 Nbd7 6.Bd3 dxc4 7.Bxc4 b5 8.Bd3 Bb7 9.a3 Bd6 10.O-O O-O
 11.b4 a5 12.Rb1 axb4 13.axb4 Qe7 14.Qb3 Nd5 15.Nxd5 exd5 16.Bd2 Nf6 17.Ra1 Ne4 18.Bc3 Nxc3 
 19.Qxc3 Bxb4 20.Qc2 g6 21.g3 Bd6 22.Kg2 f6 23.Nd2 c5 24.dxc5 Bxc5 25.Bxb5 d4+ 26.Kg1 dxe3 
 27.fxe3 Qxe3+ 0-1
alt : 2011-08-01-bennynevis-vs-whily-semi-slav.pdf

Friday, August 19, 2011

Transition from Attack to Defense

Recently I played a corresponding game at chess.com. It is one of the games I played in a Ruy Lopez thematic tournament. I attacked first, but later on have to defense and lost the game quickly (as I thought). Below is the PGN and an embedded PDF analyzing the game.

[Event "Ruy Lopez - Round 1"]
[Site "Chess.com"]
[Date "2011.07.25"]
[White "nadreck"]
[Black "whily"]
[Result "1-0"]
[WhiteElo "2022"]
[BlackElo "1882"]
[TimeControl "1 in 5 days"]
[Termination "nadreck won by resignation"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 {Thematic Game - This is the starting
position.}  Nf6 4.O-O Nxe4 5.Re1 Nd6 6.Bxc6 dxc6 7.Nxe5 Be7 8.d4 Be6
9.Bf4 O-O 10.c3 Nf5 11.Nd2 c5 12.g4 Nh4 13.dxc5 Bxc5 14.Ne4 Bd6
15.Nxd6 cxd6 16.Nd3 Qd7 17.f3 Qc6 18.Re3 Bxg4 19.Nb4 Nxf3+ 20.Kh1 Qd7
21.Rxf3 Bxf3+ 22.Qxf3 Rfe8 23.Rg1 Re6 24.Nd5 Rae8 25.Qg4 1-0
alt : 2011-07-25-nadreck-vs-whily-ruy-lopez.pdf

Tuesday, August 2, 2011

Wild King's Gambit

Recently I played a corresponding game at chess.com. I played King's gambit, and the game went wild as what usually happens in this opening. Both white and black kept making tactical blunders and I won the game although I just intended to draw the game at the critical moment. Below is the PGN and an embedded PDF analyzing the game.

[Event "The super wally's that will crush YOU!!! - Board 36"]
[Site "Chess.com"]
[Date "2011.07.22"]
[White "whily"]
[Black "graywyvern"]
[Result "1-0"]
[WhiteElo "1896"]
[BlackElo "1822"]
[TimeControl "1 in 5 days"]
[Termination "whily won by resignation"]

1.e4 e5 2.f4 exf4 3.Nf3 g5 4.h4 g4 5.Ne5 Nf6 6.Bc4 d5 7.exd5 Bd6 8.d4
 f3 9.O-O fxg2 10.Kxg2 h6 11.Nc3 Nbd7 12.Bf4 Nb6 13.Qe2 Qe7 14.Rae1
 Kf8 15.Nb5 Qd8 16.Nxd6 cxd6 17.Ng6+ fxg6 18.Bxd6+ Kg8 19.Rxf6 1-0
alt : 2011-07-22-whily-vs-graywyvern-kga.pdf

One technical note: I generated the PDF file by using LaTeX package xskak, which is great for chess articles/books.