<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Development Notes &#187; Programming</title>
	<atom:link href="http://blog.eood.cn/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eood.cn</link>
	<description>PHP, Drupal, Erlang, MySQL, Java, MongoDB, Linux, vim, ssh, screen etc</description>
	<lastBuildDate>Sat, 31 Dec 2011 12:49:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Enter Django Development</title>
		<link>http://blog.eood.cn/enter_django_python_development</link>
		<comments>http://blog.eood.cn/enter_django_python_development#comments</comments>
		<pubDate>Mon, 17 Oct 2011 08:55:13 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development Story]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1751</guid>
		<description><![CDATA[Introduction: Django is the modern base stack for web development. Compared with Ruby on Rails, I think I like Django better: Build-in ready to use admin interface Written in Python, with better performance Simpler and reasonable project struct Smaller base stack, but you can add what you want (ajax, south, REST, oauth &#8230;) Essential tools [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right;" src="http://blog.eood.cn/wp-content/uploads/2011/10/django_serious-pony-331x300.jpg" alt="Django" width="331" height="300" /></p>
<p><strong><span style="font-size: large;">Introduction:</span></strong></p>
<p>Django is the modern base stack for web development. Compared with Ruby on Rails, I think I like Django better:</p>
<ul>
<li>Build-in ready to use admin interface</li>
<li>Written in Python, with better performance</li>
<li>Simpler and reasonable project struct</li>
<li>Smaller base stack, but you can add what you want (ajax, south, REST, oauth &#8230;)</li>
</ul>
<p><strong><span style="font-size: large;">Essential tools for Django development:</span></strong></p>
<p><span style="color: #000000;"><strong>virtualenv</strong></span></p>
<p>We use this to manage the library for the project. You can have different environments (different python modules, different python versions) for every projects.</p>
<blockquote><p><strong>Create new clean environment foobar</strong></p>
<p>virtualenv &#8211;no-site-packages foobar</p>
<p><strong>Active the environment foobar</strong></p>
<p>source foobar/bin/activate</p>
<p><strong>Then install library in the environment foobar</strong></p>
<p>pip &#8230;</p>
<p><strong>At the end leave the environment foobar</strong></p>
<p>deactivate</p>
</blockquote>
<p><strong>pip or easy_install</strong></p>
<p><em></em>To install python libraries.</p>
<p><strong> Django south</strong></p>
<p>Database migration tool. Alertanative tool for syncdb</p>
<p><strong>Create migration for your app</strong></p>
<p><em> ./manage.py schemamigration myapp &#8211;initial</em></p>
<p><strong>Apply the migration</strong></p>
<p><em> ./manage.py migrate myapp</em></p>
<p><strong> Then change the model myapp, and make a new migratation</strong></p>
<p><em> ./manage.py schemamigration myapp &#8211;auto</em></p>
<p><strong> And apply it</strong></p>
<p><em> ./manage.py migrate myapp django-annoying</em></p>
<p><strong> Useful decorators:</strong></p>
<p><em> rederto ajaxrequest JSONField getobjectorNone</em></p>
<p><strong>django-compressor</strong></p>
<p>Compresses linked and inline javascript or CSS into a single cached file. And support coffeescript and less css framework.</p>
<p><strong>django-pagination</strong></p>
<p>pagination tools</p>
<p><strong>django-piston</strong></p>
<p><strong></strong>A mini-framework for Django for creating RESTful APIs.</p>
<p><strong>django-celery</strong></p>
<p>Celery integration for Django.</p>
<p>Celery is a task queue/job queue based on distributed message passing.</p>
<p><strong>django-mongodb</strong></p>
<p>MongoDB backend</p>
<p><strong>django-admin-tools</strong></p>
<p>Custom user interface, customizable dashboard</p>
<p><strong>django-socialauth</strong></p>
<p>oauth for social sites, login with twitter account, facebook account or gmail account</p>
<p><strong>django-storages</strong></p>
<p>Amazon S3, MogileFS file storage</p>
<p><strong>django-grappelli</strong></p>
<p>A jazzy skin for the Django Admin-Interface</p>
<p><strong>django-profiles</strong></p>
<p>A simple application which provides basic features for working with custom user profiles in Django projects.</p>
<p><strong>django-registration</strong></p>
<p>User registration and login</p>
<p><strong>simplejson</strong></p>
<p>JSON encoding and decoding</p>
<p><strong>django-imagekit</strong></p>
<p>Image process, support S3.</p>
<p><strong>Beautiful Soup</strong></p>
<p>Web Scrapping tool</p>
<p><strong>django-workflows</strong></p>
<p>django-workflows provides a generic workflow engine for Django.</p>
<p><span style="font-size: large;">The Django development environment steps:</span></p>
<p><strong>How to install the virtualenv &amp; django:</strong></p>
<blockquote><p>sudo apt-get install python-virtualenv</p>
<p>virtualenv &#8211;no-site-packages env_nm</p>
<p>source env_nm/bin/activate</p>
<p>pip install django</p>
<p>&#8230; ( install other modules )</p>
<p>deactivate</p>
<p>Export the libraries of the environment to a configuration file</p>
<p>pip freeze &gt; requirements.txt</p>
<p>Install the environment in a clean environment</p>
<p>pip install -r requirements.txt</p>
</blockquote>
<p><strong>The missing part of Django settings.py</strong></p>
<blockquote><p><span style="font-size: small;">import os</span></p>
<p><span style="font-size: small;">ROOT_PATH = os.path.dirname(file)</span></p>
<p><span style="font-size: small;">MEDIAROOT = os.path.join(ROOTPATH, &#8216;static&#8217;)</span></p>
<p><span style="font-size: small;">TEMPLATE_DIRS = (</span></p>
<p><span style="font-size: small;">os.path.join(ROOT_PATH, &#8216;templates&#8217;)</span></p>
<p><span style="font-size: small;">)</span></p>
</blockquote>
<p><strong>Django Signals &#8211; You should pay attentation to this</strong></p>
<p>This is the ECA (Aka: Event Condition Action) part of Django.&nbsp;</p>
<p>ECA is the essentail part of modern web appliactions.</p>
<p><strong><span style="font-size: large;">Other useful modules:</span></strong></p>
<p>SQLAlchemy &#8211; use this when the django ORM is not enough.</p>
<p>Haystack &#8211; Modular search for Django.</p>
<p>Django-mptt &#8211; Preorder tree management</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/enter_django_python_development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What tools and software used for development</title>
		<link>http://blog.eood.cn/what-tools-and-software-used-fro-development</link>
		<comments>http://blog.eood.cn/what-tools-and-software-used-fro-development#comments</comments>
		<pubDate>Sun, 19 Jun 2011 04:25:34 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Algorithm & Life]]></category>
		<category><![CDATA[Development tools]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1679</guid>
		<description><![CDATA[Recently. I totally changed my development tools at home. I can not change that at the office since that will also be lots of .NET development and the project related to M$ OFFICE SDK. Developers always interested to share or show off there development tools, because they want to improve there productivity. You can see [...]]]></description>
			<content:encoded><![CDATA[<p>Recently. I totally changed my development tools at home. I can not change that at the office since that will also be lots of .NET development and the project related to M$ OFFICE SDK.</p>
<p>Developers always interested to share or show off there development tools, because they want to improve there productivity.</p>
<p>You can see how developers care about there development machine and tools:</p>
<p><img class=" size-full wp-image-1681" title="tools_software_use" src="http://blog.eood.cn/wp-content/uploads/2011/06/tools_software_use.gif" alt="" width="590" height="400" /><br />
What is my development tools and software?</p>
<p>I use Ubuntu 11.04 as the main OS. There will be tons of work to do after you install the default Ubuntu.</p>
<p>I installed more fonts such as MSYH, Arial, then you will see the similar web page when you surfing the web.</p>
<p>Change the Ubuntu theme back to Ubuntu 10 style.</p>
<p>Soft wares installed under Ubuntu:</p>
<p>1. JDK (power lots of tools, support JAVA development)</p>
<p>2. Chromium (Main browser)</p>
<p>3. GIMP (Photoshop under Linux)</p>
<p>4. Dropbox (Sync tool for my documents)</p>
<p>5. Filezilla (FTP client)</p>
<p>6. Skype (Chatting tool)</p>
<p>7. IDE:</p>
<p>Aptana (Support PHP, Python, Ruby developement. But not used very frequently)</p>
<p>Eclipse (Java development)</p>
<p>Gvim (My main development tool)</p>
<p>8. Ubuntu tweak (configuration tool)</p>
<p>9. Chromium plugins:</p>
<p>Google reader notifier</p>
<p>Screen capture</p>
<p>Color pick</p>
<p>&#8230;</p>
<p>10. Vim plugins:</p>
<p>Vim wiki</p>
<p>Calander</p>
<p>ctags</p>
<p>Nerdtree</p>
<p>bufferexplorer</p>
<p>taglist</p>
<p>zencoding</p>
<p>&#8230;</p>
<p>11. Avant window navigator (Similar as Dock in Mac OS)</p>
<p><img class="size-full wp-image-1682" title="avant" src="http://blog.eood.cn/wp-content/uploads/2011/06/avant.png" alt="" width="426" height="75" /></p>
<p>12. Mysql, PHP, Apache2, Nodejs, mongodb, git, svn, redis and lots of shell scripts to complete tasks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/what-tools-and-software-used-fro-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WEB Development Rookie &#8211; NodeJS</title>
		<link>http://blog.eood.cn/web-development-rookie-nodejs</link>
		<comments>http://blog.eood.cn/web-development-rookie-nodejs#comments</comments>
		<pubDate>Sat, 16 Apr 2011 11:21:03 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Manament]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[NodeJS]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/web-development-rookie-nodejs</guid>
		<description><![CDATA[The nodejs growing very fast recently. New library or framework added to nodejs  almost everyday, since it is very easy to build a nodejs based module and javascript is used very widely. I have done the A/B testing of nodeJS vs Erlang mochiweb, Erlang misultin, Nginx static page on my poor VM machine, and got [...]]]></description>
			<content:encoded><![CDATA[<p>The nodejs growing very fast recently. New library or framework added to nodejs  almost everyday, since it is very easy to build a nodejs based module and javascript is used very widely.</p>
<p>I have done the A/B testing of nodeJS vs Erlang mochiweb, Erlang misultin, Nginx static page on my poor VM machine, and got the following result:</p>
<p><em>Nodejs helloworld:                     724 qps</em></p>
<p><em>Erlang mochiweb helloworld:     430 qps</em></p>
<p><em>Erlang misultin helloworld:         690 qps</em></p>
<p><em>Nginx static page:                    1045 qps</em></p>
<p>You can see that nodeJS is bloody fast thanks to the good performance of V8 <span style="border-collapse: separate; color: #000000; font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: small;"><span style="line-height: 15px;">JavaScript engine.</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: small;"><span style="line-height: 15px;">Talk about server side javascript, you should say Rhino, but nodejs is 20x faster than Rhino. NodeJS is stable, and not seen a bug of the code, like Nginx. You can build asynchronous system based on nodeJS and drop Tornado. What is important is that you can reuse your code both on client side and server side.</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: small;"><span style="line-height: 15px;">NodeJS is good at heavy IO usage, but not heavy CPU usage. And you should not change your current web system to nodeJS since it is too young.You can build your JSON interface by NodeJS, construct JSON from data fetched from database or remote web service, output the JSON format result. </span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: small;"><span style="line-height: 15px;">Nodejs library:</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/isaacs/npm">npm</a><span> </span>— A node package manager that uses CommonJS-compatible package.json files, written in asynchronous JavaScript.</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/visionmedia/express/tree/master">Express</a><span> </span>— A robust feature rich web development framework<span> </span><strong>inspired by Sinatra</strong></span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/tautologistics/nodemachine">nodemachine</a><span> </span>— A port of WebMachine to Node.js</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="http://senchalabs.github.com/connect/">Connect</a><span style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;"> </span></span></span><span style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;"><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;">— A  middleware framework for node</span></span></span><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="http://senchalabs.github.com/connect/"><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><br />
</span></span></a></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/LearnBoost/Socket.IO">Socket.io</a><span> </span>— WebSocket-compatible server and client with fallback for legacy browsers</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/felixge/node-mysql">node-mysql</a><span> </span>— A node.js module implementing the MySQL protocol</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span style="font-family: helvetica,arial,freesans,clean,sans-serif; font-size: 14px; line-height: 19px;"><a style="margin: 0px; padding: 0px; line-height: 1.4em; color: #4183c4; text-decoration: none; outline-style: none;" href="https://github.com/igo/redis2json/">redis2json</a><span> </span>— Easily loads data from Redis into structured JS object</span></span></p>
<p><span style="border-collapse: separate; color: #000000; font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: small;"><span style="line-height: 15px;">See more:</span></span></p>
<p><a href="https://github.com/joyent/node/wiki/modules">https://github.com/joyent/node/wiki/modules</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/web-development-rookie-nodejs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何停止Windows服务器上僵死进程</title>
		<link>http://blog.eood.cn/kill_zombie_process</link>
		<comments>http://blog.eood.cn/kill_zombie_process#comments</comments>
		<pubDate>Sun, 27 Mar 2011 02:35:28 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Office PIA]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1640</guid>
		<description><![CDATA[假如在 Windows 服务器上调用某些服务，可能因为多种原因导致程序卡在那里。这在 Office PIA 开发中最常遇到，一般调用 WORD 来处理某些任务，会遇到 WORD 的僵死。我们想停掉处理超时的程序，用 .NET 写一个 console 小程序仅仅数行就能达到这个目的： using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using System.Threading; namespace WORD_Monitor { class Program { static void Main(string[] args) { System.Console.WriteLine("Monitor service start"); // check every 2 seconds Timer timer = new Timer(new TimerCallback(TimCallBack), null, 1000, 2000); Console.Read(); [...]]]></description>
			<content:encoded><![CDATA[<p>假如在 Windows 服务器上调用某些服务，可能因为多种原因导致程序卡在那里。这在 Office PIA 开发中最常遇到，一般调用 WORD 来处理某些任务，会遇到 WORD 的僵死。我们想停掉处理超时的程序，用 .NET 写一个 console 小程序仅仅数行就能达到这个目的：</p>
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace WORD_Monitor
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("Monitor service start");
            // check every 2 seconds
            Timer timer = new Timer(new TimerCallback(TimCallBack), null, 1000, 2000);
            Console.Read();
            timer.Dispose();
        }

        public static void TimCallBack(object o)
        {
            Process[] proc = null;
            proc = Process.GetProcesses();
            foreach (Process pr in proc)
            {
               // only check WINWORD process
               if (!(pr.ProcessName.IndexOf("WINWORD") < 0))
               {
                  DateTime now = DateTime.Now;
                  TimeSpan dtDiff = now - pr.StartTime;
                  // kill the process over 30 seconds
                  if (dtDiff.TotalSeconds > 30)
                  {
                      pr.Kill();
                  }
              }
             }
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/kill_zombie_process/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML 文件处理利器 VTD-XML</title>
		<link>http://blog.eood.cn/vtd-xml_xml_parser</link>
		<comments>http://blog.eood.cn/vtd-xml_xml_parser#comments</comments>
		<pubDate>Sat, 26 Mar 2011 15:27:19 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[VTD-XML]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1642</guid>
		<description><![CDATA[最近项目中涉及到解析处理庞大的 XML 文件。对于 XML 文件的解析在 PHP 中可以用正则表达式或者其中的 XML dom 库，在 JAVA 中可以用 DOM 的方式来解析或者比较高效的 SAX。但是发现更好的 VTD-XML, 它完美支持 Xpath 查询。 VTD-XML 项目主页上称自己为 XML 处理的未来，非常适合 SOA 和云计算中大量 XML 文件的处理。 列举 VTD-XML 的各个优点： 世界上最节省内存的 XML 解析器 世界上最快的 XML 解析器, 比 DOM 快 5-12 倍 世界上最快的 Xpath 解析 世界上唯一支持增量更新的 XML 解析器 可以用来 Xpath 来查询 256G 大小的 XML 文件的解析器 支持 [...]]]></description>
			<content:encoded><![CDATA[<p>最近项目中涉及到解析处理庞大的 XML 文件。对于 XML 文件的解析在 PHP 中可以用正则表达式或者其中的 XML dom 库，在 JAVA 中可以用 DOM 的方式来解析或者比较高效的 SAX。但是发现更好的 VTD-XML, 它完美支持 Xpath 查询。<br />
VTD-XML 项目主页上称自己为 XML 处理的未来，非常适合 SOA 和云计算中大量 XML 文件的处理。<br />
列举 VTD-XML 的各个优点：<br />
世界上最节省内存的 XML 解析器<br />
世界上最快的 XML 解析器, 比 DOM 快 5-12 倍<br />
世界上最快的 Xpath 解析<br />
世界上唯一支持增量更新的 XML 解析器<br />
可以用来 Xpath 来查询 256G 大小的 XML 文件的解析器<br />
支持 JAVA C C++ C#</p>
<p>VTD-XML Xpath 查询的例子：</p>
<pre>
VTDGen vg = new VTDGen();
if (vg.parseFile("blog.eood.cn.xml", true)) {
	VTDNav vn = vg.getNav();
	File fo = new File("blog.eood.cn.xml");
	FileOutputStream fos = new FileOutputStream(fo);
	AutoPilot ap = new AutoPilot(vn);
	XMLModifier xm = new XMLModifier(vn);
	// test if the element which has a child a content = ACONTENT and child b content = BCONTENT exist
	ap.selectXPath("/a/*[child::a[.='ACONTENT'] and child::b[.='BCONTENT']]");

	if(ap.evalXPath()!=-1){
		System.out.println("================ Existed.");
	}
	xm.output(fos);
	fos.close();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/vtd-xml_xml_parser/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>高效程序调试和测试方法</title>
		<link>http://blog.eood.cn/efficient_debugging_php_java_python</link>
		<comments>http://blog.eood.cn/efficient_debugging_php_java_python#comments</comments>
		<pubDate>Sun, 28 Nov 2010 03:26:30 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[My Thinking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1419</guid>
		<description><![CDATA[调试程序往往比编写程序更浪费时间，正如一些有经验的程序员所说，软件的开发应该包括20%的程序编写时间和80%的Debug时间。并且调试程序比编写程序要难2倍。编写巧妙的程序并不一定调试方便。 程序的调试有很多方法，比如最常见的VC之类的IDE都提供加断点，逐步执行，逐段执行的功能。但是这只能针对程序某个微小的片段，对于前期bug的范围的界定并不是很方便。况且对于不满IDE的臃肿，身陷Vim, notepad++, Editplus之类的编辑器之中，我们需要找到更加高效的程序调试和测试方法。 在程序执行的关键点打印Log是一个非常高效的方法，如何打印log进行程序调试呢? 以PHP程序开发为例，需要2个步骤: 1. PHP函数中两个关键的打印变量的方法 print_r var_dump 所以我们可以在关键的地方打印需要的变量。 2. 收集我们在程序中打印的变量 我们可以把程序执行过程中打印的变量逐条写到文本文件里。在程序执行完毕之后进行分析，查找Bug，修正程序。 PHP中打印时间，和变量的程序片段： function file_log($message) { global $file_log_location; ob_start(); echo date("Y-m-d H:i:s \t", time()); print_r($message); echo "\n"; $var = ob_get_contents(); ob_end_clean(); $open=@fopen($file_log_location,"a"); @fwrite($open,$var); fclose($open); } 应用此段程序还需要对log的存储位置$file_log_location赋值。 在需要的地方插入此片段，执行PHP程序，就会得到所需信息。 但是假如是长时间运行的程序如何在程序执行的过程中就查看到log的信息？相信你已经想到了可以在shell中用 tail -f /var/debug.log 这样总可以看到程序吐出的最新的debug信息。 附件是Drupal中进行debug的一个小的module,做drupal开发的同学可以尝试一下。 Drupal debug module 虽然本文针对PHP开发所言，但是这种方法也适合python,java之类的动态语言的开发。 &#8211;EOF&#8211;]]></description>
			<content:encoded><![CDATA[<blockquote><p>调试程序往往比编写程序更浪费时间，正如一些有经验的程序员所说，软件的开发应该包括20%的程序编写时间和80%的Debug时间。并且调试程序比编写程序要难2倍。编写巧妙的程序并不一定调试方便。</p></blockquote>
<p><img class="alignright size-full wp-image-1435" title="debug" src="http://blog.eood.cn/wp-content/uploads/2010/11/debug.gif" alt="" width="410" height="171" />程序的调试有很多方法，比如最常见的VC之类的IDE都提供加断点，逐步执行，逐段执行的功能。但是这只能针对程序某个微小的片段，对于前期bug的范围的界定并不是很方便。况且对于不满IDE的臃肿，身陷Vim, notepad++, Editplus之类的编辑器之中，我们需要找到更加高效的程序调试和测试方法。</p>
<p>在程序执行的关键点打印Log是一个非常高效的方法，如何打印log进行程序调试呢? 以PHP程序开发为例，需要2个步骤:</p>
<h4>1. PHP函数中两个关键的打印变量的方法</h4>
<p><em><span style="color: #000000;">print_r var_dump</span></em></p>
<p>所以我们可以在关键的地方打印需要的变量。</p>
<h4>2. 收集我们在程序中打印的变量</h4>
<p>我们可以把程序执行过程中打印的变量逐条写到文本文件里。在程序执行完毕之后进行分析，查找Bug，修正程序。</p>
<p>PHP中打印时间，和变量的程序片段：</p>
<pre>function file_log($message) {
    global $file_log_location;
    ob_start();
    echo date("Y-m-d H:i:s \t", time());
    print_r($message);
    echo "\n";
    $var = ob_get_contents();
    ob_end_clean();
    $open=@fopen($file_log_location,"a");
    @fwrite($open,$var);
    fclose($open);
}
</pre>
<p>应用此段程序还需要对log的存储位置<em><span style="color: #000000;">$file_log_location</span></em>赋值。</p>
<p>在需要的地方插入此片段，执行PHP程序，就会得到所需信息。</p>
<p>但是假如是长时间运行的程序如何在程序执行的过程中就查看到log的信息？相信你已经想到了可以在shell中用</p>
<p><em><span style="color: #000000;">tail -f /var/debug.log</span></em></p>
<p>这样总可以看到程序吐出的最新的debug信息。</p>
<p>附件是Drupal中进行debug的一个小的module,做drupal开发的同学可以尝试一下。</p>
<p><a href="http://blog.eood.cn/wp-content/uploads/2010/11/filelog_0.zip">Drupal debug module</a></p>
<p>虽然本文针对PHP开发所言，但是这种方法也适合python,java之类的动态语言的开发。</p>
<p>&#8211;EOF&#8211;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/efficient_debugging_php_java_python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Office PIA to extract the sentences of MS Word files</title>
		<link>http://blog.eood.cn/how-to-use-office-pia-to-extract-the-sentences-of-ms-word-files</link>
		<comments>http://blog.eood.cn/how-to-use-office-pia-to-extract-the-sentences-of-ms-word-files#comments</comments>
		<pubDate>Tue, 12 Oct 2010 13:47:51 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1252</guid>
		<description><![CDATA[Part of Programming Office PIA and OpenXML SDK Our tasks: 1. Get the total word count of the file 1. Extract the content text in the doc/docx files 2. Modify the sentences in the doc/docx files, replace with a sequence tag #ORDER# Develop environment: Visual Studio 2010 Office 2007 Firstly, add the COM reference of [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-5744751471423663";
google_ad_slot = "7076368164";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<span style="text-decoration: underline;">Part of Programming Office PIA and OpenXML SDK</span></p>
<p><strong>Our tasks:</strong><br />
1. Get the total word count of the file<br />
1. Extract the content text in the doc/docx files<br />
2. Modify the sentences in the doc/docx files, replace with a sequence tag #ORDER#</p>
<p><strong>Develop environment:</strong><br />
Visual Studio 2010<br />
Office 2007</p>
<p>Firstly, add the COM reference of Microsoft.Office.Interop.Word in your project.<br />
Change the Embed Interop Types to false.</p>
<p><span style="color: #ff0000;">static object Unknown = Type.Missing;</span></p>
<p><span style="color: #ff0000;">ApplicationClass app = new ApplicationClass();<br />
app.Visible = true;<br />
object filePath = (object)&#8221;c:\\test1.docx&#8221;;<br />
Document doc;<br />
// Open the document<br />
var doc = (DocumentClass)app.Documents.Open(ref filePath, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown,<br />
ref Unknown, ref Unknown);<br />
// get total word count of the document<br />
WdStatistic stat = WdStatistic.wdStatisticWords;<br />
int num = doc.ComputeStatistics(stat, ref Unknown);<br />
// get the sentences<br />
Sentences sentences = doc.Sentences;<br />
System.Collections.IEnumerator ie = sentences.GetEnumerator();</span></p>
<p><span style="color: #ff0000;">for (int i = sentences.Count; i &gt;= 1; i&#8211;)<br />
{<br />
// select the sentence range<br />
object startLocation = sentences[i].Start;<br />
object endLocation = sentences[i].End  &#8211; 1;<br />
Range rng = doc.Range(ref startLocation, ref endLocation);<br />
rng.Select();<br />
app.Selection.TypeText(&#8220;#&#8221;+ i + &#8220;#&#8221;);<br />
// add your words<br />
// app.Selection.Font.Bold = -1;<br />
// app.Selection.TypeText(&#8220;test&#8221;);<br />
// sentences[i].Revisions.AcceptAll();<br />
// get the xml of the range<br />
content += sentences[i].XML + &#8220;\r\n&#8221;;<br />
// get the text of the sentence<br />
//sentences[i].Text;<br />
}<br />
app.Quit();</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/how-to-use-office-pia-to-extract-the-sentences-of-ms-word-files/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10条测验自己PHP水平的语句</title>
		<link>http://blog.eood.cn/10_questions_to_test_your_php_level</link>
		<comments>http://blog.eood.cn/10_questions_to_test_your_php_level#comments</comments>
		<pubDate>Fri, 01 Oct 2010 02:50:39 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1235</guid>
		<description><![CDATA[心算以下十条PHP语句的结果,假如正确率在80%以上,标志你的水平在中等以上。 print_r(unserialize(null)); print_r(is_array(null)); print_r(is_array(array())); print_r(array_pop(array_reverse(explode(&#8216;.&#8217;, &#8217;0.1&#8242;)))); print_r(null == 0); print_r(null === 0); print_r(array() == null); print_r(array_rand(array(0=&#62;1))); print_r(in_array(1, array(0=&#62;1))); print_r((list($a, $b) = array(0, 1)) &#38;&#38; $b);]]></description>
			<content:encoded><![CDATA[<p><strong>心算以下十条PHP语句的结果,假如正确率在80%以上,标志你的水平在中等以上。</strong></p>
<p><span style="color: #0000ff;">print_r(unserialize(null));</span></p>
<p><span style="color: #0000ff;">print_r(is_array(null));</span></p>
<p><span style="color: #0000ff;">print_r(is_array(array()));</span></p>
<p><span style="color: #0000ff;">print_r(array_pop(array_reverse(explode(&#8216;.&#8217;, &#8217;0.1&#8242;))));</span></p>
<p><span style="color: #0000ff;">print_r(null == 0);</span></p>
<p><span style="color: #0000ff;">print_r(null === 0);</span></p>
<p><span style="color: #0000ff;">print_r(array() == null);</span></p>
<p><span style="color: #0000ff;">print_r(array_rand(array(0=&gt;1)));</span></p>
<p><span style="color: #0000ff;">print_r(in_array(1, array(0=&gt;1)));</span></p>
<p><span style="color: #0000ff;">print_r((list($a, $b) = array(0, 1)) &amp;&amp; $b);</span></p>
<p><span style="color: #0000ff;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/10_questions_to_test_your_php_level/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Drupal: Show custom links as Primary / Secondary links.</title>
		<link>http://blog.eood.cn/drupal-show-custom-links-as-primary-secondary-links</link>
		<comments>http://blog.eood.cn/drupal-show-custom-links-as-primary-secondary-links#comments</comments>
		<pubDate>Mon, 02 Aug 2010 12:30:30 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1206</guid>
		<description><![CDATA[Add the code in page.tpl.php Output in template: &#60;?php print theme(&#8216;links&#8217;, menu_navigation_links(&#8220;menu-merchant&#8221;), array(&#8216;id&#8217; =&#62; &#8216;features-menu&#8217;, &#8216;class&#8217; =&#62; &#8216;links primary-links&#8217;)) ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Add the code in page.tpl.php<a href="http://blog.eood.cn/wp-content/uploads/2010/02/drupal1.gif"><img class="size-full wp-image-796 alignright" title="drupal" src="http://blog.eood.cn/wp-content/uploads/2010/02/drupal1.gif" alt="" width="159" height="159" /></a><br />
Output in template:<br />
&lt;?php print theme(&#8216;links&#8217;, menu_navigation_links(&#8220;menu-merchant&#8221;), array(&#8216;id&#8217; =&gt; &#8216;features-menu&#8217;, &#8216;class&#8217; =&gt; &#8216;links primary-links&#8217;)) ?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/drupal-show-custom-links-as-primary-secondary-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP抓取外部资源函数fopen / file_get_contents / curl 的区别</title>
		<link>http://blog.eood.cn/php_fopen-file_get_contents-curl-difference</link>
		<comments>http://blog.eood.cn/php_fopen-file_get_contents-curl-difference#comments</comments>
		<pubDate>Mon, 02 Aug 2010 04:56:19 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[fopen]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1195</guid>
		<description><![CDATA[fopen / file_get_contents 每次请求都会重新做DNS查询，并不对DNS信息进行缓存。 但是CURL会自动对DNS信息进行缓存。对同一域名下的网页或者图片的请求只需要一次DNS查询。 这大大减少了DNS查询的次数。 所以CURL的性能比fopen / file_get_contents 好很多。]]></description>
			<content:encoded><![CDATA[<p>fopen / file_get_contents 每次请求都会重新做DNS查询，并不对DNS信息进行缓存。<img class="alignright" src="http://static.php.net/www.php.net/images/php.gif" alt="" /><br />
但是CURL会自动对DNS信息进行缓存。对同一域名下的网页或者图片的请求只需要一次DNS查询。<br />
这大大减少了DNS查询的次数。<br />
所以CURL的性能比fopen / file_get_contents 好很多。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/php_fopen-file_get_contents-curl-difference/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.519 seconds. -->
<!-- File not cached! Super Cache Couldn't write to: wp-content/cache/wp-cache-ca0f6611db5ce101c8114f9c7adec8fb.html -->

