2/15/2014

Parallel, Concurrent and Asynchronous Programming

Parallel Programming

In parallel programming, multiple calculations are executed simultaneously. The computations are typically CPU-intensive and perform either different operations on the same data set or perform the same operation on parts of a data set.

  • To be run using multiple processors
  • A problem is broken into discrete parts that can be solved concurrently
  • Each part is further broken down to a series of instructions
  • Instructions from each part execute simultaneously on different processors
  • An overall control/coordination mechanism is employed

Concurrent Programming

In concurrent programming, programs are designed as computations that interact. The computations may be executed on multiple threads, but also using just a single thread.

  • Multiple threads of control

A number of sequential programs programs work together to achieve a goal.

  • Inter-process Communication

Shared variables and Message passing

  • Synchronization
  1. Mutual exclusion

processes must execute their critical sections one at a time.

  1. Conditional synchronization

processes wait until a condition is true.

Asynchronous Programming

The term asynchronous is used when describing I/O operations that do not block a thread while waiting for completion.

It's common to look at asynchronous processes as non-blocking (the system won't lock up, will continue). Asynchronous programming was typically implemented using callbacks or events.

10/13/2013

8 Useful Mac keyboard shortcuts while editing the text

If you spend a lot of time typing the plain text, writing the program, I suggest that you should remember the below Mac keyboard shortcuts to save your time. Here are a few quick shortcuts to set the matter straight for everyone in Mac OSX.

  1. Command + Right
  2. Move to beginning of line.
  3. Command + Left
  4. Move to end of line.
  5. Command + Up
  6. Move to beginning of document.
  7. Command + Down
  8. Move to end of document.
  9. Command + Delete
  10. Delete the entire line of text or paragraph behind the cursor.
  11. Option + Delete
  12. Delete the entire word behind the cursor.
  13. Shift + Command + Left
  14. Select text to beginning of a line.
  15. Shift + command + Right
  16. select text to end of a line.

8/08/2013

How to re-enable Java SE 6 web plug-in in Google Chrome

I think that this problem of applet not working in chrome (32bits) has plagued me for too long. Now, Apple provided us a resolution which re-enables follow these steps:

Open Terminal, located in the Utilities folder.

sudo mkdir -p /Library/Internet\ Plug-Ins/disabled 
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws

http://support.apple.com/kb/ht5559

7/25/2013

Retrieve Email Addresses From Outlook

When we copied a group of email address from outlook, how to export into csv file?
echo "Abc 1234 <abc@example.com>; cde 1234 <cde@example.com>" | tr ';' '\n'|  sed 's/.*/ &/;s/.* <\([^ @]*@[^ @]*.com\).*/\1/'

7/22/2013

XML Format in Console

xmllint is a command line xml tool in console to parse one or more xml files. It also can print type of output by the options selected and detect erros both in XML code.

But I mainly used it to format XML format, by using aliases, it can save a lot of time when doing XML format task.

alias xmlformat="xmllint --c14n '$*' | XMLLINT_INDENT=$'  ' xmllint --encode UTF-8 --format -"
http://xmlsoft.org/xmllint.html

What is Refactoring?

A series of small steps, each of which changes the program's internal structure without changing its external behavior - Martin Fowler ^^~

5/07/2012

設定JAVA_HOME on Mac OSX

對一個Java開發者而言手上應該有很多JDK要試,如何快速設定JDK相關變數?

  • open /Applications/Utilities/Java\ Preferences.app
  • 選擇優先要使用的JDK版本

  • 設定 $JAVA_HOME 自動化取得現在JDK路徑
  • vim ~/.bash_profile

    export JAVA_HOME=`/usr/libexec/java_home`

非常實用Tip!