<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4319079131407015379</id><updated>2012-01-30T22:46:51.586-08:00</updated><category term='Software Engineering'/><category term='SQL'/><category term='news'/><category term='Game'/><category term='Misc'/><category term='Math'/><category term='Apple'/><category term='AI'/><category term='IT Trend'/><category term='Quine'/><category term='Marketing'/><category term='History'/><category term='JEE'/><category term='CS'/><category term='Infomation Theory'/><category term='barcode'/><category term='MSSQL'/><category term='jQuery'/><category term='CSS'/><category term='PDF'/><category term='Subversion'/><category term='Javascript'/><category term='Rails'/><category term='Data Mining'/><category term='Perl'/><category term='windows API'/><category term='Astronomy'/><category term='Experience'/><category term='Latex'/><category term='Haskell'/><category term='Software Tools'/><category term='Drupal'/><category term='Computer diagnosis'/><category term='Web application'/><category term='Socket'/><category term='Technical article'/><category term='Version control'/><category term='Suse'/><category term='compiler'/><category term='.NET'/><category term='OS'/><category term='Design patterns'/><category term='numerical computation'/><category term='IT'/><category term='Machine Learning'/><category term='smart phone'/><category term='Probability and Statistics'/><category term='Management'/><category term='Security'/><category term='System design'/><category term='Interview'/><category term='IT Education'/><category term='Finance'/><category term='C++'/><category term='Data Structure'/><category term='Wikipedia'/><category term='Information Retrieval Theory'/><category term='windows script'/><category term='Writing'/><category term='CGI'/><category term='programming language'/><category term='Chart'/><category term='Storage'/><category term='Book'/><category term='Large System'/><category term='science'/><category term='HTML5'/><category term='MIS'/><category term='Trend'/><category term='Network'/><category term='Go'/><category term='Script'/><category term='C/C++'/><category term='programming'/><category term='Physics'/><category term='ASP'/><category term='Dynamic Programming'/><category term='programming langage'/><category term='Workflow'/><category term='Art'/><category term='MS SQL'/><category term='Java'/><category term='Fun'/><category term='Number theory'/><category term='C#'/><category term='PHP'/><category term='Algorithm'/><category term='Browser'/><category term='Functional Programming'/><category term='Install'/><category term='Ruby'/><category term='Database'/><category term='Linux'/><category term='Memory'/><category term='Bioinformatics'/><category term='DOS'/><category term='e-commerce'/><title type='text'>HomeTom - CS</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default?start-index=101&amp;max-results=100'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>157</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-445830745122654257</id><published>2012-01-30T22:40:00.000-08:00</published><updated>2012-01-30T22:46:51.605-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Computer diagnosis'/><title type='text'>Fix UNMOUNTABLE_BOOT_VOLUME problem</title><content type='html'>Upon startup, a computer running windows XP is dead with a blue screen reporting "UNMOUNTABLE_BOOT_VOLUME" error. &lt;br /&gt;&lt;br /&gt;The reason is that the master boot record of the computer is damaged. The fix is to reboot the computer with a XP installation disk. Press "R" to enter recovery console. Then at C:&gt; prompt, enter:&lt;br /&gt;&lt;br /&gt;chkdsk c: /r /p&lt;br /&gt;fixmbr&lt;br /&gt;fixboot&lt;br /&gt;exit (to reboot)&lt;br /&gt;&lt;br /&gt;References: &lt;a href="http://msgoodies.blogspot.com/2007/08/fixing-unmountablebootvolume-on-windows.html"&gt;1&lt;/a&gt;, &lt;a href="http://www.ehow.com/how_4937440_fix-unmountablebootvolume-blue-screen-death.html"&gt;2&lt;/a&gt;, &lt;a href="http://support.microsoft.com/kb/297185"&gt;3&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-445830745122654257?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/445830745122654257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=445830745122654257' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/445830745122654257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/445830745122654257'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2012/01/fix-unmountablebootvolume-problem.html' title='Fix UNMOUNTABLE_BOOT_VOLUME problem'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5365397579489010190</id><published>2011-11-29T19:23:00.000-08:00</published><updated>2011-11-29T19:33:51.267-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>SQL Clustered Index</title><content type='html'>A primary key is usually a unique clustered index. A primary key cannot be null.&lt;br /&gt;&lt;br /&gt;A unique clustered index, if not a primary key, can be null. &lt;br /&gt;&lt;br /&gt;A clustered index determines the physical order of rows in a table.&lt;br /&gt;&lt;br /&gt;There can be at most one clustered index on a table. Non-clustered index is built upon clustered index, and can be created only when a clustered index already exists on the table.&lt;br /&gt;&lt;br /&gt;A unique key is non-clustered by default, unless you specify it to be clustered.&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://msdn.microsoft.com/en-us/library/ms186342.aspx"&gt;Creating Clustered Indexes&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://msdn.microsoft.com/en-us/library/aa933131%28v=sql.80%29.aspx"&gt;Using Clustered Indexes&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://msdn.microsoft.com/en-us/library/ms188783.aspx"&gt;CREATE INDEX (Transact-SQL)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5365397579489010190?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5365397579489010190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5365397579489010190' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5365397579489010190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5365397579489010190'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/sql-clustered-index.html' title='SQL Clustered Index'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4004179241073005352</id><published>2011-11-29T18:23:00.000-08:00</published><updated>2011-11-29T19:34:18.759-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>MSSQL - Change table design not-allowed error</title><content type='html'>Sometimes, for example, when you add a column to a table, or when you want to create a primary key field on a table containing millions of rows, you may encounter the dialog message: "The changes you have made require the following tables to be dropped and re-created". &lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.sql-server-performance.com/2009/saving-changes-not-permitted/"&gt;The solution&lt;/a&gt; is: From top menu select Tools -&gt; Options -&gt; Designers -&gt; Table and Database Designers, uncheck the box "Prevent saving changes that require table re-creation". When the table is big, you may also need to increase the value of "Transaction Time-out after" textbox.&lt;br /&gt;&lt;br /&gt;However, it is recommended not&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4004179241073005352?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4004179241073005352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4004179241073005352' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4004179241073005352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4004179241073005352'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/changes-you-have-made-require-following.html' title='MSSQL - Change table design not-allowed error'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5853881935484881630</id><published>2011-11-29T18:17:00.000-08:00</published><updated>2011-11-29T18:23:11.159-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>Query Plan</title><content type='html'>When a query goes complicated and data involved is huge, query plan reveals the query execution sequence and helps to optimize the query [1].&lt;br /&gt;&lt;br /&gt;In MSSQL Server Management Studio, after opening a query window, one can choose "Query -&gt; Display Estimated Execution Plan" to see the estimated query plan, and select "Include Actual Execution Plan" to show actual query plan in the result. [2] is a very good introduction.&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://en.wikipedia.org/wiki/Query_plan"&gt;Query plan&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://www.sql-server-performance.com/2006/query-execution-plan-analysis/"&gt;SQL Server Query Execution Plan Analysis&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5853881935484881630?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5853881935484881630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5853881935484881630' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5853881935484881630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5853881935484881630'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/query-plan.html' title='Query Plan'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1787831811586724850</id><published>2011-11-26T22:57:00.000-08:00</published><updated>2011-11-26T23:51:44.265-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Apple'/><title type='text'>MacBook Pro with Mac OS X Lion 10.7</title><content type='html'>I got a MacBook Pro 13" for the Thanksgiving sales Friday. It's $101 off the regular price -- $1098, plus tax it's $1150. I didn't get an Air because an Air lacks wired ethernet jacket and CD/DVD drive. I'll have to buy extra accessories. Air has 128GB super fast SSD hard drive. Pro has ATA drive but it's 500GB. For 13.3" size, Pro is 2.04kg, Air is 1.35kg, which does not create a big difference for me since I don't carry laptop around often. &lt;br /&gt;&lt;br /&gt;The current OS is called Lion, it is called Mac OS X Lion 10.7.&lt;br /&gt;&lt;br /&gt;So far the feeling is: the 13.3" screen is indeed a little big small, can't evenly distribute the different windows without interfering each other. Besides a bigger screen, I also prefer a mouse instead of the touchpad. I may but these separately later, but now let me just setup the environment first.&lt;br /&gt;&lt;br /&gt;So now I'm installing softwares to make it a development machine. It already has php, perl, python, ruby, vi, emacs, svn, git, cvs, lex/yacc. I need to have apache, mysql, postgresql, c/c++, java, rails, gcc, make, Xcode, so that I can develop LAMP web applications, iOS applications, and c/c++/java applications. &lt;br /&gt;&lt;br /&gt;First I need to enable root account, since many operations will need root permission. See &lt;a href="http://www.spy-hill.com/~myers/help/apple/EnableRoot.html"&gt;How to Enable the "root" Account on Mac OS X&lt;/a&gt;. I used the "2.2 Directory Utility - (Mac OS X 10.4 or later)" method.&lt;br /&gt;&lt;br /&gt;To setup LAMP, I referred to &lt;a href="http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/"&gt;Setting up PHP, MySQL, and Apache in Mac OSX Leopard&lt;/a&gt;, and &lt;a href="http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/"&gt;Installation of MySQL server on Apple Mac OS X 10.7 aka Lion&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;To setup pear, I followed &lt;a href="http://i.justrealized.com/2011/setup-php-pear-mac-os-lion/"&gt;How to setup PHP Pear in Mac OS X Lion&lt;/a&gt;. To restore a LAMP application I wrote in the past, I need pear::DB, so I use "pear install DB" command to install it, quite easy.&lt;br /&gt;&lt;br /&gt;When trying to make php work with mysql, I had a problem "&lt;a href="http://stackoverflow.com/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi"&gt;Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock)&lt;/a&gt;". The solution is found in the above link. &lt;br /&gt;&lt;br /&gt;From the above link, you may have a socket file as /tmp/mysql.sock or /var/mysql/mysql.sock but php is looking in the wrong place. Instead of moving the socket or editing config files one can just create a symbolic link so mac finds the required socket. In my case I have /tmp/mysql.sock but not /var/mysql/mysql.sock, so I used this:&lt;br /&gt;cd /var &lt;br /&gt;mkdir mysql&lt;br /&gt;cd mysql&lt;br /&gt;ln -s /tmp/mysql.sock mysql.sock&lt;br /&gt;&lt;br /&gt;To install Xcode, I visited &lt;a href="https://developer.apple.com/downloads/index.action"&gt;Downloads for Apple Developers&lt;/a&gt; (needs apple ID). Early versions of Xcode is also available here. The most recent version Xcode 4.2.1 was just released on 11/17/2011. Its major new features are support to iOS 5 and iCloud. But I'm a little conservative. After checking some user reviews on Xcode 4.2.1, which seem to complain about some backward incompatibility issues, I decided to go with the last one, Xcode 4.1, which was released in July. After Xcode is installed, gcc/g++/make all work. &lt;br /&gt;&lt;br /&gt;When type "java" or "javac", Lion pops up a dialog box on installing java runtime environment. This installation seems to actually install the sdk as well, since now I can also compile java programs.&lt;br /&gt;&lt;br /&gt;Installing rails is also by following hints of Lion. I don't know why the first time it didn't work, complaining about the missing of a ruby header file. But a second try works. &lt;br /&gt;&lt;br /&gt;So far I don't have postgresql yet. But that's ok since I won't use it in a short time. My development environment is nearly setup after one day.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1787831811586724850?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1787831811586724850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1787831811586724850' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1787831811586724850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1787831811586724850'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/macbook-pro-with-mac-os-x-lion-107.html' title='MacBook Pro with Mac OS X Lion 10.7'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8570190270264061358</id><published>2011-11-22T16:41:00.001-08:00</published><updated>2011-11-22T16:48:23.198-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Tools'/><title type='text'>OS Tools</title><content type='html'>&lt;a href="http://http://kdirstat.sourceforge.net/"&gt;KDirStat&lt;/a&gt; is a linux/unix disk usage statistics viewer and cleanup tool. Its Windows version is &lt;a href="http://windirstat.info/"&gt;WinDirStat&lt;/a&gt; and Mac version is &lt;a href="http://www.derlien.com/"&gt;Disk Inventory X&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8570190270264061358?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8570190270264061358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8570190270264061358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8570190270264061358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8570190270264061358'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/windows-tools.html' title='OS Tools'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1914740441349842272</id><published>2011-11-22T16:26:00.000-08:00</published><updated>2011-11-23T02:04:33.499-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>Escape special char</title><content type='html'>When transferring data, special characters may be used as separators of records, e.g., row or record separators. In that case you need to escape the special characters from the data, and recover them at the data receiving side. Here is PHP code for this purpose:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;test("\.");&lt;br /&gt;&lt;br /&gt;function test($s) {&lt;br /&gt;  $t = encode($s);&lt;br /&gt;  $o = decode($t);&lt;br /&gt;  p("s = [$s], encode(s) = [$t], decode(encode(s)) = [$o]. " . (($o == $s) ? "passed" : "failed !!!"));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Escape row separator "\n" in a string.&lt;br /&gt;// Encoding scheme:&lt;br /&gt;// \ -&gt; \\&lt;br /&gt;// \n -&gt; \.&lt;br /&gt;//&lt;br /&gt;function encode($s) {&lt;br /&gt;  return str_replace(",", "\;", str_replace("\\", "\\\\", $s));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Decoding scheme:&lt;br /&gt;// \. -&gt; \n&lt;br /&gt;// \\ -&gt; \&lt;br /&gt;// Note: can't use the following:&lt;br /&gt;//   return str_replace("\\\\", "\\", str_replace("\.", "\n", $s));&lt;br /&gt;// because it fails for the below case:&lt;br /&gt;//   s = "\.". encode(s) = "\\.", decode(encode(s)) = "\n".&lt;br /&gt;//&lt;br /&gt;function decode($s) {&lt;br /&gt;  // Use "===", since "==" treats 0 as false. See http://www.php.net/manual/en/function.strpos.php&lt;br /&gt;  if (strpos($s, "\\") === false) return $s;&lt;br /&gt;&lt;br /&gt;  $t = "";&lt;br /&gt;  $len = strlen($s);&lt;br /&gt;  for ($i = 0; $i &lt; $len; $i ++) {&lt;br /&gt;    $c = $s[$i]; &lt;br /&gt;    if ($c == "\\") {&lt;br /&gt;      $d = $s[$i + 1];&lt;br /&gt;      if ($d == "\\") { $t .= "\\"; $i ++; }&lt;br /&gt;      else if ($d == ".") { $t .= "\n"; $i ++; }&lt;br /&gt;      else { $t .= "(error)"; } // This shouldn't happen.&lt;br /&gt;    }&lt;br /&gt;    else { $t .= $c; }&lt;br /&gt;  }&lt;br /&gt;  return $t;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function p($s) {&lt;br /&gt;  print str_replace("\n", "&amp;lt;br&amp;gt;", $s) . "&amp;lt;br&amp;gt;";&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1914740441349842272?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1914740441349842272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1914740441349842272' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1914740441349842272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1914740441349842272'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/escape-special-char.html' title='Escape special char'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-19061919846508392</id><published>2011-11-11T13:14:00.000-08:00</published><updated>2011-11-11T13:17:04.321-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Machine Learning'/><title type='text'>Machine Learning Online Course</title><content type='html'>&lt;a href="http://www.ml-class.org/course/auth/welcome"&gt;Machine Learning Online Course&lt;/a&gt; by Stanford AI lab director &lt;a href="http://cs.stanford.edu/~ang/"&gt;Andrew Ng&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-19061919846508392?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/19061919846508392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=19061919846508392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/19061919846508392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/19061919846508392'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/machine-learning-online-course.html' title='Machine Learning Online Course'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-537273684950466023</id><published>2011-11-10T18:12:00.000-08:00</published><updated>2011-11-10T18:25:08.354-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>iPhone/iPad hover function</title><content type='html'>The hover event (can be provided by css or javascript) is not supported in iPad/iPhone. &lt;br /&gt;&lt;br /&gt;The workaround is use javascript: "onclick='javascript: f1();'". f1() is defined as:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;function f1(o) {&lt;br /&gt;  if ( navigator.userAgent.match(/iPhone/i) || &lt;br /&gt;       navigator.userAgent.match(/iPad/i) ) { &lt;br /&gt;    // do the hover work. for example:&lt;br /&gt;    var x = document.getElementById('elemId');&lt;br /&gt;    x.style.left = u.parentNode.offsetLeft + 'px'; // needed for positioning.&lt;br /&gt;    x.style.visibility = 'visible';&lt;br /&gt;  }&lt;br /&gt;  return true;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Some sources say one can also use ontouchstart() and ontouchend(). But they didn't work in my situation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-537273684950466023?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/537273684950466023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=537273684950466023' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/537273684950466023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/537273684950466023'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/11/ipad-hover-function.html' title='iPhone/iPad hover function'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5811660788707440593</id><published>2011-10-27T22:25:00.000-07:00</published><updated>2011-11-10T18:23:42.400-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>MSSQL partitioning and sp_whoisactive</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/ms345146%28v=sql.90%29.aspx"&gt;Partitioned Tables and Indexes in SQL Server 2005&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd578580%28SQL.100%29.aspx"&gt;Partitioned Table and Index Strategies Using SQL Server 2008&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2008/12/31/a-gift-of-script-for-2009-who-is-active-redux.aspx"&gt;Who is Active&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;MSSQL does not support remote scale-valued user define function call.&lt;br /&gt;&lt;br /&gt;MSSQL 2008 added new functions merge().&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5811660788707440593?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5811660788707440593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5811660788707440593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5811660788707440593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5811660788707440593'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/10/mssql-partitioning-and-spwhoisactive.html' title='MSSQL partitioning and sp_whoisactive'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4025180849365531330</id><published>2011-10-24T15:59:00.000-07:00</published><updated>2011-10-24T16:01:19.638-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows script'/><title type='text'>Zip file in windows script</title><content type='html'>&lt;pre&gt;&lt;br /&gt;'&lt;br /&gt;' http://superuser.com/questions/110991/can-you-zip-a-file-from-command-prompt&lt;br /&gt;' http://www.rondebruin.nl/windowsxpzip.htm&lt;br /&gt;' http://msdn.microsoft.com/en-us/library/windows/desktop/bb787866%28v=vs.85%29.aspx&lt;br /&gt;'&lt;br /&gt;Dim objArgs, InputFolder, ZipFile, objShell, source, ct&lt;br /&gt;&lt;br /&gt;Set objArgs = WScript.Arguments &lt;br /&gt;InputFolder = objArgs(0) &lt;br /&gt;ZipFile = objArgs(1) &lt;br /&gt;CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" &amp; Chr(5) &amp; Chr(6) &amp; String(18, vbNullChar) &lt;br /&gt;Set objShell = CreateObject("Shell.Application") &lt;br /&gt;Set source = objShell.NameSpace(InputFolder).Items &lt;br /&gt;&lt;br /&gt;' 4 - Do not display a progress dialog box.&lt;br /&gt;objShell.NameSpace(ZipFile).CopyHere source, 4 &lt;br /&gt;&lt;br /&gt;'Keep script waiting until Compressing is done&lt;br /&gt;ct = 0&lt;br /&gt;Do Until objShell.Namespace(ZipFile).items.Count = objShell.NameSpace(InputFolder).items.count&lt;br /&gt;   WScript.sleep 1000&lt;br /&gt;   ct = ct + 1&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;WScript.Echo "Zip used " &amp; ct &amp; " seconds."&lt;br /&gt;&lt;br /&gt;Set source = nothing&lt;br /&gt;Set objShell = nothing&lt;br /&gt;WScript.Quit(0)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4025180849365531330?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4025180849365531330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4025180849365531330' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4025180849365531330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4025180849365531330'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/10/zip-file-in-windows-script.html' title='Zip file in windows script'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8060655515944333891</id><published>2011-10-05T17:20:00.000-07:00</published><updated>2011-10-05T17:31:17.287-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Astronomy'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><category scheme='http://www.blogger.com/atom/ns#' term='Physics'/><title type='text'>Some recent progresses in astronomy and physics</title><content type='html'>All happen in September and October:&lt;br /&gt;&lt;br /&gt;- European experiment reveals the possibility of neutrinos running faster than light. See &lt;a href="http://arxiv.org/ftp/arxiv/papers/1109/1109.4897.pdf"&gt;paper&lt;/a&gt; and &lt;a href="http://www.youtube.com/watch?v=qJ0m13iJw0k"&gt;Youtube video&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;- 3 physicists won Nobel Prize for research in the accelerating expansion of the university.&lt;br /&gt;&lt;br /&gt;- European Space Agency (ESA) selected the close Solar Orbitor Probe (expected 2017) and Euclid Space mission (expected 2019) projects, to investigate into the sun and the dark matters. See &lt;a href="http://www.pcmag.com/article2/0,2817,2394189,00.asp#fbid=_NfdJOavots"&gt;Europeans Planning Closest Solar Probe Ever&lt;/a&gt; and &lt;a href="http://spaceref.eu/news/viewpr.html?pid=34868"&gt;Euclid Space Mission Selected by ESA&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8060655515944333891?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8060655515944333891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8060655515944333891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8060655515944333891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8060655515944333891'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/10/some-recent-progresses-in-astronomy-and.html' title='Some recent progresses in astronomy and physics'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7471313285817043959</id><published>2011-09-30T17:59:00.000-07:00</published><updated>2011-09-30T18:08:51.441-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><title type='text'>File system size limit</title><content type='html'>There is a limit on how many files or folders you can have in a file system. When that limit is reached the program will bomb.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Ext3"&gt;http://en.wikipedia.org/wiki/Ext3&lt;/a&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/466521/how-many-files-in-a-directory-is-too-many"&gt;http://stackoverflow.com/questions/466521/how-many-files-in-a-directory-is-too-many&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7471313285817043959?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7471313285817043959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7471313285817043959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7471313285817043959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7471313285817043959'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/file-system-size-limit.html' title='File system size limit'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2484736617043185782</id><published>2011-09-27T20:22:00.000-07:00</published><updated>2011-11-11T13:14:12.028-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical article'/><category scheme='http://www.blogger.com/atom/ns#' term='Trend'/><category scheme='http://www.blogger.com/atom/ns#' term='IT Trend'/><title type='text'>Trends of technology</title><content type='html'>It would be of interests to watch the trend of technologies. Below are some websites:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://trends.builtwith.com/"&gt;http://trends.builtwith.com/&lt;/a&gt; - show deployment technology of websites.&lt;br /&gt;&lt;a href="http://news.netcraft.com/"&gt;http://news.netcraft.com/&lt;/a&gt;  - show deployment technology of websites.&lt;br /&gt;&lt;a href="http://www.google.com/trends/"&gt;http://www.google.com/trends/&lt;/a&gt; - show search trends&lt;br /&gt;&lt;a href="http://www.tiobe.com/"&gt;http://www.tiobe.com/&lt;/a&gt; - for programming languages&lt;br /&gt;&lt;a href="http://langpop.com/"&gt;http://langpop.com/&lt;/a&gt; - for programming languages. (This site is for sale as of November, 2011)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2484736617043185782?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2484736617043185782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2484736617043185782' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2484736617043185782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2484736617043185782'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/trends-of-technology.html' title='Trends of technology'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4761952287010550022</id><published>2011-09-14T02:06:00.000-07:00</published><updated>2011-09-27T21:48:57.192-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>RoR</title><content type='html'>RoR is yet another framework for web development. Its major principles are: DRY (Don't Repeat Yourself), CoC (Convention over Configuration) and MVC design pattern.&lt;br /&gt;&lt;br /&gt;Ruby was design by Japanese computer scientist Yukihiro "Matz" Matsumoto since mid-1990s. RoR started to become hot back in 2006 due to the release of rails (initial release in 2004) by a Finnish programmer David Heinemeier Hansson. It peaked around end of 2008, since then it is declining (see &lt;a href="http://www.tiobe.com/index.php/paperinfo/tpci/Ruby.html"&gt;tiobe index report&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Frankly I don't like RoR very much. It gives you a complete/complicated infrastructure from the very beginning, sure. But following development is restricted to this framework. Building the development environment involves Ruby, Rails is a confusing process, especially when you need to incorporate postgreSQL, Git, Github and Heroku. It's an entire self-contained platform. It adds another layer of abstraction, for example, with the use of HAML and SASS.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book"&gt;RoR Tutorial Book&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blog.bryanbibat.net/2011/01/03/starting-a-professional-rails-app-with-haml-rspec-devise-and-web-app-theme/"&gt;Starting a Rails app with HAML, Rspec, Devise and Web app theme&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Personally, I would prefer PHP, or Python. PHP has a huge body of code repository. Setting up development environment for PHP is much easier.&lt;br /&gt;&lt;br /&gt;Twitter has been using RoR, but when scaling the size the site became unstable. Twitter thus updated part of its server end to use Scala in 2008-2009. Now in April 2011, they further replaced the RoR front end to Java, see &lt;a href="http://www.readwriteweb.com/cloud/2011/04/twitter-drops-ruby-for-java.php"&gt;twitter's engineering log&lt;/a&gt;. The Netbeans IDE used to support RoR, but dropped it in 2011, see &lt;a href="http://netbeans.org/community/news/show/1507.html"&gt;here&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Ruby will continue to have a seat in its corner. Ever ranked within top 10, and still in top 11 right now is quite an achievement. But I don't think it'll ever sweep the floor as claimed years ago.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4761952287010550022?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4761952287010550022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4761952287010550022' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4761952287010550022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4761952287010550022'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/ror.html' title='RoR'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6627431683224413341</id><published>2011-09-07T11:35:00.001-07:00</published><updated>2011-09-07T11:35:46.942-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Storage'/><title type='text'>Petabytes storage</title><content type='html'>&lt;a href="http://blog.backblaze.com/2011/07/20/petabytes-on-a-budget-v2-0revealing-more-secrets/"&gt;Petabytes on a Budget v2.0: Revealing More Secrets&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6627431683224413341?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6627431683224413341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6627431683224413341' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6627431683224413341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6627431683224413341'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/petabytes-storage.html' title='Petabytes storage'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7293778823641027367</id><published>2011-09-07T11:32:00.000-07:00</published><updated>2011-09-07T11:34:38.914-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='science'/><category scheme='http://www.blogger.com/atom/ns#' term='Bioinformatics'/><title type='text'>Two games on folding protein and RNA</title><content type='html'>Report: &lt;a href="http://www.smartplanet.com/blog/pure-genius/citizen-scientists-use-games-to-design-protein-and-rna/7005"&gt;Citizen scientists use games to design protein and RNA&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Games:&lt;br /&gt;&lt;a href="http://fold.it/portal/info/science"&gt;Fold it&lt;/a&gt;&lt;br /&gt;&lt;a href="http://eterna.cmu.edu"&gt;eterna&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7293778823641027367?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7293778823641027367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7293778823641027367' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7293778823641027367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7293778823641027367'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/two-games-on-folding-protein-and-rna.html' title='Two games on folding protein and RNA'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-9022205795009030476</id><published>2011-09-01T15:22:00.000-07:00</published><updated>2011-09-01T15:23:35.857-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Version control'/><title type='text'>SVN tips</title><content type='html'>&lt;a href="http://gcc.gnu.org/wiki/SvnTricks"&gt;SVN tricks and tips&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-9022205795009030476?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/9022205795009030476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=9022205795009030476' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9022205795009030476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9022205795009030476'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/09/svn-tips.html' title='SVN tips'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2583993239261247585</id><published>2011-08-08T14:01:00.000-07:00</published><updated>2011-08-08T14:05:19.430-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>Use transaction in stored procedure</title><content type='html'>When timeout error occurs, the transaction is left open and wait for user handling. But using "SET XACT_ABORT ON" instructs the server to automatically roll back. It is recommended to always set this on. See: &lt;br /&gt;&lt;a href="http://weblogs.sqlteam.com/dang/archive/2007/10/20/Use-Caution-with-Explicit-Transactions-in-Stored-Procedures.aspx"&gt;Use Caution with Explicit Transactions in Stored Procedures&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2583993239261247585?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2583993239261247585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2583993239261247585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2583993239261247585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2583993239261247585'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/08/use-transaction-in-stored-procedure.html' title='Use transaction in stored procedure'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4864712195640944254</id><published>2011-08-04T17:10:00.000-07:00</published><updated>2011-08-04T17:11:23.917-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Browser'/><title type='text'>The Acid3 test</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Acid3"&gt;wiki: Acid3&lt;/a&gt;&lt;br /&gt;&lt;a href="http://acid3.acidtests.org/"&gt;The browser compatibility Acid3 Test.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4864712195640944254?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4864712195640944254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4864712195640944254' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4864712195640944254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4864712195640944254'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/08/acid3-test.html' title='The Acid3 test'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-300532141831628658</id><published>2011-08-04T04:46:00.000-07:00</published><updated>2011-08-12T17:19:49.353-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AI'/><category scheme='http://www.blogger.com/atom/ns#' term='Game'/><category scheme='http://www.blogger.com/atom/ns#' term='Go'/><title type='text'>Go implementation</title><content type='html'>See the &lt;a href="http://code.google.com/p/eidogo/"&gt;eidogo project&lt;/a&gt;. It is written by &lt;a href="http://jkkramer.com/"&gt;Justin Kramer&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://app.baidu.com/handtalk"&gt;This&lt;/a&gt; is based on the eidogo project.&lt;br /&gt;&lt;br /&gt;Another open source Go project is &lt;a href='http://www.gnu.org/s/gnugo/'&gt;GNUGo&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-300532141831628658?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/300532141831628658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=300532141831628658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/300532141831628658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/300532141831628658'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/08/go-implementation.html' title='Go implementation'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4684114669766390875</id><published>2011-08-03T00:43:00.001-07:00</published><updated>2011-08-03T00:43:56.758-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming language'/><category scheme='http://www.blogger.com/atom/ns#' term='History'/><title type='text'>The History of Programming Languages</title><content type='html'>&lt;a href="http://www.readwriteweb.com/hack/2011/07/the-history-of-programming-languages-infographic.php"&gt;The History of Programming Languages&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4684114669766390875?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4684114669766390875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4684114669766390875' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4684114669766390875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4684114669766390875'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/08/history-of-programming-languages.html' title='The History of Programming Languages'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-9042618346196105100</id><published>2011-08-02T01:20:00.001-07:00</published><updated>2011-08-02T01:21:04.940-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Functional Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><title type='text'>The Evolution of a Haskell Programmer</title><content type='html'>&lt;a href="http://www.willamette.edu/~fruehr/haskell/evolution.html"&gt;The Evolution of a Haskell Programmer&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Interesting. A lot of ways to achieve the same goal.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-9042618346196105100?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/9042618346196105100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=9042618346196105100' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9042618346196105100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9042618346196105100'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/08/evolution-of-haskell-programmer.html' title='The Evolution of a Haskell Programmer'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1067346431534575067</id><published>2011-07-29T02:30:00.001-07:00</published><updated>2011-08-04T17:10:17.032-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='smart phone'/><title type='text'>An attempt to platform independence compromisation</title><content type='html'>I got a problem. &lt;br /&gt;&lt;br /&gt;I have an application that I hope to be able to: 1) visit directly from its hosting server, and 2) visit on facebook (where it is enclosed in an iframe). I want it to look all right in both a computer and an iphone in both cases.&lt;br /&gt;&lt;br /&gt;I was using the following to define the application's width:&lt;br /&gt;&lt;br /&gt;var D=navigator.userAgent.toLowerCase();&lt;br /&gt;var x=(D.indexOf("android")!=-1)||(D.indexOf("iphone")!=-1);&lt;br /&gt;this.w0 = x ? (window.innerWidth - 20) : 320;&lt;br /&gt;&lt;br /&gt;Use of "window.innerWidth - 20" lets it automatically adjust the width for an iphone. However since facebook embeds my application in an iframe, window.innertWidth will be the width of the iframe window. The application looks big and its bottom half is hidden and covered by the iframe. It does not look right. &lt;br /&gt;&lt;br /&gt;I was thinking of letting the application determine if it is in an iframe AND in an iphone, and if so pop up a new window pointing to the original hosting server. Then "window.innerWidth - 20" will adjust the width properly. This failed. It failed because when the application uses parent.location.href to get the parent window, it has permission issue when the application and its enclosing iframe window are on different server. What made it worse, iphone does not allow javascript to pop up a new window, obviously also for security reason.&lt;br /&gt;&lt;br /&gt;I thus gave up and use the following:&lt;br /&gt;&lt;br /&gt;this.w0 = x ? 300 : 320;&lt;br /&gt;&lt;br /&gt;I use 300 because my iphone4 (3G) screen width is 320. This way when visiting facebook in iphone, I still can zoom in the screen to use the application, and it still looks all right to me. &lt;br /&gt;&lt;br /&gt;This will look small with larger cell phone screen. &lt;br /&gt;&lt;br /&gt;The morale is: platform independence is always a problem. You need different versions for your application :(&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1067346431534575067?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1067346431534575067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1067346431534575067' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1067346431534575067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1067346431534575067'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/failed-attempt-to-platform-independence.html' title='An attempt to platform independence compromisation'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4606913534366496807</id><published>2011-07-27T19:12:00.000-07:00</published><updated>2011-07-27T19:13:49.422-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>find command batch processing</title><content type='html'>Find some folders (say all .svn folders) and remove them all, in one command:&lt;br /&gt;find -iwholename './*.svn' -exec rm -Rf '{}' \;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4606913534366496807?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4606913534366496807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4606913534366496807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4606913534366496807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4606913534366496807'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/find-command.html' title='find command batch processing'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4946923716649494087</id><published>2011-07-24T14:31:00.000-07:00</published><updated>2011-07-24T14:39:34.205-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IT Education'/><title type='text'>程序员技术练级攻略</title><content type='html'>&lt;a href="http://coolshell.cn/articles/4990.html/"&gt;程序员技术练级攻略&lt;/a&gt;&lt;br /&gt;&lt;a href='http://www.joelonsoftware.com/'&gt;Joel Spolsky's blog&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.joelonsoftware.com/articles/CollegeAdvice.html"&gt;Joel Spolsky: Advice for Computer Science College Students&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4946923716649494087?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4946923716649494087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4946923716649494087' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4946923716649494087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4946923716649494087'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/blog-post.html' title='程序员技术练级攻略'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6024170522769572714</id><published>2011-07-24T14:19:00.000-07:00</published><updated>2011-07-24T14:22:32.985-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IT Trend'/><title type='text'>The Interconnected World of Tech Companies</title><content type='html'>Very interesting. See how new companies emerge as the result of being established by employees from earlier companies: &lt;a href='http://mashable.com/2011/07/19/tech-companies-infographic/'&gt;The Interconnected World of Tech Companies&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6024170522769572714?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6024170522769572714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6024170522769572714' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6024170522769572714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6024170522769572714'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/interconnected-world-of-tech-companies.html' title='The Interconnected World of Tech Companies'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4054313171919316499</id><published>2011-07-08T19:51:00.000-07:00</published><updated>2011-07-08T20:21:10.429-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='smart phone'/><title type='text'>iPhone/iPad/android touch event</title><content type='html'>I have been looking for ways of detecting touch screen events on iPhone comparable to mouse events on a regular computer. I found this today and think it's wonderful. My game now can interact with user on iPhone.&lt;br /&gt;&lt;br /&gt;On iPhone/iPad/android, can use the follow replacements for mouse events:&lt;br /&gt;mousedown -&gt; touchstart&lt;br /&gt;mousemove -&gt; touchmove&lt;br /&gt;mouseup -&gt; touchend&lt;br /&gt;&lt;br /&gt;In mouse/touch events, obtain page location by:&lt;br /&gt;&lt;pre&gt;me.vSelectCanvas.addEventListener('mousedown', function(e) {&lt;br /&gt;  if (e.which == 3) { return; } // do nothing for right mouse button.&lt;br /&gt;  var mouse_x = e.pageX - this.offsetLeft,&lt;br /&gt;      mouse_y = e.pageY - this.offsetTop;&lt;br /&gt;   // ...&lt;br /&gt;}, false);&lt;br /&gt;&lt;br /&gt;me.vSelectCanvas.addEventListener('touchstart', function(e) {&lt;br /&gt;  if (e.touches.length == 1) {&lt;br /&gt;    var mouse_x = e.touches[0].pageX - this.offsetLeft,&lt;br /&gt;        mouse_y = e.touches[0].pageY - this.offsetTop;&lt;br /&gt;    // ...&lt;br /&gt;  }&lt;br /&gt;}, false);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To detect browser agent type (regular browser or smart phone) and reset window size:&lt;pre&gt;  var D=navigator.userAgent.toLowerCase();&lt;br /&gt;  var x=(D.indexOf("android")!=-1)||(D.indexOf("iphone")!=-1)||(D.indexOf("ipad")!=-1);&lt;br /&gt;  var d=x?window.innerWidth:900;&lt;br /&gt;  var B=x?window.innerHeight:550;&lt;br /&gt;&lt;/pre&gt;(&lt;a href="http://10k.aneventapart.com/Uploads/83/"&gt;See code here&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;And here's information on &lt;a href="http://sree.cc/iphone/how-to-get-ipadiphone-screen-dimensions-and-orientation-using-javascript"&gt;How to get iPad/iPhone screen dimensions in javascript&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4054313171919316499?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4054313171919316499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4054313171919316499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4054313171919316499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4054313171919316499'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/iphone-touch-event.html' title='iPhone/iPad/android touch event'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-136164465760690533</id><published>2011-07-06T01:44:00.000-07:00</published><updated>2011-07-06T01:45:04.784-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Finance'/><title type='text'>Quant</title><content type='html'>&lt;a href="http://pop.6park.com/finance/messages/69926.html"&gt;金融工程师Quant的简介&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-136164465760690533?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/136164465760690533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=136164465760690533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/136164465760690533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/136164465760690533'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/quant.html' title='Quant'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7261661752870137573</id><published>2011-07-05T13:49:00.000-07:00</published><updated>2011-07-07T19:30:33.140-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IT Trend'/><title type='text'>IT new trend</title><content type='html'>Seems it includes social/mobile/cloud computing, and mining on large data.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.quora.com/"&gt;Quora&lt;/a&gt; - a question-answer addition/search web site (&lt;a href="http://www.quora.com/about"&gt;About&lt;/a&gt;). &lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110704/301049.html"&gt;浅析Quora的技术架构&lt;/a&gt;&lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110704/301038.html"&gt;Quora使用到的技术&lt;/a&gt;&lt;br /&gt;What's interesting to me is long polling (comet) - a server push technology.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://news.csdn.net/a/20110705/301081.html"&gt;今年科技公司IPO表现点评&lt;/a&gt;.&lt;br /&gt;Interesting ones to me include LinkedIn, Zillow, Zygna (&lt;a href="http://news.csdn.net/a/20110703/300979.html"&gt;简介&lt;/a&gt;), Facebook.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.csdn.net/shenyisyn/article/details/595307"&gt;如何科学的建立自己的个人网站&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.infoq.com/cn/articles/cjz-architecture-corruption"&gt;The Myth of Architecture Corruption&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://app.baidu.com/contest/list?pid=1"&gt;Baidu Web App Contest&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7261661752870137573?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7261661752870137573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7261661752870137573' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7261661752870137573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7261661752870137573'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/it-new-trend.html' title='IT new trend'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6966724572396363108</id><published>2011-07-02T01:12:00.000-07:00</published><updated>2011-07-02T01:15:58.813-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>Call a C program from php and read output</title><content type='html'>&lt;a href="http://stackoverflow.com/questions/5555912/call-a-c-program-from-php-and-read-program-output"&gt;Use shell_exec() command&lt;/a&gt;: &lt;br /&gt;&lt;br /&gt;$output = shell_exec('/path/to/your/program'); // $output contains whatever program prints.&lt;br /&gt;&lt;br /&gt;This is great. It makes possible writing C code for computation intensive part and pass result back to php.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6966724572396363108?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6966724572396363108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6966724572396363108' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6966724572396363108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6966724572396363108'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/07/call-c-program-from-php-and-read-output.html' title='Call a C program from php and read output'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5532191709404773027</id><published>2011-06-29T01:17:00.000-07:00</published><updated>2011-07-06T14:18:05.534-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Game'/><category scheme='http://www.blogger.com/atom/ns#' term='Management'/><category scheme='http://www.blogger.com/atom/ns#' term='Marketing'/><title type='text'>Gaming Industry Marketing and Management</title><content type='html'>&lt;a href="http://zonghe.17xie.com/book/10539080/"&gt;游戏市场运营管理&lt;/a&gt; - Good market overview.&lt;br /&gt;&lt;a href="http://blog.csdn.net/xiaominghimi/article/details/6556289"&gt;【Iphone 游戏开发】游戏引擎剖析&lt;/a&gt; - Good technology overview.&lt;br /&gt;&lt;a href="http://www.cccbbs.net/htm_data/5/0712/15099.html"&gt;游戏外挂设计技术探讨&lt;/a&gt; - Only interested in the technologies involved.&lt;br /&gt;&lt;br /&gt;This is a game I wrote for run recently in HTML5+Javascript+jQuery: &lt;a href="http://cssauh.com/sp/en.html"&gt;Six-Piece Chess&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;YUI compressor online is a handy tool to use.&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5532191709404773027?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5532191709404773027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5532191709404773027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5532191709404773027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5532191709404773027'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/gaming-industry-marketing-and.html' title='Gaming Industry Marketing and Management'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5683303642072655305</id><published>2011-06-16T20:02:00.000-07:00</published><updated>2011-06-16T20:17:41.301-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL'/><title type='text'>wsdl cache, count_big</title><content type='html'>PHP web service, cache files are stored in /tmp as "wsdl-..." files. After update web service, you need to delete these files to clear the cache so the changes are reflected.&lt;br /&gt;&lt;br /&gt;"select count(*) from tbl" would time out and says: "Arithmetic overflow error converting expression to data type int.". &lt;a href="http://poeticsql.blogspot.com/2008/01/arithmetic-overflow-error-converting.html"&gt;This site&lt;/a&gt; has it that you should use "select COUNT_BIG(*) from tbl" instead. Also see MSDN at &lt;a href='http://msdn.microsoft.com/en-us/library/ms189826%28v=SQL.90%29.aspx'&gt;Transact-SQL reference&lt;/a&gt; or &lt;a href='http://msdn.microsoft.com/en-US/library/ms190317%28v=SQL.90%29.aspx'&gt;COUNT_BIG&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5683303642072655305?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5683303642072655305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5683303642072655305' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5683303642072655305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5683303642072655305'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/wsdl-cache-countbig.html' title='wsdl cache, count_big'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8148274163385462245</id><published>2011-06-15T15:35:00.000-07:00</published><updated>2011-06-15T15:36:44.368-07:00</updated><title type='text'>Blob Sallad</title><content type='html'>Very funny and interesting: &lt;a href='http://www.blobsallad.se/'&gt;Blob Sallad&lt;/a&gt;&lt;br /&gt;An article on its implementation: &lt;a href='http://dev.opera.com/articles/view/blob-sallad-canvas-tag-and-javascrip/'&gt;Blob Sallad – canvas tag and JavaScript physics simulation experiment&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8148274163385462245?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8148274163385462245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8148274163385462245' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8148274163385462245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8148274163385462245'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/blob-sallad.html' title='Blob Sallad'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8784799511682086331</id><published>2011-06-14T16:03:00.000-07:00</published><updated>2011-06-14T16:06:30.547-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='Web application'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Dropdown menu</title><content type='html'>&lt;a href="http://www.hongkiat.com/blog/drop-down-menu-30-free-scripts-to-enhance-header-navigation/"&gt;Drop-Down Menu: 30+ Useful Scripts to Enhance Header Navigation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.unintentionallyblank.co.uk/2006/09/19/if-internet-explorer-then-do-something-else-a-how-to/"&gt;IF Internet Explorer THEN Do Something Else (A How To…)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8784799511682086331?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8784799511682086331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8784799511682086331' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8784799511682086331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8784799511682086331'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/dropdown-menu.html' title='Dropdown menu'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7332473982886659709</id><published>2011-06-14T14:03:00.000-07:00</published><updated>2011-06-14T14:04:26.677-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>What Every Programmer Should Know About Memory</title><content type='html'>&lt;a href="http://www.akkadia.org/drepper/cpumemory.pdf"&gt;What Every Programmer Should Know About Memory&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ulrich Drepper&lt;br /&gt;Red Hat, Inc.&lt;br /&gt;November 21, 2007&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7332473982886659709?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7332473982886659709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7332473982886659709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7332473982886659709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7332473982886659709'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/what-every-programmer-should-know-about.html' title='What Every Programmer Should Know About Memory'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3786643944709334036</id><published>2011-06-13T20:57:00.000-07:00</published><updated>2011-06-13T21:26:28.887-07:00</updated><title type='text'>Create iPhone application on windows</title><content type='html'>&lt;a href="http://geeknizer.com/how-to-develop-iphone-apps-on-windows/"&gt;How To Develop iPhone Apps on Windows&lt;/a&gt;&lt;br /&gt;&lt;a href="http://maniacdev.com/2010/01/iphone-development-windows-options-available/"&gt;iPhone Development On Windows – 7 Options&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.sellmyapplication.com/develop-iphone-apps-on-windows/"&gt;Develop iphone Apps on Windows&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Seems the top methods are:&lt;br /&gt;1) Flash CS 5.5 (not free)&lt;br /&gt;2) &lt;a href="http://www.airplaysdk.com/"&gt;Airplay SDK&lt;/a&gt;&lt;br /&gt;3) html/css/javascript&lt;br /&gt;4) In C/C++ (&lt;a href="http://www.dragonfiresdk.com/"&gt;DragonFireSDK&lt;/a&gt;) or Java.&lt;br /&gt;&lt;br /&gt;Cocoachina: &lt;a href="http://www.cocoachina.com/"&gt;http://www.cocoachina.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3786643944709334036?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3786643944709334036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3786643944709334036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3786643944709334036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3786643944709334036'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/create-iphone-application-on-windows.html' title='Create iPhone application on windows'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2208906201863552751</id><published>2011-06-10T15:40:00.000-07:00</published><updated>2011-06-10T15:41:47.412-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='History'/><title type='text'>Fairchild semiconductor</title><content type='html'>Root of silicon valley semiconductor industry.&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Fairchild_Semiconductor"&gt;Fairchild Semiconductor&lt;/a&gt;&lt;br /&gt;&lt;a href="http://baike.baidu.com/view/621898.htm"&gt;仙童半导体公司&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2208906201863552751?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2208906201863552751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2208906201863552751' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2208906201863552751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2208906201863552751'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/fairchild-semiconductor.html' title='Fairchild semiconductor'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7930819597706680527</id><published>2011-06-06T17:27:00.000-07:00</published><updated>2011-06-06T17:43:49.647-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MIS'/><title type='text'>Document Management System</title><content type='html'>Some existing document management systems:&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://www.endnote.com"&gt;EndNote&lt;/a&gt;. One important function is to create bibliography. Commercial ($25 annual license). Has versions for web, windows, mac. &lt;br /&gt;- &lt;a href="http://www.zotero.org/"&gt;Zotero&lt;/a&gt;. Collect, organize, cite, and share documents. Competitor of EndNote. Open source. Has versions for web, windows, mac and linux.&lt;br /&gt;&lt;br /&gt;I'm looking forward to these functions: record file source, record read time, save local copy, classification, allow comment, can search, can generate report, easy to download and wrap all, can share between users. Better to have iPhone version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7930819597706680527?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7930819597706680527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7930819597706680527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7930819597706680527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7930819597706680527'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/document-management-system.html' title='Document Management System'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5469548730744380002</id><published>2011-06-06T15:38:00.000-07:00</published><updated>2011-06-16T15:50:53.755-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Chart'/><category scheme='http://www.blogger.com/atom/ns#' term='jQuery'/><title type='text'>jQuery, Charting</title><content type='html'>&lt;a href="http://jquery.com/"&gt;http://jquery.com/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/flot/"&gt;flot - Javascript plotting for jQuery &lt;/a&gt;: draws on the canvas element (For IE version earlier than 9, needs &lt;a href="http://code.google.com/p/explorercanvas/"&gt;excanvas&lt;/a&gt; JavaScript emulation helper and &lt;a href="http://code.google.com/p/canvas-text/"&gt;canvas-text&lt;/a&gt;). Purposes are easy use, attractive look, and interactive features.&lt;br /&gt;&lt;a href="http://code.google.com/apis/chart/"&gt;Google charts&lt;/a&gt; - This is actually closed source. The JavaScript is compacted, and loads libraries dynamically at runtime.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110616/299817.html"&gt;用于图片处理的10个超级jQuery插件&lt;/a&gt;&lt;br /&gt;Comparison: &lt;a href="http://sd.csdn.net/a/20110616/299824.html"&gt;Javascript框架和jQuery&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5469548730744380002?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5469548730744380002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5469548730744380002' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5469548730744380002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5469548730744380002'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/06/jquery.html' title='jQuery, Charting'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2062963061442224752</id><published>2011-05-29T12:30:00.001-07:00</published><updated>2011-05-29T12:32:35.322-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='e-commerce'/><title type='text'>PayPal – Authorize.net – Google Checkout</title><content type='html'>For e-commerce website: &lt;a href="http://www.websitedesignby.com/uncategorized/paypal-authroize-net-google-checkout/"&gt;PayPal – Authorize.net – Google Checkout&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2062963061442224752?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2062963061442224752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2062963061442224752' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2062963061442224752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2062963061442224752'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/paypal-authorizenet-google-checkout.html' title='PayPal – Authorize.net – Google Checkout'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3920989055788456003</id><published>2011-05-26T21:37:00.000-07:00</published><updated>2011-09-12T21:21:42.447-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>The Connection String Reference</title><content type='html'>&lt;a href="http://www.connectionstrings.com/"&gt;The Connection String Reference: http://www.connectionstrings.com/&lt;/a&gt;. Very convenient for use.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codemaker.co.uk/it/tips/ado_conn.htm"&gt;ADO Connection String Samples&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3920989055788456003?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3920989055788456003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3920989055788456003' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3920989055788456003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3920989055788456003'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/connection-string-reference.html' title='The Connection String Reference'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2043153649863513306</id><published>2011-05-26T17:22:00.000-07:00</published><updated>2011-05-26T17:23:17.447-07:00</updated><title type='text'>Character Coding Schemes</title><content type='html'>&lt;a href="http://topic.csdn.net/u/20110524/23/E1E169B6-DF47-4D8D-BD9E-391F319ADC26.html"&gt;编码问题，关于gb2312和utf-8&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cnblogs.com/KevinYang/archive/2010/06/18/1760597.html"&gt;关于字符编码，你所需要知道的&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2043153649863513306?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2043153649863513306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2043153649863513306' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2043153649863513306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2043153649863513306'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/character-coding-schemes.html' title='Character Coding Schemes'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4990912049944043144</id><published>2011-05-26T14:44:00.000-07:00</published><updated>2011-06-03T19:12:56.782-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>PHP class to do paging</title><content type='html'>This code can be easily ported to other languages. Note that the database used here is MSSQL, it has a paging function starting from version 2005 [1][2]. In MySQL, this can be achieved using 'Limit'.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Test&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;h1&amp;gt;Test Paging&amp;lt;/h1&amp;gt;&lt;br /&gt;&amp;lt;?php &lt;br /&gt;// General variables for navBar.&lt;br /&gt;$paging = new PagingClass( getService('getDataCount', array()), $_REQUEST['pg'] );&lt;br /&gt;  &lt;br /&gt;// Get data according to range.&lt;br /&gt;$data = getService('getData', array('RangeStart' =&amp;gt; $paging-&amp;gt;getStart(), 'RangeEnd' =&amp;gt; $paging-&amp;gt;getEnd()));&lt;br /&gt;&lt;br /&gt;// Output navBar and data.&lt;br /&gt;print $paging-&amp;gt;writeNavBar();&lt;br /&gt;print Service2Table($data);&lt;br /&gt;print $paging-&amp;gt;writeNavBar();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// @Author: HomeTom&lt;br /&gt;// @Date: 5/26/2011&lt;br /&gt;//&lt;br /&gt;class PagingClass {  &lt;br /&gt;    &lt;br /&gt;    private $pageSize;&lt;br /&gt;    private $pageButtonCount;&lt;br /&gt;    private $totalCount;&lt;br /&gt;    private $pageCount;&lt;br /&gt;    private $currentPage;&lt;br /&gt;    private $BaseUrl;&lt;br /&gt;    &lt;br /&gt;    //&lt;br /&gt;    // Parameters:&lt;br /&gt;    //   $totalCount: Total number of rows/records.&lt;br /&gt;    //   $curPage: Current page index (usually passed as request parameter).&lt;br /&gt;    // Preassumption: No parameter uses the name "pg", which is used for paging.&lt;br /&gt;    //&lt;br /&gt;    public function __construct($totalCount, $curPage) {&lt;br /&gt;        $this-&amp;gt;pageSize = 3;           // Default page size.&lt;br /&gt;        $this-&amp;gt;pageButtonCount = 4;    // Default number of paging buttons.&lt;br /&gt;&lt;br /&gt;        $this-&amp;gt;totalCount = $totalCount;&lt;br /&gt;        $this-&amp;gt;pageCount = ceil($totalCount / $this-&amp;gt;pageSize);&lt;br /&gt;      &lt;br /&gt;        $this-&amp;gt;currentPage = $curPage; &lt;br /&gt;        if ($this-&amp;gt;currentPage == "") { $this-&amp;gt;currentPage = 1; }&lt;br /&gt;        else if ($this-&amp;gt;currentPage &amp;lt; 0) { $this-&amp;gt;currentPage = 0; }&lt;br /&gt;        else if ($this-&amp;gt;currentPage &amp;gt;= $this-&amp;gt;pageCount) { $this-&amp;gt;currentPage = $this-&amp;gt;pageCount - 1; }&lt;br /&gt;      &lt;br /&gt;        // Base URL used by page links. Page parameter should be at the end. E.g. "index.php?pg="&lt;br /&gt;        $baseUrl = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];&lt;br /&gt;        if (preg_match("#pg=[0-9]*$#", $baseUrl) &gt; 0) { &lt;br /&gt;          $this-&gt;BaseUrl = preg_replace("#pg=[0-9]*$#", "", $baseUrl) . "pg=";&lt;br /&gt;        } else if ( empty($_SERVER['QUERY_STRING']) ) {&lt;br /&gt;          $this-&gt;BaseUrl = $baseUrl . "pg=";&lt;br /&gt;        } else {&lt;br /&gt;          $this-&gt;BaseUrl = $baseUrl . "&amp;pg="; &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Get start and end row/record number in current page.&lt;br /&gt;    public function getStart() { return $this-&amp;gt;currentPage * $this-&amp;gt;pageSize + 1; }&lt;br /&gt;    public function getEnd() { return (1 + $this-&amp;gt;currentPage) * $this-&amp;gt;pageSize; }&lt;br /&gt;  &lt;br /&gt;    //&lt;br /&gt;    // Parameters:&lt;br /&gt;    //   $PageCount: Total number of pages.&lt;br /&gt;    //   $CurrentPageIndex: Current page index.&lt;br /&gt;    //   $PageButtonCount: Number of page buttons to show on one page.&lt;br /&gt;    //&lt;br /&gt;    public function writeNavBar() {&lt;br /&gt;        $PageCount = $this-&amp;gt;pageCount;&lt;br /&gt;        $CurrentPageIndex = $this-&amp;gt;currentPage;&lt;br /&gt;        $PageButtonCount = $this-&amp;gt;pageButtonCount;&lt;br /&gt;        $baseUrl = $this-&amp;gt;BaseUrl; //"index.php?pg=";&lt;br /&gt;    &lt;br /&gt;        $DEBUG = 0;&lt;br /&gt;        $lblNext = "Next";&lt;br /&gt;        $lblPrev = "Prev";&lt;br /&gt;        $lblFirst = "First";&lt;br /&gt;        $lblLast = "Last";&lt;br /&gt;    &lt;br /&gt;        $s = "";&lt;br /&gt;&lt;br /&gt;        if ($DEBUG) {&lt;br /&gt;            print "pagecount: $PageCount, currentPageIndex: $CurrentPageIndex, ";&lt;br /&gt;            print "PageButtonCount: $PageButtonCount&amp;lt;br&amp;gt;";&lt;br /&gt;        }&lt;br /&gt;  &lt;br /&gt;        $startPage = (floor(($CurrentPageIndex)/$PageButtonCount) * $PageButtonCount);&lt;br /&gt;        if ($DEBUG) print "startpage = $startPage&amp;lt;br&amp;gt;";&lt;br /&gt;    &lt;br /&gt;        $tmp = $PageCount - $PageButtonCount;&lt;br /&gt;        if ($tmp &amp;gt; 0 &amp;&amp; $tmp &amp;lt; $startPage) { $startPage = $tmp; }&lt;br /&gt;    &lt;br /&gt;        // First.&lt;br /&gt;        if ($CurrentPageIndex == 0) { $s .= $lblFirst . " "; }&lt;br /&gt;        else { $s .= "&amp;lt;a href=\"" . $baseUrl . "0\"&amp;gt;" . $lblFirst . "&amp;lt;/a&amp;gt; "; }&lt;br /&gt;       &lt;br /&gt;        // Prev.&lt;br /&gt;        if ($CurrentPageIndex == 0) { $s .= $lblPrev . " "; }&lt;br /&gt;        else &lt;br /&gt;        { &lt;br /&gt;            $j = $CurrentPageIndex - 1;&lt;br /&gt;            $s .= "&amp;lt;a href=\"" . $baseUrl . $j . "\"&amp;gt;" . $lblPrev . "&amp;lt;/a&amp;gt; "; &lt;br /&gt;        }&lt;br /&gt;      &lt;br /&gt;        // ...&lt;br /&gt;        if ($startPage &amp;gt; 0) { $s .= "&amp;lt;a href=\"" . $baseUrl . ($startPage - 1) . "\"&amp;gt;...&amp;lt;/a&amp;gt; "; }&lt;br /&gt;    &lt;br /&gt;        for ($i = 0; $i &amp;lt; $PageCount; $i ++) {&lt;br /&gt;            if ($i &amp;lt; $startPage || $i &amp;gt;= $startPage + $PageButtonCount) { continue; }&lt;br /&gt;            if ($i == $CurrentPageIndex) { $s .= " " . (1 + $i); }&lt;br /&gt;            else { $s .= " &amp;lt;a href='" . $baseUrl . $i . "'&amp;gt;". (1 + $i) . "&amp;lt;/a&amp;gt;"; }&lt;br /&gt;        }&lt;br /&gt;      &lt;br /&gt;        // ...&lt;br /&gt;        if ($startPage + $PageButtonCount &amp;lt;= $PageCount - 1) {&lt;br /&gt;            $j = $PageButtonCount + $startPage;&lt;br /&gt;            $s .= " &amp;lt;a href=\"" . $baseUrl . $j . "\"&amp;gt;...&amp;lt;/a&amp;gt; ";      &lt;br /&gt;        }&lt;br /&gt;      &lt;br /&gt;        // Next.&lt;br /&gt;        if ($CurrentPageIndex &amp;gt;= $PageCount - 1) { $s .= " " . $lblNext; } &lt;br /&gt;        else &lt;br /&gt;        {&lt;br /&gt;            $j = $CurrentPageIndex + 1;&lt;br /&gt;            $s .= " &amp;lt;a href=\"" . $baseUrl . $j . "\"&amp;gt;" . $lblNext . "&amp;lt;/a&amp;gt;";&lt;br /&gt;        }&lt;br /&gt;  &lt;br /&gt;        // Last.&lt;br /&gt;        if ($CurrentPageIndex &amp;gt;= $PageCount - 1) { $s .= " " . $lblLast; }&lt;br /&gt;        else { $s .= " &amp;lt;a href=\"" . $baseUrl . ($PageCount - 1) . "\"&amp;gt;" . $lblLast . "&amp;lt;/a&amp;gt;"; }&lt;br /&gt;  &lt;br /&gt;        return $s;&lt;br /&gt;    }  &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// This function retrieves a web service return result.&lt;br /&gt;// http://www.php.net/manual/en/soapclient.soapcall.php&lt;br /&gt;//&lt;br /&gt;// Parameters:&lt;br /&gt;// $func: Name of the web service function.&lt;br /&gt;// $params: Array of parameters used by this function.&lt;br /&gt;//&lt;br /&gt;function getService($func, $params) {&lt;br /&gt;    try {&lt;br /&gt;        $url = "http://localhost/test/TestService.asmx?WSDL";&lt;br /&gt;        $client = new SoapClient($url);&lt;br /&gt;        $result = $client-&amp;gt;$func($params);&lt;br /&gt;        //reset($result); // 'reset' sets the array pointer to the start of the array.&lt;br /&gt;        // 'each' gets the current key/value pair into a separate array.&lt;br /&gt;        list($key, $val) = each($result); &lt;br /&gt;        //print $key . ": " . $val . "&amp;lt;br&amp;gt;";&lt;br /&gt;        return $val;&lt;br /&gt;    } catch (Exception $e) {&lt;br /&gt;        die ("&amp;lt;br&amp;gt;&amp;lt;font color='red'&amp;gt;getService() error: " . $e-&amp;gt;getMessage() . "&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;");&lt;br /&gt;    }&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// This function converts web service return result into a table.&lt;br /&gt;//&lt;br /&gt;// rows are delimited by '\n', &lt;br /&gt;// cols are delimited by '\t'.&lt;br /&gt;//&lt;br /&gt;// explode() v.s. split():&lt;br /&gt;// Biggest difference is explode() takes a delimiter to split by, &lt;br /&gt;// while split() takes a regular expression. explode is faster.&lt;br /&gt;//&lt;br /&gt;function Service2Table($val) {&lt;br /&gt;    $row_delimiter = "\n";&lt;br /&gt;    $col_delimiter = "\t";&lt;br /&gt;    $DEBUG = 0;&lt;br /&gt;  &lt;br /&gt;    $v = ""; &lt;br /&gt;    $v_row = "";&lt;br /&gt;    $rows = explode($row_delimiter, $val);&lt;br /&gt;    $row_count = count($rows);&lt;br /&gt;    if ($DEBUG) print "&amp;lt;br&amp;gt;row count: " . $row_count . "&amp;lt;br&amp;gt;";&lt;br /&gt;    for ($i = 0; $i &amp;lt; $row_count; $i ++) {&lt;br /&gt;        $s = $rows[$i];&lt;br /&gt;        if ($s != "") {&lt;br /&gt;            if ($DEBUG) print "$i. $s&amp;lt;br&amp;gt;";    &lt;br /&gt;            $cols = explode($col_delimiter, $s);&lt;br /&gt;            $col_count = count($cols);&lt;br /&gt;            $v_row = "";&lt;br /&gt;            for ($j = 0; $j &amp;lt; $col_count; $j ++) {&lt;br /&gt;                $v_row .= "&amp;lt;td&amp;gt;" . $cols[$j] . "&amp;nbsp;&amp;lt;/td&amp;gt;";&lt;br /&gt;            }&lt;br /&gt;            $v .= "&amp;lt;tr&amp;gt;$v_row&amp;lt;/tr&amp;gt;";&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    $v = "&amp;lt;table border=1&amp;gt;$v&amp;lt;/table&amp;gt;";&lt;br /&gt;    return $v;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;On server side, the web service function (in C#) looks like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[WebMethod]&lt;br /&gt;public string getData(int RangeStart, int RangeEnd) {&lt;br /&gt;    string row_delimiter = "\n";&lt;br /&gt;    string col_delimiter = "\t";&lt;br /&gt;&lt;br /&gt;    string s = "";&lt;br /&gt;&lt;br /&gt;    string connStr = ConfigurationManager.ConnectionStrings["LocalDB"].ConnectionString;&lt;br /&gt;    SqlConnection conn = new SqlConnection(connStr);&lt;br /&gt;    conn.Open();&lt;br /&gt;    string sql =  @"with TmpDataTable AS &lt;br /&gt;        (SELECT *, ROW_NUMBER() OVER (ORDER BY JobID) as 'RowNum' FROM DataTable)&lt;br /&gt;        SELECT * FROM TmpDataTable WHERE RowNum between " + RangeStart + " and " + RangeEnd;&lt;br /&gt;    SqlCommand cmd = new SqlCommand(sql, conn);&lt;br /&gt;    SqlDataReader sdr = cmd.ExecuteReader();&lt;br /&gt;&lt;br /&gt;    int fieldCount = sdr.VisibleFieldCount;&lt;br /&gt;&lt;br /&gt;    // get column names.&lt;br /&gt;    s = sdr.GetName(0);&lt;br /&gt;    for (int i = 1; i &lt; fieldCount; i++)&lt;br /&gt;    {&lt;br /&gt;        s += col_delimiter + formatStr(sdr.GetName(i));&lt;br /&gt;    }&lt;br /&gt;    s += row_delimiter;&lt;br /&gt;&lt;br /&gt;    if (sdr.HasRows) {&lt;br /&gt;        // get column values.&lt;br /&gt;        while (sdr.Read()) {&lt;br /&gt;            s += sdr[0];&lt;br /&gt;            for (int i = 1; i &lt; fieldCount; i++) {&lt;br /&gt;                s += col_delimiter + formatStr(sdr[i]);&lt;br /&gt;            }&lt;br /&gt;            s += row_delimiter;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    conn.Close();&lt;br /&gt;&lt;br /&gt;    return s.Trim();&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;[1] &lt;a href="http://noprobs.wordpress.com/2008/07/24/pagination-in-sql-server-selecting-a-specific-range-of-records-from-a-table-or-resultset-in-sql-server/"&gt;Pagination in SQL Server&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://stackoverflow.com/questions/1023841/retrieve-specific-range-of-rows-in-a-sql-server-table"&gt;retrieve specific range of rows in a SQL Server table&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4990912049944043144?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4990912049944043144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4990912049944043144' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4990912049944043144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4990912049944043144'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/example-php-code-to-do-paging.html' title='PHP class to do paging'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6629153892012527493</id><published>2011-05-24T18:38:00.000-07:00</published><updated>2011-05-24T18:44:33.726-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>PHP upload size limit</title><content type='html'>Default PHP upload size limit is 2MB. That's too small.&lt;br /&gt;&lt;br /&gt;A place to change this limit is in php.ini. Change "upload_max_filesize" and "post_max_size" bigger should save it [1][2]. Another place to increase this is in .htaccess [2]. If PHP SOAP client gives "Error Fetching http headers" warning, then you need to increase default_socket_timeout in php.ini to fix it [3].&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://www.radinks.com/upload/config.php"&gt;Howto optimize your PHP installation to handle large file uploads&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/"&gt;PHP Increase Upload File Size Limit&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://www.aidanfindlater.com/php-soap-client-giving-error-fetching-http-headers"&gt;PHP SOAP client giving "Error Fetching http headers"&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6629153892012527493?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6629153892012527493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6629153892012527493' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6629153892012527493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6629153892012527493'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/php-upload-size-limit.html' title='PHP upload size limit'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3217142076539888336</id><published>2011-05-20T19:38:00.000-07:00</published><updated>2011-05-20T19:39:24.082-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Javascript PC simulator</title><content type='html'>Amazing for me: use Javascript to simulate a linux box in a browser:&lt;br /&gt;&lt;a href="http://bellard.org/jslinux/"&gt;http://bellard.org/jslinux/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3217142076539888336?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3217142076539888336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3217142076539888336' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3217142076539888336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3217142076539888336'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/javascript-pc-simulator.html' title='Javascript PC simulator'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2042034394358766557</id><published>2011-05-06T13:34:00.000-07:00</published><updated>2011-05-06T13:36:20.286-07:00</updated><title type='text'>Hammer projection</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Hammer_projection"&gt;wiki: Hammer projection&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2042034394358766557?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2042034394358766557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2042034394358766557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2042034394358766557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2042034394358766557'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/hammer-projection.html' title='Hammer projection'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8080745668577315950</id><published>2011-05-06T13:21:00.000-07:00</published><updated>2011-08-15T14:34:26.767-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><title type='text'>More HTML5 and Javascript</title><content type='html'>- A &lt;a href="http://www.math.rutgers.edu/~erowland/playground.html"&gt;list of javascript functions&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://dev.opera.com/articles/view/html-5-canvas-the-basics/"&gt;HTML5 canvas - the basics&lt;/a&gt;&lt;br /&gt;- Layering multiple canvases: good for avoiding over redrawing.&lt;br /&gt;  - &lt;a href="http://html5.litten.com/using-multiple-html5-canvases-as-layers/"&gt;Using Multiple HTML5 Canvases as Layers&lt;/a&gt;&lt;br /&gt;  - &lt;a href="http://www.mikechambers.com/blog/2011/01/25/layering-multiple-canvas-elements-using-javascript-and-easeljs/"&gt;Layering Multiple Canvas Elements using JavaScript and EaselJS&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://html5.litten.com/understanding-save-and-restore-for-the-canvas-context/"&gt;Understanding save() and restore() for the Canvas Context&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://jsfiddle.net/noonat/6uBRd/"&gt;Canvas motion blur&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- HTML/JavaScript - Select list - Add/Remove Options: &lt;a href="http://www.mredkj.com/tutorials/tutorial005.html"&gt;DOM&lt;/a&gt;, &lt;a href="http://www.mredkj.com/tutorials/tutorial006.html"&gt;Old school&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://www.davidtong.me/innerhtml-innertext-textcontent-html-and-text/"&gt;innerHTML, innerText, textContent&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen"&gt;Snippets: Howto Grey-Out The Screen&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://blog.chapagain.com.np/jquery-grey-out-background-and-preview-image-as-popup/"&gt;jQuery: Grey out background and preview image as popup&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://programming.top54u.com/post/Javascript-Create-New-Div-HTML-Element-Dynamically.aspx"&gt;Javascript Create New Div HTML Element Dynamically&lt;/a&gt;&lt;br /&gt;- &lt;a href="https://developer.mozilla.org/en/Canvas_tutorial"&gt;Canvas tutorial&lt;/a&gt; - From Mozilla, a very good one.&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://sd.csdn.net/a/20110630/300815.html"&gt;10个让人眼花缭乱的HTML5和JavaScript效果&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.iteye.com/news/22225"&gt;13 个强大的基于 HTML5 的 Web 应用&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.iteye.com/news/22303"&gt;当设计师遭遇HTML5&lt;/a&gt; - Good article&lt;br /&gt;- &lt;a href="http://www.iteye.com/news/22270"&gt;HTML5 完胜 Flash 的 7 大特性&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://hakim.se/"&gt;HAKIM&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://simon.html5.org/dump/html5-canvas-cheat-sheet.html"&gt;HTML5 Canvas Cheat Sheet&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.diveintohtml5.org/"&gt;Dive Into HTML5&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://10k.aneventapart.com/"&gt;10k Apart Contest&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://chromium.googlecode.com/svn/trunk/samples/audio/index.html"&gt;Web audio in chrome&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://chrome.blogspot.com/2011/08/building-better-web-apps-with-new.html"&gt;Building better web apps with a new Chrome Beta&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://blog.csdn.net/dojotoolkit/article/details/6614883"&gt;深入HTML5: HTML5 本地存储( Local Storage )的前世今生&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Several HTML5 web app of my favorite:&lt;br /&gt;- &lt;a href="http://hakim.se/experiments/html5/keylight/03/"&gt;Keylight&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://hakim.se/experiments/html5/blob/03/"&gt;Blob&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.openrise.com/lab/FlowerPower/"&gt;FlowPower&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8080745668577315950?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8080745668577315950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8080745668577315950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8080745668577315950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8080745668577315950'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/more-html-5.html' title='More HTML5 and Javascript'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4129629675818240532</id><published>2011-05-01T01:22:00.000-07:00</published><updated>2011-05-01T01:52:10.799-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Fun'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Obfuscated Programming Contests</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Obfuscated_code"&gt;Wiki: Obfuscated code&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In C:&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest"&gt;Wiki: International Obfuscated C Code Contest&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www0.us.ioccc.org/years.html"&gt;The International Obfuscated C Code Contest Winning entries&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In Assembly:&lt;br /&gt;&lt;a href="http://artori.us/3d-program-champion-of-assembly/"&gt;世界编程大赛第一名的3D程序&lt;/a&gt; (or &lt;a href="http://www.knowledgesutra.com/forums/topic/30364-program-from-mekka-97-4k/"&gt;see here&lt;/a&gt;)&lt;br /&gt;&lt;a href="http://artori.us/another-64k-assembly-fantastic-program/"&gt;又是一个64k华丽至极的程序&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4129629675818240532?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4129629675818240532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4129629675818240532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4129629675818240532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4129629675818240532'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/obfuscated-programming-contests.html' title='Obfuscated Programming Contests'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6223698079002165975</id><published>2011-05-01T01:05:00.000-07:00</published><updated>2011-05-01T01:16:47.977-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quine'/><category scheme='http://www.blogger.com/atom/ns#' term='Fun'/><category scheme='http://www.blogger.com/atom/ns#' term='programming language'/><title type='text'>Quine and Programming languages for fun</title><content type='html'>Quine is a program that prints itself. See &lt;a href="http://en.wikipedia.org/wiki/Quine_%28computing%29"&gt;wiki page on Quine&lt;/a&gt;. &lt;a href="http://d.hatena.ne.jp/ku-ma-me/20090916/p1"&gt;Here is a special Quine&lt;/a&gt; that prints a series of programs in 11 languages and eventually comes back to itself.&lt;br /&gt;&lt;br /&gt;Here is an article &lt;a href="http://coolshell.cn/articles/4458.html"&gt;BT雷人的程序语言（大全）&lt;/a&gt; about strange programming languages (made for fun in most cases). They are really funny. The end of this article gives these references:&lt;br /&gt;&lt;br /&gt; - &lt;a href="http://en.wikipedia.org/wiki/Category:Esoteric_programming_languages"&gt;Esoteric_programming_languages&lt;/a&gt;&lt;br /&gt; - &lt;a href="http://www.topdesignmag.com/top-13-most-absurd-programming-languages/"&gt;Top 13 Most Absurd Programming Languages&lt;/a&gt;&lt;br /&gt; - &lt;a href="http://wei.si/blog/2011/04/befunge-and-perlyuyan/"&gt;Befunge语言和文言文编程&lt;/a&gt;&lt;br /&gt; - &lt;a href="http://hi.baidu.com/namekin/blog/item/9f36f21fc6be296df724e452.html"&gt;疯狂的编程语言——ENGLISH，Chef Shakespeare&lt;/a&gt;&lt;br /&gt; - &lt;a href="http://www.dangermouse.net/esoteric/"&gt;DM’s Esoteric Programming Languages&lt;/a&gt;&lt;br /&gt; - &lt;a title="Permanent Link to 十大另类程序语言（上）"&gt;十大另类程序语言（上）&lt;/a&gt;&lt;br /&gt; - &lt;a title="Permanent Link to 十大另类程序语言（下）"&gt;十大另类程序语言（下）&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6223698079002165975?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6223698079002165975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6223698079002165975' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6223698079002165975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6223698079002165975'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/05/quine-and-programming-languages-for-fun.html' title='Quine and Programming languages for fun'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1944526420736373353</id><published>2011-04-28T16:44:00.000-07:00</published><updated>2011-05-08T18:03:48.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>HTML 5</title><content type='html'>Some cool HTML 5 stuff:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alteredqualia.com/canvasmol/"&gt;CanvasMol&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.queness.com/post/4105/13-amazing-examples-of-html5-and-css3"&gt;13 Amazing Examples of HTML5 and CSS3&lt;/a&gt;&lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110504/297181.html"&gt;20款绝佳的HTML5应用程序示例&lt;/a&gt;&lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110421/296337.html"&gt;学习HTML5不可错过的12家国外网站&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/"&gt;Create a Drawing App with HTML5 Canvas and JavaScript&lt;/a&gt;&lt;br /&gt;3D effect with only html and css: &lt;a href="http://www.romancortes.com/blog/css-3d-meninas/"&gt;CSS 3D Meninas&lt;/a&gt;&lt;br /&gt;&lt;a href="http://francisshanahan.com/tsa/tsaGAworkers.htm"&gt;Solving the Traveling Salesman Problem with Genetic Algorithms and HTML5 Web Workers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blog.csdn.net/Oneway102/archive/2011/03/21/6266474.aspx"&gt;HTML5笔记(1-3)&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.w3.org/TR/html5-diff/"&gt;HTML5 differences from HTML4&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sd.csdn.net/a/20110225/292527.html"&gt;Web开发人员应当知道的15个开源项目&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1944526420736373353?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1944526420736373353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1944526420736373353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1944526420736373353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1944526420736373353'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/04/html-5.html' title='HTML 5'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-9056120093382089091</id><published>2011-04-25T19:16:00.000-07:00</published><updated>2011-04-25T19:24:42.547-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# Mapping a network drive</title><content type='html'>C# can map a network drive by calling OS commands [1] or using native win32 API [2].&lt;br /&gt;&lt;br /&gt;The code below is from [1]:&lt;br /&gt;&lt;br /&gt;System.Diagnostics.Process.Start("net.exe", "use K: \\Server\URI\\path\\here");&lt;br /&gt;System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();&lt;br /&gt;psi.FileName = "C:\\application.exe";&lt;br /&gt;psi.WorkingDirectory = "K:\\working\\directory";&lt;br /&gt;psi.WindowStyle = System.Diagnostics.&lt;br /&gt;ProcessWindowStyle.Maximized;&lt;br /&gt;System.Diagnostics.Process p =&lt;br /&gt;System.Diagnostics.Process.Start(psi);&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://forum.codecall.net/c-programming/1119-c-mapping-network-drive.html"&gt;http://forum.codecall.net/c-programming/1119-c-mapping-network-drive.html&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://bytes.com/topic/c-sharp/answers/812115-mapping-network-drive-c"&gt;http://bytes.com/topic/c-sharp/answers/812115-mapping-network-drive-c&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-9056120093382089091?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/9056120093382089091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=9056120093382089091' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9056120093382089091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/9056120093382089091'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/04/mapping-network-drive-in-c.html' title='C# Mapping a network drive'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7453336993657302858</id><published>2011-04-23T19:20:00.000-07:00</published><updated>2011-04-23T19:31:01.425-07:00</updated><title type='text'>Nature: The Future of the PhD</title><content type='html'>&lt;a href="http://www.nature.com/news/specials/phdfuture/index.html"&gt;Nature: The Future of the PhD&lt;/a&gt; [Nature 472 (20 April 2011)]&lt;br /&gt;&lt;br /&gt;Set of articles discussing the current (problematic) system of PhD, from the training of PhD to the career prospects, and speculations on ways to fix the problems.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7453336993657302858?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7453336993657302858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7453336993657302858' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7453336993657302858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7453336993657302858'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/04/nature-future-of-phd.html' title='Nature: The Future of the PhD'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4786783953783845728</id><published>2011-02-28T20:33:00.000-08:00</published><updated>2011-02-28T20:37:53.214-08:00</updated><title type='text'>A problem with process pipe communication in C#</title><content type='html'>In C#, the Process component communicates with a child process via a pipe. If a child process writes enough data to the pipe to fill the buffer, the child will block until the parent reads the data from the pipe. This can cause deadlock if your application is reading all output to standard error and standard output, for example, using the following C# code.&lt;br /&gt;&lt;pre&gt;              Process p = new Process("...", "...");&lt;br /&gt;              p.StartInfo.UseShellExecute = false;&lt;br /&gt;              p.StartInfo.RedirectStandardOutput = true;&lt;br /&gt;              p.Start();&lt;br /&gt;              p.WaitForExit();&lt;br /&gt;              string output = p.StandardOutput.ReadToEnd();&lt;/pre&gt;&lt;br /&gt;In this instance, both the parent and the child processes would be blocked, as the filled pipe prevents the child process from completing, while the parent process is waiting indefinitely for the child process to exit. The pipe buffer, in my code, was 4096 bytes. If the output reaches this limit, it would hang.&lt;br /&gt;&lt;br /&gt;This problem can be solved by moving the ReadToEnd() before the WaitForExit(), as follows..&lt;br /&gt;&lt;pre&gt;              Process p = new Process("...", "...");&lt;br /&gt;              p.StartInfo.UseShellExecute = false;&lt;br /&gt;              p.StartInfo.RedirectStandardOutput = true;&lt;br /&gt;              p.Start();&lt;br /&gt;              string output = p.StandardOutput.ReadToEnd();&lt;br /&gt;              p.WaitForExit();&lt;/pre&gt;&lt;br /&gt;References:&lt;br /&gt;[1] http://bytes.com/topic/c-sharp/answers/459800-redirect-standard-output-size-limit&lt;br /&gt;[2] http://www1.cs.columbia.edu/~lok/csharp/refdocs/System.Diagnostics/types/Process.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4786783953783845728?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4786783953783845728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4786783953783845728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4786783953783845728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4786783953783845728'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/02/problem-with-process-in-c.html' title='A problem with process pipe communication in C#'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8500460246048188390</id><published>2011-02-28T20:16:00.000-08:00</published><updated>2011-03-07T21:16:03.934-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Script'/><title type='text'>Command line utilities</title><content type='html'>Many GUI functions have command line counterparts. This makes it possible to write scripts to automate a lot of tasks. The ones here are for the windows platform, specifically here we are talking about windows host script (*.vbs).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) For SVN, slik svn is a command line version. &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) The sqlcmd command enables running SQL script from command line.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;E.g., this runs eg.sql from command line.&lt;br /&gt;sqlcmd -S localhost -d database_name -i eg.sql&lt;br /&gt;&lt;br /&gt;This lists all databases on localhost:&lt;br /&gt;sqlcmd -S localhost -i list_databases.sql&lt;br /&gt;&lt;br /&gt;list_databases.sql:&lt;br /&gt;select distinct db_name(database_id) AS DATABASE_NAME from sys.master_files group by database_id;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;So if you want to do something to certain databases in a server, you can use this to get a list of databases, and check which ones are you need, then construct sql command dynamically.&lt;br /&gt;&lt;br /&gt;Just enter sqlcmd, you enter the interactive mode.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Build a visual studio solution from command line:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;"c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" c:\projects\Project1\Project1.sln /build Debug /out&lt;br /&gt;&lt;br /&gt;Or: &lt;br /&gt;&lt;br /&gt;C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe c:\projects\Project1\Project1.sln&lt;br /&gt;&lt;br /&gt;Script can invoke other executables. Executables (e.g. windows service) can invoke scripts. Both can also capture each other's output. This makes rich interaction.&lt;br /&gt;&lt;br /&gt;Windows service uses socket in usual. It can use windows remoting (TcpClientChannel) as well.&lt;br /&gt;&lt;br /&gt;The following installs a windows service:&lt;br /&gt;&lt;br /&gt;C:\Projects\wsService1\wsService1\bin\Debug&gt;InstallUtil /LogToConsole=true wsService1.exe&lt;br /&gt;&lt;br /&gt;Adding the /u switch will uninstall it.&lt;br /&gt;&lt;br /&gt;When install the windows service under a user account, you will be prompted for the account name and password. The name should be [domain_name]\account_name. If it is a local user (i.e., no domain_name), then it should be .\account_name. Not doing this causes failure.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) The WMIC command.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The WMIC command is a powerful command line tool to get all kinds of system information, from running processes to OS related. &lt;a href="http://support.microsoft.com/servicedesks/webcasts/wc072402/listofsampleusage.asp"&gt;See here for examples&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5) FileSystemObject.copyFolder and XCOPY&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;FileSystemObject.copyFolder fails when some target files are readonly, this is so even when the OverwriteExisting argument is set to true. The solution is to use XCOPY instead. You may want to use XCOPY this way: &lt;br /&gt;&lt;br /&gt;start /WAIT /B XCOPY %1 %2 /R /Y /E /H /Q&lt;br /&gt;&lt;br /&gt;/WAIT - wait until this finishes.&lt;br /&gt;/B - do not open another dos window.&lt;br /&gt;For the rest, use XCOPY /? for details. &lt;a href="http://support.microsoft.com/kb/941190"&gt;See here for more details&lt;/a&gt;.&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8500460246048188390?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8500460246048188390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8500460246048188390' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8500460246048188390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8500460246048188390'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/02/command-line-script.html' title='Command line utilities'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1358662299129664411</id><published>2011-02-17T19:50:00.000-08:00</published><updated>2011-02-17T19:55:16.219-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# script to strip comment</title><content type='html'>This code extracts comment from a line of string. Feeding a stream of lines to it, it concatenates the comment and non-comment parts and return them. Comment is defined by "/**/" or "//" as in C/C++.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// Input: line.&lt;br /&gt;    /// Output: &lt;br /&gt;    ///   rStr - The non-comment part is concatenated to rStr.&lt;br /&gt;    ///   rCmt - The comment part is concatenated to rCmt.&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    private void stripComment(string line, ref string rStr, ref string rCmt)&lt;br /&gt;    {&lt;br /&gt;        bool debug = false;&lt;br /&gt;        bool comment_block = false, comment_line = false;&lt;br /&gt;        int index, index2;&lt;br /&gt;        string NEWLINE = "\r\n";&lt;br /&gt;        string s = "";&lt;br /&gt;        string cmt = "";&lt;br /&gt;&lt;br /&gt;        if (line.Trim() == "") return; // ignore empty line.&lt;br /&gt;&lt;br /&gt;        string subline = line;&lt;br /&gt;        while (subline.Length &amp;gt; 0)&lt;br /&gt;        {&lt;br /&gt;            // if not in both comments mode:&lt;br /&gt;            //     if find /*, start comment_block from the point on.&lt;br /&gt;            //     elsif find --, start comment_line from here to end of line.&lt;br /&gt;            //     Since both "/*" and "--" may exist on this line, find the one occur first.&lt;br /&gt;            if (comment_block == false)&lt;br /&gt;            {&lt;br /&gt;                index = subline.IndexOf("/*");&lt;br /&gt;                index2 = subline.IndexOf("--");&lt;br /&gt;                if (index != -1 &amp;&amp; index2 != -1)&lt;br /&gt;                {&lt;br /&gt;                    if (index &amp;lt; index2) { comment_block = true; }&lt;br /&gt;                    else { comment_line = true; }&lt;br /&gt;                }&lt;br /&gt;                else if (index != -1) { comment_block = true; }&lt;br /&gt;                else if (index2 != -1) { comment_line = true; }&lt;br /&gt;&lt;br /&gt;                if (comment_block)&lt;br /&gt;                {&lt;br /&gt;                    // comment_block start found.&lt;br /&gt;                    // print the substring before "/*".&lt;br /&gt;                    if (debug) Console.WriteLine(subline.Substring(0, index));&lt;br /&gt;                    s += subline.Substring(0, index);&lt;br /&gt;                    // strip the first part.&lt;br /&gt;                    subline = subline.Substring(index);&lt;br /&gt;                    continue;&lt;br /&gt;                }&lt;br /&gt;                else if (comment_line)&lt;br /&gt;                {&lt;br /&gt;                    // comment_line found.&lt;br /&gt;                    cmt += subline.Substring(index2) + NEWLINE; // comment part.&lt;br /&gt;                    // print the substring before "--".&lt;br /&gt;                    subline = subline.Substring(0, index2);&lt;br /&gt;                    if (subline.Trim() != "")&lt;br /&gt;                    {&lt;br /&gt;                        if (debug) Console.WriteLine(subline);&lt;br /&gt;                        s += subline + NEWLINE;&lt;br /&gt;                    }&lt;br /&gt;                    comment_line = false;&lt;br /&gt;                    break;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    // is a normal line.&lt;br /&gt;                    if (subline.Length &amp;gt; 0)&lt;br /&gt;                    {&lt;br /&gt;                        if (debug) Console.WriteLine(subline);&lt;br /&gt;                        s += subline + NEWLINE;&lt;br /&gt;                        break;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                // $comment_block == 1. In comment_block, &lt;br /&gt;                // search for */, if found, ends comment_block.&lt;br /&gt;                // Note that in comment_block mode, "--" has no effect.&lt;br /&gt;                index = subline.IndexOf("*/");&lt;br /&gt;                if (index != -1)&lt;br /&gt;                {&lt;br /&gt;                    cmt += subline.Substring(0, index + 2); // comment part.&lt;br /&gt;                    comment_block = false;&lt;br /&gt;                    if (debug) Console.WriteLine("comment_block end found.");&lt;br /&gt;                    subline = subline.Substring(index + 2);&lt;br /&gt;                    continue;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    // entire line is in comment_block.&lt;br /&gt;                    cmt += subline; // comment part.&lt;br /&gt;                    if (subline != line)&lt;br /&gt;                    {&lt;br /&gt;                        if (debug) Console.WriteLine(NEWLINE);&lt;br /&gt;                        s += NEWLINE;&lt;br /&gt;                        cmt += NEWLINE; // comment part.&lt;br /&gt;                    }&lt;br /&gt;                    break;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        rStr += s; &lt;br /&gt;        rCmt += cmt; &lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1358662299129664411?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1358662299129664411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1358662299129664411' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1358662299129664411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1358662299129664411'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/02/c-script-to-strip-comment.html' title='C# script to strip comment'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6170339543114319593</id><published>2011-01-29T14:35:00.001-08:00</published><updated>2011-01-29T14:36:41.813-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Writing'/><title type='text'>The Chicago Manual of Style</title><content type='html'>&lt;a href="http://www.chicagomanualofstyle.org/tools_citationguide.html"&gt;The Chicago Manual of Style&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Two types: 1) notes and bibliography, 2) author-date.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6170339543114319593?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6170339543114319593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6170339543114319593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6170339543114319593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6170339543114319593'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/01/chicago-manual-of-style.html' title='The Chicago Manual of Style'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7595158603158602228</id><published>2011-01-21T16:00:00.000-08:00</published><updated>2011-01-21T16:01:41.935-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Mining'/><title type='text'>Ten classic data mining algorithms</title><content type='html'>&lt;a href="http://blog.csdn.net/v_JULY_v/archive/2011/01/15/6142146.aspx"&gt;Ten classic data mining algorithms&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7595158603158602228?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7595158603158602228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7595158603158602228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7595158603158602228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7595158603158602228'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/01/ten-classic-data-mining-algorithms.html' title='Ten classic data mining algorithms'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1139029108184823733</id><published>2011-01-20T14:35:00.001-08:00</published><updated>2011-01-20T14:39:39.503-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Engineering'/><title type='text'>Software Carpentry</title><content type='html'>Today finished reading the &lt;a href="http://osl.iu.edu/~lums/swc/"&gt;software carpentry&lt;/a&gt;. It introduces the basic principles of software engineering to research scientists and engineers. In doing so in a short and effective manner, it claims to introduce 10% of the software engineering that can meet 90% of the needs. This material becomes open licensed since 2005.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1139029108184823733?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1139029108184823733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1139029108184823733' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1139029108184823733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1139029108184823733'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/01/software-carpentry.html' title='Software Carpentry'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3277213867747004831</id><published>2011-01-19T18:42:00.000-08:00</published><updated>2011-01-21T12:41:08.408-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Tools'/><title type='text'>PHPUnit, Hudson CI, Doxygen and Silverlilght</title><content type='html'>PHPUnit is used for writing unit tests in PHP. This is &lt;a href="http://www.lastcraft.com/first_test_tutorial.php"&gt;a first tutorial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://hudson-ci.org/"&gt;Hudson CI&lt;/a&gt; is a continuous integration server system. Can be used for automated unit testing.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.stack.nl/~dimitri/doxygen/"&gt;Doxygen&lt;/a&gt; is a documentation system for many programming languages.&lt;br /&gt;&lt;br /&gt;Silverlight is Microsoft's RIA solution coming with MPF. &lt;a href="http://www.silverlight.net/getstarted/"&gt;See here for tutorial&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3277213867747004831?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3277213867747004831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3277213867747004831' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3277213867747004831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3277213867747004831'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/01/doxygen-and-hudson-ci.html' title='PHPUnit, Hudson CI, Doxygen and Silverlilght'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4541698722310901998</id><published>2011-01-05T18:34:00.000-08:00</published><updated>2011-01-05T18:40:01.984-08:00</updated><title type='text'>MS SQL schema</title><content type='html'>Obtain metadata of objects of a database can add lots of flexibility. This can be obtained in the following ways:&lt;br /&gt;&lt;br /&gt;1) &lt;a href="http://www.mssqltips.com/tutorial.asp?tutorial=179"&gt;INFORMATION_SCHEMA&lt;/a&gt;&lt;br /&gt;e.g.:&lt;br /&gt;select table_name as Name FROM INFORMATION_SCHEMA.Tables where TABLE_TYPE ='VIEW'&lt;br /&gt;&lt;br /&gt;2) &lt;a href="http://bytes.com/topic/sql-server/answers/82200-how-do-i-grab-simple-list-sql-server-views-tables-sprocs"&gt;sysobjects&lt;/a&gt;&lt;br /&gt;e.g.:&lt;br /&gt;SELECT name FROM sysobjects WHERE xtype = 'U' -- Tables&lt;br /&gt;SELECT name FROM sysobjects WHERE xtype = 'V' -- Views&lt;br /&gt;SELECT name FROM sysobjects WHERE xtype = 'P' -- Stored Procedures&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4541698722310901998?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4541698722310901998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4541698722310901998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4541698722310901998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4541698722310901998'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2011/01/ms-sql-schema.html' title='MS SQL schema'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5864017230434598430</id><published>2010-12-29T16:33:00.000-08:00</published><updated>2011-02-16T16:51:39.083-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Subversion'/><title type='text'>A Subversion Cheat Sheet</title><content type='html'>SVN can use a GUI interface such as &lt;a href="http://tortoisesvn.net/"&gt;TortoiseSVN&lt;/a&gt;, or a command line version such as &lt;a href="http://www.sliksvn.com/en/download"&gt;slik SVN&lt;/a&gt;.&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Setup ssh key for svn so no need to enter password each time: &lt;a href="http://pkeck.myweb.uga.edu/ssh/"&gt;HOWTO: set up ssh keys&lt;/a&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Recursive_descent_parser"&gt;A short usage note for Subversion&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Often used svn commands are:&lt;br /&gt;&lt;br /&gt;Create a Repository&lt;br /&gt;&lt;br /&gt;UNIX: svnadmin create /path/to/repository&lt;br /&gt;Windows: svnadmin create d:/path_to_repository&lt;br /&gt;&lt;br /&gt;Checking Out a Project - svn checkout&lt;br /&gt;&lt;br /&gt;UNIX: svn checkout file:///repository_name/project/trunk project&lt;br /&gt;Windows: svn checkout file:///d:/repository_name/project/trunk project&lt;br /&gt;Network: svn checkout http://host_name/svn_dir/repository_name/project/trunk project&lt;br /&gt;&lt;br /&gt;Getting a List of Projects - svn list&lt;br /&gt;&lt;br /&gt;UNIX: svn list --verbose file:///repository_name/project&lt;br /&gt;Network: svn list --verbose http://host_name/svn_dir/repository_name/project&lt;br /&gt;&lt;br /&gt;Reviewing Changes - svn status&lt;br /&gt;&lt;br /&gt;UNIX: svn status&lt;br /&gt;&lt;br /&gt;Adding New Files and Directories - svn add&lt;br /&gt;&lt;br /&gt;UNIX: svn add file_or_dir_name&lt;br /&gt;&lt;br /&gt;Deleting Files and Directories - svn delete&lt;br /&gt;&lt;br /&gt;UNIX: svn delete file_or_dir_name&lt;br /&gt;Network: svn delete -m "Deleting project dir" http://localhost/svn_dir/repository/project_dir&lt;br /&gt;&lt;br /&gt;Committing Changes - svn commit&lt;br /&gt;&lt;br /&gt;Network: svn commit -m "Saving recent changes" http://localhost/svn_dir/repository/project_dir&lt;br /&gt;&lt;br /&gt;Updating Your Local Files - svn update&lt;br /&gt;&lt;br /&gt;Network: svn update&lt;br /&gt;&lt;br /&gt;Get revision number - svn info&lt;br /&gt;&lt;br /&gt;svn info | grep Rev&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5864017230434598430?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5864017230434598430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5864017230434598430' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5864017230434598430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5864017230434598430'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/subversion-cheat-sheet.html' title='A Subversion Cheat Sheet'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6096360093705359666</id><published>2010-12-29T16:25:00.001-08:00</published><updated>2010-12-29T16:31:03.671-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>MSSQL extended property</title><content type='html'>MSSQL extended property is used to store metadata information on database objects (tables, views, columns, indexes etc.). &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;- Extended Property is NOT case sensitive.&lt;br /&gt;- MSDN: add, drop, update, list extended properties:&lt;br /&gt;  &lt;a href='http://msdn.microsoft.com/en-us/library/ms180047.aspx'&gt;http://msdn.microsoft.com/en-us/library/ms180047.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- list all extended properties:&lt;br /&gt;  SELECT * FROM sys.extended_properties;&lt;br /&gt;- list all extended properties for columns in all tables:&lt;br /&gt;  SELECT major_id, minor_id, t.name AS [Table Name], c.name AS [Column Name], value AS [Extended Property]&lt;br /&gt;  FROM sys.extended_properties AS ep&lt;br /&gt;  INNER JOIN sys.tables AS t ON ep.major_id = t.object_id &lt;br /&gt;  INNER JOIN sys.columns AS c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id&lt;br /&gt;  WHERE class = 1;&lt;br /&gt;- Show all the E.P. of a specific columns in a specific table:&lt;br /&gt;  SELECT objtype, objname, name, value&lt;br /&gt;  FROM fn_listextendedproperty (NULL, 'schema', 'dbo', 'table', 'T1', 'column', 'id');&lt;br /&gt;  &lt;br /&gt;&lt;b&gt;Add/drop/update/list the Extended Property of a column:&lt;/b&gt;&lt;br /&gt;  &lt;br /&gt;- Show an E.P. of a columns in a table:&lt;br /&gt;  SELECT objtype, objname, name, value&lt;br /&gt;  FROM fn_listextendedproperty ('[E.P. name]', 'schema', 'dbo', 'table', 'T1', 'column', 'id');&lt;br /&gt;&lt;br /&gt;- Add an E.P. of a column in a table (the IF part is optional check):&lt;br /&gt;&lt;br /&gt;  IF NOT Exists (SELECT * FROM fn_listextendedproperty(&lt;br /&gt;    'Summary', 'schema', 'dbo', 'table', 'T1', 'column', 'id'&lt;br /&gt;  ))&lt;br /&gt;  EXEC sp_addextendedproperty &lt;br /&gt;    @name = 'caption' &lt;br /&gt;    ,@value = 'Employee ID' &lt;br /&gt;    ,@level0type = 'schema', @level0name = dbo&lt;br /&gt;    ,@level1type = 'table', @level1name = 'T1'&lt;br /&gt;    ,@level2type = 'column', @level2name = id;&lt;br /&gt;  GO&lt;br /&gt;&lt;br /&gt;- Drop an E.P. of a column in a table (the IF part is optional check):&lt;br /&gt;&lt;br /&gt;  IF Exists (SELECT * FROM fn_listextendedproperty(&lt;br /&gt;    'Summary', 'schema', 'dbo', 'table', 'T1', 'column', 'id'&lt;br /&gt;  ))&lt;br /&gt;  EXEC sp_dropextendedproperty &lt;br /&gt;    @name = 'caption' &lt;br /&gt;    ,@level0type = 'schema', @level0name = dbo&lt;br /&gt;    ,@level1type = 'table', @level1name = 'T1'&lt;br /&gt;    ,@level2type = 'column', @level2name = id;&lt;br /&gt;  GO&lt;br /&gt;&lt;br /&gt;- Update an E.P. of a column in a table:&lt;br /&gt;  EXEC sp_updateextendedproperty &lt;br /&gt;    @name = N'Caption'&lt;br /&gt;    ,@value = 'Employee ID must be unique.'&lt;br /&gt;    ,@level0type = N'Schema', @level0name = dbo&lt;br /&gt;    ,@level1type = N'Table',  @level1name = T1&lt;br /&gt;    ,@level2type = N'Column', @level2name = id;&lt;br /&gt;  GO&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Add/drop/update/list the Extended Property of a table:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;- The above shows how to add/drop/update/list the E.P. of a column.&lt;br /&gt;  To do the same thing for a table, just ignore the last 2 items for&lt;br /&gt;  level2type/level2name. For the IF part, use NULL for the last two items. E.g.:&lt;br /&gt;  IF Exists (SELECT * FROM fn_listextendedproperty(&lt;br /&gt;    'Summary', 'schema', 'dbo', 'table', 'T1', NULL, NULL&lt;br /&gt;  ))&lt;br /&gt;  Examples are given below.&lt;br /&gt;&lt;br /&gt;- Drop an extended property of a table:  &lt;br /&gt;  IF Exists (SELECT * FROM fn_listextendedproperty(&lt;br /&gt;    'Summary', 'schema', 'dbo', 'table', 'T1', null, null&lt;br /&gt;  ))&lt;br /&gt;  EXEC sp_dropextendedproperty &lt;br /&gt;    @name = 'Summary' &lt;br /&gt;    ,@level0type = 'schema' ,@level0name = dbo&lt;br /&gt;    ,@level1type = 'table' ,@level1name = 'T1';&lt;br /&gt;  GO&lt;br /&gt;  &lt;br /&gt;- Add an extended property to a table:  &lt;br /&gt;  IF NOT Exists (SELECT * FROM fn_listextendedproperty(&lt;br /&gt;    'Summary', 'schema', 'dbo', 'table', 'T1', null, null&lt;br /&gt;  ))&lt;br /&gt;  EXEC sp_addextendedproperty &lt;br /&gt;    @name = 'Summary' &lt;br /&gt;    ,@value = 'T1 table''s summary' &lt;br /&gt;    ,@level0type = 'schema' ,@level0name = dbo&lt;br /&gt;    ,@level1type = 'table' ,@level1name = 'T1';&lt;br /&gt;  GO  &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Add/drop/update/list the Extended Property of a view or view's column:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;- Same as table, except that use "view" instead of "table" as level1type.&lt;br /&gt;  &lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;- Since single quote "'" is used as delimiter, it should escaped&lt;br /&gt;  by "''" if it is used in the value.&lt;br /&gt;- Note that string quoted by "'" is allowed to contain new line character.&lt;br /&gt;  So if a value spans multiple lines, it won't be a problem.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6096360093705359666?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6096360093705359666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6096360093705359666' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6096360093705359666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6096360093705359666'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/mssql-extended-property.html' title='MSSQL extended property'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5834814868317305691</id><published>2010-12-29T16:14:00.000-08:00</published><updated>2010-12-29T16:30:44.374-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><title type='text'>Perl OOP and reference</title><content type='html'>Perl can do OOP for sure. I reviewed relevant material for recent work. Use "Package" to define a class. What's interesting is the use of "bless" keyword. An object is used in the syntax of a C++ object, say you use "-&gt;" to retrieve its member variable or function.&lt;br /&gt;&lt;br /&gt;The use of reference facilitates a lot of programming features. In Perl using a back slash "\" in front of a variable (scalar, array or hash) turns it into a reference. This can be passed to subroutines, to be used recursively etc. To cast it back and refer to the object, use $/@{}/%{} for scalar/array/hash respectively.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;- &lt;a href='http://www.tutorialspoint.com/perl/perl_oo_perl.htm'&gt;Object Oriented Programming in PERL&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5834814868317305691?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5834814868317305691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5834814868317305691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5834814868317305691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5834814868317305691'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/perl-oop-and-reference.html' title='Perl OOP and reference'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4426891745274185954</id><published>2010-12-17T13:24:00.000-08:00</published><updated>2010-12-17T13:28:23.572-08:00</updated><title type='text'>Perl - count number of occurrences</title><content type='html'>&lt;a href="http://www.chengfu.net/2005/10/count-occurrences-perl/"&gt;http://www.chengfu.net/2005/10/count-occurrences-perl/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The author wants to find out what's the fastest way of counting occurrences of a string in a text. e.g. '-' in “1-4-7-8-37-5-7-8-3-42″. He gives 5 ways of doing this:&lt;br /&gt;&lt;br /&gt;   1. my $size = (scalar(@{[$string =~ /-/g]}) + 1);&lt;br /&gt;   2. my $size = scalar(split /-/, $string);&lt;br /&gt;   3. my $size = (($string =~ s/-//g) + 1);&lt;br /&gt;   4. my $size = (($string =~ tr/-//) + 1);&lt;br /&gt;   5. my $size = 1; $size++ while $string =~ /-/g;&lt;br /&gt;&lt;br /&gt;He found the speed to be 4, 3, 5, 1, 2 in the order of fastest to slowest on his machine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4426891745274185954?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4426891745274185954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4426891745274185954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4426891745274185954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4426891745274185954'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/perl-count-number-of-occurrences-of.html' title='Perl - count number of occurrences'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2395179182640047109</id><published>2010-12-17T01:11:00.000-08:00</published><updated>2010-12-17T01:12:37.609-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Art'/><title type='text'>Doodling in math class</title><content type='html'>Doodling in math class: &lt;a href="http://vihart.com/doodling/"&gt;http://vihart.com/doodling/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Interesting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2395179182640047109?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2395179182640047109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2395179182640047109' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2395179182640047109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2395179182640047109'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/doodling-in-math-class.html' title='Doodling in math class'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2577969486511976830</id><published>2010-12-14T15:33:00.000-08:00</published><updated>2010-12-14T15:36:08.991-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><title type='text'>Perlpod</title><content type='html'>&lt;a href='http://perldoc.perl.org/perlpod.html'&gt;Perlpod&lt;/a&gt;: The Plain Old Document format.&lt;br /&gt;&lt;br /&gt;Description about Perlpod from the above source: &lt;br /&gt;&lt;br /&gt;Pod is a simple-to-use markup language used for writing documentation for Perl, Perl programs, and Perl modules.&lt;br /&gt;Translators are available for converting Pod to various formats like plain text, HTML, man pages, and more.&lt;br /&gt;Pod markup consists of three basic kinds of paragraphs: ordinary, verbatim, and command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2577969486511976830?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2577969486511976830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2577969486511976830' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2577969486511976830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2577969486511976830'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/perlpod.html' title='Perlpod'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8954454910554628272</id><published>2010-12-13T19:20:00.000-08:00</published><updated>2010-12-13T19:25:25.846-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Setup email forwarding in linux/unix</title><content type='html'>Email forwarding can be setup in an email client such as Thunderbird.&lt;br /&gt;&lt;br /&gt;Under linux/unix, it can done by admin or by user himself, as explained &lt;a href="http://dettox.blogspot.com/2008/01/automatic-forward-to-another-email.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;To do it by the user himself, he only needs to create a file .forward in his account root, and enter the forward email addresses separated by comma or new line. The .forward file should have permission 644.&lt;br /&gt;&lt;br /&gt;An example .forward file is:&lt;br /&gt;&lt;br /&gt;"|/usr/local/bin/procmail"&lt;br /&gt;example@gmail.com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8954454910554628272?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8954454910554628272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8954454910554628272' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8954454910554628272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8954454910554628272'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/setup-email-forwarding-in-linux.html' title='Setup email forwarding in linux/unix'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2880350379195357656</id><published>2010-12-11T02:32:00.000-08:00</published><updated>2010-12-11T02:38:42.407-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming language'/><title type='text'>Java becomes closed source</title><content type='html'>&lt;a href="http://blogs.apache.org/foundation/entry/the_asf_resigns_from_the"&gt;December 9, 2010: The ASF Resigns From the JCP Executive Committee&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It seems that now Java to Oracle is as C# to Microsoft. Java becomes proprietary language of Oracle. But, C/C++/PHP/Perl/Python/Ruby are still open source. &lt;br /&gt;&lt;br /&gt;Since Oracle also owns MySQL, don't know what will happen to MySQL. PostgreSQL is still open source though.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2880350379195357656?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2880350379195357656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2880350379195357656' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2880350379195357656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2880350379195357656'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/12/java-becomes-closed-source.html' title='Java becomes closed source'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8638896251034649744</id><published>2010-11-17T15:16:00.001-08:00</published><updated>2010-11-17T15:16:42.298-08:00</updated><title type='text'>Silicon valley</title><content type='html'>Here is &lt;a href="http://en.wikipedia.org/wiki/Silicon_Valley"&gt;an introduction to silicon valley&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8638896251034649744?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8638896251034649744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8638896251034649744' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8638896251034649744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8638896251034649744'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/11/silicon-valley.html' title='Silicon valley'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-678751931242820971</id><published>2010-10-01T15:16:00.000-07:00</published><updated>2010-10-01T16:17:11.033-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Web application'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL Injection Attack</title><content type='html'>One of the servers is hacked. The symptom is that javascript code were inserted into some database tables. When users visit the site, the javascript code would invoke remote site scripts, display a faked virus scan and report (might be a dynamic gif image), and ask the user to download and install a virus removal software. Once the user installs the software, his computer will be infected.&lt;br /&gt;&lt;br /&gt;A script is written to search and clean the database based on signature (characteristic substring) in the javascript code. SQL Query log is added to record all the executed queries. Nothing was found. The problem was finally identified by checking the web server visit log. There are visit requests where SQL commands such as UPDATE used in query string parameter value. It takes advantage of the fact that two consecutive SQL statements can be executed one after the other. This SQL injection attack achieved its goal. Checking the request parameter before executing the SQL can catch such problems. Use of stored procedure and avoid this vulnerability.&lt;br /&gt;&lt;br /&gt;A perl script is written to analyze the visit log files and extract these attack requests. The attacked page and attacker's IP is found. Whois service is used to locate where the attacker's IP is from. Patches were made to the attacked page and the site.&lt;br /&gt;&lt;br /&gt;Below is the perl script to analyze web server visit log. It extract queries using the 'update' command. Actually it's found that command 'select' is also used in other queries. Can change the script to extract those as well.&lt;br /&gt;&lt;pre&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# @Author: Tom&lt;br /&gt;# @Created on: 9/30/2010&lt;br /&gt;# @Last modified: 9/30/2010&lt;br /&gt;# @Usage example: perl Analyzer.pl &amp;lt; ex100920.log &amp;gt; 100920.txt&lt;br /&gt;# All lines containing the substring "1091+update" are extracted.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;use strict;&lt;br /&gt;&lt;br /&gt;my @fields;&lt;br /&gt;my $fields_ct;&lt;br /&gt;my $line_ct = 0;&lt;br /&gt;my $attack_line_ct = 0;&lt;br /&gt;my @attacked_Pages;&lt;br /&gt;my @attack_IPs;&lt;br /&gt;my $v;&lt;br /&gt;my @vs;&lt;br /&gt;my $i;&lt;br /&gt;my $prefix;&lt;br /&gt;&lt;br /&gt;my @ascii_table = (&lt;br /&gt;"NUL",&lt;br /&gt;"SOH",&lt;br /&gt;"STX",&lt;br /&gt;"ETX",&lt;br /&gt;"EOT",&lt;br /&gt;"ENQ",&lt;br /&gt;"ACK",&lt;br /&gt;"BEL",&lt;br /&gt;"BS",&lt;br /&gt;"HT",&lt;br /&gt;"LF",&lt;br /&gt;"VT",&lt;br /&gt;"FF",&lt;br /&gt;"CR",&lt;br /&gt;"SO",&lt;br /&gt;"SI",&lt;br /&gt;"DLE",&lt;br /&gt;"DC1",&lt;br /&gt;"DC2",&lt;br /&gt;"DC3",&lt;br /&gt;"DC4",&lt;br /&gt;"NAK",&lt;br /&gt;"SYN",&lt;br /&gt;"ETB",&lt;br /&gt;"CAN",&lt;br /&gt;"EM",&lt;br /&gt;"SUB",&lt;br /&gt;"ESC",&lt;br /&gt;"FS",&lt;br /&gt;"GS",&lt;br /&gt;"RS",&lt;br /&gt;"US",&lt;br /&gt;" ",&lt;br /&gt;"!",&lt;br /&gt;"\"",&lt;br /&gt;"#",&lt;br /&gt;"\$",&lt;br /&gt;"%",&lt;br /&gt;"&amp;",&lt;br /&gt;"'",&lt;br /&gt;"(",&lt;br /&gt;")",&lt;br /&gt;"*",&lt;br /&gt;"+",&lt;br /&gt;",",&lt;br /&gt;"-",&lt;br /&gt;".",&lt;br /&gt;"/",&lt;br /&gt;"0",&lt;br /&gt;"1",&lt;br /&gt;"2",&lt;br /&gt;"3",&lt;br /&gt;"4",&lt;br /&gt;"5",&lt;br /&gt;"6",&lt;br /&gt;"7",&lt;br /&gt;"8",&lt;br /&gt;"9",&lt;br /&gt;":",&lt;br /&gt;";",&lt;br /&gt;"&amp;lt;",&lt;br /&gt;"=",&lt;br /&gt;"&amp;gt;",&lt;br /&gt;"?",&lt;br /&gt;"@",&lt;br /&gt;"A",&lt;br /&gt;"B",&lt;br /&gt;"C",&lt;br /&gt;"D",&lt;br /&gt;"E",&lt;br /&gt;"F",&lt;br /&gt;"G",&lt;br /&gt;"H",&lt;br /&gt;"I",&lt;br /&gt;"J",&lt;br /&gt;"K",&lt;br /&gt;"L",&lt;br /&gt;"M",&lt;br /&gt;"N",&lt;br /&gt;"O",&lt;br /&gt;"P",&lt;br /&gt;"Q",&lt;br /&gt;"R",&lt;br /&gt;"S",&lt;br /&gt;"T",&lt;br /&gt;"U",&lt;br /&gt;"V",&lt;br /&gt;"W",&lt;br /&gt;"X",&lt;br /&gt;"Y",&lt;br /&gt;"Z",&lt;br /&gt;"[",&lt;br /&gt;"\\",&lt;br /&gt;"]",&lt;br /&gt;"^",&lt;br /&gt;"_",&lt;br /&gt;"`",&lt;br /&gt;"a",&lt;br /&gt;"b",&lt;br /&gt;"c",&lt;br /&gt;"d",&lt;br /&gt;"e",&lt;br /&gt;"f",&lt;br /&gt;"g",&lt;br /&gt;"h",&lt;br /&gt;"i",&lt;br /&gt;"j",&lt;br /&gt;"k",&lt;br /&gt;"l",&lt;br /&gt;"m",&lt;br /&gt;"n",&lt;br /&gt;"o",&lt;br /&gt;"p",&lt;br /&gt;"q",&lt;br /&gt;"r",&lt;br /&gt;"s",&lt;br /&gt;"t",&lt;br /&gt;"u",&lt;br /&gt;"v",&lt;br /&gt;"w",&lt;br /&gt;"x",&lt;br /&gt;"y",&lt;br /&gt;"z",&lt;br /&gt;"{",&lt;br /&gt;"|",&lt;br /&gt;"}",&lt;br /&gt;"~",&lt;br /&gt;"DEL",&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;while(&amp;lt;&amp;gt;) {&lt;br /&gt;  $line_ct ++;&lt;br /&gt;  if (/^\s+$/) { next; } # ignore empty line.&lt;br /&gt;  if (/id=1091\+update/) {} else { next; } # ignore non-attack lines.&lt;br /&gt;  $attack_line_ct ++;&lt;br /&gt;&lt;br /&gt;  print $line_ct . ": \n" ;&lt;br /&gt;  print $_ . "\n"; &lt;br /&gt;  print "Fields dump: \n";&lt;br /&gt;  @fields = split(' ', $_);&lt;br /&gt;  $fields_ct = @fields;&lt;br /&gt;  for ($i = 0; $i &amp;lt; $fields_ct; $i ++) {&lt;br /&gt;    print "$i: ";&lt;br /&gt;    $v = $fields[$i];&lt;br /&gt;    if ($i == 6) {&lt;br /&gt;      $v =~ s/\%2B/+/g;&lt;br /&gt;      #print "$v\n";&lt;br /&gt;      @vs = split('\+', $v);&lt;br /&gt;      foreach my $u (@vs) {&lt;br /&gt;        if ($u =~ /^varchar\(8000\)/) {&lt;br /&gt;          print "$u";&lt;br /&gt;        } elsif ($u =~ /(cast\()(char\()((\d)+)\)/) {&lt;br /&gt;          print "cast(" . $ascii_table[$3]; &lt;br /&gt;        } elsif ($u =~ /(char\()((\d)+)\)/) {&lt;br /&gt;          print $ascii_table[$2]; &lt;br /&gt;        } else {&lt;br /&gt;          print "$u";&lt;br /&gt;        }&lt;br /&gt;        #print "+";&lt;br /&gt;        print " ";&lt;br /&gt;      }&lt;br /&gt;      print "\n";&lt;br /&gt;    } elsif ($i == 5) {&lt;br /&gt;      if (Page_Exists($v) == 0) {&lt;br /&gt;        push(@attacked_Pages, $v);&lt;br /&gt;      }&lt;br /&gt;      print "$v\n";&lt;br /&gt;    } elsif ($i == 9) {&lt;br /&gt;      if (IP_Exists($v) == 0) {&lt;br /&gt;        push(@attack_IPs, $v);&lt;br /&gt;      }&lt;br /&gt;      print "$v\n";&lt;br /&gt;    } else {&lt;br /&gt;      print "$v\n";&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  print "\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;print "$attack_line_ct attack requests found.\n";&lt;br /&gt;&lt;br /&gt;my $Page_ct = @attacked_Pages;&lt;br /&gt;print "$Page_ct attacked Page(s) found: \n";&lt;br /&gt;foreach my $p (@attacked_Pages) {&lt;br /&gt;  print "$p\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;my $IP_ct = @attack_IPs;&lt;br /&gt;print "$IP_ct attacking IP(s) found: \n";&lt;br /&gt;foreach my $p (@attack_IPs) {&lt;br /&gt;  print "$p\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sub Page_Exists() {&lt;br /&gt;  my ($ip) = @_;&lt;br /&gt;  foreach my $p (@attacked_Pages) {&lt;br /&gt;    if ($ip eq $p) { return 1; }&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub IP_Exists() {&lt;br /&gt;  my ($ip) = @_;&lt;br /&gt;  foreach my $p (@attack_IPs) {&lt;br /&gt;    if ($ip eq $p) { return 1; }&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For cleaning the database, an ASP script is written.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;'&lt;br /&gt;' Remove injected code from database tables.&lt;br /&gt;' Use signature and full_signature to specify the injected code.&lt;br /&gt;' Use request string "doClean=y" to do cleaning.&lt;br /&gt;' If not use doClean, will only show infected rows.&lt;br /&gt;' Tom 9-24-2010&lt;br /&gt;'&lt;br /&gt;Dim signature, full_signature&lt;br /&gt;signature = "&amp;lt;/script&amp;gt;" &lt;br /&gt;full_signature = "&amp;lt;script src=http://.../...js&amp;gt;&amp;lt;/script&amp;gt;"&lt;br /&gt;&lt;br /&gt;Dim doClean&lt;br /&gt;doClean = false&lt;br /&gt;if request("doClean") &amp;lt;&amp;gt; "" then doClean = true&lt;br /&gt;&lt;br /&gt;Response.Write("&amp;lt;p&amp;gt;Use doClean request parameter to do cleaning. ")&lt;br /&gt;Response.Write("doClean = " &amp;amp; doClean &amp;amp; "&amp;lt;/p&amp;gt;")&lt;br /&gt;call getTables()&lt;br /&gt;&lt;br /&gt;function getTables()&lt;br /&gt;    'Response.Write("test()&amp;lt;br&amp;gt;")&lt;br /&gt;    Dim db, rs, sql, count, tbl, infectedTblCount&lt;br /&gt;    infectedTblCount = 0&lt;br /&gt;&lt;br /&gt;    sql = "select table_name as Name from INFORMATION_SCHEMA.Tables where TABLE_TYPE ='BASE TABLE'"&lt;br /&gt;    set db = Connect()&lt;br /&gt;    set rs = ExecuteRS(db, sql)&lt;br /&gt;    &lt;br /&gt;    count = 1&lt;br /&gt;    do while not rs.eof&lt;br /&gt;        tbl = rs("Name")&lt;br /&gt;            Response.Write("Table " &amp;amp; count &amp;amp; ". " &amp;amp; tbl &amp;amp; "&amp;lt;br&amp;gt;")&lt;br /&gt;            if getTableColumns(tbl) &amp;gt; 0 then infectedTblCount = infectedTblCount + 1&lt;br /&gt;            count = count + 1&lt;br /&gt;        rs.MoveNext()&lt;br /&gt;    loop&lt;br /&gt;    &lt;br /&gt;    Response.Write("&amp;lt;p&amp;gt;" &amp;amp; infectedTblCount &amp;amp; " tables are infected.&amp;lt;/p&amp;gt;")&lt;br /&gt;&lt;br /&gt;    call rs.close()&lt;br /&gt;    set rs = nothing&lt;br /&gt;    call db.close()&lt;br /&gt;    set db = nothing    &lt;br /&gt;end function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function getTableColumns(tbl)&lt;br /&gt;    Dim db, rs, sql, col, str, chk&lt;br /&gt;&lt;br /&gt;    sql = "select column_name as Name from INFORMATION_SCHEMA.COLUMNS where TABLE_name ='" &amp;amp; tbl &amp;amp; "'"&lt;br /&gt;    set db = Connect()&lt;br /&gt;    set rs = ExecuteRS(db, sql)&lt;br /&gt;    &lt;br /&gt;    count = 0 ' count of infected columns.&lt;br /&gt;    &lt;br /&gt;    do while not rs.eof&lt;br /&gt;        col = rs("Name")&lt;br /&gt;        chk = checkTblColumn(tbl, col)&lt;br /&gt;        str = str &amp;amp; "&amp;lt;li&amp;gt;" &amp;amp; col &amp;amp; chk &amp;amp; "&amp;lt;/li&amp;gt;"&lt;br /&gt;        if len(chk) &amp;gt; 0 then &lt;br /&gt;            count = count + 1&lt;br /&gt;            if doClean then str = str &amp;amp; cleanTblColumn(tbl, col)&lt;br /&gt;        end if&lt;br /&gt;        rs.MoveNext()&lt;br /&gt;    loop&lt;br /&gt;    str = "&amp;lt;ol&amp;gt;" &amp;amp; str &amp;amp; "&amp;lt;/ol&amp;gt;"&lt;br /&gt;    Response.Write(str)&lt;br /&gt;    &lt;br /&gt;    getTableColumns = count&lt;br /&gt;&lt;br /&gt;    call rs.close()&lt;br /&gt;    set rs = nothing&lt;br /&gt;    call db.close()&lt;br /&gt;    set db = nothing&lt;br /&gt;end function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function checkTblColumn(tbl, col)&lt;br /&gt;    Dim db, rs, sql, val, str&lt;br /&gt;&lt;br /&gt;    sql = "select " &amp;amp; col &amp;amp; " as Name from " &amp;amp; tbl&lt;br /&gt;    set db = Connect()&lt;br /&gt;    set rs = ExecuteRS(db, sql)&lt;br /&gt;    &lt;br /&gt;    count = 0   &lt;br /&gt;    str = ""&lt;br /&gt;    do while not rs.eof&lt;br /&gt;        val = rs("Name")&lt;br /&gt;        if InStr(1, val, signature) &amp;gt; 0 then&lt;br /&gt;            str = str &amp;amp; ("&amp;lt;li&amp;gt;Infected row: " &amp;amp; encodeStr(val) &amp;amp; "&amp;lt;/li&amp;gt;")&lt;br /&gt;            count = count + 1&lt;br /&gt;        end if&lt;br /&gt;        rs.MoveNext()&lt;br /&gt;    loop&lt;br /&gt;    if count &amp;gt; 0 then&lt;br /&gt;        str = "&amp;lt;font color='red'&amp;gt;" &amp;amp; count &amp;amp; " rows infected&amp;lt;/font&amp;gt;" &amp;amp; str&lt;br /&gt;        str = "&amp;lt;ol&amp;gt;" &amp;amp; str &amp;amp; "&amp;lt;/ol&amp;gt;"&lt;br /&gt;        'Response.Write(str)&lt;br /&gt;        checkTblColumn = str&lt;br /&gt;    else&lt;br /&gt;        checkTblColumn = ""&lt;br /&gt;    end if&lt;br /&gt;&lt;br /&gt;    call rs.close()&lt;br /&gt;    set rs = nothing&lt;br /&gt;    call db.close()&lt;br /&gt;    set db = nothing&lt;br /&gt;end function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function cleanTblColumn(tbl, col)&lt;br /&gt;    Dim db, rs, sql, val, str&lt;br /&gt;&lt;br /&gt;    set db = Connect()&lt;br /&gt;    set rs = Server.CreateObject("ADODB.Recordset")&lt;br /&gt;    rs.Open tbl, db, 1, 2, adCmdTableDirect&lt;br /&gt;    &lt;br /&gt;    count = 0   &lt;br /&gt;    str = ""&lt;br /&gt;    do while not rs.eof&lt;br /&gt;        val = rs(col)&lt;br /&gt;        if InStr(1, val, signature) &amp;gt; 0 then&lt;br /&gt;            rs(col) = replace(val, full_signature, "")&lt;br /&gt;            rs.Update()&lt;br /&gt;            count = count + 1&lt;br /&gt;        end if&lt;br /&gt;        rs.MoveNext()&lt;br /&gt;    loop&lt;br /&gt;    if count &amp;gt; 0 then&lt;br /&gt;        str = "&amp;lt;font color='red'&amp;gt;CLEANED " &amp;amp; count &amp;amp; " rows infected&amp;lt;/font&amp;gt;" &amp;amp; str&lt;br /&gt;        cleanTblColumn = str&lt;br /&gt;    else&lt;br /&gt;        cleanTblColumn = ""&lt;br /&gt;    end if&lt;br /&gt;&lt;br /&gt;    call rs.close()&lt;br /&gt;    set rs = nothing&lt;br /&gt;    call db.close()&lt;br /&gt;    set db = nothing&lt;br /&gt;end function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function encodeStr(s)&lt;br /&gt;    s = replace(s, "&amp;lt;", "&amp;amp;lt;")&lt;br /&gt;    s = replace(s, "&amp;gt;", "&amp;amp;gt;")&lt;br /&gt;    encodeStr = s&lt;br /&gt;end function&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;BTW, this is &lt;a href="http://en.wikipedia.org/wiki/SQL_injection"&gt;a wiki article on SQL injection&lt;/a&gt;. Search on google for SQL injection would bring up much more articles. Good and important to know for web developers, for security concern.&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-678751931242820971?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/678751931242820971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=678751931242820971' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/678751931242820971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/678751931242820971'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/10/sql-injection-hack.html' title='SQL Injection Attack'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4465672989595201863</id><published>2010-09-16T19:57:00.000-07:00</published><updated>2010-09-16T20:10:43.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JEE'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>Book: Apache Jakarta and Beyond</title><content type='html'>Book: &lt;a href="http://www.amazon.com/Apache-Jakarta-Beyond-Programmers-Introduction/dp/0321237714/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1284692321&amp;sr=1-1"&gt;Apache Jakarta and Beyond - A Java programmer's introduction&lt;/a&gt;. By Larne Pekowsky. ISBN 0-321-23771-4 QA76.73.J38P44 2004. 2005.&lt;br /&gt;&lt;br /&gt;This book introduces a series of Jakarta tools to be used by Java programmers. Including:&lt;pre&gt;&lt;br /&gt;- Ant&lt;br /&gt;- Eclipse&lt;br /&gt;- Testing with JUnit&lt;br /&gt;- Testing web sites with HTTPUnit&lt;br /&gt;- Further web testing with Jakarta Cactus&lt;br /&gt;- Stress Testing with Jakarta JMeter&lt;br /&gt;- Simplifying Bean Development with BeanUtils&lt;br /&gt;- Traversing Hierarchical Data with JXPath&lt;br /&gt;- Database tools: &lt;br /&gt;  Hsqldb, DBCP, OJB&lt;br /&gt;- Logging&lt;br /&gt;  - Java.util.logging&lt;br /&gt;  - Log4j&lt;br /&gt;- Configuring program options&lt;br /&gt;  - Jakarta CLI (Command-Line Interface)&lt;br /&gt;  - Jakarta Digester (XML-based: object stack, element matching patterns, processing rules)&lt;br /&gt;- Working with Text 1: Regular Expressions&lt;br /&gt;- Working with Text 2: Searching  &lt;br /&gt;- Creating office documents with POI&lt;br /&gt;- Scripting&lt;br /&gt;- Tomcat&lt;br /&gt;- The standard tag library&lt;br /&gt;- Struts: application toolkit/web application framework&lt;br /&gt;- Cocoon: provides a complete XML-based publishing suite, for the generation, manipulation and rendering of XML.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4465672989595201863?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4465672989595201863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4465672989595201863' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4465672989595201863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4465672989595201863'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/09/apache-jakarta-and-beyond.html' title='Book: Apache Jakarta and Beyond'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-88982645087926311</id><published>2010-08-25T13:51:00.000-07:00</published><updated>2010-08-25T15:08:52.766-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Design patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>Design Patterns</title><content type='html'>Design Patterns - Elements of Reusable Object-Oriented Software. This is a classical book. &lt;a href="http://mags.acm.org/communications/201007?pg=17#pg17"&gt;The authors won ACM 2010 SIGSOFT outstanding research award&lt;/a&gt; for their contribution to software engineering for. The four authors are classed the GoF (Gang of Four). The design patterns in their book is called the GoF patterns.&lt;br /&gt;&lt;br /&gt;Design patterns are solutions abstracted from repeatedly occurring design problems and can be reused in similar situations. Each has a pattern name, associated problem, solution and consequence.&lt;br /&gt;&lt;br /&gt;Some design patterns are bounded to languages features, so is easier to implement in some languages than the others. For example, the Template pattern is easy to do in C++ and Java, since C++ provides template and Java provides generics.&lt;br /&gt;&lt;br /&gt;In this book, designed patterns are divided into 3 categories based on purpose. The following notes are extracted from the book.&lt;br /&gt;&lt;br /&gt;A. Creational&lt;br /&gt;&lt;br /&gt;Class: &lt;br /&gt;&lt;br /&gt;1. Factory method&lt;br /&gt;Define an interface for creating an object, but let subclasses decide which class to instantiate. It lets a class defer instantiation to subclasses.&lt;br /&gt;&lt;br /&gt;Object:&lt;br /&gt;&lt;br /&gt;2. Abstract Factory&lt;br /&gt;Provide an interface for creating families of related or dependent objects w/o specifying their concrete classes.&lt;br /&gt;&lt;br /&gt;Isn't this the interface concept in C++/Java? Obviously it's related to polymorphism.&lt;br /&gt;&lt;br /&gt;3. Builder&lt;br /&gt;Separate the construction of a complex object from its representation so that the same construction process can create different representations. &lt;br /&gt;&lt;br /&gt;4. Prototype&lt;br /&gt;Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.&lt;br /&gt;&lt;br /&gt;5. Singleton&lt;br /&gt;Ensure a class only has one instance, and provide a global point of access to it.&lt;br /&gt;&lt;br /&gt;B. Structural&lt;br /&gt;&lt;br /&gt;Class:&lt;br /&gt;&lt;br /&gt;6. Adapter (class)&lt;br /&gt;Convert the interface of a class into another interface clients expect. It lets classes work together that couldn't otherwise because of incompatible interfaces.&lt;br /&gt;&lt;br /&gt;Object:&lt;br /&gt;&lt;br /&gt;7. Adapter (object)&lt;br /&gt;&lt;br /&gt;8. Bridge&lt;br /&gt;Decouple an abstraction from its implementation so that the two can vary independently.&lt;br /&gt;&lt;br /&gt;This is the abstraction and encapsulation principles of OOP.&lt;br /&gt;&lt;br /&gt;9. Composite&lt;br /&gt;Compose objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly.&lt;br /&gt;&lt;br /&gt;OOP uses inheritance for IS-A relationship, and uses composition for HAS-A relationship.&lt;br /&gt;&lt;br /&gt;10. Decorator&lt;br /&gt;Attach additional responsibilities to an object dynamically. It provides a flexible alternative to subclassing for extending functionality.&lt;br /&gt;&lt;br /&gt;11. Facade&lt;br /&gt;Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.&lt;br /&gt;&lt;br /&gt;12. Flyweight&lt;br /&gt;Use sharing to support large numbers of fine-grained objects efficiently.&lt;br /&gt;&lt;br /&gt;13. Proxy&lt;br /&gt;Provide a surrogate or placeholder for another object to control access to it.&lt;br /&gt;&lt;br /&gt;C. Behavioral&lt;br /&gt;&lt;br /&gt;Class:&lt;br /&gt;&lt;br /&gt;14. Interpreter&lt;br /&gt;Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.&lt;br /&gt;&lt;br /&gt;Sounds related to compiler/interpreter.&lt;br /&gt;&lt;br /&gt;15. Template method&lt;br /&gt;Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm w/o changing the algorithm's structure.&lt;br /&gt;&lt;br /&gt;Object:&lt;br /&gt;&lt;br /&gt;16. Chain of Responsibility&lt;br /&gt;Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.&lt;br /&gt;&lt;br /&gt;One example to this is to catch a series of exceptions in C++/Java.&lt;br /&gt;&lt;br /&gt;17. Command&lt;br /&gt;Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.&lt;br /&gt;&lt;br /&gt;18. Iterator&lt;br /&gt;Provide a way to access the elements of an aggregate object sequentially w/o exposing its underlying representation. &lt;br /&gt;&lt;br /&gt;This occurs abundantly in C++/Java.&lt;br /&gt;&lt;br /&gt;19. Mediator&lt;br /&gt;Define an object that encapsulates how a set of objects interact. It promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.&lt;br /&gt;&lt;br /&gt;20. Memento&lt;br /&gt;W/o violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.&lt;br /&gt;&lt;br /&gt;21. Observer&lt;br /&gt;Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.&lt;br /&gt;&lt;br /&gt;For example, Java uses wait(), notify() and notifyAll() methods for threads communication.&lt;br /&gt;&lt;br /&gt;22. State&lt;br /&gt;Allow an object to alter its behavior when its internal state changes. It will appear to change it class.&lt;br /&gt;&lt;br /&gt;One example for this is the workflow state management as in my work.&lt;br /&gt;&lt;br /&gt;23. Strategy&lt;br /&gt;Define a family of algorithms, encapsulate each one, and make them interchangeable. It lets the algorithm vary independently from clients that use it.&lt;br /&gt;&lt;br /&gt;24. Visitor&lt;br /&gt;Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation w/o changing the classes of the elements on which it operates. &lt;br /&gt;&lt;br /&gt;The famous MVC is not included in list because it's a combination of multiple patterns. Use Smalltalk MVC as an example. The VC relationship uses the Strategy pattern. MVC also uses Factory method to specify the default controller class for a view, and Decorator pattern to add scrolling to a view.&lt;br /&gt;&lt;br /&gt;A new comer at OOD can start with the simplest and most common patterns:&lt;br /&gt;Creational: Abstract Factory, Factory&lt;br /&gt;Structural: Adapter, Composite, Decorator&lt;br /&gt;Behavioral: Observer, Strategy, Template(! Yeah, this is behavioral, not structural)&lt;br /&gt;&lt;br /&gt;Seems like I already had experience with at least these design patterns:&lt;br /&gt;Creational: Singleton, Factory&lt;br /&gt;Structural: Adapter, Bridge, Composite&lt;br /&gt;Behavioral: Interpreter, Template, Chain of Responsibility, Iterator, Observer, State&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612"&gt;Amazon: Design patterns&lt;/a&gt;. By Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. QA 76.64 .D47 1994.&lt;br /&gt;[2] &lt;a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29"&gt;Wiki - design patterns&lt;/a&gt;. Short but comprehensive list of design patterns from different sources.&lt;br /&gt;[3] &lt;a href="http://www.dofactory.com/Patterns/Patterns.aspx"&gt;Design pattern implementation in C# and VB.NET&lt;/a&gt;. Good link with real code examples. E.g., load balancer using the Singleton pattern.&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-88982645087926311?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/88982645087926311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=88982645087926311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/88982645087926311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/88982645087926311'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/design-patterns.html' title='Design Patterns'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5740873489837101986</id><published>2010-08-24T20:17:00.000-07:00</published><updated>2010-08-24T20:55:51.820-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web application'/><category scheme='http://www.blogger.com/atom/ns#' term='Experience'/><title type='text'>Tips on IMS development</title><content type='html'>Here are some tips on information management system web application development from my work. Most are platform independent and can be easily applied to different platforms and technologies. They can also be applied to non-web applications, and are actually general design tips.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Menu. The menu can be dynamically generated from database. This allows flexible configuration and update. If there are multiple roles, each can be configured to draw from the pool of menu items. For this first get a javascript menu template, then create it dynamically. For better performance and void regenerate it each time, such menu can be generated once at creation time, then be stored for later use.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Roles and permissions. There can be many roles. The permission can be configured this way: for each item that needs permission control, say we need read/write/delete, then can use a string such as "742172". Here each digit stands for the permission setting of one role. The value of a digit is the combined sum of 4/2/1, which stands for read/write/delete, similar to unix.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Workflow. A table can be used for this, which records stage and stage transition settings. Each role may have different permissions at different stages. Such a table can easily store these information.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Email. If there are emails to be sent, an admin interface can be provided to configure the subject, body and other fields of emails. For specific information, provide some macros that the administrator can use, which will be replaced by program later.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;HTML Form. Can create a self-defined framework, instead of using that of such as .NET's control. This allows more flexibility, and can be more efficient since .NET's control may keep more information than necessary. To store the state/parameters, such as when you need to ask for confirmation of user, use hidden HTML control.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;HTML Form fields. The form fields settings can be managed in the database. So there is no need to go to code for update. Everything can be configured from database. Like label management below, adding a new field can automatically insert itself to a table in database with default settings. Given each form and each form field (if needed) a class name, and control display properties from CSS.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Label management. An admin interface can be provided for this. When a tag is put on a page, it can automatically check if it's in database already, if not then insert itself in as a unique tag name. This allows domain experts to change it, and frees programmers from such ad-hoc, trivial but time-consuming and distracting chores.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;The use of coding. Any systematic categorizing paradigms can be implemented by coding for ease of control and ease of versioning. Say we can use the starting code of 001 to stand for version 1, 002 to stand for version 2, etc. This can apply to many things and is highly useful. &lt;br /&gt;&lt;br /&gt;&lt;li&gt;Use classes as much as possible, decouple business logic from interface files.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5740873489837101986?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5740873489837101986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5740873489837101986' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5740873489837101986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5740873489837101986'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/some-tips-on-ims-development.html' title='Tips on IMS development'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5488874005933706846</id><published>2010-08-22T15:42:00.000-07:00</published><updated>2010-08-27T03:09:50.331-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>Computer Systems: A Programmer’s Perspective</title><content type='html'>&lt;a href="http://www.amazon.com/Computer-Systems-Programmers-Perspective-2nd/dp/0136108040/"&gt;Computer Systems: A Programmer’s Perspective&lt;/a&gt;. 1st edition (August 23, 2002). 2nd edition (February 14, 2010). By R. E. Bryant, D. R. O’Hallaron.&lt;br /&gt;&lt;br /&gt;This books introduces computer systems in a broad way, including operating system, architecture, compiler, network and more. It is a good reference for system programmers to improve their understanding on computer systems and improve programming skills.&lt;br /&gt;&lt;pre&gt;Chapter 1. Introduction&lt;br /&gt;&lt;br /&gt;- Compilation&lt;br /&gt;- Processors Read and Interpret Instructions Stored in Memory&lt;br /&gt;  Hardware Organization of a System.&lt;br /&gt;- Cache&lt;br /&gt;  - cache hierarchy (registers, on-chip L1 cache, off-chip L2 cache, memory, local disk, remote storage)&lt;br /&gt;- OS: process, thread, virtual memory, files&lt;br /&gt;- Inter system communication by network.&lt;br /&gt;&lt;br /&gt;Part I Program Structure and Execution&lt;br /&gt;&lt;br /&gt;Chapter 2 Representing and Manipulating Information&lt;br /&gt;Chapter 3 Machine-Level Representation of C Programs&lt;br /&gt;Chapter 4 Processor Architecture &lt;br /&gt;&lt;br /&gt;Chapter 5 Optimizing Program Performance&lt;br /&gt;&lt;br /&gt;5.1 Capabilities and Limitations of Optimizing Compilers&lt;br /&gt;5.2 Expressing Program Performance&lt;br /&gt;5.3 Program Example&lt;br /&gt;5.4 Eliminating Loop Inefficiencies&lt;br /&gt;5.5 Reducing Procedure Calls&lt;br /&gt;5.6 Eliminating Unneeded Memory References&lt;br /&gt;5.7 Understanding Modern Processors&lt;br /&gt;5.7.1 Overall Operation&lt;br /&gt;5.7.2 Functional Unit Performance&lt;br /&gt;5.7.3 A Closer Look at Processor Operation&lt;br /&gt;- Translating Instructions into Operations&lt;br /&gt;- Processing of Operations by the Execution Unit&lt;br /&gt;- Scheduling of Operations with Unlimited Resources&lt;br /&gt;- Scheduling of Operations with Resource Constraints&lt;br /&gt;5.8 Reducing Loop Overhead&lt;br /&gt;5.9 Converting to Pointer Code&lt;br /&gt;5.10 Enhancing Parallelism&lt;br /&gt;5.10.1 Loop Splitting&lt;br /&gt;5.10.2 Register Spilling&lt;br /&gt;5.10.3 Limits to Parallelism&lt;br /&gt;5.11 Putting it Together: Summary of Results for Optimizing Combining Code&lt;br /&gt;5.11.1 Floating-Point Performance Anomaly&lt;br /&gt;5.11.2 Changing Platforms&lt;br /&gt;5.12 Branch Prediction and Misprediction Penalties&lt;br /&gt;5.13 Understanding Memory Performance&lt;br /&gt;5.13.1 Load Latency&lt;br /&gt;5.13.2 Store Latency&lt;br /&gt;5.14 Life in the Real World: Performance Improvement Techniques&lt;br /&gt;5.15 Identifying and Eliminating Performance Bottlenecks&lt;br /&gt;5.15.1 Program Profiling&lt;br /&gt;5.15.2 Using a Profiler to Guide Optimization&lt;br /&gt;5.15.3 Amdahl’s Law&lt;br /&gt;5.16 Summary&lt;br /&gt;&lt;br /&gt;Chapter 6 The Memory Hierarchy&lt;br /&gt;&lt;br /&gt;- A memory system is a hierarchy of storage devices with different capacities, costs, and access times.&lt;br /&gt;- SRAM, DRAM, disk. &lt;br /&gt;- Storage technologies&lt;br /&gt;  - Random-access memory&lt;br /&gt;    - SRAM - bistable memory cell.&lt;br /&gt;    - DRAM - capacitors.&lt;br /&gt;    - Nonvolatile memory: ROM, PROM, EPROM, EEPROM.&lt;br /&gt;    - Accessing main memory.&lt;br /&gt;  - Disk storage&lt;br /&gt;    - geometry, capacity, operation (seek time, rotational latency, transfer time),&lt;br /&gt;      logical disk blocks, accessing disks&lt;br /&gt;  - Storage technology trends.&lt;br /&gt;    - price/performance trade-off&lt;br /&gt;- Locality: temporal/spatial locality.&lt;br /&gt;  - Locality of references to program data.&lt;br /&gt;  - Locality of Instruction Fetches.&lt;br /&gt;  - Summary&lt;br /&gt;- The memory hierarchy&lt;br /&gt;  + Different storage technologies have widely different access times.&lt;br /&gt;  + Well-written programs tend to exhibit good locality.&lt;br /&gt;  - Caching in the Memory Hierarchy&lt;br /&gt;    - Cache hits&lt;br /&gt;    - Cache misses&lt;br /&gt;    - Cache Management&lt;br /&gt;  - Summary of Memory Hierarchy Concepts&lt;br /&gt;    - Exploiting temporal/spatial locality&lt;br /&gt;- Cache Memories&lt;br /&gt;  - CPU registers, L1 cache, L2 cache, main DRAM memory, and disk storage&lt;br /&gt;- Writing Cache-friendly Code&lt;br /&gt;  + Make the common case go fast.&lt;br /&gt;  + Minimize the number of cache misses in each inner loop.&lt;br /&gt;- Putting it Together: The Impact of Caches on Program Performance&lt;br /&gt;  - The Memory Mountain&lt;br /&gt;  - Rearranging Loops to Increase Spatial Locality&lt;br /&gt;  - Using Blocking to Increase Temporal Locality&lt;br /&gt;- Summary&lt;br /&gt;&lt;br /&gt;Part II Running Programs on a System &lt;br /&gt;&lt;br /&gt;Chapter 7 Linking&lt;br /&gt;Chapter 8 Exceptional Control Flow&lt;br /&gt;Chapter 9 Measuring Program Execution Time&lt;br /&gt;&lt;br /&gt;Chapter 10 Virtual Memory&lt;br /&gt;&lt;br /&gt;10.1 Physical and Virtual Addressing&lt;br /&gt;10.2 Address Spaces&lt;br /&gt;10.3 VM as a Tool for Caching&lt;br /&gt;+ Set of virtual pages: Unallocated/Cached/Uncached&lt;br /&gt;10.3.1 DRAM Cache Organization&lt;br /&gt;10.3.2 Page Tables&lt;br /&gt;10.3.3 Page Hits&lt;br /&gt;10.3.4 Page Faults&lt;br /&gt;10.3.5 Allocating Pages&lt;br /&gt;10.3.6 Locality to the Rescue Again&lt;br /&gt;10.4 VM as a Tool for Memory Management&lt;br /&gt;10.4.1 Simplifying Linking&lt;br /&gt;10.4.2 Simplifying Sharing&lt;br /&gt;10.4.3 Simplifying Memory Allocation&lt;br /&gt;10.4.4 Simplifying Loading&lt;br /&gt;10.5 VM as a Tool for Memory Protection&lt;br /&gt;10.6 Address Translation&lt;br /&gt;10.6.1 Integrating Caches and VM&lt;br /&gt;10.6.2 Speeding up Address Translation with a TLB&lt;br /&gt;10.6.3 Multi-level Page Tables&lt;br /&gt;10.6.4 Putting it Together: End-to-end Address Translation&lt;br /&gt;10.7 Case Study: The Pentium/Linux Memory System&lt;br /&gt;10.8 Memory Mapping&lt;br /&gt;10.8.1 Shared Objects Revisited&lt;br /&gt;10.8.2 The fork Function Revisited&lt;br /&gt;10.8.3 The execve Function Revisited&lt;br /&gt;10.8.4 User-level Memory Mapping with the mmap Function&lt;br /&gt;10.9 Dynamic Memory Allocation&lt;br /&gt;10.9.1 The malloc and free Functions&lt;br /&gt;10.9.2 Why Dynamic Memory Allocation?&lt;br /&gt;10.9.3 Allocator Requirements and Goals&lt;br /&gt;- Requirements:&lt;br /&gt;  - Handling arbitrary request sequences&lt;br /&gt;  - Making immediate responses to requests&lt;br /&gt;  - Using only the heap.&lt;br /&gt;  - Aligning blocks (alignment requirement).&lt;br /&gt;  - Not modifying allocated blocks.&lt;br /&gt;- Goals:&lt;br /&gt;  - Goal 1: Maximizing throughput.&lt;br /&gt;  - Goal 2: Maximizing memory utilization.&lt;br /&gt;10.9.4 Fragmentation&lt;br /&gt;- internal fragmentation: &lt;br /&gt;  occurs when an allocated block is larger than the payload.&lt;br /&gt;  e.g. to satisfy memory alignment.&lt;br /&gt;- external fragmentation: &lt;br /&gt;  there is enough aggregate free memory to satisfy an &lt;br /&gt;  allocate request, but no single free block is large enough&lt;br /&gt;- External fragmentation is much more difficult to quantify than internal&lt;br /&gt;  fragmentation&lt;br /&gt;10.9.5 Implementation Issues&lt;br /&gt;10.9.6 Implicit Free Lists&lt;br /&gt;10.9.7 Placing Allocated Blocks&lt;br /&gt;10.9.8 Splitting Free Blocks&lt;br /&gt;10.9.9 Getting Additional Heap Memory&lt;br /&gt;10.9.10 Coalescing Free Blocks&lt;br /&gt;10.9.11 Coalescing with Boundary Tags&lt;br /&gt;10.9.12 Putting it Together: Implementing a Simple Allocator&lt;br /&gt;10.9.13 Explicit Free Lists&lt;br /&gt;10.9.14 Segregated Free Lists&lt;br /&gt;10.10 Garbage Collection&lt;br /&gt;10.10.1 Garbage Collector Basics&lt;br /&gt;- A garbage collector views memory as a directed reachability graph.&lt;br /&gt;- The nodes of the graph are partitioned into 1) root nodes and 2) heap nodes.&lt;br /&gt;10.10.2 Mark&amp;Sweep Garbage Collectors&lt;br /&gt;10.10.3 Conservative Mark&amp;Sweep for C Programs&lt;br /&gt;10.11 Common Memory-related Bugs in C Programs&lt;br /&gt;10.11.1 Dereferencing Bad Pointers&lt;br /&gt;10.11.2 Reading Uninitialized Memory&lt;br /&gt;10.11.3 Allowing Stack Buffer Overflows&lt;br /&gt;10.11.4 Assuming that Pointers and the Objects they Point to Are the Same Size&lt;br /&gt;10.11.5 Making Off-by-one Errors&lt;br /&gt;10.11.6 Referencing a Pointer Instead of the Object it Points to&lt;br /&gt;10.11.7 Misunderstanding Pointer Arithmetic&lt;br /&gt;10.11.8 Referencing Non-existent Variables&lt;br /&gt;10.11.9 Referencing Data in Free Heap Blocks&lt;br /&gt;10.11.10 Introducing Memory Leaks&lt;br /&gt;10.12 Summary&lt;br /&gt;&lt;br /&gt;Part III Interaction and Communication Between Programs&lt;br /&gt;&lt;br /&gt;Chapter 11 Concurrent Programming with Threads&lt;br /&gt;&lt;br /&gt;- A thread is a unit of execution, associated with a process, with its own &lt;br /&gt;  thread ID, stack, stack pointer, program counter, condition codes, and &lt;br /&gt;  general-purpose registers.&lt;br /&gt;11.1 Basic Thread Concepts&lt;br /&gt;- process context: 1) program context, 2) kernel context.&lt;br /&gt;11.2 Thread Control&lt;br /&gt;- Pthreads defines about 60 functions&lt;br /&gt;11.2.1 Creating Threads&lt;br /&gt;11.2.2 Terminating Threads&lt;br /&gt;11.2.3 Reaping Terminated Threads&lt;br /&gt;11.2.4 Detaching Threads&lt;br /&gt;11.3 Shared Variables in Threaded Programs&lt;br /&gt;11.3.1 Threads Memory Model&lt;br /&gt;11.3.2 Mapping Variables to Memory&lt;br /&gt;11.3.3 Shared Variables&lt;br /&gt;11.4 Synchronizing Threads with Semaphores&lt;br /&gt;11.4.1 Sequential Consistency&lt;br /&gt;11.4.2 Progress Graphs&lt;br /&gt;11.4.3 Protecting Shared Variables with Semaphores&lt;br /&gt;11.4.4 Posix Semaphores&lt;br /&gt;11.4.5 SignalingWith Semaphores&lt;br /&gt;11.5 Synchronizing Threads with Mutex and Condition Variables&lt;br /&gt;11.5.1 Mutex Variables&lt;br /&gt;11.5.2 Condition Variables&lt;br /&gt;11.5.3 Barrier Synchronization&lt;br /&gt;11.5.4 Timeout Waiting&lt;br /&gt;11.6 Thread-safe and Reentrant Functions&lt;br /&gt;- A function is thread-safe if and only if it will always produce correct results &lt;br /&gt;  when called repeatedly within multiple concurrent threads.&lt;br /&gt;- Four (non-disjoint) classes of thread-unsafe functions:&lt;br /&gt;  1) Failing to protect shared variables.&lt;br /&gt;  2) Relying on state across multiple function invocations.&lt;br /&gt;  3) Returning a pointer to a static variable.&lt;br /&gt;  4) Calling thread-unsafe functions.&lt;br /&gt;11.6.1 Reentrant Functions&lt;br /&gt;- Property: do not reference any shared data when called by multiple threads.&lt;br /&gt;- Reentrant functions are typically more efficient than non-reentrant&lt;br /&gt;  thread-safe functions because they require no synchronization operations.&lt;br /&gt;- Reentrant functions is a subset of thread-safe functions.&lt;br /&gt;11.6.2 Thread-safe Library Functions&lt;br /&gt;11.7 Other Synchronization Errors&lt;br /&gt;11.7.1 Races&lt;br /&gt;11.7.2 Deadlocks&lt;br /&gt;11.8 Summary&lt;br /&gt;&lt;br /&gt;Chapter 12 Network Programming&lt;br /&gt;&lt;br /&gt;12.1 Client-Server Programming Model&lt;br /&gt;- The fundamental operation in the client-server model is the transaction.&lt;br /&gt;12.2 Networks&lt;br /&gt;12.3 The Global IP Internet&lt;br /&gt;12.3.1 IP Addresses&lt;br /&gt;12.3.2 Internet Domain Names&lt;br /&gt;12.3.3 Internet Connections&lt;br /&gt;12.4 Unix file I/O&lt;br /&gt;12.4.1 The read and write Functions&lt;br /&gt;12.4.2 Robust File I/OWith the readn and writen Functions&lt;br /&gt;12.4.3 Robust Input of Text Lines Using the readline Function&lt;br /&gt;12.4.4 The stat Function&lt;br /&gt;12.4.5 The dup2 Function&lt;br /&gt;12.4.6 The close Function&lt;br /&gt;12.4.7 Other Unix I/O Functions&lt;br /&gt;12.4.8 Unix I/O vs. Standard I/O&lt;br /&gt;12.5 The Sockets Interface&lt;br /&gt;12.5.1 Socket Address Structures&lt;br /&gt;12.5.2 The socket Function&lt;br /&gt;12.5.3 The connect Function&lt;br /&gt;12.5.4 The bind Function&lt;br /&gt;12.5.5 The listen Function&lt;br /&gt;12.5.6 The accept Function&lt;br /&gt;12.5.7 Example Echo Client and Server&lt;br /&gt;12.6 Concurrent Servers&lt;br /&gt;12.6.1 Concurrent Servers Based on Processes&lt;br /&gt;12.6.2 Concurrent Servers Based on Threads&lt;br /&gt;12.7 Web Servers&lt;br /&gt;12.7.3 HTTP Transactions&lt;br /&gt;12.8 Putting it Together: The TINY Web Server&lt;br /&gt;12.9 Summary&lt;br /&gt;&lt;br /&gt;Appendix A Error handling&lt;br /&gt;Appendix B Solutions to Practice Problems&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5488874005933706846?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5488874005933706846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5488874005933706846' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5488874005933706846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5488874005933706846'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/computer-systems-programmers.html' title='Computer Systems: A Programmer’s Perspective'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6409824574976671863</id><published>2010-08-20T18:52:00.000-07:00</published><updated>2010-08-20T19:01:34.170-07:00</updated><title type='text'>memcached</title><content type='html'>Memcached - distributed key-value pair memory caching system. Very easy to use.&lt;br /&gt;&lt;br /&gt;Download:&lt;br /&gt;- &lt;a href="http://memcached.org/"&gt;http://memcached.org/&lt;/a&gt;: C source code.&lt;br /&gt;- &lt;a href="http://www.northscale.com/"&gt;NorthScale Membase server - based on memcached&lt;/a&gt;: server for various platforms. Clients can be C, .NET, Java, Perl, PHP, Ruby.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6409824574976671863?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6409824574976671863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6409824574976671863' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6409824574976671863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6409824574976671863'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/memcached.html' title='memcached'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6212068639249844921</id><published>2010-08-18T21:54:00.000-07:00</published><updated>2010-08-22T20:37:53.071-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JEE'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Web application'/><title type='text'>JEE</title><content type='html'>It's been some time since I used J2EE in class. Well it's called JEE nowadays. Today reviewed JEE tools.&lt;br /&gt;&lt;pre&gt;Tutorials: &lt;br /&gt;- &lt;a href="http://static.springsource.org/docs/Spring-MVC-step-by-step/"&gt;Spring Tutorial&lt;/a&gt;. (Took about 5 hours to finish, spreaded into 3 days)&lt;br /&gt;- &lt;a href="http://www.roseindia.net/hibernate/index.shtml"&gt;Hibernate Tutorial&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html"&gt;Maven Tutorial&lt;/a&gt;. (Took half an hour to finish)&lt;br /&gt;- &lt;a href="http://www.roseindia.net/maven2/"&gt;Another Maven Tutorial&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://download.oracle.com/javaee/5/tutorial/doc/"&gt;Oracle's JEE 5 tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The environment is:&lt;br /&gt;- OS: Windows XP&lt;br /&gt;- Java: 1.60&lt;br /&gt;- Ant: 1.7 (http://ant.apache.org/manual/index.html)&lt;br /&gt;  [Need to setup environment variables ANT_HOME and Java_HOME]&lt;br /&gt;- Apache Tomcat: 6.0.29 (http://tomcat.apache.org/download-60.cgi#6.0.29)&lt;br /&gt;  Install as a service. (32-bit/64-bit Windows Service Installer). Use port 8080.&lt;br /&gt;  Local site: http://localhost:8080&lt;br /&gt;  Homepage root is: $CATALINA_HOME/webapps/ROOT/index.html&lt;br /&gt;  $CATALINA_HOME is installation site of Tomcat.&lt;br /&gt;- Spring: 2.5.0&lt;br /&gt;  Most recent version is at http://www.springsource.org/download&lt;br /&gt;  But I need version 2.5.0, which can be downloaded from &lt;br /&gt;  https://olex.openlogic.com/packages/spring&lt;br /&gt;  This contains many other utilities. The most recent version package does not.&lt;br /&gt;- Maven: 2.2.1. Obtained &lt;a href="http://maven.apache.org/download.html"&gt;here&lt;/a&gt;. [Need to set up M2_HOME]&lt;br /&gt;- Eclipse: Java EE IDE for web developers. (http://www.eclipse.org/downloads/)&lt;br /&gt;&lt;br /&gt;A little note:&lt;br /&gt;- &lt;a href="http://static.springsource.org/docs/Spring-MVC-step-by-step/part5.html"&gt;Step 5.5&lt;/a&gt; code for JdbcProductDaoTests.java should include the following two imports to function:&lt;br /&gt;  import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;&lt;br /&gt;  import springapp.domain.Product;&lt;br /&gt;  Here the first imported class is in library spring-test.jar. &lt;br /&gt;  If eclipse can't find this then manually add it to properties-&gt;Java Build Path-&gt;Libraries.&lt;br /&gt;&lt;br /&gt;Some concepts:&lt;br /&gt;- SSH: Struts, Spring, Hibernate.&lt;br /&gt;- EJB3.0+struts2+iBATIS&lt;br /&gt;- jsp+Servlet+jdbc is the basics for all Java frameworks.&lt;br /&gt;- jQuery: light-weighted javascript framework.&lt;br /&gt;- Dojo, extjs: javascript frameworks. Used with JSF.&lt;br /&gt;- SOA: Service Oriented Application&lt;br /&gt;- &lt;a href="http://lucene.apache.org/java/docs/index.html"&gt;Apache lucene&lt;/a&gt;: text search engine library written in Java&lt;br /&gt;- &lt;a href="http://nutch.apache.org/"&gt;Nutch&lt;/a&gt;: Open-source web-search software, built on Lucene Java.&lt;br /&gt;- &lt;a href="http://www.opensymphony.com/webwork/"&gt;Webwork&lt;/a&gt;: Java web-application development framework.&lt;br /&gt;- NoSQL&lt;br /&gt;- Local search. e.g. &lt;a href="http://foursquare.com/"&gt;foursquare&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Some thoughts so far:&lt;br /&gt;- A lot of work for simple application in Spring.&lt;br /&gt;- JEE tools apply software engineering concepts, that may be the reason &lt;br /&gt;  it's said to be suitable for large web application development. On the &lt;br /&gt;  other hand this makes it heavy-weighted. Setup environment and getting &lt;br /&gt;  familiar with the tools cost lots of time. On this, .NET, PHP, ASP are&lt;br /&gt;  easier to catch up.&lt;br /&gt;- Eclipse eats big memory (over 200MB). &lt;br /&gt;- Maven is like Ant.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6212068639249844921?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6212068639249844921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6212068639249844921' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6212068639249844921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6212068639249844921'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/j2ee.html' title='JEE'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2112384569014982176</id><published>2010-08-12T01:57:00.000-07:00</published><updated>2010-08-12T02:02:07.611-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C/C++'/><category scheme='http://www.blogger.com/atom/ns#' term='CGI'/><title type='text'>CGI in C</title><content type='html'>Write CGI in C was a primitive idea. It's nonetheless interesting to know how it works.&lt;br /&gt;&lt;br /&gt;It can be done by renaming the compiled executable with the suffix .cgi (this suffix needs be setup in Apache config file). Then put this into the server's cgi-bin folder. Visit http://server/cgi-bin/*.cgi should do. &lt;br /&gt;&lt;br /&gt;See this short introduction on &lt;a href="http://www.cs.tut.fi/~jkorpela/forms/cgic.html"&gt;Getting Started with CGI Programming in C&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2112384569014982176?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2112384569014982176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2112384569014982176' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2112384569014982176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2112384569014982176'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/cgi-in-c.html' title='CGI in C'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-188552021538852961</id><published>2010-08-12T01:19:00.000-07:00</published><updated>2010-09-03T19:47:41.573-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>Ruby on Rails</title><content type='html'>Tried Ruby on Rails. Ruby was released in 1995. Rails was released in 2005.&lt;br /&gt;&lt;br /&gt;First is to setup the system. I tried it on Centos.&lt;br /&gt;&lt;br /&gt;1) Install Ruby.&lt;br /&gt;&lt;br /&gt;Download Ruby, extract zipped file, configure, make, make install. Now have this:&lt;br /&gt;[root@localhost]# ruby -v&lt;br /&gt;ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]&lt;br /&gt;&lt;br /&gt;The ruby binary is in /usr/local/bin, which is not on path now. &lt;br /&gt;So edit /etc/profile, add:&lt;br /&gt;&lt;pre&gt;if [ "$EUID" = "0" ]; then&lt;br /&gt;        pathmunge /sbin&lt;br /&gt;        pathmunge /usr/sbin&lt;br /&gt;        pathmunge /usr/local/sbin&lt;br /&gt;        pathmunge /usr/local/bin # &lt;-- add this path for all users&lt;br /&gt;fi  &lt;/pre&gt;&lt;br /&gt;2) Install RubyGems, which is a package manager for Ruby.&lt;br /&gt;&lt;br /&gt;# Go to http://rubygems.org/ to find the link to the latest version.&lt;br /&gt;wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz&lt;br /&gt;tar -xvf rubygems-1.3.7.tgz&lt;br /&gt;cd rubygems-1.3.7&lt;br /&gt;ruby setup.rb&lt;br /&gt;gems update --system&lt;br /&gt;&lt;br /&gt;3) Install Rails&lt;br /&gt;gem install rails --include-dependencies&lt;br /&gt;# Rails 2.3.8 is now installed.&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Enable Ruby CGI on Apache &lt;font color='#000000'&gt;[9/3/2010]&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;To enable a web directory for ruby cgi is the same as doing so for others.&lt;br /&gt;Say the directory to enable is /var/www/html/ror, &lt;br /&gt;add the following to Apache's conf.d file:&lt;br /&gt;&amp;lt;Directory /var/www/html/ror&amp;gt;&lt;br /&gt;  Options +ExecCGI&lt;br /&gt;  AddHandler cgi-script .rb&lt;br /&gt;&amp;lt;/Directory&amp;gt;&lt;br /&gt;&lt;br /&gt;Alternatively, copy/paste the ruby file to cgi-bin folder.&lt;br /&gt;&lt;br /&gt;Don't forget to include "#![ruby path]" as the first line in the script file.&lt;br /&gt;Also set the permission to allow execute: chmod 755 *.rb&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;These are online resources:&lt;ul&gt;&lt;li&gt;Installation guide: &lt;br /&gt;&lt;a href="http://rubyonrails.org/download"&gt;http://rubyonrails.org/download&lt;/a&gt;&lt;br /&gt;&lt;li&gt;Top 12 Ruby on Rails Tutorials:&lt;br /&gt;&lt;a href="http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials"&gt;http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials&lt;/a&gt;&lt;br /&gt;&lt;li&gt;4 days on rails:&lt;br /&gt;&lt;a href="http://rails.homelinux.org/"&gt;http://rails.homelinux.org/&lt;/a&gt;&lt;br /&gt;&lt;li&gt;Ruby documentation:&lt;br /&gt;&lt;a href="http://www.ruby-lang.org/en/documentation/"&gt;http://www.ruby-lang.org/en/documentation/&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)"&gt;http://en.wikipedia.org/wiki/Ruby_(programming_language)&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Ruby_on_Rails"&gt;http://en.wikipedia.org/wiki/Ruby_on_Rails&lt;/a&gt;&lt;br /&gt;&lt;li&gt;Install ruby on Centos: &lt;br /&gt;&lt;a href="http://www.ruby-forum.com/topic/178186"&gt;http://www.ruby-forum.com/topic/178186&lt;/a&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a href="http://java.csdn.net/a/20100820/278465.html"&gt;Ruby 1.9.2 was released on 8/19/2010&lt;/a&gt;. Rails also released RC 3.0 version, and the formal 3.0 version is on the way to release.&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-188552021538852961?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/188552021538852961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=188552021538852961' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/188552021538852961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/188552021538852961'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/08/ruby-on-rails.html' title='Ruby on Rails'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2375807531664392168</id><published>2010-07-29T06:10:00.000-07:00</published><updated>2010-07-29T06:14:04.695-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical article'/><category scheme='http://www.blogger.com/atom/ns#' term='IT'/><title type='text'>Summary on web app layers and languages</title><content type='html'>&lt;a href="http://sixrevisions.com/web-technology/web-languages-decoded/"&gt;Web Languages: Decoded&lt;/a&gt; (&lt;a href="http://news.csdn.net/a/20100623/218903.html"&gt;Chinese version&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;This article is a summary on web application layers and languages. Not totally accurate in some places. But is a good summary anyways.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2375807531664392168?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2375807531664392168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2375807531664392168' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2375807531664392168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2375807531664392168'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/summary-on-web-app-layers-and-languages.html' title='Summary on web app layers and languages'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7621408295193684047</id><published>2010-07-27T20:26:00.000-07:00</published><updated>2010-08-02T17:41:24.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Drupal'/><title type='text'>Drupal Customization - Add New tab to a page</title><content type='html'>In a Drupal content page, when the user is logged in, on the top of the page there are "View" and "Edit" link buttons for the user to view and edit the content of the page. Now we want to add a "New" link button to allow the user create a new page of this type. This can be done this way. &lt;br /&gt;&lt;br /&gt;In "themes -&gt; [theme folder] -&gt; page.tpl.php", we have these two lines:&lt;br /&gt;&lt;br /&gt;&amp;lt;?php if ($title): print '&amp;lt;h2'. ($tabs ? ' class="with-tabs"' : '') .'&amp;gt;'. $title .'&amp;lt;/h2&amp;gt;'; endif; ?&amp;gt;&lt;br /&gt;&amp;lt;?php if ($tabs): print '&amp;lt;ul class="tabs primary"&amp;gt;'. $tabs . '&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;'; endif; ?&amp;gt;&lt;br /&gt;&lt;br /&gt;The first line is for the title. The second line is for the tabs "View" and "Edit". So we change the second line to be:&lt;br /&gt;&lt;br /&gt;&amp;lt;?php if ($tabs): print '&amp;lt;ul class="tabs primary"&amp;gt;'. $tabs . print_custom_tab($node) . '&amp;lt;/ul&amp;gt;&amp;lt;/div&amp;gt;'; endif; ?&amp;gt;&lt;br /&gt;&lt;br /&gt;And define the print_custom_tab() function at the end of the page:&lt;br /&gt;&lt;pre&gt;&amp;lt;?php&lt;br /&gt;function print_custom_tab($node) {&lt;br /&gt;  // Use this to limit the "New" tab to certain page types.&lt;br /&gt;  //if (substr($node-&amp;gt;type, 0) == "[page type name]") &lt;br /&gt;  {&lt;br /&gt;    return "&amp;lt;li&amp;gt;&amp;lt;a href='?q=node/add/" . str_replace("_", "-", $node-&amp;gt;type) . "'&amp;gt;New&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;";&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;From the $node we can also get $node-&gt;uid and other variables associated with node, and can do many other things this way.&lt;br /&gt;&lt;br /&gt;Alternatively or in a cleaner way, there is an &lt;a href="http://drupal.org/project/addanother"&gt;Add another&lt;/a&gt; module that do this. It needs to be configured on what page type and when to show. The configuration is done in "Administer -&gt; Site configuration -&gt; Add another".&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7621408295193684047?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7621408295193684047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7621408295193684047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7621408295193684047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7621408295193684047'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/drupal-customization.html' title='Drupal Customization - Add New tab to a page'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-4799031187092355502</id><published>2010-07-26T21:12:00.000-07:00</published><updated>2010-09-03T01:18:06.940-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# read Excel, get Access schema</title><content type='html'>&lt;pre&gt;///&lt;br /&gt;/// Reference: &lt;a href="http://www.c-sharpcorner.com/UploadFile/mgold/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET11282005034134AM/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET.aspx"&gt;How To Open and Read an Excel Spreadsheet into a ListView in .NET&lt;/a&gt;&lt;br /&gt;///&lt;br /&gt;public static void readExcel(string fullpath) {&lt;br /&gt;  Excel.Application excelObj = new Excel.Application();&lt;br /&gt;  if (excelObj == null) {&lt;br /&gt;    MessageBox.Show("Error: Excel cannot be started.");&lt;br /&gt;    return;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  excelObj.Visible = false; &lt;br /&gt;&lt;br /&gt;  Excel.Workbook theWorkbook = excelObj.Workbooks.Open(fullpath, 0, true, 5, "", "",&lt;br /&gt;    true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, false, false, false);&lt;br /&gt;  // get the collection of sheets in the workbook&lt;br /&gt;  Excel.Sheets sheets = theWorkbook.Worksheets;&lt;br /&gt;  // get the first and only worksheet from the collection of worksheets&lt;br /&gt;  Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);&lt;br /&gt;  &lt;br /&gt;  // getExcelSize(worksheet); // get row/col: ws.Rows.Count, ws.Columns.Count&lt;br /&gt;&lt;br /&gt;  // loop through 10 rows of the spreadsheet and place each row in the list view&lt;br /&gt;  for (int i = 1; i &lt;= 10; i++)&lt;br /&gt;  {&lt;br /&gt;    Excel.Range range = worksheet.get_Range("A"+i.ToString(), "FB" + i.ToString());&lt;br /&gt;    System.Array myvalues = (System.Array)range.Cells.Value2;&lt;br /&gt;    string str = ConvertArrayToString(myvalues);&lt;br /&gt;    MessageBox.Show(str);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Reference: &lt;a href="http://zamov.online.fr/EXHTML/CSharp/CSharp4.html"&gt;How to read an Excel file with OleDb and a simple SQL query?&lt;/a&gt; &lt;br /&gt;/// To use this, the Excel version should be 8.0 or compatible.&lt;br /&gt;/// &lt;br /&gt;/// The link http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=107963&amp;SiteID=1&lt;br /&gt;/// says that to use this method, it takes a little setup in your Excel document. &lt;br /&gt;/// Basically, you need to define "named objects" in Excel that are synonymous to &lt;br /&gt;/// tables in a database. The first row of the named object are the column headers. &lt;br /&gt;/// To set up a named object, first select the range of cells (your "table," with &lt;br /&gt;/// the first row being the column headers), then go to menu Insert-&gt;Names-&gt;Define. &lt;br /&gt;/// Name your object and press "Add." Now you have an object which can be read by &lt;br /&gt;/// ADO.NET.&lt;br /&gt;///&lt;br /&gt;public static void readExcel2(string fullpath) {&lt;br /&gt;  String sConnectionString = &lt;br /&gt;    "Provider=Microsoft.Jet.OLEDB.4.0;" +&lt;br /&gt;    "Data Source=" + fullpath + ";" + "Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";&lt;br /&gt;    MessageBox.Show(sConnectionString);&lt;br /&gt;&lt;br /&gt;  try &lt;br /&gt;  {&lt;br /&gt;    OleDbConnection objConn = new OleDbConnection(sConnectionString);&lt;br /&gt;    objConn.Open();&lt;br /&gt;&lt;br /&gt;    string sheetName = filename.Substring(0, filename.IndexOf(".xls"));&lt;br /&gt;    MessageBox.Show("sheetName: " + sheetName);&lt;br /&gt;&lt;br /&gt;    //OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);&lt;br /&gt;    OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [" + sheetName + "$]", objConn);&lt;br /&gt;    OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();&lt;br /&gt;    objAdapter1.SelectCommand = objCmdSelect;&lt;br /&gt;    DataSet objDataset1 = new DataSet();&lt;br /&gt;    objAdapter1.Fill(objDataset1);&lt;br /&gt;&lt;br /&gt;    string str = objAdapter1.ToString();&lt;br /&gt;    MessageBox.Show(str);&lt;br /&gt;&lt;br /&gt;    objConn.Close();&lt;br /&gt;  } &lt;br /&gt;  catch (Exception e) {&lt;br /&gt;    MessageBox.Show("error: " + e.Message);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Get Access Schema.&lt;br /&gt;///&lt;br /&gt;public void getSchema(string path) &lt;br /&gt;{&lt;br /&gt;  int i, j;&lt;br /&gt;  string result = "";&lt;br /&gt;  DataTable userTables = null;&lt;br /&gt;  DataTable userTable = null;&lt;br /&gt;  System.Windows.Forms.TreeNode node = null;&lt;br /&gt;  System.Windows.Forms.TreeNode[] nc;&lt;br /&gt;&lt;br /&gt;  try &lt;br /&gt;  {&lt;br /&gt;    OleDbConnection conn = new OleDbConnection();&lt;br /&gt;    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;&lt;br /&gt;    conn.Open();&lt;br /&gt;&lt;br /&gt;    userTables = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, &lt;br /&gt;                   new object[] {null, null, null, "TABLE"});&lt;br /&gt;&lt;br /&gt;    this.treeViewDBSchema.Nodes.Clear();&lt;br /&gt;    // Add list of table names to listBox&lt;br /&gt;    for (i=0; i &lt; userTables.Rows.Count; i++) &lt;br /&gt;    {&lt;br /&gt;        result += userTables.Rows[i][2].ToString() + " { ";&lt;br /&gt;        userTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,&lt;br /&gt;            new object[] {null, null, userTables.Rows[i][2].ToString(), null});&lt;br /&gt;&lt;br /&gt;        nc = new TreeNode[userTable.Rows.Count];&lt;br /&gt;        for (j = 0; j &lt; userTable.Rows.Count - 1; j ++) &lt;br /&gt;        {&lt;br /&gt;            result += userTable.Rows[j][3].ToString() + ", "; // [2].ToString();&lt;br /&gt;            nc[j] = new TreeNode("Field: " + userTable.Rows[j][3].ToString());&lt;br /&gt;            nc[j].Tag = userTable.Rows[j][3].ToString();&lt;br /&gt;        }&lt;br /&gt;        // for the last item.&lt;br /&gt;        result += userTable.Rows[j][3].ToString(); // [2].ToString();&lt;br /&gt;        nc[j] = new TreeNode("Field: " + userTable.Rows[j][3].ToString());&lt;br /&gt;        nc[j].Tag = userTable.Rows[j][3].ToString();&lt;br /&gt;&lt;br /&gt;        result += " }\n";&lt;br /&gt;        node = new TreeNode("Table: " + userTables.Rows[i][2].ToString(), nc);&lt;br /&gt;        node.Tag = userTables.Rows[i][2].ToString();&lt;br /&gt;        this.treeViewDBSchema.Nodes.Add(node);&lt;br /&gt;    }&lt;br /&gt;    conn.Close();&lt;br /&gt;    //MessageBox.Show(this, result);&lt;br /&gt;    this.frmMain.setOutput(result);&lt;br /&gt;  } &lt;br /&gt;  catch (Exception ex) &lt;br /&gt;  {&lt;br /&gt;    MessageBox.Show(this, "Error: " + ex.Message);&lt;br /&gt;  } &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-4799031187092355502?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/4799031187092355502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=4799031187092355502' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4799031187092355502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/4799031187092355502'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/c-read-excel.html' title='C# read Excel, get Access schema'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2824592743066060661</id><published>2010-07-26T20:38:00.000-07:00</published><updated>2010-07-27T14:56:38.200-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Network'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# work with local IP address</title><content type='html'>&lt;pre&gt;/// &lt;br /&gt;/// Ref: &lt;a href="http://www.codeproject.com/csharp/network.asp"&gt;How To Get IP Address Of A Machine&lt;/a&gt;&lt;br /&gt;/// Ref: &lt;a href="http://www.dotnet247.com/247reference/msgs/20/104068.aspx"&gt;WMI or How to change my IP address&lt;/a&gt;&lt;br /&gt;/// using System.Management;&lt;br /&gt;///&lt;br /&gt;&lt;br /&gt;public string getLocalIP() &lt;br /&gt;{&lt;br /&gt;  string localIP = "";&lt;br /&gt;  string strHostName = Dns.GetHostName();&lt;br /&gt;&lt;br /&gt;  IPHostEntry ipEntry = Dns.GetHostByName (strHostName);&lt;br /&gt;  IPAddress [] addr = ipEntry.AddressList;&lt;br /&gt;&lt;br /&gt;  /* what if more than one instance exists? */&lt;br /&gt;  for (int i = 0; i &lt; addr.Length; i++)  &lt;br /&gt;  {&lt;br /&gt;    localIP = addr[i].ToString();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  return localIP;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public bool setLocalIP(string newIP) {&lt;br /&gt;  try &lt;br /&gt;  {&lt;br /&gt;    ManagementBaseObject inPar = null;&lt;br /&gt;    ManagementBaseObject outPar = null;&lt;br /&gt;    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");&lt;br /&gt;    ManagementObjectCollection moc = mc.GetInstances();&lt;br /&gt;    foreach (ManagementObject mo in moc) &lt;br /&gt;    {&lt;br /&gt;      if (!(bool) mo["IPEnabled"]) continue;&lt;br /&gt;      inPar = mo.GetMethodParameters("EnableStatic");&lt;br /&gt;      inPar["IPAddress"] = new string[] {newIP};&lt;br /&gt;      inPar["SubnetMask"] = new string[] {subnetMask};&lt;br /&gt;      outPar = mo.InvokeMethod("EnableStatic", inPar, null);&lt;br /&gt;      break;&lt;br /&gt;    }&lt;br /&gt;  &lt;br /&gt;    this.currentIP = newIP;&lt;br /&gt;    return true;&lt;br /&gt;  } &lt;br /&gt;  catch (Exception e) &lt;br /&gt;  {&lt;br /&gt;    this.setErrMsg(e.Message + "\nsource: " + e.Source);&lt;br /&gt;    return false;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;static void SwitchToDHCP()&lt;br /&gt;{&lt;br /&gt;  ManagementBaseObject inPar = null;&lt;br /&gt;  ManagementBaseObject outPar = null;&lt;br /&gt;  ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");&lt;br /&gt;  ManagementObjectCollection moc = mc.GetInstances();&lt;br /&gt;  foreach( ManagementObject mo in moc )&lt;br /&gt;  {&lt;br /&gt;    if( ! (bool) mo["IPEnabled"] )&lt;br /&gt;      continue;&lt;br /&gt;&lt;br /&gt;    inPar = mo.GetMethodParameters("EnableDHCP");&lt;br /&gt;    outPar = mo.InvokeMethod( "EnableDHCP", inPar, null );&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;static void SwitchToStatic()&lt;br /&gt;{&lt;br /&gt;  string newIP;&lt;br /&gt;  string subnetMask = "255.255.255.0";&lt;br /&gt;  newIP = (curIP.Equals("192.168.168.209"))?"192.168.168.204":"192.168.168.209";&lt;br /&gt;&lt;br /&gt;  ManagementBaseObject inPar = null;&lt;br /&gt;  ManagementBaseObject outPar = null;&lt;br /&gt;  ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");&lt;br /&gt;  ManagementObjectCollection moc = mc.GetInstances();&lt;br /&gt;  foreach( ManagementObject mo in moc )&lt;br /&gt;  {&lt;br /&gt;    if( ! (bool) mo[ "IPEnabled" ] )&lt;br /&gt;      continue;&lt;br /&gt;&lt;br /&gt;    inPar = mo.GetMethodParameters( "EnableStatic" );&lt;br /&gt;    inPar["IPAddress"] = new string[] { newIP };&lt;br /&gt;    inPar["SubnetMask"] = new string[] { subnetMask };&lt;br /&gt;    outPar = mo.InvokeMethod( "EnableStatic", inPar, null );&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;static void ReportIP()&lt;br /&gt;{&lt;br /&gt;  Console.WriteLine( "****** Current IP addresses:" );&lt;br /&gt;  ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");&lt;br /&gt;  ManagementObjectCollection moc = mc.GetInstances();&lt;br /&gt;  foreach( ManagementObject mo in moc )&lt;br /&gt;  {&lt;br /&gt;    if( ! (bool) mo[ "IPEnabled" ] )&lt;br /&gt;      continue;&lt;br /&gt;&lt;br /&gt;    Console.WriteLine( "{0}\n SVC: '{1}' MAC: [{2}]", (string) mo["Caption"],&lt;br /&gt;      (string) mo["ServiceName"], (string) mo["MACAddress"] );&lt;br /&gt;&lt;br /&gt;    string[] addresses = (string[]) mo[ "IPAddress" ];&lt;br /&gt;    string[] subnets = (string[]) mo[ "IPSubnet" ];&lt;br /&gt;&lt;br /&gt;    Console.WriteLine( " Addresses :" );&lt;br /&gt;    foreach(string sad in addresses)&lt;br /&gt;      Console.WriteLine( "\t'{0}'", sad );&lt;br /&gt;&lt;br /&gt;    Console.WriteLine( " Subnets :" );&lt;br /&gt;    foreach(string sub in subnets )&lt;br /&gt;      Console.WriteLine( "\t'{0}'", sub );&lt;br /&gt;&lt;br /&gt;    curIP = addresses[0];&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2824592743066060661?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2824592743066060661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2824592743066060661' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2824592743066060661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2824592743066060661'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/c-get-and-set-local-ip.html' title='C# work with local IP address'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1736929220032670455</id><published>2010-07-26T20:34:00.000-07:00</published><updated>2010-07-27T14:48:41.632-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# GET/POST request, login, download, axWebBrowser</title><content type='html'>&lt;pre&gt;///&lt;br /&gt;/// Example of HTTP Get request.&lt;br /&gt;///&lt;br /&gt;private string requestURL(string url, int timeout) &lt;br /&gt;{&lt;br /&gt;  HttpWebRequest wr;&lt;br /&gt;  HttpWebResponse resp = null;&lt;br /&gt;  Stream stream;&lt;br /&gt;  StreamReader reader;&lt;br /&gt;  string strResponse = "";&lt;br /&gt;&lt;br /&gt;  try {&lt;br /&gt;    wr = (HttpWebRequest) WebRequest.Create(url);&lt;br /&gt;    wr.Timeout = timeout; // in milliseconds.&lt;br /&gt;    resp = (HttpWebResponse) wr.GetResponse();&lt;br /&gt;    stream = resp.GetResponseStream();&lt;br /&gt;    reader = new StreamReader(stream);&lt;br /&gt;    try { strResponse = reader.ReadToEnd(); } &lt;br /&gt;    finally { reader.Close(); }&lt;br /&gt;    resp = null;&lt;br /&gt;  }&lt;br /&gt;  catch (Exception ex) { &lt;br /&gt;    this.output_response("::" + ex.Message); &lt;br /&gt;  }&lt;br /&gt;  finally { &lt;br /&gt;    if (resp != null) resp.Close();&lt;br /&gt;  }&lt;br /&gt;  return strResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Example of HTTP Post request.&lt;br /&gt;/// Call the following function: e.g. &lt;br /&gt;/// string html = HttpPost("http://abcde.com", "a=1&amp;b=2");&lt;br /&gt;///&lt;br /&gt;private string HttpPost(string URI, string Parameters) &lt;br /&gt;{&lt;br /&gt;  WebRequest req = WebRequest.Create(URI);&lt;br /&gt;  //req.Proxy = new System.Net.WebProxy(ProxyString, true);&lt;br /&gt;&lt;br /&gt;  req.ContentType = "application/x-www-form-urlencoded";&lt;br /&gt;  req.Method = "POST";&lt;br /&gt;&lt;br /&gt;  byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);&lt;br /&gt;  req.ContentLength = bytes.Length;&lt;br /&gt;&lt;br /&gt;  Stream os = req.GetRequestStream ();&lt;br /&gt;  os.Write (bytes, 0, bytes.Length); &lt;br /&gt;  os.Close ();&lt;br /&gt;&lt;br /&gt;  WebResponse resp = req.GetResponse();&lt;br /&gt;  if (resp== null) return null;&lt;br /&gt;&lt;br /&gt;  StreamReader sr = new StreamReader(resp.GetResponseStream());&lt;br /&gt;  return sr.ReadToEnd().Trim();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Example of using HTTP Post to log into a site.&lt;br /&gt;///&lt;br /&gt;private void login() {&lt;br /&gt;  HTMLDocument myDoc = new HTMLDocumentClass();&lt;br /&gt;  myDoc = (HTMLDocument) axWebBrowser1.Document;&lt;br /&gt;&lt;br /&gt;  try &lt;br /&gt;  {&lt;br /&gt;    HTMLInputElement oUser = null, oPass = null;&lt;br /&gt;&lt;br /&gt;    oUser = (HTMLInputElement) myDoc.all.item("username", 0);&lt;br /&gt;    oPass = (HTMLInputElement) myDoc.all.item("password", 0);&lt;br /&gt;&lt;br /&gt;    if (oUser == null || oPass == null) return;&lt;br /&gt;&lt;br /&gt;    oUser.value = "username_value";&lt;br /&gt;    oPass.value = "password_value";&lt;br /&gt;&lt;br /&gt;    HTMLFormElement frm = (HTMLFormElement) myDoc.all.item("login", 0);&lt;br /&gt;    frm.submit();&lt;br /&gt;&lt;br /&gt;    this.Task = 1; &lt;br /&gt;  } &lt;br /&gt;  catch (Exception ex) &lt;br /&gt;  {&lt;br /&gt;    this.showInfo("test() error: " + ex.Message);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Example of using HTTP Post to download an Excel file.&lt;br /&gt;///&lt;br /&gt;private void getExcel() {&lt;br /&gt;  HttpWebResponse resp = null;&lt;br /&gt;  Stream stream;&lt;br /&gt;  string filename = this.downloadFolder + "/download.xls";&lt;br /&gt;&lt;br /&gt;  try &lt;br /&gt;  {&lt;br /&gt;    wr = (HttpWebRequest) WebRequest.Create(this.excel_url);&lt;br /&gt;    wr.Method = "POST";&lt;br /&gt;    wr.ContentType = "application/x-www-form-urlencoded";&lt;br /&gt;    wr.ContentLength = byteArray.Length;&lt;br /&gt;    wr.Timeout = 100000; // in ms. Set this bigger than the site timeout value.&lt;br /&gt;    MyUtil.appendLog("wr.contentlength: " + wr.ContentLength);&lt;br /&gt;&lt;br /&gt;    wr.CookieContainer = new CookieContainer();&lt;br /&gt;    wr.CookieContainer.SetCookies(new Uri(this.excel_url) , &lt;br /&gt;        ((mshtml.HTMLDocumentClass) this.axWebBrowser1.Document).cookie.ToString());&lt;br /&gt;    MyUtil.appendLog("cookie: " + &lt;br /&gt;        ((mshtml.HTMLDocumentClass) this.axWebBrowser1.Document).cookie);&lt;br /&gt;&lt;br /&gt;    // Send post request&lt;br /&gt;    Stream dataStream = wr.GetRequestStream();&lt;br /&gt;    dataStream.Write(byteArray, 0, byteArray.Length);&lt;br /&gt;    dataStream.Close();&lt;br /&gt;    resp = (HttpWebResponse) wr.GetResponse();&lt;br /&gt;    resp.Cookies = wr.CookieContainer.GetCookies(resp.ResponseUri);&lt;br /&gt;    MyUtil.appendLog("resp status: " + resp.StatusDescription);&lt;br /&gt;&lt;br /&gt;    stream = resp.GetResponseStream();&lt;br /&gt;&lt;br /&gt;    //MyUtil.appendLog("resp header: " + resp.ContentType );&lt;br /&gt;    // Header: usually 'txt/html'. here is 'application/vnd.ms-excel'&lt;br /&gt;    StreamReader reader = new StreamReader(stream);&lt;br /&gt;    try &lt;br /&gt;    {&lt;br /&gt;      MyUtil.saveFile(filename, reader.ReadToEnd());&lt;br /&gt;      this.downloadSucceed = true;&lt;br /&gt;    } &lt;br /&gt;    catch (Exception ex) &lt;br /&gt;    { &lt;br /&gt;      MyUtil.FileDelete(filename);&lt;br /&gt;      this.downloadSucceed = false;&lt;br /&gt;    }&lt;br /&gt;    finally &lt;br /&gt;    {&lt;br /&gt;      reader.Close();&lt;br /&gt;    }&lt;br /&gt;  } &lt;br /&gt;  catch (Exception ex) &lt;br /&gt;  {&lt;br /&gt;    this.downloadSucceed = false;&lt;br /&gt;    MyUtil.FileDelete(filename);&lt;br /&gt;  } &lt;br /&gt;  finally &lt;br /&gt;  {&lt;br /&gt;    if (resp != null) { resp.Close(); }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Another way of navigating website: use the axWebBrowser control.&lt;br /&gt;///&lt;br /&gt;this.axWebBrowser1.Navigate(url);&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="http://www.pinvoke.net/default.aspx/user32.SendInput"&gt;The user32 SendInput windows API&lt;/a&gt;. The SendInput function synthesizes &lt;br /&gt;    keystrokes, mouse motions, and button clicks to the currently active window. &lt;br /&gt;[2] &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=432637&amp;SiteID=1"&gt;Capturing binary download via code through axwebbrowser1&lt;/a&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1736929220032670455?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1736929220032670455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1736929220032670455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1736929220032670455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1736929220032670455'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/c-get-request.html' title='C# GET/POST request, login, download, axWebBrowser'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-7653861676962935978</id><published>2010-07-24T15:10:00.000-07:00</published><updated>2010-07-26T21:29:59.526-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='news'/><category scheme='http://www.blogger.com/atom/ns#' term='IT'/><title type='text'>Per capita revenue of high tech companies</title><content type='html'>&lt;a href="http://news.csdn.net/a/20100423/218095.html"&gt;Here is an article on per capita revenue of some high tech companies&lt;/a&gt; (In Chinese).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/List_of_companies_by_revenue"&gt;Here's the list of world's largest public and private business's gross annual revenue, number of employees and other information&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It is interesting to see the data. &lt;br /&gt;&lt;br /&gt;&lt;img src='http://news.csdn.net/a//uploads/2010/04/23/20100423-095420-pic1.jpg'&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src='http://news.csdn.net/a//uploads/2010/04/23/20100423-095458-pic1.png'&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-7653861676962935978?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/7653861676962935978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=7653861676962935978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7653861676962935978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/7653861676962935978'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/per-capita-profit-of-high-tech.html' title='Per capita revenue of high tech companies'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1141981335845672441</id><published>2010-07-20T15:03:00.001-07:00</published><updated>2010-08-22T16:09:38.077-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Network'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>Sams Teach Yourself TCP/IP in 24 Hours</title><content type='html'>&lt;a href="http://www.amazon.com/Sams-Teach-Yourself-TCP-Hours/dp/0672329964/ref=dp_ob_title_bk/186-1625080-1365934"&gt;Sams Teach Yourself TCP/IP in 24 Hours (4th Edition)&lt;/a&gt; - by Joe Casad, 2008, 456 pages. ISBN-10: 0672329964.&lt;br /&gt;&lt;br /&gt;I caught this book in sight at Barns and Noble. It is a short book to read, to the point and clear on basic concepts. Short is good.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;I. TCP/IP basics&lt;br /&gt;&lt;br /&gt;II. TCP/IP Protocol system&lt;br /&gt;&lt;br /&gt;2. Correspondence of TCP/IP model and OSI model.&lt;br /&gt;  TCP/IP                      OSI         Relevant protocols&lt;br /&gt;  ----------------------------------------------------------------------------------&lt;br /&gt;  Application layer           A,P,S          &lt;br /&gt;  Transport layer             T           TCP/UDP&lt;br /&gt;  Internet layer              N           IP, ARP, RARP, ICMP, router(RIP, OSPF etc.)&lt;br /&gt;  Network access layer        D,P         FTS, FDDI, PPP, 802.11, 802.3, 802.16&lt;br /&gt;&lt;br /&gt;  note: 802.3 - ethernet, 802.11 - wireless, 802.16 - winmax&lt;br /&gt;&lt;br /&gt;3. Network access layer&lt;br /&gt;  - physical addressing.&lt;br /&gt;  - LAN - ethernet.&lt;br /&gt;    CSMA/CS (Carrier Sense Multiple Access with Collision Detect)&lt;br /&gt;    ethernet frame: preamble|dest addr|sr addr|length|data|FCS(CRC)&lt;br /&gt;&lt;br /&gt;4. Internet layer&lt;br /&gt;  - IP, IP header&lt;br /&gt;  - IP addressing: class A(8/24), B(16/16), C(24/8), D, E&lt;br /&gt;  - ARP (Address Resolution Protocol)&lt;br /&gt;  - RARP (Reverse ARP)&lt;br /&gt;  - ICMP&lt;br /&gt;  - BGP (Border Gateway Protocol), RIP (Routing Information Protocol)&lt;br /&gt;&lt;br /&gt;5. Subnetting &amp; CIDR (Classless Inter-Domain Routing)&lt;br /&gt;  - subnet mask/host ID&lt;br /&gt;  - split and combine networks.&lt;br /&gt;&lt;br /&gt;6. Transport layer&lt;br /&gt;  - TCP/UDP&lt;br /&gt;  - ports, sockets&lt;br /&gt;  - multiplexing, demultiplexing.&lt;br /&gt;  - TCP: stream, resequencing, flow control, precedence &amp; security, graceful close.&lt;br /&gt;&lt;br /&gt;7. Application layer&lt;br /&gt;  - use socket/port to communicate with transport layer.&lt;br /&gt;  - target of multiplexing/de-multiplexing&lt;br /&gt;&lt;br /&gt;III. Networking with TCP/IP&lt;br /&gt;&lt;br /&gt;8. Routing&lt;br /&gt;  - routing table&lt;br /&gt;  - IP forwarding&lt;br /&gt;  - Dynamic routing algorithm&lt;br /&gt;    - DV (Distance vector). e.g. RIP&lt;br /&gt;    - LS (Link state). e.g. OSPF (Open Shortest Path First)&lt;br /&gt;      LS is more popular than DV now.&lt;br /&gt;  - Complex network routing&lt;br /&gt;    1) core router - backbone network (GGP)&lt;br /&gt;    2) exterior router - on border of autonomous systems (EGP: e.g. BGP)&lt;br /&gt;    3) interior router - within autonomous system (IGP: OSPF/RIP)&lt;br /&gt;  - classless routing: CIDR.&lt;br /&gt;  - OSPF: implemented as routed on unix/linux, builds SPT (Shortest Path Tree)&lt;br /&gt;&lt;br /&gt;10. Firewall&lt;br /&gt;  - DMZ (Demilitarized Zone)&lt;br /&gt;  - rules&lt;br /&gt;  - proxy service&lt;br /&gt;  - reverse proxy&lt;br /&gt;&lt;br /&gt;11. Name resolution&lt;br /&gt;  - DNS (Domain Name Server)&lt;br /&gt;&lt;br /&gt;IV. TCP/IP utilities.&lt;br /&gt;&lt;br /&gt;V. TCP/IP and the internet&lt;br /&gt;&lt;br /&gt;18. Email&lt;br /&gt;  - outgoing email: SMTP&lt;br /&gt;  - incoming email: POP3/IMAP&lt;br /&gt;&lt;br /&gt;19. Streaming and casting&lt;br /&gt;  - stack:&lt;br /&gt;    RTP&lt;br /&gt;    UDP&lt;br /&gt;    Internet layer&lt;br /&gt;    Network Access layer&lt;br /&gt;&lt;br /&gt;VI. Advanced topics&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1141981335845672441?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1141981335845672441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1141981335845672441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1141981335845672441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1141981335845672441'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/learning-tcpip-in-24-hours.html' title='Sams Teach Yourself TCP/IP in 24 Hours'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2626280110952174761</id><published>2010-07-20T14:36:00.000-07:00</published><updated>2010-08-22T16:09:12.881-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C/C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>C Traps and Pitfalls</title><content type='html'>&lt;a href="http://www.amazon.com/C-Traps-Pitfalls-Andrew-Koenig/dp/0201179288/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1279664958&amp;sr=1-1"&gt;C Traps and Pitfalls&lt;/a&gt; - by Andrew Koenig, 1989, 160 pages. ISBN-10: 0201179288.&lt;br /&gt;&lt;br /&gt;Andrew Koenig wrote a small reference manual on C programming based on his experience when he worked at AT&amp;T lab. Since it received wide acceptance, he added more material and resulted in this book. It's highly recommended to any serious C programmers. Some contents are kind of outdated, such as those about problems of early day compilers. But many points are still ubiquitously applicable.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;- Introduction&lt;br /&gt;&lt;br /&gt;- Chapter 1. Lexical pitfalls&lt;br /&gt;  1.3 greedy principle in evaluating statement.&lt;br /&gt;      e.g. a --- b is: a-- - b, &lt;br /&gt;           y = x/*p is: y=x plus the start of a comment! &lt;br /&gt;                        Should write as y = x / *p or y = x / (*p).&lt;br /&gt;           a +++++ b is: a++ ++ + b. This has compile error since a++ is not l-value.&lt;br /&gt;      Be careful, if a number starts with 0, it's an octal number.&lt;br /&gt;&lt;br /&gt;- Chapter 2. Syntax pitfalls&lt;br /&gt;  2.1 Function declaration.&lt;br /&gt;      This casts address 0 as the pointer to function void f() and call it.&lt;br /&gt;      (* (void (*)()) 0)(); &lt;br /&gt;  2.2 Operator precedence.&lt;br /&gt;      if (a == 'a' || b = 'b' || c == 'c') {} is equivalent to:&lt;br /&gt;      if ((a == 'a' || b) = ('b' || c == 'c')) {}&lt;br /&gt;  2.6 dangling else.&lt;br /&gt;      if (a) &lt;br /&gt;        if (b) b ++;&lt;br /&gt;      else { c ++; }&lt;br /&gt;      is equivalent to:&lt;br /&gt;      if (a) {&lt;br /&gt;        if (b) b ++;&lt;br /&gt;        else { c ++; }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;Chapter 3. Semantic pitfalls&lt;br /&gt;  3.6 off-by-1 error - is the most prevalent.&lt;br /&gt;      One solution in C: 0-based C array, using asymmetric boundary.&lt;br /&gt;      e.g. x &amp;gt;= 16 &amp;&amp; x &amp;lt; 38. 38-16 is exactly the size of the range.&lt;br /&gt;  3.9 Check overflow.&lt;br /&gt;      method 1: if ((unsigned) a + (unsigned) b &amp;gt; INT_MAX) // overflowed&lt;br /&gt;      method 2: if (a &amp;gt; INT_MAX - b) // overflowed&lt;br /&gt;&lt;br /&gt;Chapter 4. Linking&lt;br /&gt;  lint.&lt;br /&gt;&lt;br /&gt;Chapter 5. Library functions&lt;br /&gt;  5.1 int getchar() - return types does not match function, can cause problem.&lt;br /&gt;  5.2 I/O buffer. &lt;br /&gt;      setbuf(stdout, (char *) 0); // no buffer&lt;br /&gt;  5.4 errno&lt;br /&gt;  5.5 signal, longjmp&lt;br /&gt;&lt;br /&gt;Chapter 6. Preprocessor&lt;br /&gt;  - macro&lt;br /&gt;  - use of -- or ++ can cause unexpected side effects in macro.&lt;br /&gt;  6.3 assert&lt;br /&gt;      #define assert(e) \&lt;br /&gt;              ((void) ((e) || _assert_error(__FILE__, __LINE__)))&lt;br /&gt;&lt;br /&gt;Chapter 7. Portability&lt;br /&gt;  7.5 &amp;gt;&amp;gt; and divide by 2. &amp;gt;&amp;gt; is faster and works correctly when var is positive.&lt;br /&gt;      e.g. replace "mid = (left + right) / 2" with "mid = (left + right) &amp;gt;&amp;gt; 1".&lt;br /&gt;  7.11 literal string can represent an array.&lt;br /&gt;      e.g. "0123456789"[n%10] is equivalent to: a[] = "0123456789"; a[n%10];&lt;br /&gt;           This is used in systems where 0-9 may not be consecutive.&lt;br /&gt;&lt;br /&gt;Chapter 8. Suggestions and answers.&lt;br /&gt;  - Optimize binary search: &lt;br /&gt;    1) use &amp;gt;&amp;gt; instead of 1/2, 2) use pointer instead of array indexing.&lt;br /&gt;  - Little/big ending.&lt;br /&gt;  - getchar(), putchar() have both macro and function definitions. macro is faster.&lt;br /&gt;  - atol().&lt;br /&gt;&lt;br /&gt;Appendix A&lt;br /&gt;  - printf. %p, %n, %06d is equivalent to %.6d in most cases.&lt;br /&gt;  - varargs&lt;br /&gt;  - stdarg&lt;br /&gt;&lt;br /&gt;Author's suggestions on using C++:&lt;br /&gt;  - avoid pointer&lt;br /&gt;  - use library&lt;br /&gt;  - use class&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2626280110952174761?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2626280110952174761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2626280110952174761' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2626280110952174761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2626280110952174761'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/c-traps-and-pitfalls.html' title='C Traps and Pitfalls'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1373293575086680677</id><published>2010-07-07T15:41:00.001-07:00</published><updated>2010-07-26T21:30:13.115-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Math'/><title type='text'>Smale's Sphere Eversion Paradox</title><content type='html'>&lt;a href="http://v.youku.com/v_show/id_XMjYzNDY0NzY=.html"&gt;Interesting video demonstrates the process and explains why&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1373293575086680677?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1373293575086680677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1373293575086680677' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1373293575086680677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1373293575086680677'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/smales-sphere-eversion-paradox.html' title='Smale&apos;s Sphere Eversion Paradox'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-990660399899421395</id><published>2010-07-06T23:41:00.000-07:00</published><updated>2010-08-29T00:57:56.580-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='Interview'/><title type='text'>Some algorithm/system resources</title><content type='html'>- &lt;a href="http://www.madandmoonly.com/doctormatt/mathematics/dice1.pdf"&gt;A Collection of Dice Problems&lt;/a&gt;. For probability issues.&lt;br /&gt;- &lt;a href="http://www.ibm.com/developerworks/java/library/j-jtp04186/index.html"&gt;Lock free algorithms&lt;/a&gt;.&lt;br /&gt;- &lt;a href="http://www.cs.princeton.edu/introcs/42sort"&gt;Sorting and searching&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.amazon.com/Art-Debugging-GDB-DDD-Eclipse/dp/1593271743"&gt;The Art of Debugging with GDB, DDD, and Eclipse&lt;/a&gt;. For debugging multi-threaded applications.&lt;br /&gt;- &lt;a href="http://gee.cs.oswego.edu/dl/html/malloc.html"&gt;A Memory Allocator&lt;/a&gt;. About implementation of malloc() etc.&lt;br /&gt;- &lt;a href="ftp://g.oswego.edu/pub/papers/C++Report89.txt"&gt;Some Storage Management Techniques for Container Classes&lt;/a&gt;. C++ stuff.&lt;br /&gt;- &lt;a href="http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html"&gt;Beej's Guide to Network Programming Using Internet Sockets&lt;/a&gt;. One page guide.&lt;br /&gt;- &lt;a href="http://hi.baidu.com/mianshiti/home"&gt;Some interview questions&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-990660399899421395?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/990660399899421395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=990660399899421395' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/990660399899421395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/990660399899421395'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/some-interview-resources.html' title='Some algorithm/system resources'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-6885733280982021200</id><published>2010-07-02T20:42:00.001-07:00</published><updated>2010-07-02T20:44:17.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Programming'/><title type='text'>Dynamic Programming</title><content type='html'>Some links to DP:&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://www.comp.nus.edu.sg/~xujia/mirror/algorithm.myrice.com/algorithm/technique/dynamic_programming/index.htm"&gt;Dynamic Programming&lt;/a&gt; (in Chinese)&lt;br /&gt;- &lt;a href="http://people.csail.mit.edu/bdean/6.046/dp/"&gt;Dynamic Programming Practice Problems&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf"&gt;Book chapter on Dynamic Programming&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-6885733280982021200?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/6885733280982021200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=6885733280982021200' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6885733280982021200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/6885733280982021200'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/07/dynamic-programming.html' title='Dynamic Programming'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8033912122410318338</id><published>2010-06-18T20:30:00.001-07:00</published><updated>2010-07-02T20:41:28.438-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal'/><title type='text'>Adding PHP snippets through the Drupal user interface</title><content type='html'>Enable PHP input filter: Go to Administer -&gt; Site building -&gt; Modules, and check PHP Filter under core - optional. Now when create new content, a PHP option  will appear under input formats - select this to paste a PHP code snippet. This opens a powerful door to creating dynamic content on a Drupal site.&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://drupal.org/node/337959"&gt;Drupal: A beginner's guide to using snippets&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Often a PHP snippet is written inside a drupal module block. What if you want to access Drupal database from an external PHP file? Below is an example. See &lt;a href="http://drupal.org/node/166409"&gt;here&lt;/a&gt; for reference.&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;// Root path of drupal site, can be obtained using getcwd().&lt;br /&gt;$path = "/web/1/www.hawaii.edu/drupalc/"; &lt;br /&gt;chdir($path); &lt;br /&gt;&lt;br /&gt;// include needed files&lt;br /&gt;include_once('includes/bootstrap.inc');&lt;br /&gt;include_once('includes/database.inc');&lt;br /&gt;//include_once('includes/database.mysql.inc'); // Disable this for drupal 6.&lt;br /&gt;&lt;br /&gt;// Launch drupal start: configuration and database bootstrap&lt;br /&gt;conf_init();&lt;br /&gt;drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);&lt;br /&gt;drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);&lt;br /&gt;&lt;br /&gt;// Page start. Output page as an Excel file download.&lt;br /&gt;header("Content-type: application/vnd.ms-excel");&lt;br /&gt;header("Content-Disposition: attachment; filename=\"excel_download.xls\"");&lt;br /&gt;header("Pragma: no-cache");&lt;br /&gt;header("Expires: 0");&lt;br /&gt;&lt;br /&gt;// table header&lt;br /&gt;echo "&amp;lt;table border='1'&amp;gt;";&lt;br /&gt;db_query("SELECT * FROM users"); // access to database.&lt;br /&gt;// more processing ...&lt;br /&gt;echo "&amp;lt;/table&amp;gt;";&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8033912122410318338?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8033912122410318338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8033912122410318338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8033912122410318338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8033912122410318338'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/adding-php-snippets-through-drupal-user.html' title='Adding PHP snippets through the Drupal user interface'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8062712046020654619</id><published>2010-06-04T15:25:00.000-07:00</published><updated>2010-07-02T21:21:08.401-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C#.Net recover password by email</title><content type='html'>In C#.Net 2005, the asp:PasswordRecovery control by default use User Name to recover password. But sometimes the user may forget user name, and User Email is used instead. For this we can do it this way (from &lt;a href="http://forums.aspfree.com/net-development-11/passwordrecovery-with-email-instead-of-user-name-139984.html"&gt;here&lt;/a&gt;):&lt;br /&gt;&lt;br /&gt;In aspx page:&lt;br /&gt;&amp;lt;asp:PasswordRecovery Id="PasswordRecovery1" runat="server" OnVerifyingUser="PasswordRecovery1_VerifyingUser"&amp;gt; &lt;br /&gt;&amp;lt;/asp:PasswordRecovery&amp;gt; &lt;br /&gt;&lt;br /&gt;In Code behind:&lt;br /&gt;protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;  PasswordRecovery1.UserName = Membership.GetUserNameByEmail(PasswordRecovery1.Us  erName); &lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8062712046020654619?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8062712046020654619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8062712046020654619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8062712046020654619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8062712046020654619'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/cnet-recover-password-by-email.html' title='C#.Net recover password by email'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5969556445122218192</id><published>2010-06-03T16:33:00.000-07:00</published><updated>2011-04-28T16:51:18.807-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Javascript resources</title><content type='html'>- Unbelievably easy javascript for sortable table header columns: &lt;a href="http://www.kryogenix.org/code/browser/sorttable/"&gt;Available here&lt;/a&gt;.&lt;br /&gt;- Calendar date picker: datepickercontrol. &lt;a href="http://katystomachdoctor.com/includes/date/"&gt;Available here&lt;/a&gt;.&lt;br /&gt;- Slider: &lt;a href="http://webfx.eae.net/dhtml/slider/slider.html"&gt;Easy slider&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5969556445122218192?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5969556445122218192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5969556445122218192' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5969556445122218192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5969556445122218192'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/javascript-resources.html' title='Javascript resources'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3693598807376325759</id><published>2010-06-02T22:30:00.001-07:00</published><updated>2010-07-02T20:47:37.887-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><title type='text'>The Longest Palindrome problem</title><content type='html'>See here for &lt;a href="http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/"&gt;a linear solution&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Another blog for &lt;a href="http://johanjeuring.blogspot.com/2007/08/finding-palindromes.html"&gt;linear solution&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Another linear solution is to use suffix tree.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3693598807376325759?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3693598807376325759/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3693598807376325759' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3693598807376325759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3693598807376325759'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/longest-palindrome-problem.html' title='The Longest Palindrome problem'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-3172684292842270464</id><published>2010-06-02T21:44:00.000-07:00</published><updated>2010-08-22T16:10:04.481-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>More Effective C++</title><content type='html'>More Effective C++&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;b&gt;Basics&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Pointers and References.&lt;br /&gt;- A reference must be initialized. There is no null reference.&lt;br /&gt;- result of the following is undefined:&lt;br /&gt;  char *pc = 0;          // set pointer to null&lt;br /&gt;  char&amp; rc = *pc;        // make reference refer to&lt;br /&gt;- Reference is more efficient, b/c there is no need to test its validity.&lt;br /&gt;- Pointers should generally be tested against NULL first.&lt;br /&gt;- A pointer can be reassigned, but a reference does not change.&lt;br /&gt;- certain operators need to use reference, e.g., [].&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer C++-style casts. (over C-style cast: (type) expression)&lt;br /&gt;- static_cast (similar to C-style cast in fxn): static_cast&lt;type&gt;(expression)&lt;br /&gt;- const_cast: cast away the constness or volatileness of an expression. enforced by compiler&lt;br /&gt;- dynamic_cast: perform safe casts down or across an inheritance hierarchy. Failed casts are indicated by a null pointer (when casting pointers) or an exception (when casting references).&lt;br /&gt;- reinterpret_cast: result is implementation-defined. rarely portable.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Never treat arrays polymorphically.&lt;br /&gt;- not able to distinguish between base type and derived type for correct polymorphism.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid gratuitous default constructors. &lt;/li&gt;&lt;br /&gt;&lt;b&gt;Operators&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Be wary of user-defined conversion functions.&lt;br /&gt;- Single-argument constructors &lt;br /&gt;- Implicit type conversion operators (better avoid)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Distinguish between prefix and postfix forms of increment and decrement operators. &lt;br /&gt;- E.g. Class UPInt. prefix ++ returns reference, postfix ++ returns const object.&lt;br /&gt;- i ++++ is inhibited.&lt;br /&gt;- i ++ is less efficient because it creates a temporary copy of its return value.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Never overload &amp;&amp;, ||, or ,. &lt;br /&gt;- otherwise it'll lose short-circuit semantics, and sequence of evaluation becomes uncertain.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand the different meanings of new and delete. &lt;br /&gt;- new operator: 1) allocates memory, 2) calls constructor&lt;br /&gt;- operator new: does memory allocation only. knows nothing about constructor&lt;br /&gt;- placement new &lt;br /&gt;- Deletion and Memory Deallocation &lt;br /&gt;- Array&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Exceptions&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Use destructors to prevent resource leaks. &lt;br /&gt;- pointer operation may lead to memory leak if exception is thrown&lt;br /&gt;- a possible solution is to use local object instead of pointer, with help of smart_ptr, or STL auto_ptr.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prevent resource leaks in constructors. &lt;br /&gt;- destructor deletes only FULLY constructed objects. So if an exception is thrown in constructor, destructor won't be called.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prevent exceptions from leaving destructors.&lt;br /&gt;- if control leaves a destructor due to an exception while another exception is active, C++ terminates the program.&lt;br /&gt;- stack unwinding.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand how throwing an exception differs from passing a parameter or calling a virtual function. (more reading needed)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Catch exceptions by reference. &lt;br /&gt;- four standard exceptions: 1) bad_alloc (thrown when operator new (see Item 8) can't satisfy a memory request), 2) bad_cast (thrown when a dynamic_cast to a reference fails; see Item 2), 3) bad_typeid (thrown when dynamic_cast is applied to a null pointer), and 4) bad_exception (available for unexpected exceptions).&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use exception specifications judiciously. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand the costs of exception handling.&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Efficiency&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Remember the 80-20 rule. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Consider using lazy evaluation. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Amortize the cost of expected computations.&lt;br /&gt;- over eager evaluation, caching&lt;br /&gt;- prefetching&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand the origin of temporary objects. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Facilitate the return value optimization. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Overload to avoid implicit type conversions.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Consider using op= instead of stand-alone op.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Consider alternative libraries.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand the costs of virtual functions, multiple inheritance, virtual base classes, and RTTI.&lt;br /&gt;- virtual table (vtable)&lt;br /&gt;- RTTI: runtime type identification &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Techniques&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Virtualizing constructors and non-member functions.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Limiting the number of objects of a class.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Requiring or prohibiting heap-based objects.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Smart pointers.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Reference counting. &lt;br /&gt;- a simple form of garbage collection.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Proxy classes.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Making functions virtual with respect to more than one object. &lt;/li&gt;&lt;br /&gt;&lt;b&gt;Miscellany&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Program in the future tense. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Make non-leaf classes abstract. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Understand how to combine C++ and C in the same program.&lt;br /&gt;- name mangling&lt;br /&gt;- initialization of statics&lt;br /&gt;- dynamic memory allocation&lt;br /&gt;- data structure compatibility&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Familiarize yourself with the language standard.&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Recommended Reading &lt;/b&gt;&lt;br /&gt;&lt;b&gt;An auto_ptr Implementation &lt;/b&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-3172684292842270464?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/3172684292842270464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=3172684292842270464' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3172684292842270464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/3172684292842270464'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/more-effective-c.html' title='More Effective C++'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-8471737954641090953</id><published>2010-06-01T22:48:00.000-07:00</published><updated>2010-08-22T16:10:30.195-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Book'/><title type='text'>Effective C++</title><content type='html'>Scott Meyers' Effective C++ (1997)&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;b&gt;Shifting from C to C++&lt;/b&gt;&lt;br&gt;&lt;br /&gt;&lt;li&gt;Prefer const and inline to #define&lt;br /&gt;- Value by #define does not go to symbol table, but processed by preprocessor.&lt;br /&gt;- For const pointer, needs to be like const char * const a = "zzz";&lt;br /&gt;- Class-specific constants: in class declaration: "static const int a;", need to define outside class.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer &amp;lt;iostream&amp;gt; to &amp;lt;stdio.h&amp;gt;&lt;br /&gt;- stdio.h is not type-safe and not extensible.&lt;br /&gt;- e.g. friend ostream&amp; operator&amp;lt;&amp;lt;(ostream&amp; s, const Rational&amp; r);&lt;br /&gt;- iostream is in std (preferred), iostream.h is in global range.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer new/delete to malloc/free&lt;br /&gt;- Reason: malloc/delete do not know constructor/destructor&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer C++ style comments (// ...) over C'(/* ... */)&lt;br /&gt;- Note some preprocessors only recognize /* ... */&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Memory management&lt;/b&gt;&lt;br&gt;&lt;br /&gt;&lt;li&gt;Use the same form in corresponding uses of new and delete. &lt;br /&gt;- Example:&lt;br /&gt;  string *stringPtr1 = new string;&lt;br /&gt;  string *stringPtr2 = new string[100];&lt;br /&gt;  ...&lt;br /&gt;  delete stringPtr1;           // delete an object&lt;br /&gt;  delete [] stringPtr2;        // delete an array of&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use delete on pointer members in destructors&lt;br /&gt;- Delete a NULL pointer does no harm (free a NULL pointer causes error though)&lt;br /&gt;- One way to avoid using delete is to use smart pointers (e.g. auto_ptr in STL)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Be prepared for out-of-memory conditions (more reading needed..)&lt;br /&gt;- When new fails, it throws an exception std::bad_alloc (in old compilers, it may return NULL)&lt;br /&gt;- assert is a macro. It does not work when NDEBUG is defined.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Adhere to convention when writing operator new and operator delete.  (more reading needed..)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid hiding the "normal" form of new.&lt;br /&gt;- Declare a function called "operator new" inside the class would block access to the "normal" form of new.&lt;br /&gt;- Two solutions: 1) overload operator new, 2) provide default value for additional parameters.&lt;br /&gt;- Example:&lt;pre&gt;class X {&lt;br /&gt;public:&lt;br /&gt;  void f();&lt;br /&gt;  static void * operator new(size_t size, new_handler p);&lt;br /&gt;  static void * operator new(size_t size)&lt;br /&gt;  { return ::operator new(size); }&lt;br /&gt;};&lt;br /&gt;X *px1 = new (specialErrorHandler) X;  // calls X::operator new(size_t, new_handler)&lt;br /&gt;X* px2 = new X;                        // calls X::operator new(size_t)&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Write operator delete if you write operator new. (new/delete should be paired) (more reading needed..)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Constructors, Destructors and Assignment Operators&lt;/b&gt;&lt;br&gt;&lt;br /&gt;Almost every class has one or more constructors, a destructor, and an assignment operator.&lt;br /&gt;&lt;li&gt;Declare a copy constructor and an assignment operator for classes with dynamically allocated memory.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer initialization to assignment in constructors. (more reading needed..)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;List members in an initialization list in the order in which they are declared.&lt;br /&gt;- Otherwise there is overhead for compiler to track information.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Make sure base classes have virtual destructors.&lt;br /&gt;- Base class virtual destructor should be used when base class has virtual fxns.&lt;br /&gt;- No virtual fxns in a base class often means it's not suitable to be a base class.&lt;br /&gt;- When need an abstract class, it may be convenient to declare destructor as pure virtual destructor, but then a definition of it should also be defined.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Have operator= return a reference to *this. (more reading needed..)&lt;br /&gt;- So as to be able to chain assignments together (assignment is right associative)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Assign to all data members in operator=. (more reading needed..)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check for assignment to self in operator=. (more reading needed..)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Classes and Functions: Design and Declaration&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Strive for class interfaces that are complete and minimal.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Differentiate among member functions, non-member functions, and friend functions.&lt;br /&gt;- Member fxns can be virtual, non-member fxns can't.&lt;br /&gt;- Operator&amp;gt;&amp;gt; and operator&amp;lt;&amp;lt; are never members.&lt;br /&gt;- Only non-member functions get type conversions on their left-most argument.&lt;br /&gt;- Everything else should be a member function.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid data members in the public interface.&lt;br /&gt;- Use access/inline functions instead of data members.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use const whenever possible. (more reading needed)&lt;br /&gt;- const value and const pointer&lt;br /&gt;- mutable&lt;br /&gt;- const_cast()&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer pass-by-reference to pass-by-value.&lt;br /&gt;- The meaning of passing an object by value is defined by the copy constructor of that object's class. This can be expensive.&lt;br /&gt;- Bad use: Student returnStudent(Student s) { return s; }&lt;br /&gt;- Good use: const Student&amp; returnStudent(const Student&amp; s) { return s; }&lt;br /&gt;- Slicing problem. (Pass by base class type will cut off derived class members.)&lt;br /&gt;- Aliasing.&lt;br /&gt;- Reference is implemented by pointer.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Don't try to return a reference when you must return an object. &lt;br /&gt;- E.g., operator* should return an object instead of reference.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Choose carefully between function overloading and parameter defaulting.&lt;br /&gt;- 2 questions: 1) is there a value you can use for a default? 2) how many algorithms do you want to use?&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid overloading on a pointer and a numerical type.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Guard against potential ambiguity. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Explicitly disallow use of implicitly generated member functions you don't want.&lt;br /&gt;- E.g. operator=&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Partition the global namespace. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Classes and Functions: Implementation&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Avoid returning "handles" to internal data.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid member functions that return non-const pointers or references to members less accessible than themselves.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Never return a reference to a local object or to a dereferenced pointer initialized by new within the function. &lt;br /&gt;- e.g. this is bad because the difficulty of applying delete: &lt;br /&gt;inline const Rational&amp; operator*(const Rational&amp; lhs, const Rational&amp; rhs)&lt;br /&gt;{ Rational *result = new Rational(lhs.n * rhs.n, lhs.d * rhs.d); return *result; }&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Postpone variable definitions as long as possible.&lt;br /&gt;- instead of "string encrypted; encrypted = password;", use "string encrypted = password;", this avoids calling default constructor on string.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Item 33:  Use inlining judiciously.&lt;br /&gt;- inline function used extensively may increase code size a lot.&lt;br /&gt;- inline, like "register", is only a hint to compiler.&lt;br /&gt;- uninlined inline function, in old rule, is treated as static and included into every translation unit.&lt;br /&gt;- library needs careful consideration on inline function, inline functions make it impossible to provide binary upgrades to the inline functions in a library - all clients have to recompile.&lt;br /&gt;- inline function should avoid using static variable.&lt;br /&gt;- most debuggers have problem with inline function.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Minimize compilation dependencies between files.&lt;br /&gt;- should do: replacement of dependencies on class definitions with dependencies on class declarations&lt;br /&gt;- Avoid using objects when object references and pointers will do.&lt;br /&gt;- Use class declarations instead of class definitions whenever you can.&lt;br /&gt;- Don't #include header files in your header files unless your headers won't compile without them.&lt;br /&gt;- Handle/body class, envelope/letter class.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Inheritance and Object-Oriented Design&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Make sure public inheritance models "isa."&lt;br /&gt;- isa == public inheritance&lt;br /&gt;- Two other common inter-class relationships are "has-a" and "is-implemented-in-terms-of." &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Differentiate between inheritance of interface and inheritance of implementation. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Never redefine an inherited nonvirtual function.&lt;br /&gt;- nonvirtual - statically bound&lt;br /&gt;- virtual - dynamically bound&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Never redefine an inherited default parameter value.&lt;br /&gt;- default parameters are statically bound!&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Avoid casts down the inheritance hierarchy.&lt;br /&gt;- down cast: from a base class pointer to a derived class pointer &lt;br /&gt;- down cast leads to a maintenance nightmare&lt;br /&gt;- safe downcasting: by using dynamic_cast&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Model "has-a" or "is-implemented-in-terms-of" through layering.&lt;br /&gt;- difference between isa and is-implemented-in-terms-of&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Differentiate between inheritance and templates. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use private inheritance judiciously. (more reading needed)&lt;br /&gt;- compilers will generally not convert a derived class object into a base class object if the inheritance relationship between the classes is private.&lt;br /&gt;- members inherited from a private base class become private members of the derived class, even if they were protected or public in the base class.&lt;br /&gt;- private inheritance means is-implemented-in-terms-of.&lt;br /&gt;- use layering whenever you can, use private inheritance whenever you must.&lt;br /&gt;- template-induced code bloat. It is not a good thing.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use multiple inheritance (MI) judiciously. (more reading needed)&lt;br /&gt;- MI leads to many problems, one is ambiguity (diamond inheritance).&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Say what you mean; understand what you're saying.&lt;/li&gt;&lt;br /&gt;&lt;b&gt;Miscellaneous&lt;/b&gt;&lt;br /&gt;&lt;li&gt;Know what functions C++ silently writes and calls.&lt;br /&gt;- default constructor, destructor, assignment/copy constructor, address-of operator, const address-of operator.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Prefer compile-time and link-time errors to runtime errors. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Ensure that non-local static objects are initialized before they're used. (more reading needed)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pay attention to compiler warnings.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Familiarize yourself with the standard library.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Improve your understanding of C++. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-8471737954641090953?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/8471737954641090953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=8471737954641090953' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8471737954641090953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/8471737954641090953'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/06/effective-c.html' title='Effective C++'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-513987825318050387</id><published>2010-05-30T02:32:00.001-07:00</published><updated>2010-07-02T20:47:32.531-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><title type='text'>The Longest Increasing Subsequence problem</title><content type='html'>The Longest Increasing Subsequence problem can be solved by these methods:&lt;br /&gt;&lt;br /&gt;1) Sort the sequence L into L_sorted, then find LCS(L, L_sorted). Since sort takes O(NlogN) time and LCS takes O(N^2) time, total it takes O(N^2) time.&lt;br /&gt;2) There is a DP method [2]. It's O(N^2) and can be improved to O(NlogN) by using binary search.&lt;br /&gt;3) &lt;a href="http://placementsindia.blogspot.com/2007/12/solutions-to-few-google-top-interview.html"&gt;Find the longest path in a directed acyclic graph&lt;/a&gt;. The source provides no detail on this solution. But it should be like building a tree with internal links (a DAG). It won't be easy.&lt;br /&gt;4) Patience sort [3]. This is a card game and easy to understand by taking a deck of cards to try out oneself. Similar to the DP method, this is also O(N^2) and can be improved to O(NlogN) by using binary search. I prefer this method, since it's easy to find both the length and one of the LIS sequences.&lt;br /&gt;&lt;br /&gt;Patience sort is an interesting sort [4]. This is one case where greedy strategy works optimally. Here are some excerpts from [4] about the history of patience sort:&lt;br /&gt;&lt;br /&gt;The name "patience sorting" comes from Mallows (1973), who credits A.S.C. Ross for its invention for the motivation of sorting a deck of cards. Mallow's analysis was done in 1960 but not published until a long time later. Robert Floyd discovered this&lt;br /&gt;independently and exchanged idea on it with Donald Knuth in private letters. Hammersley (1972) independently recognized its use as an algorithm for computing the length of LIS.&lt;br /&gt;&lt;br /&gt;A related problem of LIS is LCIS: Longest Continuous Increasing Subsequence. This is much easier. A one-pass traversal of the sequence will do. we just keep 2 variables: the length of the current LCIS, and the ending location of it. At the end we know both the length and the location.&lt;br /&gt;&lt;br /&gt;[1] http://en.wikipedia.org/wiki/Longest_increasing_subsequence&lt;br /&gt;[2] http://blog.programfan.com/article.asp?id=13086&lt;br /&gt;[3] http://en.wikipedia.org/wiki/Patience_sort&lt;br /&gt;[4] &lt;a href="http://www-stat.stanford.edu/~cgates/PERSI/year.html#99"&gt;Longest Increasing Subsequences: From Patience Sorting to the Baik-Dieft-Johansson Theorem&lt;/a&gt;. Caroline Gates, D. Aldous, Bull. Amer. Math. Soc., 36:413-32 (1999)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-513987825318050387?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/513987825318050387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=513987825318050387' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/513987825318050387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/513987825318050387'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/05/longest-increasing-subsequence-problem.html' title='The Longest Increasing Subsequence problem'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-1126913116478212036</id><published>2010-05-25T15:18:00.000-07:00</published><updated>2010-07-02T20:47:01.161-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web application'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP'/><title type='text'>ASP upload file size upper limit</title><content type='html'>When use multipart/form-data type to upload file in ASP, there is a problem of file size limit. On windows server 2003, this limit is about 200KB (204800 bytes). This is not enough since that's really a small file size in today's standards.&lt;br /&gt;&lt;br /&gt;The solution on windows server 2003 (IIS 6.0) is to set a bigger value on variable AspMaxRequestEntityAllowed, which is in &lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/a0ea8e51-fb2a-4e80-9d5a-7fe3ae246570.mspx?mfr=true"&gt;systemroot\System32\Inetsrv\Metabase.xml&lt;/a&gt;. On earlier versions of IIS, the value of AspMaxRequestEntityAllowed can be set in the registry. &lt;br /&gt;&lt;br /&gt;Now since big file upload can take long, it may need to set ASP ScriptTimeout value bigger than default (90 seconds). Can do this by "&amp;lt;%Server.ScriptTimeout[=NumSeconds]%&amp;gt;" [3], or in IIS6.0 can set this in IIS manager [4].&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;[1] &lt;a href="http://classicasp.aspfaq.com/forms/what-is-the-limit-on-form/post-parameters.html"&gt;What is the limit on Form / POST parameters?&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://support.microsoft.com/kb/260694/en-us"&gt;Description of the MaxClientRequestBuffer Registry Value&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://www.w3schools.com/asp/prop_scripttimeout.asp"&gt;ASP ScriptTimeout Property&lt;/a&gt;&lt;br /&gt;[4] &lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/2275a2ba-5b12-4e18-8266-8a3b0678e419.mspx?mfr=true"&gt;Setting the ASP Script Timeout (IIS 6.0)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-1126913116478212036?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/1126913116478212036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=1126913116478212036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1126913116478212036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/1126913116478212036'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/05/asp-upload-file-size-upper-limit.html' title='ASP upload file size upper limit'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-2109117323303833499</id><published>2010-05-21T17:53:00.000-07:00</published><updated>2010-05-21T17:55:11.297-07:00</updated><title type='text'>10 Papers Every Programmer Should Read</title><content type='html'>Interesting.&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://blog.objectmentor.com/articles/2009/02/26/10-papers-every-programmer-should-read-at-least-twice"&gt;10 Papers Every Programmer Should Read (At Least Twice)&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://www.rgoarchitects.com/nblog/2009/02/27/10PapersEverySoftwareArchitectShouldReadAtLeastTwice.aspx"&gt;10 Papers Every Software Architect Should Read (At Least Twice)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-2109117323303833499?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/2109117323303833499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=2109117323303833499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2109117323303833499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/2109117323303833499'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/05/10-papers-every-programmer-should-read.html' title='10 Papers Every Programmer Should Read'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4319079131407015379.post-5511261946236638784</id><published>2010-05-20T16:40:00.000-07:00</published><updated>2010-07-02T20:46:17.172-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><title type='text'>Disk scheduling algorithms</title><content type='html'>Several common disk scheduling algorithms: &lt;br /&gt;&lt;br /&gt;First Come First Served (FCFS)&lt;br /&gt;Shortest Seek Time First (SSTF)&lt;br /&gt;SCAN (Elevator algorithm)&lt;br /&gt;Circular SCAN (C-SCAN)&lt;br /&gt;LOOK&lt;br /&gt;Circular LOOK (C-LOOK)&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;[1] &lt;a href="http://web.archive.org/web/20080606005055/http://www.dcs.ed.ac.uk/home/stg/pub/D/disk.html"&gt;Disk scheduling&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://en.wikipedia.org/wiki/Elevator_algorithm"&gt;Wiki: elevator algorithm&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://zhidao.baidu.com/question/81059256"&gt;Example of calculation&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4319079131407015379-5511261946236638784?l=homeofcox-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homeofcox-cs.blogspot.com/feeds/5511261946236638784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4319079131407015379&amp;postID=5511261946236638784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5511261946236638784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4319079131407015379/posts/default/5511261946236638784'/><link rel='alternate' type='text/html' href='http://homeofcox-cs.blogspot.com/2010/05/disk-scheduling-algorithms.html' title='Disk scheduling algorithms'/><author><name>Tom</name><uri>http://www.blogger.com/profile/15200614294221441958</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
