Saturday, November 9, 2013

Detect Ipad Mini Available


Apple introduced new product several weeks ago. However so far Ipad Mini is still not available. Recently there is some news that Apple may not have enough Ipad Mini to sell. Therefore it is good to order the Ipad as soon as it is available.

Now if we visit the Ipad Mini homepage at http://www.apple.com/sg/ipad-mini/, there is a notice that "Coming later in November". Therefore I wrote a program to detect the Ipad Mini is on sale by detect that the notice no longer appears in the website. This approach may be not general, but at least it detects the change of the website. In this case, it is likely that the Ipad Mini is available. If it is available, then the program will print a notice on the screen and send an email to your preferred email address.

Then to make the program check frequently, you can create a Task in Windows and set it to run hourly or daily. I prefer hourly.

To use this program, you need to configure "fromaddr" (the email address to send), "toaddrs" (the email address to receive), and username and password are for the email address account to send.

Link to download the program

Monday, September 9, 2013

Can Not Install Applications in Windows 8

Today an student approached to me and asked about why he can not install an application on his computer. He told me that the computer says he has insufficient privilege, even though, he is using administrator account on this computer.

First I tried to right-click on this *.msi file to see its properties. I plan to select "Run this program as an administrator". Unfortunately this section is disabled.

After doing some Googles and trying suggestions, finally I found a suggestion which works. I'm not sure this is a good solution. Anyway it fixes the problem. Below is the solution.

  1. Type secpol.msc in the Start Menu and press Enter.
  2.  Double click on Local Policies then double click on Security Options.
  3. Scroll to the bottom to this entry -
  4. User Account Control: Run all administrators in Admin approval mode.
  5. Double click that line.
  6. Set it to disabled then press OK.
  7. Reboot.
Basically from Windows Vista, there is a so-called  User Account Control (UAC) which limits the softwares to be able to installed. By disable the "User Account Control: Run all administrators in Admin approval mode", all the policies from UAC are disabled and now you become a real administrator without any limitation. If you know what you are doing on your computer, I recommend you to disable this on your computer to have full control.


Friday, September 6, 2013

Read PDF file in Kindle with Larger Text Size

The Kindle satisfies me when I'm reading a PRC-format book. However when it comes to PDF, the screen is too small to display the page. Even I rotate the Kindle, the text is still small to me. I notice that the margins of the PDF book is often large. So I think that why we don't make use of these margins and increase the text size. Below is my solution

  1. You need to have a PDF virtual printer. You computer may  have "Adobe PDF" printer already. Otherwise I recommend PDFCreator.
  2. Open your PDF book, print it and select your PDF virtual printer. In my case, I select PDFCreator. Then in "Page Sizing and Handling", select the "Custom Scale" and select the maximum percentage where your book is still displayed completely. For my example, I can select up to 150%. In other words, I just increase the text font size 1.5 times. On the right of the dialog, you can scroll the horizontal bar to check whether the page is not over the border of the page.


