Monday, October 24, 2016

Install Khmer Unicode Keyboard on Mac OSX Lion v10.7

Installing Khmer Unicode Keyboard

Khmer font was added by default on Mac OSX Lion v10.7 but you have to enable it by go to
- System Preferences then Language & Text
- Under Input Sources tab, check Khmer from the "Select input sources to use." pane.



Or you can also download the keyboard layout and install it from Cambosastra website (read its instruction).  

Problems

1. The Khmer keyboard layout come within OSX maps 'F' key to letter 'ផ' instead of 'ថ' so you should use the layout from Cambosastra team instead by selecting 'Khmer V2' in Keyboard preferences.

2. In Microsoft Word, the Apple's Khmer font named "Khmer Sangam MN" is broken; It does not display correctly when you type. You should install another font such as Koh Santepheap. You can download it from here too.


Create shortcut key to switch between languages

- Go to System Preferences then Keyboard and click on Keyboard Shortcuts tab
- Then, click on Keyboard & Text at the right sidebar and check "Select the previous input source" and then modify its shortcut key to Shirt + Command + Space. Then, make sure "Select next source in Input menu" is unchecked. Then, change the shortcut



- After that, click on Spotlight then check "Show Spotlight search field" and change its shortcut key to Command + Space and make sure "Show Spotlight window" is unchecked






References

- http://www.cambosastra.org/how-to-set-up-khmer-unicode-for-mac/


Monday, September 5, 2016

Depth First Search, Breadth First Search and Uniform Cost Search Algorithms

Before knowing Uniform Cost Search (UCS) algorithm, we should know about Depth First Search (DFS) and Breadth First Search (BFS).

DFS is an algorithm to search a graph for a path from one vertex (node) to another. It just tells you if there is a path or not, nothing more. There can be many paths from one vertex to another. It will just choose one that it meets first; it doesn't care about how long the path is. The pseudocode to implement this algorithm uses an array variable to store the nodes that have been already explored so that the search won't go back to the already explored nodes. We still another (Map) variable to trackback the path or to know the parent or preceding node of the current node. There can be more than parent or preceding nodes but there is only one that the search crosses to reach the current node.




BFS is also an algorithm to search for a path in a graph or tree. It is based on DFS but it can find the shortest path. In processing, DFS uses stack data structure but BFS uses queue data structure. In the pseudocode from my teacher below looks like it does not have anything to do with path cost. And the only difference between it and DFS's pseudocode is frontier variable uses queue, not stack.




UCS use priority queue to store the explored nodes and their cumulative path costs so that it can find the shortest path. I'm not sure how BFS is different from UCS. The algorithm below is from my teacher. In the third line from top and another third line from bottom, it should have said cumulative PATH-COST instead of only PATH-COST.






My homework is to implement DFS, BFS and then UCS in R programming. The source code can be found here https://github.com/vathanakmao/ai-assignments



Sunday, September 4, 2016

Heapsort Algorithm

What is heap?

Heap is an untidy pile of mass of things, for example, a heap of clothes/rubbish. In data structure, a heap is tree-based data structure that satisfies the heap property: if A is a parent of node B then the key (the value) of node A is ordered with the respect of the key of node B with the same ordering applying to the heap.

Heap can be divided into 2 categories: max heap and min heap. In max heap, the max-heap property means that the keys of parent nodes are always greater than or equal to those of the children and the highest key is in the root node. In min heap, the min-heap property means that the keys of parent nodes are always less than or equal to those of the children and the lowest key is in the root node.

Algorithm

The items are stored in an array but we logically convert it to a tree.


The below algorithm of how to find the indices of the left and right children of a (parent) node. For example, node 16 has two children, node 14 and node 10.

The max-heapify operation (function) makes sure the child nodes are not greater than their parents but it doesn't go through all the nodes, just one path straight down to the children. We need another function to call this function in a loop (build-max-heap operation).














Below is the example of how max-heapify operation make change to the tree.



The build-max-heap operation (function) makes sure all nodes in the binary tree satisfy the max-heap property. In other words, the keys of child nodes must be less than or equals to the key of parent node.



Below is the example of how the build-max-heap operation make change to the tree.

























The heapsort() function below will sort the tree completely.



Below is the example of how the tree is sorted step by step.




I have implemented it in Java for learning purpose. You can find the source code here: https://github.com/vathanakmao/sort-algorithms.git





References
Book: Introduction to Algorithms (3rd edition), Thomas H. Cormen, Charles E. Leiserson, ...


Friday, August 5, 2016

Desktop notification for GMail on Mac

I'm using Mac OS X Lion 10.7 and I want a desktop notification when there is a new mail in my Gmail account. I'm using Mail Notifr (formerly Gmail Notifr). It has the old version worked with OSX 10.7. DOWNLOAD

The problem is when you add a Gmail account and type password wrong, it does nothing. I typed my password wrong and it didn't alert me so i thought it's correct but I didn't get any notifications at all.


Thursday, July 28, 2016

CalDAV server can't log into Google with iCal

