cygwin: WARNING: terminal is not fully functional

I recently encoun­tered an error where when I do a less in cygwin it goes WARNING: terminal is not fully functional Quite some people seem to have encoun­tered this prob­lem before and there are some dis­cus­sion threads on the Web, but I couldn’t find a page that pointed out the direct solu­tion after some googling. Here’s what I did to fix the prob­lem: It turns out that the envi­ron­ment vari­able TERM is some­how set to dumb instead of the normal cygwin. Appar­ently the dumb ter­mi­nal is not as fully func­tional as cygwin. Here’s what I did to con­firm the prob­lem: $ echo $TERM dumb I got less work­ing prop­erly again by doing: $ export TERM=cygwin $ less It turned out that some­how the $TERM envi­ron­ment vari­able got set to dumb. To fix that, simply run sysdm.cpl from a Win­dows com­mand prompt, and delete the envi­ron­ment vari­able TERM. cygwin will then default TERM to cygwin

type​r​acer.com – Simple typing game against other live people!

Today I bumped into this very addic­tive game called Type­R­acer. A pic­ture says is all:

At first I thought “Oh it’s just another Flash game, I’ll give it a try because I like typing”, then volia! It’s not your ordi­nary every­day Flash game. For a Web-​based game, it offers a com­plete fea­ture set and a smooth expe­ri­ence of that of a real, installed game!

The random match­ing process is as smooth as it can be – just clikc “Race against others” and you’ll find your­self typing away in sec­onds! Simply click “race again” after a race and you’ll be instantly matched against other play­ers. The time I tried, there were enough play­ers on the server that I never had to wait for more than 10 sec­onds to be matched against other players.

They also have a “Invite friends” fea­tures where you can open a pri­vate room for invited friends only. That can be done by sim­ply­ing send­ing the URL to your friend, and they can instantly start play­ing – no forced reg­is­tra­tion, no noth­ing – that’s what you call fun!

Talk­ing about the reg­is­tra­tion, the sign up process was really smooth. First off, you don’t have to go through a clumsy reg­is­tra­tion process to start play­ing. Anyone can play as Guest, and if they find that they want to keep their records, just click on Sign up which only required you to fill in the user­name and pass­word – all in an AJAX box that required 0 page reloads.

Give it a try, my hats off to the devel­oper (Yeah I heard it’s a one-​man project.) Great job!

why should I give (for nothing)?

We’ve all been in sit­u­a­tions where we are expected to give. Let’s say I’m in a team project and I’m expected to con­tribute a fair amount; maybe when I see an elderly trying to cross the street, I’m expected to give a help­ing hand; even when I want to fill my stom­ach and go down the con­ve­nience store, I’m expected to give money.

On a very prim­i­tive level, we can think of the reason that we give is because we’ll receive. If I con­tribute my fair share in the team project, we all enjoy a good end result. Obvi­ously if I paid in a con­ve­nience store for some food I get a sat­is­fied stom­ach. Yah, even if I help the elderly across the street I’d get a warm feel­ing in my heart.

And then there are cases where I don’t know why the fuck I’m giving, or giving more than I’m expected. Those are cases where I feel very fuck­ing bad. When for some very weird reason I’m expected to give more than other people in a team, and other people seem to take it for granted.

Don’t get me wrong here. I think giving is gen­er­ally a good thing. I once thought noth­ing was more divine than uncon­di­tional giving. Jesus Christ is wor­shipped by many because he gave his life uncon­di­tion­ally to wash the sins of all people, for all of our greater good. But hey, I’m just a human, why should I give more than nec­es­sary for other people, when I don’t get any­thing in return?

…when I don’t get any­thing, not even some kind words of appre­ci­a­tion, because other people fuck­ing take it for granted?

Giving is a beau­ti­ful thing, but it turns into the syn­onym of “stupid”, “being used” quickly when it is not reciprocated.

I have been think­ing very hard about this. I’ve been trying to make this world a better place for every­one, by giving a little bit more. But most of the time, the world has not become a better place for me. So tell me, why should I be the guy who makes more con­tri­bu­tions than it needs be? If no one in a group of people is going to take the last extra mile to get some­thing done, then why should I be that guy if nobody will appre­ci­ate it? Why shouldn’t I, like every­body else, let the whole thing sink and we all lose?

I have failed to find the answer, and the more I searched for it, the more I’m lean­ing into that the only ratio­nal answer is,

