Dec 13, 2013

How to install GraphViz and launch GVEdit

When study Vertica query plan, it's the first time I hear about GraphViz, it turns out to be a project with history. The official site and a brief introduction is as below:
http://www.graphviz.org/

ClusterGraphviz - Graph Visualization Software

GraphvizDrawing graphs since 1988

Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics,  software engineering, database and web design, machine learning, and in visual interfaces for other technical domains. 


Question is: if I got an GraphViz codes, how to make it displayed?

Step 1: Please download a package here
There are many versions and I downloaded Windows msi package






Step 2: launch a command window with administrator access






Please run a command

msiexec /a graphviz-x.xx.msi

And install the software as normal.

Step 3: open a command shell, go to GraphViz installation path, for example mine is:
D:\Program Files (x86)\Graphviz2.34\
Go to the bin folder, and run gvedit.exe







And you will see GVEdit launched!































If you think this article is useful, please click the ads on this page to help. Thank you very much.

Dec 11, 2013

SkyDrive How to Share to Everyone

I have been using Microsoft MSN space to manage my photos, and it's called SkyDrive now. SkyDrive now provides more functions and the UI are improved a lot. However, in MSN space it was very easy to share the picture or album you created to others, with SkyDrive it's not easy to find it out. Luckily, I figured out how to make it work:

1. in SkyDrive click "Files"
This will list all your files and folders