I was trying to add Google account in iCal so that iCal will synchronize events to my Google account but I got the error message "iCal found a CalDAV server but couldn't log in with the user name 'myuse...@gmail.com'. Make sure the user name and password you entered are correct, then try again.". I did verify the password and it was correct.

Then, when i checked my email, Google had just sent me one to tell me that it had blocked an app from logging into my Google account because it used less secured method. It asked me if I want to allow access to the app and then i clicked on the Allow Access button and it redirected me to this page https://www.google.com/settings/security/lesssecureapps?rfn=27&rfnc=1&asae=2&anexp=lbe2-R1_C I checked "Turn On" for "Access for less secure apps" optionbox.

Monday, June 20, 2016

How to create a WiFi Hotspot on a desktop computer

I was surprised today that my friend had just turned the desktop computer in my classroom into a WiFi hotspot. In other words, the computer connects to internet through Ethernet cable but he shared the internet connection to other devices via WiFi network card. I've never known that before. However, it's not new because this technology has been used on mobile phones for years.

I think to be able to do that we need a WiFi network card and then an application to enable that feature. I used Baidu because it's free and it allows unlimited clients connected to the hotspot.

Sunday, April 24, 2016

Post-installation configuration (also reduce heat) for Windows 7/8 on Macbook Pro

After installing Windows 7 on Macbook Pro 13 inch late 2011, most of the things work out of the box using Boot Camp drivers. However, there are still things you need to manually configure to make them work well such as:

HOT TEMPERATURE NOTE

I'm not sure if they are the cause of the problem, but I made the change and my machine cooled down a lot. Seems like Windows has many more services that do disk activities even when the machine is idle such as indexing, defrag scheduler, and Windows Defender. This cause the disk much hotter than on Mac OS then the rest palm area is very warm all the time.
- Don't use third-party anti-virus program. Use Windows Defender, but turn off Real Time Protection or completely disable this program.
- Go to Control Panel, Power Options, and click on Change Plan Settings. Then, click on "Change advance power settings" and select "Process power management" item from the listbox. Set "Maximum processor state to 97%" and "System cooling polcy" to "Passive" for both "Plugged in" and "On battery".
- Disable Adobe Flash Player in all browsers
- Install Power Plan Assistance (i installed it to turn off backlid keyboard automatically when login but the temperature seemed to reduce too)
- Go to Control Panel > Administrative Tools > Task Scheduler > Task Scheduler Library > Microsoft > Windows > Defrag > then disable the "ScheduledDefrag"
- Disable PreFetch and SuperFetch
- Go to Control Panel > System > Advanced system settings > Advance > Settings > Custom and check only: "Animate controls and elements inside windows", "Fade out menu items after clicking", "Show shadows under windows", "Show thumbnails instead of icons", "Slide open combo boxes", "Smooth edges of screen fonts", "Smooth-scroll list boxes"
- Reduce CPU usage and Disk Activity in Chrome by disable "Enable phising and maleware protection"
- Turn off "Auto-play video" feature on Facebook
- Perform the step in Disable Unnecessary Services section below

Increase SSD's lifespan

Reducing read/write operations does increase the lifespan of SSD. Turning off some services such as indexing, hibernation, and automatic defragmentation not only reduce the heat but also increase the SSD's lifespan.

SMC Fan

What i hate about Lubbo's Fan Control is you have to put it in Startup menu yourself to make start automatically when login and its GUI will open too. It does not minimize in system tray automatically. MacFan Control beat it to this. Then, I configure the fan speed based sensor CPU Core 1. Min value is 35 degree celsius and max value is 83 celsius so that the fan speed is never below 4200 even if the machine is idle.

Power Saver

I enable Power Saver mode in Control Panel. Then, I click on Change plan setting and Change advance power settings. Then, under Processor Power Management, I set Maximum Processor State to 90% when On Battery and Minimum Processor State to 5% for both On battery and Plugged in.

Reduce Animations

Open Control Panel, then Ease of Access and Ease of Access Center. Then check the option "Turn off all unnecessary animations (when possible)"

Disable Indexing Search (to improve performance or might reduce heat)
1. Open Windows Explorer and right click on the drive you want to stop indexing then select Properties. After than, uncheck "Allow files on this drive to have contents indexed in addition to file properties" and click OK.
2. Disable Windows Indexing service in services.msc.

Disable Unnecessary Services

Start "services.msc" program and stop and disable the following services (reference):
- Windows Update
- Google Update Service
- Server
- Computer Browser
TCP/IP NetBIOS Helper
Windows Error Reporting Service
Windows Image Acquisition (WIA) (If you don't have a scanner)
- Windows Search (If you don't use Windows built-in Search feature frequently)
Print Spooler (If you don't have a printer)
IP Helper (If you don't use IPv6 connection)
- Diagnostic Policy Service
- Superfetch
** You might also try registry tweak here to make it faster and so not hotter.

Remap Keys

- To remap the right Command key to Control key, you can use sharpkeys.codeplex.com