You can apply this technique not only Kindle but any device where the screen is not large. Make sure that the margin of the book you are reading is large enough. Otherwise the scaling up is not sufficient for you.

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

    Tuesday, June 18, 2013

    What's Latex command for...?

    Get problem on finding Latex command for a symbol. Try Detexify. This website allows you to draw the symbol on its canvas. Then it will try to recognize that symbol and find corresponding Latex command.

    Wednesday, June 12, 2013

    What is Locking this File?

    I often encounter the problem that I can not delete a file or remove a USB. Windows does not allow me to reject the USB safely. The reason is because there is some hidden process which is accessing this file. However it is not easy to find which process is locking the file. So it is useful to have a tool to detect such process and can help me to unlock the file.

    I used to use the tool Unlocker. However recently I found that it does not work well with Windows 64x and was looking for a replacement. Then I found a tool called LockHunter which does a nice job. Using its is very simple. Just right click a file, folder, or even a USB and select "What is Locking this File". The tool will list all program using that file and offer you some action like kill that process or unlock the file.

    Tuesday, June 11, 2013

    Cách Tạo Mục Lục Tự Động

    Trong bài này, tôi sẽ trình bày cách tạo mục lục tự động đơn giản, bằng cách sử dụng công cụ Style. Công cụ Style có thể tìm thấy trên tab Home của Word.

    1. Cách tạo Style cho một đoạn văn bản.
    Tạo style cho một đoạn văn bản rất đơn giản. Chỉ cần format cho nó như mong muốn, ví dụ "Bold", "Italic", font, size... Sau đó chọn đoạn văn bản đó, click chuột phải, chọn "Style-Save Selection as a New Quick Style". Sau đó bạn nhập tên style vào. Bằng cách này, ta có thể áp dụng style này cho nhiều đoạn văn bản khác nhau bằng cách chọn đoạn văn bản đó, chọn Style với tên bạn vừa đặt.

    Sau đây tôi sẽ hướng dẫn cách tạo style cho tiêu đề xuất hiện ở mục lục. Xuất hiện ở mục lục có nhiều cấp độ, ví dụ chương 1, mục 1.1, mục 1.1.1.

    1.1 Đầu tiên qui định cấu trúc mục lục. Click vào biểu tượng như trên hình trong tab Paragraph. Tôi chọn cấu trúc 1, 1.1, 1.1.1 cho đơn giản.

    1.2 Tạo style cho chương 1: Chọn đoạn tiêu đề của chương, chọn Numbering để đánh số chương. Bạn có thể chỉnh thêm các thông số như font, size... Sau đó lưu style cho cái tiều đề này là "Style 1".
    1.3 Tạo style cho mục 1.1: Chọn đoạn tiều đề của mục, chọn Numbering để đánh số mục. Lưu ý bạn sẽ thấy là số đáng lý nên 1.1 thay vì 2. Để qui định cấp độ cho mục, bạn click vào cái hình tam giác bên cạnh Numbering như hình vẽ, chọn cấp độ là 1.1. Lưu style cho đoạn text này là "Style 1.1"

    - Tương tự như trên, tạo style cho mục 1.1.1

    Sau đó áp dụng style "Style 1" cho chương 2, 3, 4..., "Style 1.1" cho mục 1.2, 1.3, 2.1..., "Style 1.1.1" cho mục 1.1.2, 1.2.1, 2.1.1...

    2. Tạo mục lục tự động
    Click Tab References, chọn Table of Contents - Insert Table of Contents. Đầu tiên bạn cần chú ý Show levels. Nếu chọn 3, tức là 1, 1.1, 1.1.1. Nếu chọn 2 thì không có 1.1.1. Giả sử chọn 3. Tiếp theo rất quan trọng, bạn sẽ qui định Style nào thuộc cấp độ nào. Click vào Options



    Bạn sẽ thấy "Heading 1" ứng với level 1. Nghĩa là những đoạn văn bản nào style là "Heading 1" sẽ là chương 1. Tuy nhiên chúng ta đã có style riêng, nên bạn cần xóa các số 1, 2, 3 của các Heading 1, 2, 3. Sau đó kéo chuột xuống tìm style mà bạn đã tạo, nhập 1, 2, 3 lần lượt cho "Style 1", "Style 1.1" và "Style 1.1.1".




    Sau khi nhấn OK, mục lục sẽ xuất hiện như bạn mong muốn

    Update: Đôi khi bạn muốn có cấu trúc mục lục mới, mà những cái có sẵn của Word không làm bạn hài lòng, bạn có thể tự định định nghĩa cấu trúc mới. Click vào biểu tượng "1 a i" bên cạnh cái biểu tượng Number "1 2 3" trong mục Paragraph, chọn "Define new multilevel list". Giả sử chúng ta muốn tạo 3 Level như bên dưới:


    - Level 1: Chọn Number style for this level: I, II, III. Rồi sau đó trên cái mục "Enter formatting for number", gõ chữ "Chương". Bạn có thể xài dấu chấm "." hoặc dấu ngoặc ")" cuối. Format sẽ là "Chương I)"
    - Level 2: chỉ cần chọn Number style for this level là "1, 2, 3,..."
    - Level 3: Lưu ý là số của level 3 la gồm số của level 2, cộng thêm số thứ tự của level 3. Nên ta sẽ chọn Number style for thí level là "1, 2, 3...". Rồi sau đó khi vào mục "Enter formatting for number", nhảy đến dầu dòng, rồi sau đó click vào "Include level number from", chọn Level 2. Nghĩa là ta đã chọn giá trị Level 2 xuất hiện đầu tiên. Sau đó gõ dấu chấm "." vào giữa.

    Sau khi đã tạo ra cấu trúc cho mục lục, lúc áp dụng ở mục Lưu ý 1.3, bạn chỉ cần chọn level phù hợp cho mục hiện tại.

    Friday, June 7, 2013

    Escape a XML String in C#

    Given a XML string, we can manually escape by replacing invalid XML characters with their escaping characters. Below is the list of invalid XML characters and their escaping characters.
    < <
    > >
    " "
    ' '
    & &

    Another easier way is to use the function System.Security.SecurityElement.Escape(string).

    Specification Pattern Repository

    Spec Patterns provides a good collection of popular specification patterns for popular specification languages like LTL, CTL.

    Notice when doing payment for Tiger Airways

    Today when I do payment for Tiger Airways for the trip from HCM-SING. The number is in USD and the website offers me to pay with the currency of my Visa card. It was about 400 USD and Tiger Airways asks me to pay 527 Singapore Dollar. I check the rate from Google and the number in Singapore Dollar is about 496. So I choose to pay in USD.

    After do the payment, in my bank transaction, that transaction costs me about 516 Singapore Dollar. So I save about $11 :)

    Lesson learned: Never accept the offer to pay in another currency in Tiger Airways. The exchange rate including the service fee is high.

    Wednesday, June 5, 2013

    How to Turn your Computer to an Internet-TV

    I love films and I guess you too. However it is difficult for me in Singapore to afford a TV with cable. Recently I found a software named XBMC which is able to turn computers to Internet-TVs. Now I will show you how to install and use it.

    1. Download XBMC and install it.
    2. Import Media to XBMC. You can add photo, music, video to XBMC and play them.
    3. The most interesting thing of XBMC is we can watch many high-res video from Movies, TV Shows from it. Just install Video add-on to watch. Below is the list of Video add-on I highly recommend:

    • 1Channel: many movies and TV Shows.
    • allscience: hundreds of videos about science
    • Discovery Channel: famous Discovery program
    • TED Talks: Watching TED talks from XBMC
    • TubePlus: good to follow latest aired TV Shows like British Got Talent, The Voice US/UK...
    Note that some video add-on are included in XBMC. Some good add-on like 1Channel, you need to install later. You can visit XBMC Blog to know how to install.
    4. If you are using iPhone, Android Phone, remember to download the XBMC app to control your new internet-TV :) iPhone app can be download at AppStore

    Enjoy!

    Tuesday, June 4, 2013

    Send your particulars faster to others

    It is around 2 years since my last post. Recently I feel I have many thoughts and want to share with you. So today I decide to write blog again :)

    Today I want to share one of my tips in using iPhone efficiently. In daily life, you are often asked to send or input to some website your full name, address, bank account, passport number, your email address, many to count.

    Instead of typing them again and again, I find a way to type them faster by creating shortcut in iPhone. You can go Settings - General - Keyboard - Shortcuts and add new shortcut. For example, I add a shortcut "myemail" to "truongkhanhit@gmail.com" and later whenever I type myemail, iPhone will suggest "truongkhanhit@gmail.com". Remember to choose the shortcut special and not frequently appear in your text.