“You shouldn’t.”

the magic cross

Stare at the black cross below. You’ll see the purple dots start to dis­ap­pear! You’ve got to stare at it pretty hard for this trick to work. Prob­a­bly about 30 sec­onds to a minute.

Windows: Delete to Recycle Bin from the command line

Update: Check out the new tool cmd-​recycle which is a lot more robust, writ­ten much more cleanly and just more cool!

I wrote this simple utiltiy some while ago, thought I might as well pub­lish it here.

Just copy recycle.exe to WINDOWS\system32 and you can start using

recycle recycle ... recycle * recycle ...

Full source code included (using C#). Enjoy!

Down­load

we make choices; our choices make us

Found an inspi­ra­tional story on the Web today:

Jerry is the kind of guy you love to hate. He is always in a good mood and always has some­thing pos­i­tive to say. When some­one would ask him how he was doing, he would reply, “If I were any better, I would be twins!” He was a unique man­ager because he had sev­eral wait­ers who had fol­lowed him around from restau­rant to restau­rant. The reason the wait­ers fol­lowed Jerry was because of his atti­tude. He was a nat­ural moti­va­tor. If an employee was having a bad day, Jerry was there telling the employee how to look on the pos­i­tive side of the sit­u­a­tion. Seeing this style really made me curi­ous, so one day I went up to Jerry and asked him, I don’t get it! You can’t be a pos­i­tive person all of the time. How do you do it?” Jerry replied, “Each morn­ing I wake up and say to myself, Jerry, you have two choices today. You can choose to be in a good mood or you can choose to be in a bad mood. I choose to be in a good mood. Each time some­thing bad hap­pens, I can choose to be a victim or I can choose to learn from it. I choose to learn from it. Every time some­one comes to me com­plain­ing, I can choose to accept their com­plain­ing or I can point out the pos­i­tive side of life. I choose the pos­i­tive side of life. “Yeah, right, it’s not that easy,” I protested. “Yes, it is,” Jerry said. “Life is all about choices. When you cut away all the junk, every sit­u­a­tion is a choice. You choose how you react to sit­u­a­tions. You choose how people will affect your mood. You choose to be in a good mood or bad mood. The bottom line: It’s your choice how you live life.” I reflected on what Jerry said. Soon there­after, I left the restau­rant indus­try to start my own busi­ness. We lost touch, but I often thought about him when I made a choice about life instead of react­ing to it. Sev­eral years later, I heard that Jerry did some­thing you are never sup­posed to do in a restau­rant busi­ness: he left the back door open one morn­ing and was held up at gun point by three armed rob­bers. While trying to open the safe, his hand, shak­ing from ner­vous­ness, slipped off the com­bi­na­tion. The rob­bers pan­icked and shot him. Luck­ily, Jerry was found rel­a­tively quickly and rushed to the local trauma center. After 18 hours of surgery and weeks of inten­sive care, Jerry was released from the hos­pi­tal with frag­ments of the bul­lets still in his body. I saw Jerry about six months after the acci­dent. When I asked him how he was, he replied, “If I were any better, I’d be twins. Wanna see my scars?” I declined to see his wounds, but did ask him what had gone through his mind as the rob­bery took place. “The first thing that went through my mind was that I should have locked the back door,” Jerry replied. “Then, as I lay on the floor, I remem­bered that I had two choices: I could choose to live or I could choose to die. I chose to live.” “Weren’t you scared? Did you lose consciousness?” I asked. Jerry con­tin­ued, “…the para­medics were great. They kept telling me I was going to be fine. But when they wheeled me into the ER and I saw the expres­sions on the faces of the doc­tors and nurses, I got really scared. In their eyes, I read ‘he’s a dead man.’ I knew I needed to take action.” ” What did you do?” I asked. “Well, there was a big burly nurse shout­ing ques­tions at me,” said Jerry. “She asked if I was aller­gic to any­thing. ‘Yes,’ I replied. The doc­tors and nurses stopped work­ing as they waited for my reply. I took a deep breath and yelled, ‘Bullets!’ Over their laugh­ter, I told them, ‘I am choos­ing to live. Oper­ate on me as if I am alive, not dead.'” Jerry lived thanks to the skill of his doc­tors, but also because of his amaz­ing atti­tude. I learned from him that every day we have the choice to live fully. Atti­tude, after all, is everything.

Google to add more chaos to Web developers’ lives?

I just saw Google adver­tis­ing their new exper­i­ment ven­tur­ing into the Web browser scene. The Chrome browser, like every­thing else from Google, is in BETA.

Now that is what con­cerns me most: Will this beta soft­ware just adds to foes Web devel­op­ers have to fight when com­bat­ing cross-​browser com­pat­i­bil­i­ties? Does the fact that it is beta imply that it will be con­stantly chang­ing, which mean we’d have to cope with like 10 more dif­fer­ent cases of dif­fer­ent ver­sions of Chrome?

XP Pen graphic tablet

Update: I’ve done some exten­sive research and this graphic tablet DOES NOT work in Win­dows Vista. The Vista driver in the offi­cial home­page doesn’t work, and I see no signs from the vendor updat­ing it. Con­sid­er­ing all P-ACTIVE tablets use the same driver, I’d advice against any Vista user to buy from them :p

Update #2: After some time, I acci­den­tally got this tablet work­ing again in Vista. The prob­lem seem to be related to wisptis.exe. If you don’t see this run­ning in your tasklist, try Win + R -> wisptis. I did this before I installed the offi­cial Vista driver. It worked fine as a point­ing device (with­out pres­sure detec­tion), then I installed the offi­cial driver and voilia! It worked like a charm!

After all these years of comptem­plat­ing, yes­ter­day I finally bought the my P-Active XP Pen graphic tablet:

Played around with it for a while. It was not as dif­fi­cult to pick up as I thought. Here’s a quick sketch I did after like 10 min­utes of practice:

Pretty fun to play with, not bad for around $500 HKD 🙂

let the Web browser “remember” HTTP authentication credentials using AJAX – the correct way vs. the wrong way

Under nor­mally cir­cum­stances, if you request an HTTP pro­tected resource with your Web browser, the server would return 401 Unau­tho­rized and an popup would appear to ask you for the cor­rect credentials:

That doesn’t look too Web 2.0-ish. Cur­rently there is way to work around this using an AJAX request first (there’s an arti­cle that dis­cusses the spe­cific tech­nique used). That way, the browser would “remember” the Autho­riza­tion header used in the pre­vi­ous AJAX request, so when the user requests another pro­tected resource in the same domain, the browser would also try to include the pre­vi­ously used Autho­riza­tion header.

How­ever, I couldn’t get it to work.

It turns out that the dif­fer­ence between my approach and the approach used in the arti­cle above is this:

// My way (doesn't work) var xhr = new XMLHttpRequest; xhr.open ( 'GET', '/url/to/resource', false ); xhr.setRequestHeader ( "Authorization", "Basic " + Base64.encode ( username, password ) ); xhr.send ( null ); // The working way var xhr = new XMLHttpRequest; xhr.open ( 'GET', '/url/to/resource', false, username, password ); xhr.send ( null );

Unbe­known to me was the fact that the 4th and 5th para­me­ter of XMLHttpRequest.open() could be used to spec­ify the user­name and pass­word for the request.

Appar­ently, the browser doesn’t remem­ber the cre­den­tials if I call XMLHttpRequest.setRequestHeader directly.

Note: All these have only been tested to work with MSIE/Firefox. Opera for instance, doesn’t seem to remem­ber the cre­den­tials no matter what I tried – it would still pop up an autho­riza­tion box when the user request a pro­tected resource.

office 2007: The windows installer service cannot update one or more protected windows

I fum­bled with this prob­lem for quite some time with­out much suc­cess after rein­stalling Win­dows XP on my eee PC. Then I found the solu­tion at Ben Shoemate’s arti­cle. I’m directly quot­ing his con­tents here:

I am trying to install Office 2007 onto a clean install of Win­dows XP (on a friends eee PC – it is really a sweet little laptop.. anyway), I get the error above about pro­tected files. Here is the solu­tion. (This may have hap­pened because in opti­miz­ing XP down, some files were deleted). 1. From Win­dows install disk goto E:\I386 folder and open open (Double click) on the FP40EXT.CAB file. It should open. (or – if you do not have the disk, find a work­ing XP com­puter and go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\40\bin). 2. find fp4autl.dll in the list and copy it (ctrl-c) 3. go to c:\program files\common files\microsoft shared\web server extensions\40\bin and paste it (ctrl-v) 4. Restart the 2007 office install