Skip to main content

Posts

Showing posts from November, 2011

Dawn of Black Friday 2011

I don't have desire to join Black Friday shopping in early morning anymore, not in last 7 years, not a little bit. Things I bought from 2004 Black Friday are still in sealed boxes. This Thanksgiving, my biggest hope is to stay at home, completely forget about work, and take a long 4 days break with satisfying sleeps. Really want to do it this time. Reality emerges in unfortunate way. At 3AM, my IPhone jumped up indicating a text message was received. There can be so many reasons for a text message on 3AM, sales promotion,wrong number, payment due, or I'm paged. I kept fingers crossed in dream and hoped it was not the last one. A few seconds later pager beeped. Instead of any of the other reasons, it really was because someone paged me. Finger crossing continue to prove in vain. Walking to computer in pajama,  I opened two red eyes and read, "blah blah blah... to draw someone's attention, I escalated this ticket". No English words I learned could describe my mo

Cyclic numbers - Project Euler problem 358

Cyclic number , 1/7 specifically, is something amazed me while I was a child. However I never really thought about cyclic numbers other than 1/7 until this problem. I decided to spend an evening researching and resolving the latest Project Euler problem, #358 Cyclic Number . To solve this problem, we need an integer number X satisfying following criteria based on my understanding of cyclic number: 1. 1/X starts with 0.00000000137 2. X is dividable by 10^X-1 3. The result of (10^X-1/X) ends with 56789 4. X is a prime number 5. ? I put a question mark for the fifth criterion because I haven't figured out what it is, while only with four others, the problem can almost be solved. The first hint limits candidates between 724637681 and 729927007. Given the second and third hint, the last 5 digits of 56789 * X should be 99999, which means 56789 * (X-1) ends with 43210. X must ends with 09891 to satisfy such requirement. There are 53 numbers within range and ends with 09891,

Night of the living programmer - Facebook login in Java web application

It is a sunny Saturday, not often in autumn of Seattle. For quite a while, I've been waited for such a chance to walk peacefully in Olympic Sculpture Park. On the other side, I also always wanted to add a "Login with Facebook" button to my new website to attract users as the popularity of the website just about to reach all time low. So the plan is, finishing the login button before afternoon, have peaceful walk during sunset, which would be nice, and watch a relaxing DVD before sleep. With this guide , adding a button with popup login window wasn't difficult. Out of box, div element with class fb-login-button is decorated as long as Facebook Javascript SDK is included.  The script snippet in tutorial is mostly to enable Javascript SDK in an asynchronous fashion for performance gain. The only gotcha is that the URL of page with button must be under a registered domain of application. I did local testing by modifying my /etc/hosts and mapping local.mydomain.com to 12