2. Check the folder you want to share (it's on the top right corner) and on the right there will display a link button called "Share" on the right
3. It will pop up a modal dialog, and click Get a link and choose "Public" in the option drop down list, 

4. Then click "Crate link", You can see it's now shared with Everyone. All Set!
I am now able to share my pictures and even send the URL to people I know. 

If you think this article is useful, please click the ads on this page to help. Thank you very much.




Dec 10, 2013

A Good Regular Expression Tutorial

Regular Expression is powerful and it's one of the tools that all programmers should grasp.














I just started the trip and get into the world, and I found the tutorial by Java website is very useful.
http://docs.oracle.com/javase/tutorial/essential/regex/index.html


The most interesting part is about Quantifiers. There are three types: greedy, reluctant and possessive.

GreedyReluctantPossessiveMeaning
X?X??X?+X, once or not at all
X*X*?X*+X, zero or more times
X+X+?X++X, one or more times
X{n}X{n}?X{n}+X, exactly n times
X{n,}X{n,}?X{n,}+X, at least n times
X{n,m}X{n,m}?X{n,m}+X, at least n but not more than m times

But it doesn't very clearly say how the match works underline. And there is an interesting stack overflow website about it.

I found this excellent tutorial on regular expressions and while I intuitively understand what "greedy", "reluctant" and "possessive" quantifiers do, there seems to be a serious hole in my understanding.
Specifically, in the following example:
Enter your regex: .*foo  // greedy quantifier
Enter input string to search: xfooxxxxxxfoo
I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13.

Enter your regex: .*?foo  // reluctant quantifier
Enter input string to search: xfooxxxxxxfoo
I found the text "xfoo" starting at index 0 and ending at index 4.
I found the text "xxxxxxfoo" starting at index 4 and ending at index 13.

Enter your regex: .*+foo // possessive quantifier
Enter input string to search: xfooxxxxxxfoo
No match found.
The explanation mentions eating the entire input string, letters been consumed, matcher backing off, rightmost occurrence of "foo" has been regurgitated, etc.
Unfortunately, despite the nice metaphors, I still don't understand what is eaten by whom... Do you know of another tutorial that explains (concisely) how regular expressions engines work?
Alternatively, if someone can explain in somewhat different phrasing the following paragraph, that would be much appreciated:
The first example uses the greedy quantifier .* to find "anything", zero or more times, followed by the letters "f" "o" "o". Because the quantifier is greedy, the .* portion of the expression first eats the entire input string. At this point, the overall expression cannot succeed, because the last three letters ("f" "o" "o") have already been consumed (by whom?). So the matcher slowly backs off (from right-to-left?) one letter at a time until the rightmost occurrence of "foo" has been regurgitated (what does this mean?), at which point the match succeeds and the search ends.
The second example, however, is reluctant, so it starts by first consuming (by whom?) "nothing". Because "foo" doesn't appear at the beginning of the string, it's forced to swallow (who swallows?) the first letter (an "x"), which triggers the first match at 0 and 4. Our test harness continues the process until the input string is exhausted. It finds another match at 4 and 13.
The third example fails to find a match because the quantifier is possessive. In this case, the entire input string is consumed by .*+, (how?) leaving nothing left over to satisfy the "foo" at the end of the expression. Use a possessive quantifier for situations where you want to seize all of something without ever backing off (what does back off mean?); it will outperform the equivalent greedy quantifier in cases where the match is not immediately found.
The best answer is: 

A greedy quantifier first matches as much as possible. So the .* matches the entire string. Then the matcher tries to match the f following, but there are no characters left. So it "backtracks", making the greedy quantifier match one less thing (leaving the "o" at the end of the string unmatched). That still doesn't match the f in the regex, so it "backtracks" one more step, making the greedy quantifier match one less thing again (leaving the "oo" at the end of the string unmatched). That still doesn't match the fin the regex, so it backtracks one more step (leaving the "foo" at the end of the string unmatched). Now, the matcher finally matches the f in the regex, and the o and the next o are matched too. Success!
A reluctant or "non-greedy" quantifier first matches as little as possible. So the .* matches nothing at first, leaving the entire string unmatched. Then the matcher tries to match the f following, but the unmatched portion of the string starts with "x" so that doesn't work. So the matcher backtracks, making the non-greedy quantifier match one more thing (now it matches the "x", leaving "fooxxxxxxfoo" unmatched). Then it tries to match the f, which succeeds, and the o and the next o in the regex match too. Success!
In your example, it then starts the process over with the remaining unmatched portion of the string, following the same process.
A possessive quantifier is just like the greedy quantifier, but it doesn't backtrack. So it starts out with.* matching the entire string, leaving nothing unmatched. Then there is nothing left for it to match with the f in the regex. Since the possessive quantifier doesn't backtrack, the match fails there.
Thanks to the people who provide the question and answer on the stack verflow website. 

If you think this article is useful, please click the ads on this page to help. Thank you very much.

How to install custom recovery Team Win Recovery Project (TWRP) in Android

Team Win Recovery Project (TWRP) custom recovery is one of the best recovery tool to use. I suggest everyone to install it, it can help you install update, backup, wipe cache and support many nice features, and it support touch screen which is very convenient. Its official website is: http://teamw.in/project/twrp2


To install TWRP, there are two ways:
The easiest way is to install an app called "GooManager" from Google Play.
https://play.google.com/store/apps/details?id=com.s0up.goomanager

But in case your network doesn't support you very well to download rom via GooManager, you need to manually install TWRP, and below are the steps:
1. Go to official site http://teamw.in/project/twrp2 to find the TWRP image for your device

2. Download it

For example, mine is: openrecovery-twrp-2.6.3.4-hammerhead.img

3. go to the android SDK installation folder, go to directory platform tools
for example, mine is: D:\Program Files (x86)\Android\android-sdk\platform-tools

4. Copy the download image into this folder

5. Press Shift key and at the same time, right click your mouse you will see a menu item "Open Command Window here"





















6. boot your device to fast boot mode and connect it to USB
For my device, I power off my device, and then simultaneously press power and volume down button button it will to go fast boot mode

7 execute command fastboot flash recovery recoveryfilename.img
for example, I execuste
fastboot flash recovery openrecovery-twrp-2.6.3.4-hammerhead.img

8. In fast boot mode, select Recovery mode



9. Go! You will now see the TWRP installed.
10. Last you can delete the img file in the SDK platform-tools folder.

If you think this article is useful, please click the ads on this page to help. Thank you very much.




Dec 4, 2013

OK, Google! How to enable Google Now in China

I have got the Nexus 5 and it's very cool that you say "OK Google" to trigger voice search function, you can also speak to use Google Now to find interesting things for you. But Google Now is not available in China, and by default you will see in Android system settings it says Google Now is not supported in China. But the great fire wall cannot stop us, and below is the way you can do it.






















The prerequisite is that you have a rooted device. 

1. Please download a third party market app and install it. I recommend Cool Market, the best one I have ever used.
Download link: cool market

2. After installation, search in cool market an app called "market unlocker". Run it and turn on
1) Enable Unlocker
2) Auto Unlocker

3. Turn off location
Go to Settings, under "PERSONAL" there is "Location" icon, click it and turn it off.

4. Clear Data and Cache of Google apps
Very importantly, please turn off your WiFi in this step
Go to Settings-->Apps, slice to ALL apps, clear cache of three Google apps
1) Google Play services (Click manage space, and then clear all data)

2) Google Play Store (Click clear data)

3) Google Search (Clear data)

Now reboot your device

1. go to Google Play to initialize it.
2. long lick the "Up" icon in home screen and click Google now.

Wait Google Now to be initialized. After this, you can enable locations service and google now will be there with you.

OK, Google!