Sunday, August 11, 2013

Optimize your program

I just find out a heuristic to optimize the program, in term of improving the performance. Your program often requires a check of condition A whether it is True or False. Normally this check is cost.
The rule to optimize this check is to try to find some invariant in your program.  There are some constraints in your program. Combine with these constraints with the invariant you found, we can find a simple, cheaper to check a condition A.

PS: I will try to find a simple example to illustrate this method.

Saturday, July 27, 2013

Hướng dẫn khi đi du lịch Singapore



  • Tiền: Bạn cần chuẩn bị khoảng $500, tiền Sing hay Mỹ đều được. Cho dù bạn có sử dụng thẻ credit card đi nữa, cũng cần chuẩn bị tiền mặt phòng nhân viên hải quan hỏi. Bạn có thể mang vé máy bay ra ngân hàng để mua đô.
  • Visa: Mặc định khi bạn sang Singapore, bạn sẽ được cấp visa 30 ngày. Bạn cần mua vé khứ hồi. Sing rất nhỏ, bạn nên đi khoảng 4-5 ngày là được. Lúc ngồi trên máy bay sang Sing, bán sẽ đươcj cấp 1 phiếu khai hải quan. Sau đó nhân viên hải quan sẽ thu 1 mảnh, bạn cần giữ mảnh còn lại cẩn thận. 
  • Đi lại: Ở Sing bạn sẽ đi bộ rất nhiều, cần mang đôi giày mà bạn thấy thoải mái nhất.  Lúc nào trong người cũng mang chai nước để uống vì đôi khi đi lại mất thời gian. Ngoài ra bạn cần mua 1 thẻ Ezlink để đi lại bằng bus, tàu điện (Mrt). Nếu có smartphone có GPS, bạn nên mua sim Singtel, co gói cước 3G, 1 tuần 1Gb trong 7 ngày giá $7. Google Map là app rất tốt để tìm đường đi. Nếu không gấp nên đi Bus hoặc Mrt cho tiết kiệm. Phương tiện công cộng của Sing rất tốt và đúng giờ. 
  • Ăn uống: Sing là một nước đa sắc tộc, đa tôn giáo, vì vậy thức ăn ở đây rất da dạng. Cố thử các món ăn của các nước khác như Indo, An Do... Một số món ăn nổi tiếng cần thử như: cơm gà, cháo ếch, chili crab. Trong lúc ở Sing, sau mỗi ngày bạn nên mua thức ăn, trái cây ở Fair Price. Trái cây đây khá rẻ, thậm chí còn rẻ hơn ở Việt Nam, mà lại an toàn như dâu, cherry, kiwi. Trong lúc đi chơi bạn có thể ghé các cửa hàng 7Eleven để mua nước và đồ ăn vặt lúc đói bụng. 
  • Mua sắm: Ở Sing, VivoCity và Bugis (gồm Bugis Junction và Bugis Street Market) mua sắm được. Orchard thì toàn hàng hiệu mắc tiền. Nếu muốn mua đồ điện tử, bạn nên né Sim Lim ra nhé, chổ này kiểu như chợ trời, bạn phải trả giá nếu không sẽ bị hớ. Lưu ý là với mỗi hóa đơn trên $100, bạn có thể claim thuế GST 7%. Hoặc bạn có thể gộp tối đa 3 hóa đơn của cùng 1 cửa hàng trong cùng 1 ngày mà trên $100. Nhớ xin cái form claim thuế GST tại cửa hàng bạn mua sắm.
  • Đi chơi: Đầu tiên phải kể đến khu CityHall với các địa điểm nổi tiếng như nhà hát Esplanade, Merlion Park với 2 con sư tử nhỏ hướng ra phía biển và Marina Bay với 3 toà tháp cao đồ sộ nối với nhau bởi 1 hồ bơi bên trên và Gardens by the Bay. Sentosa là một hòn đảo với nhiều hoạt động. Ở đây có tượng con sư tử rất lớn, bảo tàng sáp, casino, thuỷ cung và bãi biển Siloso. Ở đây, bạn nên thử xem nhạc nước (Song of the sea $12). Universal Studio thì có rất nhièu trò hấp dẫn nhưng giá vé khá mắc, khoảng $70 cho 1 cái one-day pass. Trong thành phố có Botanic Garden miễn phí, còn vườn Lan rất đẹp $5. Bạn nên đi vườn Lan để chụp hình. Clarke quay ngày xưa là một bến tàu. Ở đây giờ là khu ăn uống sầm uất. Bạn nên đi River Cruise $18, chạy ra Singapore River, sẽ được thấy nhà hát Esplanade, Marina Bay, Lion park. Cảnh tượng rất đẹp. Ngay Marina Bay có Garden by the Bay $28 với rất nhiều loài hoa và cây đẹp. Bên ngoài có Supertree Grove (miễn phí) thì rất đẹp. Bạn nên đến vào buổi tối trước 9h mới đẹp, đừng đến ban ngày. Với $5 thì có thể lên cao để ngắm thành phố. Sở thú $22 và vườn chim $20 thì thich hợp cho người yêu động vật. Và một số địa điểm khác như Orchard, Bugis, China Town.
  • Để chuyến đi được an toàn, bạn nên mua bảo hiểm du lịch. Theo mình biết bảo hiểm cho 1 tuần ở Sing khoảng 200.000-500.000 VND tùy theo gói bạn muốn mua. Mình thường mua của BIDV, giao dịch online, cực kì tiện lợi. 
  • Chú ý khác: Không mang thuốc lá sang Sing. Theo luật bạn chỉ được mang một gói đang hút và cấm ăn kẹo singum. Ở Sing rất an ninh, nên bạn không cần quá lo lắng chuyện mất cắp, xin đểu... Tuy nhiên nếu bạn có ghé Geylang ăn cháo ếch thì nên cẩn thận. Khu này không được an toàn lắm. 
  • Đặt khách sạn nên ở trung tâm thành phố cho tiện đi lại như Bugis, Little Indian. Nên chọn khách sạn gần MRT.


  • Chúc bạn có một chuyến đi vui vẻ, an toàn ở Singapore


    Saturday, July 13, 2013

    Good App to Learn Vocabulary

    Dictionary.com's Flashcards is a good and free app from Dictionary.com. It is actually an app to help you to organize your vocabulary flashcard desk. This app allows you to create your own vocabulary lists and share your lists to others. Moreover your lists can be synced.

    Now you no longer need to create your own flashcard desk and bring it along with you. You can study vocabulary on your way with you phone.



    Updated: I found that there are some popular words which I could not find it from this app. To add these missing words to your list,  you can add from Dictionary.com website, then choose the tab "Word Dynamo". Now for each word, you can use the definition suggested by Dictionary.com or you can use your own definition. I like this feature. The definition from Dictionary.com is lack of  sample sentences, I prefer use definition from Oxford or Cambridge dictionary with sample.

    Saturday, June 29, 2013

    List of Bugs in Softwares I used

    3. iOS 7 on Iphone: This bug is called "impossible to slide". When the phone is in this error state, it is impossible to slide to unlock. It seems the phone is still working. It can ring when a phone call comes, or the alarm sounds. Moreover all the function from the virtual home button also works as I do the screen capture below. I guess the reason is the phone goes to some deadlock state. Is it possible to use some model checker, such as PAT, to verify whether this error happens. This could be a good case study :)



    2. Viber: After touching around on Viber screen, the selection of categories at the bottom of the screen suddenly disappear. At that time, I was in the "More" selection and I can not change to "Message" or "Recents" and others selection. The only way to escape this to kill Viber process.
    Error Screen
    Normal Screen

    1. Visual Studio 2010: After moving the Solution Explorer and some Debug Windows, now Visual Studio displays the selection of positions for Debug Windows and I can not turn it off, though Visual Studio still works.




    Sunday, June 23, 2013

    Quotes on Formal Method, Model Checking

    1. "The job of formal methods is to elucidate the assumptions upon which formal correctness depends." --Tony Hoare

    2. "Software engineers want to be real engineers. Real engineers use mathematics. Formal methods are the mathematics of software engineering. Therefore, software engineers should use formal methods." --Mike Holloway

    3. "Teaching to unsuspecting youngsters the effective use of formal methods is one of the joys of life because it is so extremely rewarding." --Edsger Dijkstra

    4. "Formal methods will never have a signi?cant impact until they can be used by people that don't understand them." --Tom Melham

    5. "We argue that proof construction is unnecessary in the case of finite state concurrent systems and can be replaced by a model-theoretic approach which will mechanically determine if the system meets a specification expressed in propositional  temporal logic." --EM Clarke

    Thursday, June 20, 2013

    How to change the font-size of chm file

    The .chm files often come with a small font-size. Some CHMs have the IE Browser Text Size button. However, most of them don't have it. So how to change the font-size: 1. Change via IE: Open IE window, go to View-Text Size and then select the suitable font-size. 2. Reopen the .chm file