<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-181484357747627654</atom:id><lastBuildDate>Sat, 18 Feb 2012 11:34:04 +0000</lastBuildDate><category>Mutex</category><category>MP4</category><category>J2ME</category><category>GWT-EXT-UX</category><category>Virtual PC</category><category>rtmpdump</category><category>Wordpress</category><category>Performance</category><category>JSP</category><category>JQueryMobile</category><category>Corflags</category><category>Outlook</category><category>Barrier</category><category>Email Digital Signature</category><category>ldconfig</category><category>Apple</category><category>RPM</category><category>Postgres</category><category>JConsole</category><category>HTTP</category><category>ADTS</category><category>EXT-GWT</category><category>Blogger Formatting</category><category>JQuery</category><category>VPN</category><category>Site Valuation</category><category>RTSP</category><category>TCP</category><category>Graphics</category><category>Camera</category><category>Jython</category><category>Persistent Connection</category><category>AVC</category><category>Flex</category><category>Apache</category><category>FireFox</category><category>Adobe</category><category>Threading</category><category>CommunicAsia</category><category>RFC</category><category>Autorun</category><category>MySQL</category><category>Javascript</category><category>Critical Section</category><category>IO</category><category>XML</category><category>Perl</category><category>VI Editor</category><category>Compression</category><category>Tomcat</category><category>iPhone</category><category>iTunes</category><category>Window Virtual PC</category><category>GWT-EXT</category><category>Readelf</category><category>Eclipse</category><category>H.264</category><category>HTML</category><category>VS2010</category><category>CLDC</category><category>Servlet Filter</category><category>RTP</category><category>Boost</category><category>IMAPIv2</category><category>MBR</category><category>.Net Framework</category><category>Python</category><category>PIL</category><category>GWT</category><category>OpenLaszlo</category><category>NTP</category><category>iPhone 3GS</category><category>OpenCV</category><category>WinXP</category><category>Monitor</category><category>Remote Access</category><category>IE 8</category><category>Encryption</category><category>Firewall</category><category>PhoneGap</category><category>C++</category><category>KeyTool</category><category>File</category><category>Blackberry</category><category>Chrome</category><category>Dumpbin</category><category>Fiddler</category><category>Surveilience</category><category>JSON</category><category>Android</category><category>FeedBurner</category><category>RTMP</category><category>Microsoft Office</category><category>JVM</category><category>oflaDemo</category><category>Live555</category><category>MSMQ</category><category>Avast</category><category>Semaphore</category><category>Java</category><category>Win7</category><category>Web 2.0</category><category>JavaFX</category><category>Command</category><category>C#</category><category>Reflection</category><category>IPC</category><category>SmartGWT</category><category>ETag</category><category>Linux</category><category>RFC3984</category><category>Memory</category><category>SDP</category><category>AAC</category><category>YSlow</category><category>Time</category><category>Ubuntu</category><category>ThreadMXBean</category><category>iptables</category><category>FFMPEG</category><category>SVN</category><category>Red5</category><category>Ant</category><category>AMF</category><title>Thompson's Technological Insight</title><description /><link>http://thompsonng.blogspot.com/</link><managingEditor>noreply@blogger.com (Thompson Ng)</managingEditor><generator>Blogger</generator><openSearch:totalResults>196</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ThompsonTechnologicalInsight" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="thompsontechnologicalinsight" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-3265289757540412806</guid><pubDate>Mon, 30 Jan 2012 04:02:00 +0000</pubDate><atom:updated>2012-01-29T20:02:28.010-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Linux - VPN with vpnc</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
If you want to set up a VPN client that connect to a CISCO vpn server. The following may help you.&lt;br /&gt;
&lt;br /&gt;
As I had tested, vpnc is compatible to connect to a CISCO vpn server. This is guide is assumed that the Linux machine is a CentOS text based linux client.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Installing vpnc&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1. You need RPMForge repository. See&amp;nbsp;&lt;a href="http://thompsonng.blogspot.com/2012/01/adding-rpmforge-to-centos.html"&gt;Add RPMForge for CentOS for guide&lt;/a&gt;&lt;br /&gt;
2. After adding RPMForge. Type&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
yum install vpnc&lt;/blockquote&gt;
&lt;br /&gt;
3. After successful installation, test your install with&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
vpnc&amp;nbsp;&lt;/blockquote&gt;
&lt;br /&gt;
and you should see the application request for the following&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
Enter IPSec gateway address:&amp;nbsp;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. Ctrl-X to terminate the program. You have successfully installed vpnc&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;Configuration and Usage&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. Go to vpnc folder&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
cd /etc/vpnc&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. You should see 2 files&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
vpnc.conf - sample configuration file&lt;br /&gt;
vpnc-script - a script that vpnc required to run&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3. Set execution permission to vpnc-script&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
chmod +x vpnc-script&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. Set up a configuration file. The configuration file is best to store at &lt;b&gt;/etc/vpnc&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Below is a sample configuration content named &lt;b&gt;my-vpnc.conf&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
### This is the gateway configuration&lt;br /&gt;
IPSec gateway your.vpn.gateway.com&lt;br /&gt;
IPSec ID your.vpn.group.id&lt;br /&gt;
IPSec secret your.vpn.ground.password&lt;br /&gt;
### Put your username here&lt;br /&gt;
Xauth username your.login.id&lt;br /&gt;
Xauth password your.login.password&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I believe those fields are self explanatory. For those information, you can obtain from your cisco pcf file.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For VPN group password, it is encoded in&amp;nbsp;enc_GroupPwd field. If you "forget" your group password, you can use&amp;nbsp;&lt;a href="http://www.unix-ag.uni-kl.de/~massar/bin/cisco-decode"&gt;http://www.unix-ag.uni-kl.de/~massar/bin/cisco-decode&lt;/a&gt;&amp;nbsp;to "recover" it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. After your configuration, type&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
vpnc my-vpnc.conf&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
my-vpnc.conf is set up at step 3, and by default, vpnc locate the configuration file at /etc/vpnc&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
5. If you connect successfully, you should see your VPN banner&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Connect Banner:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
"VPN Banner"&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
VPNC started in background (pid: 18400)...&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Also, you can try to ping your vpn network as testing.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
6. To Disconnect, type&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class="tr_bq"&gt;
vpnc-disconnect&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-3265289757540412806?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2012/01/linux-vpn-with-vpnc.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4516536956350129132</guid><pubDate>Mon, 30 Jan 2012 03:23:00 +0000</pubDate><atom:updated>2012-01-29T20:02:18.412-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Adding RPMForge to CentOS</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Base on the link, you will get enough information to add RPMForge to CentOS machine.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://wiki.centos.org/AdditionalResources/Repositories/RPMForge#head-c02c679d2b90b89efe3ac7f36f212c87bb1c17ab"&gt;http://wiki.centos.org/AdditionalResources/Repositories/RPMForge#head-c02c679d2b90b89efe3ac7f36f212c87bb1c17ab&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
For me, I have some trouble on this as my Linux machine is text based only&lt;br /&gt;
&lt;br /&gt;
1. My VM cannot use RPM to download the those listed RPM file directly.&lt;br /&gt;
2. RPM parse&amp;nbsp;PM-GPG-KEY.dag.txt with error.&lt;br /&gt;
3. My Window machine cannot download those list RPM as well (I really have no idea why???)&lt;br /&gt;
&lt;br /&gt;
If you encounter the above issue, this small tips may help. And, it is so naive....&lt;br /&gt;
&lt;br /&gt;
Use wget!!&lt;br /&gt;
&lt;br /&gt;
1.&amp;nbsp;wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt&lt;br /&gt;
&lt;div&gt;
2.&amp;nbsp;rpm --import RPM-GPG-KEY.dag.txt&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
3.&amp;nbsp;wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el4.rf.i386.rpm&lt;/div&gt;
&lt;div&gt;
4. &amp;nbsp;rpm -i rpmforge-release-0.5.2-2.el4.rf.i386.rpm or&amp;nbsp;rpm -Uhv rpmforge-release-0.5.2-2.el4.rf.i386.rpm&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That all. You can test your yum by yum install vpnc&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4516536956350129132?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2012/01/adding-rpmforge-to-centos.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-6622374664729621765</guid><pubDate>Wed, 11 Jan 2012 03:45:00 +0000</pubDate><atom:updated>2012-01-10T21:10:39.655-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Perl</category><title>Perl - Debugging</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Finally, I have to debug a perl script. These are some of the helpful command. I am assuming the perl debugger version 1.27&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;1. Debugging - Adding &lt;span style="color: red;"&gt;&lt;b&gt;-d&lt;/b&gt; &lt;/span&gt;will trigger a debug mode on your perl script&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
perl -d myscript.pl&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;Stepping - Type &lt;span style="color: red;"&gt;&lt;b&gt;s&lt;/b&gt;&lt;/span&gt; in debug console will let you step through your code line by line&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Break Point - Type&lt;span style="color: red;"&gt;&lt;b&gt; b (line number)&lt;/b&gt;&lt;/span&gt; in debug console will let you set a break point&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
b 100&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Print variable - Type &lt;span style="color: red;"&gt;&lt;b&gt;p (variable)&lt;/b&gt;&lt;/span&gt; in debug console will display your variable value&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
p $varname&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Continue - Type &lt;span style="color: red;"&gt;&lt;b&gt;c&lt;/b&gt;&lt;/span&gt; in debug console will bring you to the next break point&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Delete a Break Point - Type &lt;span style="color: red;"&gt;&lt;b&gt;B (line number) &lt;/b&gt;&lt;/span&gt;in debug console to remove a break point&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
B 100&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;List all break point/action - Type &lt;span style="color: red;"&gt;&lt;b&gt;L&lt;/b&gt;&lt;/span&gt; in debug console to list all breakpoint and action&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Watch - Type &lt;span style="color: red;"&gt;&lt;b&gt;w (variable)&lt;/b&gt;&lt;/span&gt; in debug console to set a watch to the variable. Changes will appear on the debug console if your watch variable is altered&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;br /&gt;&lt;/blockquote&gt;
&lt;blockquote class="tr_bq"&gt;
w $varname&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Delete a Watch - Type W (variable) in debug console to delete a watch point&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class="tr_bq"&gt;
W $varname&lt;/blockquote&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Help - Type &lt;span style="color: red;"&gt;&lt;b&gt;h &lt;/b&gt;&lt;/span&gt;in debug console to get help list&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Reload - Type &lt;span style="color: red;"&gt;&lt;b&gt;R&lt;/b&gt;&lt;/span&gt; in debug console to reload the program in debug mode&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Quit - Type &lt;span style="color: red;"&gt;&lt;b&gt;q&lt;/b&gt;&lt;/span&gt; in debug console to quit debugging&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
See the attached image for example&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-Pn_JQr6wu3M/Tw0FwtINJHI/AAAAAAAAAgM/tUz9TZAVwiw/s1600/perl-debug.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://1.bp.blogspot.com/-Pn_JQr6wu3M/Tw0FwtINJHI/AAAAAAAAAgM/tUz9TZAVwiw/s400/perl-debug.jpg" width="375" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-6622374664729621765?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2012/01/perl-debugging.html</link><author>noreply@blogger.com (Thompson Ng)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-Pn_JQr6wu3M/Tw0FwtINJHI/AAAAAAAAAgM/tUz9TZAVwiw/s72-c/perl-debug.jpg" height="72" width="72" /><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-1116040810710558388</guid><pubDate>Fri, 06 Jan 2012 05:59:00 +0000</pubDate><atom:updated>2012-01-05T21:59:15.853-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">iptables</category><title>Linux Command - iptables</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Finally, get irritated on iptables as it keeps blocking my web server. Done some searching online and the follow helped me to unblock my port and also redirect my port internally. I am working on CentOS 5.6&lt;br /&gt;
&lt;br /&gt;
1. Type the following, to open the iptables configuration file&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
vi /etc/sysconfig/iptables&lt;/blockquote&gt;
&lt;br /&gt;
2. Look for&amp;nbsp;:RH-Firewall-1-INPUT - [0:0] and add the following before any REJECT rule. Reject rule are&amp;nbsp;generally&amp;nbsp;the last line of the configure file before COMMIT&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
3. Save the configuration file and type&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
service iptables restart&lt;/blockquote&gt;
&lt;br /&gt;
4. If you type "iptables -L", you should see a entry like below. You can verify your rule by accessing your webserver via port 80&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
ACCEPT &amp;nbsp; &amp;nbsp; tcp &amp;nbsp;-- &amp;nbsp;anywhere &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; anywhere &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;state NEW tcp dpt:http&amp;nbsp;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
5. Now, for local redirection. You cannot add the command to the above iptables configuration file. You must type the following at run time. The following will forward port 8080 to port 80&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class="tr_bq"&gt;
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j REDIRECT --to-port 80&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
6. You can verify your entry by&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class="tr_bq"&gt;
&amp;nbsp;iptables -t nat -L -n -v&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and you should see an entry like&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class="tr_bq"&gt;
&amp;nbsp;17 &amp;nbsp; 845 REDIRECT &amp;nbsp; tcp &amp;nbsp;-- &amp;nbsp;eth0 &amp;nbsp; * &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.0.0.0/0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.0.0.0/0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tcp dpt:8080 redir ports 80&amp;nbsp;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
7. Now, you can try accessing your webserver via 8080.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
8. Important note is that if your restart your iptables (service iptables restart), you will lose this NAT configuration. It also means that when you restart your server, your NAT configuration will be gone.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
9. So, for me, I will add this redirection command at .bash_profile so that it will apply the setting on each start up. For example, I will add these 2 statement on .bash_profile&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class="tr_bq"&gt;
service iptables restart&lt;br /&gt;iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 4320 -j REDIRECT --to-port 80&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-1116040810710558388?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2012/01/linux-command-iptables.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-2995722037710605354</guid><pubDate>Thu, 29 Dec 2011 06:05:00 +0000</pubDate><atom:updated>2011-12-28T22:05:49.165-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JQueryMobile</category><title>JQueryMobile SplitView Plugin - Force Reload on Different Panel</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In paging, jQueryMobile will load your page into the DOM after your first load. So, if you try to access the same page with different parameters (ie, different web storage value), it will not reload even if you show the page again.&lt;br /&gt;
&lt;br /&gt;
This is a common scenario for a common page that display different information when tapping at different list view items. It is especially true when Android 3.0 and above does not support html query string for passing value.&lt;br /&gt;
&lt;br /&gt;
In general, you can use $.mobile.changePage with reloadPage: true option to force a reload.&lt;br /&gt;
&lt;br /&gt;
But for its split view plugin, it requires more steps to force reload a different panel.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
You can try the following code to force reload a page at different panel from your menu. My assumptions is you had already install jQueryMobile with its SplitView plugin. Also, you display panel is called main&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/-OOFTJgMVo6A/TvwCkT_v6zI/AAAAAAAAAgE/ANC-PiSUIHo/s1600/force_reload.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"&gt;&lt;img border="0" height="102" src="http://4.bp.blogspot.com/-OOFTJgMVo6A/TvwCkT_v6zI/AAAAAAAAAgE/ANC-PiSUIHo/s400/force_reload.png" width="400" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-2995722037710605354?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/jquerymobile-splitview-plugin-force.html</link><author>noreply@blogger.com (Thompson Ng)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-OOFTJgMVo6A/TvwCkT_v6zI/AAAAAAAAAgE/ANC-PiSUIHo/s72-c/force_reload.png" height="72" width="72" /><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-7096465669583841452</guid><pubDate>Thu, 29 Dec 2011 05:56:00 +0000</pubDate><atom:updated>2011-12-28T21:56:38.715-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JQueryMobile</category><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">HTML</category><title>Android - HTML Query String Issue</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
It seems that from Android 3.0, passing value from query string from HTML is broken.&lt;br /&gt;
&lt;br /&gt;
HTML query string is in the form of index.html?name=someone&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://code.google.com/p/android/issues/detail?id=17327"&gt;http://code.google.com/p/android/issues/detail?id=17327&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://code.google.com/p/android/issues/detail?id=17535"&gt;http://code.google.com/p/android/issues/detail?id=17535&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
Personally, I had tested it and I could not get it work for Android 3.0 and above platform. In the past, Android 2.XX work well. It seems that the issue persist on Android 4.0&lt;br /&gt;
&lt;br /&gt;
To workaround this issue, you could use HTML5 Web Storage. There are plenty of information regarding how to use HTML5 web storage.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.w3schools.com/html5/html5_webstorage.asp"&gt;http://www.w3schools.com/html5/html5_webstorage.asp&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
But, using web storage only solve part of the problem. When we use HTML query string, what we want to achieve is load dynamic information on the same html page that have common code.&lt;br /&gt;
&lt;br /&gt;
Web storage does solve our passing of information issue, now, we have to solve the displaying issue.&lt;br /&gt;
&lt;br /&gt;
Why would I say displaying is an issue?&lt;br /&gt;
&lt;br /&gt;
1. The html page is cached&lt;br /&gt;
2. HTML DOM object is loaded and does not refresh. (jQueryMobile does have this issue)&lt;br /&gt;
&lt;br /&gt;
For HTML page is cached, you can use window.location.reload() to force a refresh&lt;br /&gt;
&lt;br /&gt;
For inner HTML DOM reloading with jQueryMobile, you can use $.mobile.changePage with reloadPage: true as option.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-7096465669583841452?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/android-html-query-string-issue.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-7359133789515038992</guid><pubDate>Fri, 23 Dec 2011 07:11:00 +0000</pubDate><atom:updated>2011-12-22T23:12:08.123-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">JQuery</category><title>Javascript - Parsing Form</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
In some case, you may want to parse your Form information via javascript.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Below is an example script that help to parse your form when you onclick your submit button.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
It is using jQuery to access the DOM object.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
It will be called when your submit button is clicked. Then, parse the form value to variable and redirect to another page.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/--9wDtzEy0jQ/TvQoq7rIM9I/AAAAAAAAAf4/TbYxDtNZYh4/s1600/javascript+login.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="383" src="http://4.bp.blogspot.com/--9wDtzEy0jQ/TvQoq7rIM9I/AAAAAAAAAf4/TbYxDtNZYh4/s400/javascript+login.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-7359133789515038992?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/javascript-parsing-form.html</link><author>noreply@blogger.com (Thompson Ng)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/--9wDtzEy0jQ/TvQoq7rIM9I/AAAAAAAAAf4/TbYxDtNZYh4/s72-c/javascript+login.png" height="72" width="72" /><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-519300339249685056</guid><pubDate>Fri, 23 Dec 2011 02:49:00 +0000</pubDate><atom:updated>2011-12-22T18:50:20.526-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JQueryMobile</category><title>JQueryMobile - Header with Image</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
To put a image, using img tag, in JQueryMobile header toolbar, you need to following to prevent misalignment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-XuUZwQGYy7c/TvPrdQUSzyI/AAAAAAAAAfg/rTDwfQH8mfo/s1600/header_with_img.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="31" src="http://3.bp.blogspot.com/-XuUZwQGYy7c/TvPrdQUSzyI/AAAAAAAAAfg/rTDwfQH8mfo/s400/header_with_img.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
There is a few trick to make it work&lt;br /&gt;
&lt;br /&gt;
1. style="float:left;display:inline" make the image display inline at the left alignment to the header toolbar&lt;br /&gt;
2. h1 tag&amp;nbsp;create an empty placeholder to tell jQueryMobile to create a header toolbar with visible height.&lt;br /&gt;
&lt;br /&gt;
Default height for your image should be with 30 pixel.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-519300339249685056?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/jquerymobile-header-with-image.html</link><author>noreply@blogger.com (Thompson Ng)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-XuUZwQGYy7c/TvPrdQUSzyI/AAAAAAAAAfg/rTDwfQH8mfo/s72-c/header_with_img.png" height="72" width="72" /><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-1057277559991387006</guid><pubDate>Thu, 22 Dec 2011 07:48:00 +0000</pubDate><atom:updated>2011-12-22T23:12:44.938-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JQueryMobile</category><category domain="http://www.blogger.com/atom/ns#">PhoneGap</category><title>JQueryMobile - SplitView for Android phoneGap</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In jQueryMobile, they provide a SplitView resource plugin which is rather cool. You can see it yourself at the link below.&lt;br /&gt;
&lt;br /&gt;
Here, I provide some tip on using SplitView with phoneGap and Android 3.1 tablet&lt;br /&gt;
&lt;br /&gt;
1. You have to use the jQuery mobile js and css file given in the build. It seems that latest 1.0 stable version has alignment issue.&lt;br /&gt;
&lt;br /&gt;
2. You can use jQuery 1.7.1 for this library&lt;br /&gt;
&lt;br /&gt;
3. The order of css and js files is important. It is advised to include them in the following order&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
jquery.mobile.css&lt;br /&gt;
jquery.mobile.splitview.css&lt;br /&gt;
jquery.mobile.grids.collapsible.css&lt;br /&gt;
jquery-1.7.1.js&lt;br /&gt;
jquery.mobile.splitview.js&lt;br /&gt;
jquery.mobile.js&lt;br /&gt;
iscroll-wrapper.js&lt;br /&gt;
iscroll.js&lt;/blockquote&gt;
4. Add the following at your main activity java class after&amp;nbsp;super.loadUrl("file:///android_asset/www/index.html");&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
this.appView.getSettings().setUseWideViewPort(true);&lt;/blockquote&gt;
&lt;br /&gt;
setUseWideViewPort(true) make the WebView to have a normal desktop viewport. If false, it will use it own dimension and SplitView is unable to detect the layout correctly.&lt;br /&gt;
&lt;br /&gt;
Reference:&lt;br /&gt;
&lt;a href="http://jquerymobile.com/resources/"&gt;http://jquerymobile.com/resources/&lt;/a&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-1057277559991387006?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/jquerymobile-splitview-for-android.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-9091149420218204338</guid><pubDate>Thu, 22 Dec 2011 06:13:00 +0000</pubDate><atom:updated>2011-12-21T22:14:16.558-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">JQuery</category><title>Javascript - $ Symbol</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
This is a question for me when I am working with JQuery. What is a $.XXX function? Is $ a variables or object?&lt;br /&gt;
&lt;br /&gt;
In Javascript, $ is commonly use as a short hand for variable definition and function declaration. In layman term, it is just a name.&lt;br /&gt;
&lt;br /&gt;
Javascript variables must start with a letter, underscore or dollar sign.&lt;br /&gt;
&lt;br /&gt;
Thus, we can have a function variable like&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
var $ = function(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert("$ function");&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;br /&gt;
Then, you can call this function as&amp;nbsp;$()&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&amp;nbsp;onclick="$()"&lt;/blockquote&gt;
&lt;br /&gt;
Now, back to jQuery, by default, jQuery uses $ as a shortcut for "jQuery"&lt;br /&gt;
&lt;br /&gt;
That means&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
jQuery('div.foo'); === $('div.foo');&lt;/blockquote&gt;
&lt;br /&gt;
More readings:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.authenticsociety.com/blog/JavaScript_DollarSign"&gt;http://www.authenticsociety.com/blog/JavaScript_DollarSign&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries"&gt;http://docs.jquery.com/Using_jQuery_with_Other_Libraries&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-9091149420218204338?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/12/javascript-symbol.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-3936388078419128206</guid><pubDate>Fri, 04 Nov 2011 05:56:00 +0000</pubDate><atom:updated>2011-11-04T06:55:54.147-07:00</atom:updated><title>ffmpeg - Merging video files</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
ffmpeg provide a commands to merge video files together. Below is an example to merge MPEG2-TS files into 1 files&lt;br /&gt;
&lt;br /&gt;
ffmpeg -i concat:"input\\your1.ts|input\\your2.ts" -vcodec copy -acodec copy output\merge.ts&lt;br /&gt;
&lt;br /&gt;
First, the command use a ffmpeg concat function to merge the 2 files. Then, it merge the 2 files into 1 output file by copying the video and audio frames.&lt;br /&gt;
&lt;br /&gt;
See:&amp;nbsp;&lt;a href="http://ffmpeg.org/ffmpeg.html#concat"&gt;http://ffmpeg.org/ffmpeg.html#concat&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
There are other technique to merge video files with FFMPEG. But, personally, I don't like them as they involve too many file container conversion.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://ffmpeg.org/faq.html#How-can-I-join-video-files_003f"&gt;http://ffmpeg.org/faq.html#How-can-I-join-video-files_003f&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
However, both technique is restricted to MPEG-1, MPEG-2 PS, DV format&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-3936388078419128206?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/11/ffmpeg-merging-video-files.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-714672730238812411</guid><pubDate>Fri, 04 Nov 2011 05:29:00 +0000</pubDate><atom:updated>2011-11-03T23:00:03.041-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">FFMPEG</category><title>ffmpeg - Burning overlay logo</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
ffmpeg provide a way to burn a customized logo to your video. The command as folllow&lt;br /&gt;
&lt;br /&gt;
Burn logo at bottom right corner&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ffmpeg -i input\your.mp4 -vf "movie=input/your_logo.png [logo];[in][logo] overlay=W-w-10:H-h-10&amp;nbsp;[out]" -vcodec libx264 output\your_output.mp4&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Burn logo at bottm left corner&lt;br /&gt;
&lt;br /&gt;
ffmpeg -i input\your.mp4 -vf "movie=input/your_logo.png [logo];[in][logo] overlay=10:main_h-overlay_h-10 [out]" -vcodec libx264 output\your_output.mp4&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In general, the command description as follow&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
movie=input/your_logo.png&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This define your image logo. Note, if your logo exist at different folder, your path separator is /&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
overlay=W-w-10:H-h-10&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This define your location of your logo&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
See&amp;nbsp;&lt;a href="http://ffmpeg.org/libavfilter.html#overlay"&gt;http://ffmpeg.org/libavfilter.html#overlay&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-714672730238812411?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/11/ffmpeg-burning-overlay-logo.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-2690269411832647158</guid><pubDate>Tue, 25 Oct 2011 05:48:00 +0000</pubDate><atom:updated>2011-10-24T22:50:27.042-07:00</atom:updated><title>Linux - GDB to debug JNI with Tomcat</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
To debug native code in JNI with GDB, you can do the following&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Get process ID - first you must know the Java process id for your application&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ps -ef | grep java&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Connect GDB to Java&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;gdb -p &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(gdb) attach prog_port&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. If your .so is built with debug information, you should see the following when gdb load the process. To get debug information into your .so, you can use gcc or g++ with -g&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reading symbols from your_debug.so...done.&lt;br /&gt;&lt;br /&gt;Loaded symbols for your_debug.so&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Add your source directory for debugging&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(gdb) dir /your/src/path&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Below are some abstract from GNU&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;directory dirname ... dir dirname ... &lt;br /&gt;&lt;br /&gt;Add directory dirname to the front of the source path. Several directory names may be given to this command, separated by `:' (`;' on MS-DOS and MS-Windows, where `:' usually appears as part of absolute file names) or whitespace. You may specify a directory that is already in the source path; this moves it forward, so GDB searches it sooner. &lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;You can use the string `$cdir' to refer to the compilation directory (if one is recorded), and `$cwd' to refer to the current working directory. `$cwd' is not the same as `.'---the former tracks the current working directory as it changes during your GDB session, while the latter is immediately expanded to the current directory at the time you add an entry to the source path. directory &lt;br /&gt;&lt;br /&gt;Reset the source path to empty again. This requires confirmation. show directories &lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=181484357747627654"&gt;&lt;/a&gt;Print the source path: show which directories it contains.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. Set breakpoint to gdb -  the easiest way is to set break point directly to the class::method (eg, YourClass::YourMethod). gdb will locate the corresponding file and set break point to that method&lt;br /&gt;&lt;br /&gt;(gdb)&amp;nbsp;break YourClass::YourMethod&lt;br /&gt;&lt;br /&gt;You can use the following to list the breakpoints that are set&lt;br /&gt;&lt;br /&gt;(gdb) info breakpoints
Num Type Disp Enb Address What
2 breakpoint keep y 0x080483c3 in func2 at test.c:5
3 breakpoint keep y 0x080483da in func1 at test.c:10&lt;br /&gt;
&lt;br /&gt;Info provide you a number. You can use that breakpoint number to ignore/disable/ddelete the breakpoint&lt;br /&gt;&lt;br /&gt;(gdb) disable 3&lt;br /&gt;
&lt;br /&gt;(gdb) ignore 2
&lt;br /&gt;(gdb) delete 2
&lt;br /&gt;More information on break points &lt;a href="http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_28.html#SEC29"&gt;http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_28.html#SEC29&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
6. When you attach gdb to tomcat, you may realise that the web application may hang. That is because gdb has taken over the control. To continue the application, type continue at the GDB interface&lt;br /&gt;

7. To check a value in your breakpoint, do the following&lt;br /&gt;

&lt;br /&gt;(gdb) p your_variable&lt;div&gt;
&lt;br /&gt; 
8. - if you see this message, it means that your program is compile with gcc -03 where gcc optimizer think that the variable is redundant and had optimized away&lt;br /&gt; 
&lt;br /&gt;9. Step, Continue, Next - You can use these commands to&lt;br /&gt;&lt;br /&gt;s - step to next line&lt;br /&gt;&lt;br /&gt;c - continue to run the program&lt;br /&gt;&lt;br /&gt;n - to next innermost stack&lt;br /&gt;&lt;br /&gt;More information &lt;a href="http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html"&gt;http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Information comes from &lt;a href="http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_toc.html"&gt;http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_toc.html&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-2690269411832647158?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/10/linux-gdb-to-debug-jni-with-tomcat.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4865556778184636762</guid><pubDate>Tue, 27 Sep 2011 06:15:00 +0000</pubDate><atom:updated>2011-09-26T23:15:39.116-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">FFMPEG</category><title>ffmpeg - qt-faststart</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
FFMPEG provide a good utility for you to make your mp4 file optimized for web. In general, it makes the moov atom before mdat atom so that it will be easier to find moov stom and send to remote client.&lt;br /&gt;
&lt;br /&gt;
The following is assumed that you have download ffmpeg 0.8.4 source from&amp;nbsp;&lt;a href="http://ffmpeg.org/download.html"&gt;http://ffmpeg.org/download.html&lt;/a&gt;&amp;nbsp;and tar -xvzf ffmpeg-0.8.4.tar.gz to a folder&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Build qt-faststart in Linux&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1. Navigate to your ffmpeg source folder&lt;br /&gt;
2. Go to tools folder&lt;br /&gt;
3. Type make qt-faststart&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Build qt-faststart in Windows&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can build qt-faststart via cygwin using Linux build step. However, it can only be run within cygwin environment as it will bind qt-faststart with cygwin libraries&lt;br /&gt;
&lt;br /&gt;
Alternatively, build qt-faststart.exe from VS2010&lt;br /&gt;
&lt;br /&gt;
1. Create a VS2010 project&lt;br /&gt;
2. Place qt-faststart.c into your source folder&lt;br /&gt;
3. You need to find and include 2 external header files inttypes.h and stdin.h&lt;br /&gt;
4. Configure your VS2010 project to use the above header files for compilation (Project Properties -&amp;gt; C/C++ -&amp;gt; General -&amp;gt; Additional Include Directories)&lt;br /&gt;
5. Open qt-faststart.c and replace&amp;nbsp;__MINGW32__ with&amp;nbsp;the following&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifdef _WIN32&lt;br /&gt;
# &amp;nbsp; &amp;nbsp;ifdef __MINGW32__&lt;br /&gt;
# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define fseeko fseeko64&lt;br /&gt;
# &amp;nbsp; &amp;nbsp; &amp;nbsp;define ftello ftello64&lt;br /&gt;
# &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define fseeko _fseeki64&lt;br /&gt;
# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define ftello _ftelli64&lt;br /&gt;
# &amp;nbsp; &amp;nbsp;endif&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Build the project to get the qt-faststart.exe&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Usage:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
qt-faststart input.mp4 output.mp4&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4865556778184636762?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/ffmpeg-qt-faststart.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-219730993078411053</guid><pubDate>Mon, 26 Sep 2011 14:59:00 +0000</pubDate><atom:updated>2011-09-26T07:59:06.293-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Command</category><title>Windows - Command Prompt %</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In Windows batch file, % can be use to get command line parameters values from input.&lt;br /&gt;
&lt;br /&gt;
If you have a call a batch file with abc.exe hello world&lt;br /&gt;
&lt;br /&gt;
echo %2 will return world.&lt;br /&gt;
&lt;br /&gt;
There is a limitation of input&amp;nbsp;parameter&amp;nbsp;and the limitation is 9. That is, it can handle %0 to %9 parameters&lt;br /&gt;
&lt;br /&gt;
What if you have something like this your batch file&lt;br /&gt;
&lt;br /&gt;
echo hello%02world&lt;br /&gt;
&lt;br /&gt;
If you call the program with abc.exe hello world, it will print&lt;br /&gt;
&lt;br /&gt;
helloworldworld.&lt;br /&gt;
&lt;br /&gt;
The batch program will replace %02 with the third input parameters.&lt;br /&gt;
&lt;br /&gt;
You can escape % with another % parameter&lt;br /&gt;
&lt;br /&gt;
So, if you batch file has&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo hello%%02world&lt;br /&gt;
&lt;br /&gt;
Calling abc.exe hello world will print&lt;br /&gt;
&lt;br /&gt;
hello%02world&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-219730993078411053?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/windows-command-prompt.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4973394590711874503</guid><pubDate>Thu, 22 Sep 2011 07:31:00 +0000</pubDate><atom:updated>2011-09-22T00:31:03.991-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VS2010</category><category domain="http://www.blogger.com/atom/ns#">C++</category><title>VS2010 - fseeko</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
fseeko, ftello are stdio.h function that are identical to fseek and ftell. But, they are designed for handle 64 bits file offset.&lt;br /&gt;
&lt;br /&gt;
See&amp;nbsp;&lt;a href="http://www.manpagez.com/man/3/fseeko/"&gt;http://www.manpagez.com/man/3/fseeko/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
These function exists in Cygwin and Linux.&lt;br /&gt;
&lt;br /&gt;
However, for VS2010, it does not have fseeko and ftello.&lt;br /&gt;
&lt;br /&gt;
To make your program compilation with fseeko in VS2010, you can do the following&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;br /&gt;#ifdef _WIN32&lt;br /&gt;# &amp;nbsp; &amp;nbsp;ifdef __MINGW32__&lt;br /&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define fseeko fseeko64&lt;br /&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp;define ftello ftello64&lt;br /&gt;# &amp;nbsp; &amp;nbsp;else&lt;br /&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define fseeko _fseeki64&lt;br /&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;define ftello _ftelli64&lt;br /&gt;# &amp;nbsp; &amp;nbsp;endif&lt;br /&gt;#endif&lt;/blockquote&gt;
&lt;br /&gt;
This will make fseeko to use VS2010&amp;nbsp;_fseeki64. It is a 64 bit equivalent in VC++.&lt;br /&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4973394590711874503?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/vs2010-fseeko.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-8724239300870658860</guid><pubDate>Tue, 20 Sep 2011 15:46:00 +0000</pubDate><atom:updated>2011-09-20T08:46:12.231-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><category domain="http://www.blogger.com/atom/ns#">OpenCV</category><title>Python - OpenCV cvseq</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Function like&amp;nbsp;FindContours in OpenCV returns a list of cvseq. To access the list object, it provides h_next(), h_prev(), v_next(), v_prev() to access the next and previous object.&lt;br /&gt;
&lt;br /&gt;
h_next() and h_prev() allows you to access sibling items&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;v_next() and v_prev() allows you to access child/parent items&lt;br /&gt;
&lt;br /&gt;
If there is no sibling or child, it will return None&lt;br /&gt;
&lt;br /&gt;
To print the length of the sibling&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
print len(seq.h_next())&lt;/blockquote&gt;
&lt;br /&gt;
To print the list of item in sibling&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
print list(seq.h_prev())&lt;/blockquote&gt;
&lt;br /&gt;
To access individual x,y items&lt;br /&gt;
&lt;br /&gt;&lt;blockquote&gt;
for (x,y) in seq:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print (x,y)&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-8724239300870658860?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/python-opencv-cvseq.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-3200686753138179591</guid><pubDate>Wed, 14 Sep 2011 05:21:00 +0000</pubDate><atom:updated>2011-09-13T22:21:21.621-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">C++</category><title>C# / C++ - DLL not found error</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Sometime, it is rather frustrating to work with C++. I always wish that they could feedback more useful error when there is a crash of a system.&lt;br /&gt;
&lt;br /&gt;
This post is related to System.DllNotFoundException: Unable to load DLL 'xxxx.dll'. Well, this is a C# DLLImport error, but, it is kind of related to C++. DLL not found error does not really means that xxxx.dll is not found. It may means that the dll that xxxx.dll depends on is not found&lt;br /&gt;
&lt;br /&gt;
Do the following check point if you encounter this error&lt;br /&gt;
&lt;br /&gt;
1. Check if the xxxx.dll exist at the directory of your application or your library search path&lt;br /&gt;
2. If xxxx.dll exist go to ----- to download &lt;a href="http://www.dependencywalker.com/"&gt;Dependency Walker&lt;/a&gt;. Dependency Walker is a nice program to tell you which dependency is missing/linked/needed&lt;br /&gt;
3. Drop xxxx.dll to Dependency Walker. Dependency Walker will load the DLL and search for missing dll&lt;br /&gt;
4. If you have a missing DLL dependency. It will prompt you as an error.&lt;br /&gt;
5. Try to locate the missing library and place it on your application or library search path.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-3200686753138179591?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/c-c-dll-not-found-error.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-231961409116109728</guid><pubDate>Mon, 12 Sep 2011 14:16:00 +0000</pubDate><atom:updated>2011-09-13T22:22:55.004-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">FFMPEG</category><title>FFMPEG - av_interleaved_write_frame return error code -22 when passing in a H.264 frame</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Actually, until now, I don't know what is error -22 means when&amp;nbsp;av_interleaved_write_frame return me this error code. But, I am sure it is related to PTS value in your AVPacket that is going to pass into&amp;nbsp;av_interleaved_write_frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
AVPacket pkt;&lt;br /&gt;
av_init_packet(&amp;amp;pkt);&lt;br /&gt;
......&lt;br /&gt;
ret = av_interleaved_write_frame(oc, &amp;amp;pkt);&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
The above will return -22 if pkt is a H.264 encoded frame from avcodec_encode_video&lt;br /&gt;
&lt;br /&gt;
Now, you need to figure out where to set this PTS value. If you are encoding raw image frame (YUV, RGB, etc...) into H.264, you have to set the PTS at the input frame for&amp;nbsp;avcodec_encode_video.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
AVFrame * picture;&lt;br /&gt;
picture = avcodec_alloc_frame();&lt;br /&gt;
picture-&amp;gt;pts = video_pts;&lt;br /&gt;
out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture);&lt;/blockquote&gt;
&lt;br /&gt;
The line&amp;nbsp;picture-&amp;gt;pts = video_pts; is very important. It will solve not onlyyour error -22 issue but also&amp;nbsp;non-strictly-monotonic pts generate when you call&amp;nbsp;avcodec_encode_video.&lt;br /&gt;
&lt;br /&gt;
Now, you will wonder how to compute PTS.&lt;br /&gt;
&lt;br /&gt;
For H.264 frame, it will be 90000Hz for sample ratewith 30FPS. Therefore, the sequence for H.264 PTS will be&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
frame 0 -&amp;gt; &amp;nbsp;(1 / 30) * 90000 * 0 = 0&lt;br /&gt;
frame 1 -&amp;gt; &amp;nbsp;(1 / 30) * 90000 * 1 = 3000&lt;br /&gt;
frame 2 -&amp;gt; &amp;nbsp;(1 / 30) * 90000 * 2 = 6000&lt;br /&gt;
frame 3 -&amp;gt; &amp;nbsp;(1 / 30) * 90000 * 3 = 9000&lt;/blockquote&gt;
&lt;br /&gt;
So, the general formula is&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
(1 / FPS) * sample rate * frame number&lt;/blockquote&gt;
&lt;br /&gt;
Putting all the above together, it should solve all the issue.&lt;br /&gt;
&lt;br /&gt;
If you want more concrete example, just give me a ping&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-231961409116109728?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/ffmpeg-avinterleavedwriteframe-return.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4411669121326549538</guid><pubDate>Wed, 07 Sep 2011 09:00:00 +0000</pubDate><atom:updated>2011-09-13T22:22:46.832-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Android - MediaRecorder SetAudioSource Failed</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
If you encounter this issue, please check your Android manifest User Permission. Record_Audio&amp;nbsp;permission&amp;nbsp;must be given in order for setting audio source.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4411669121326549538?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/android-mediarecorder-setaudiosource.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4361552473196648969</guid><pubDate>Mon, 05 Sep 2011 16:04:00 +0000</pubDate><atom:updated>2011-09-13T22:22:21.934-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><category domain="http://www.blogger.com/atom/ns#">OpenCV</category><title>Python - Install OpenCV 2.3.1 for Window</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
OpenCV is a Open source Computer Vision library.&lt;br /&gt;
&lt;br /&gt;
This is provide some guide on installing OpenCV 2.3.1 for Window&lt;br /&gt;
&lt;br /&gt;
1. Download and install &lt;a href="http://thompsonng.blogspot.com/2011/09/python-linux-installation.html"&gt;Python 2.7&lt;/a&gt;&lt;br /&gt;
2. Download and install &lt;a href="http://sourceforge.net/projects/numpy/files/"&gt;NumPy &lt;/a&gt;and &lt;a href="http://sourceforge.net/projects/scipy/files/"&gt;SciPy&lt;/a&gt;. Installing them is as simple as double clicking the downloaded installer. It will install the extension to your Python site-package folder&lt;br /&gt;
3. Download &lt;a href="http://sourceforge.net/projects/opencvlibrary/"&gt;OpenCV 2.3.1&lt;/a&gt;&amp;nbsp;for Window Pre-build version&lt;br /&gt;
4. Double click on the OpenCV installer. It will extract OpenCV to your selected folder. For me, I extract it to C:\opencv and I will use that path for the rest of this blog&lt;br /&gt;
5. OpenCV 2.3.1 folder structure is different from OpenCV 2.2. The pre-build library and Python package are located at &lt;b&gt;C:\opencv\build&lt;/b&gt;.&lt;br /&gt;
5. Add&amp;nbsp;&lt;b&gt;C:\opencv\build\x86\vc10\bin&lt;/b&gt;&amp;nbsp;to PATH system environment variable for OpenCV.&lt;br /&gt;
6. Open Python IDLE&lt;br /&gt;
7. Add the following. Note: Having \\ for path is important. If not, Python interpretor may think some of the path as character encoding. For example, \b is consider as character encoding in Python&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
import sys&lt;br /&gt;
sys.path.append("C:\\opencv\\build\\python\\2.7")&lt;/blockquote&gt;
&lt;br /&gt;
8. Now, you are ready to import OpenCV with&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
import cv&lt;/blockquote&gt;
&lt;br /&gt;
See&amp;nbsp;&lt;a href="http://opencv.willowgarage.com/wiki/Welcome"&gt;http://opencv.willowgarage.com/wiki/Welcome&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4361552473196648969?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/python-install-opencv-231-for-window.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-6679766527605192084</guid><pubDate>Sun, 04 Sep 2011 14:50:00 +0000</pubDate><atom:updated>2011-09-13T22:22:36.710-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PIL</category><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Python - Install Python Imaging Library</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Python Imaging Library is an good open source imaging library&amp;nbsp;&lt;a href="http://www.pythonware.com/products/pil/index.htm"&gt;http://www.pythonware.com/products/pil/index.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You require any version of Python 2.7.X in 32 bits. Get the&amp;nbsp;&lt;a href="http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe"&gt;Python Imaging Library 1.1.7 for Python 2.7&lt;/a&gt;and install the executable. It is rather straight forward.&lt;br /&gt;
&lt;br /&gt;
For Linux, most Linux distribution comes with python-imaging package. You can perform yum install python-imaging to install it. However, the default package may be out-dated. For example, CentOS 5.5 only have python-imaging 1.1.5 package while the latest package from the web site is 1.1.7&lt;br /&gt;
&lt;br /&gt;
So, if you want to install for Python Imaging 1.1.7, you will need to following my previous post&amp;nbsp;&lt;a href="http://thompsonng.blogspot.com/2011/09/python-linux-installation.html"&gt;http://thompsonng.blogspot.com/2011/09/python-linux-installation.html&lt;/a&gt;&amp;nbsp;to install 2.7.X python.&lt;br /&gt;
&lt;br /&gt;
Then, goes to&amp;nbsp;&lt;a href="http://effbot.org/downloads/Imaging-1.1.7.tar.gz"&gt;Python Imaging Library 1.1.7 Source Kit&lt;/a&gt;&amp;nbsp;to download the source for Python Imaging 1.1.7.&lt;br /&gt;
&lt;br /&gt;
After that, at your Linux machine, do the following&lt;br /&gt;
&lt;br /&gt;
1. tar -xzvf&amp;nbsp;Imaging-1.1.7.tar.gz&lt;br /&gt;
2. python setup.py install&lt;br /&gt;
&lt;br /&gt;
Note: point 2 assume that your install version of python is 2.7.X. If you have other version of python, please use the correct interpreter respectively.&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #333300; font-family: Verdana, Arial, Helvetica, sans-serif, 'MS Sans Serif', sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 22px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
If install successfully, you should be able to import Image and use their module&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; import Image&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; im = Image.open("your_image.jpg");&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #333300; font-family: Verdana, Arial, Helvetica, sans-serif, 'MS Sans Serif', sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 22px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Georgia, serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="python" style="color: #044484; margin-left: 20px;"&gt;&lt;/pre&gt;
&lt;br /&gt;
See&amp;nbsp;&lt;a href="http://gausssum.sourceforge.net/DocBook/ch01s03.html"&gt;http://gausssum.sourceforge.net/DocBook/ch01s03.html&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.pythonware.com/library/pil/handbook/introduction.htm"&gt;http://www.pythonware.com/library/pil/handbook/introduction.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-6679766527605192084?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/python-install-python-imaging-library.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-4475249758200645429</guid><pubDate>Sun, 04 Sep 2011 14:37:00 +0000</pubDate><atom:updated>2011-09-13T22:21:56.258-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Python - Linux Installation</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
For Window, you can simply use the msi installer provided at&amp;nbsp;&lt;a href="http://www.python.org/download/"&gt;http://www.python.org/download/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
For Linux, you can do the following&lt;br /&gt;
&lt;br /&gt;
yum install python&lt;br /&gt;
&lt;br /&gt;
Usually, this way will install an older version of python. For example, CentOS will install python 2.4.3.&lt;br /&gt;
&lt;br /&gt;
To install the latest version, you can use this script&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="chili" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; overflow-x: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline;"&gt;&lt;code """"""""""""""="" class="bash" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;
# chmod +x install-python.sh
# ./install-python.sh

#!/bin/bash
# Install necessary packages
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make

cd /var/tmp
wget http://sqlite.org/sqlite-amalgamation-3.7.3.tar.gz
tar xfz sqlite-amalgamation-3.7.3.tar.gz
cd sqlite-3.7.3/
./configure
make
make install

cd /var/tmp
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
tar xvfz Python-2.7.1.tgz
cd Python-2.7.1
./configure --prefix=/opt/python2.7.1 --with-threads --enable-shared
make
make install

touch /etc/ld.so.conf.d/opt-python2.7.1.conf
echo "/opt/python2.7.1/lib/" &amp;gt;&amp;gt; /etc/ld.so.conf.d/opt-python2.7.1.conf
ldconfig

ln -sf /opt/python2.7.1/bin/python /usr/bin/python2.7

cd /var/tmp
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.1

/opt/python2.7.1/bin/easy_install pip
ln -sf /opt/python2.7.1/bin/pip /usr/bin/pip

pip install virtualenv
ln -sf /opt/python2.7.1/bin/virtualenv /usr/bin/virtualenv

echo "alias python=/opt/python2.7.1/bin/python" &amp;gt;&amp;gt; ~/.bash_profile
echo "alias python2.7=/opt/python2.7.1/bin/python" &amp;gt;&amp;gt; ~/.bash_profile
echo "PATH=$PATH:/opt/python2.7/bin" &amp;gt;&amp;gt; ~/.bash_profile
source ~/.bash_profile

# Done&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;code """"""""""""""="" class="bash" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I reference this script from&amp;nbsp;&lt;a href="http://willsani.com/2011/03/02/centos-5-5-x86_64-install-python-2-7/"&gt;http://willsani.com/2011/03/02/centos-5-5-x86_64-install-python-2-7/&lt;/a&gt;&amp;nbsp;and it works for me. Just change the version number accordingly. At this time of post, python has 2.7.2&lt;br /&gt;
&lt;br /&gt;
It will install python at /opt/python2.7.2&lt;br /&gt;
&lt;br /&gt;
/opt/python2.7.2/bin/python2.7 will trigger the interpreter&lt;br /&gt;
&lt;pre class="chili" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; overflow-x: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline;"&gt;&lt;code """"""""""""""="" class="bash" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; white-space: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class="chili" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 14px; outline-color: initial; outline-style: initial; outline-width: 0px; overflow-x: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline;"&gt;&lt;code """"""""""""""="" class="bash" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-4475249758200645429?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/python-linux-installation.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-1917406398518692025</guid><pubDate>Sun, 04 Sep 2011 13:40:00 +0000</pubDate><atom:updated>2011-09-13T22:21:41.654-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Linux - Setting Static IP Address</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Just a simple reference on how to set static IP address on Linux via command line&lt;br /&gt;
&lt;br /&gt;
I using CentOS 5.6 x64 with only 1 network interface.&lt;br /&gt;
&lt;br /&gt;
1. Use an editor (such as vi) to edit &lt;b&gt;/etc/sysconfig/network-scripts/ifcfg-eth0&lt;/b&gt;&lt;br /&gt;
2. At ifcfg-eth0, do the following in bold. Note: IP address and net mask is only an example.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
Change BOOTPROTO=dhcp ----&amp;gt; &lt;b&gt;BOOTPROTO=static&lt;/b&gt;Add &lt;b&gt;IPADDR=192.168.1.250&lt;/b&gt;Add &lt;b&gt;NETMASK=255.255.255.0&lt;/b&gt;&lt;/blockquote&gt;
&lt;br /&gt;
3. Save ifcfg-eth0&lt;br /&gt;
4.&amp;nbsp;Use an editor (such as vi) to edit &lt;b&gt;/etc/sysconfig/network&lt;/b&gt;&lt;br /&gt;
5. At network, do the following in bold. Note: Gateway is only an example&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
Add &lt;b&gt;GATEWAY=192.168.1.1&lt;/b&gt;&lt;/blockquote&gt;
&lt;br /&gt;
6. Save network&lt;br /&gt;
7. Restart the network interface by &lt;b&gt;service network restart&lt;/b&gt;&lt;br /&gt;
8. Alternatively, you can restart your server to check if the changes is persistence with &lt;b&gt;reboot&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
See&amp;nbsp;&lt;a href="http://www.cyberciti.biz/faq/linux-configure-a-static-ip-address-tutorial/"&gt;http://www.cyberciti.biz/faq/linux-configure-a-static-ip-address-tutorial/&lt;/a&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-1917406398518692025?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/linux-setting-static-ip-address.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-181484357747627654.post-865754895579561452</guid><pubDate>Thu, 01 Sep 2011 07:48:00 +0000</pubDate><atom:updated>2011-09-01T00:52:03.445-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PhoneGap</category><category domain="http://www.blogger.com/atom/ns#">Android</category><title>PhoneGap - AppView Setting</title><description>PhoneGap appView is the Android WebView container. By default, many setting are off. The following are some helpful setting&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//Enable Zoom&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;this.appView.getSettings().setSupportZoom(true);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//Display with Zoom control. Please note that Android 2.3 and below &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//required this in order for zoom support to be enabled&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;this.appView.getSettings().setBuiltInZoomControls(true);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//Enable normal web view port (like desktop browser). If this is false, it will&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//auto fit your content to mobile viewport&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;this.appView.getSettings().setUseWideViewPort(true);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;//enable plugin. This is needed to enable flash plugin&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;this.appView.getSettings().setPluginState(PluginState.ON);&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/181484357747627654-865754895579561452?l=thompsonng.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://thompsonng.blogspot.com/2011/09/phonegap-appview-setting.html</link><author>noreply@blogger.com (Thompson Ng)</author><thr:total>0</thr:total></item></channel></rss>

