<?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>{Chang2Chang}</title>
	<atom:link href="http://www.chang2chang.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chang2chang.com</link>
	<description>Web Technology &#124; Reviews &#124; Development &#124; Tutorials</description>
	<lastBuildDate>Fri, 23 Jul 2010 05:17:58 +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>TSP Problem</title>
		<link>http://www.chang2chang.com/2010/07/tsp-problem/</link>
		<comments>http://www.chang2chang.com/2010/07/tsp-problem/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 05:17:57 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Google maps]]></category>
		<category><![CDATA[TPS]]></category>
		<category><![CDATA[Traveling Salesman]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=162</guid>
		<description><![CDATA[I have just run into what appears to be a very classic problem that has been studied a lot: The Problem: A list of addresses in a neighborhood that someone must visit and complete in a timely manner. This is very much related to a problem called The traveling salesman problem (TSP) where an optimal [...]]]></description>
			<content:encoded><![CDATA[<p>I have just run into what appears to be a very classic problem that has been studied a lot:</p>
<p><strong>The Problem:</strong></p>
<p>A list of addresses in a neighborhood that someone must visit and complete in a timely manner.</p>
<p>This is very much related to a problem called The <a href="http://en.wikipedia.org/wiki/Travelling_salesman_problem">traveling salesman problem (TSP)</a> where an optimal walking order needs to be computed which result in the shortest distance traveled and/or shortest time taken.</p>
<p>After taking a look at different approach to this problem and taking look at a current javascript implementation at<br />
<a href="http://www.gebweb.net/optimap/">http://www.gebweb.net/optimap/</a></p>
<p>It gave me hope that this problem can be solved with web implementations, however there were two problems with the above solution.</p>
<p>1. It restricted to 24 addresses (Which is fine because TSP originally is for larger area route planning, even between cities)<br />
2. Only given 15 or less address did it return the optimal route</p>
<p><strong>The solution:</strong></p>
<p>Due to computational resources and restrictions in scripting languages, I have decided that the best and easiest way to solve this problem would be using the &#8220;Nearest Neighbor&#8221; approach.</p>
<p>This approach takes the closest location as the next location and repeat this process for route planning. Although this is not the most optimal way of solving the problem but it provides a couple of advantages:</p>
<p>1. Can always calculate straight line distance to the next address and then use google map API to calculate the direction<br />
2. The step can be repeated and increment the current location to the next address which is just calculated.</p>
<p>The biggest problem with the approach so far is that in order to calculate the route (On the server side), we must specify a starting point. Some ideas include use one of the boundary corners as a starting point, or use the middle most point and walk in a circular fashion.</p>
<p>Will keep updated with some implementation soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2010/07/tsp-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split text file by line numbers in PHP</title>
		<link>http://www.chang2chang.com/2010/06/split-text-file-by-line-numbers-in-php/</link>
		<comments>http://www.chang2chang.com/2010/06/split-text-file-by-line-numbers-in-php/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 03:17:32 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Open source development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[file split]]></category>
		<category><![CDATA[split file by lines]]></category>
		<category><![CDATA[text file split]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=144</guid>
		<description><![CDATA[On a recent project I happen to stumble upon an unique problem: splitting up a large flat text file (in my case large CSV) into equal parts so the processing could be more manageable. So the problem: Split up a CSV file with 100,000 rows of data After going through a few search engines, I [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project I happen to stumble upon an unique problem: splitting up a large flat text file (in my case large CSV) into equal parts so the processing could be more manageable. </p>
<p><strong>So the problem: </strong> Split up a CSV file with 100,000 rows of data</p>
<p>After going through a few search engines, I found that the problem was not as easy as I first thought. </p>
<p>There was one PHP class that looked promising initially: <a href=" http://www.weberdev.com/get_example-3894.html">Link here</a></p>
<p>But after taking a look more closely.</p>
<pre name="code" class="php">

 function run(){
        $i=0;
        $j=1;
        $date = date("m-d-y");
        unset($buffer);

        $handle = @fopen ($this->Getsource(), "r");
        while (!feof ($handle)) {
          $buffer .= @fgets($handle, 4096);
          $i++;
              if ($i >= $split) {
              $fname = $this->Getpath()."part.$date.$j.txt";
               if (!$fhandle = @fopen($fname, 'w')) {
                    print "Cannot open file ($fname)";
                    exit;
               }

               if (!@fwrite($fhandle, $buffer)) {
                   print "Cannot write to file ($fname)";
                   exit;
               }
               fclose($fhandle);
               $j++;
               unset($buffer,$i);
                }
        }
        fclose ($handle);
    } 
</pre>
<p>The script does not work simply because of:</p>
<pre name="code" class="php">
fgets($handle, 4096);
</pre>
<p>The second argument of fgets function dictated how the file was split up. Reading a fixed bytes will result in splitting files not by line but by size which was not desirable.</p>
<p><strong>My Solution:</strong><br />
Although the above script did not work, I was inspired by its processing logic of iterating through the file line by line and add the lines read to segmented files. So what I came up with was below:</p>
<pre name="code" class="php">
/**********************************************************************
*  Author: Chang Xiao (xiaochangfeng@gmail.com)
*  Web...: http://www.chang2chang.com
*  Name..: File Splitter
*  Desc..: A simple file splitter to split csv (or text files)
*  Date..: 6/2/2010
*  PHP Version: 5.x
*/

/*
 * Usage Example
 *
 *
 * // 1. Input and Output files in the current directory
 *
 * $file = new split_file();
 * $result = $file->file_split('randomdata.csv', 'split', 45);
 *
 *
 * // 2. Input file in a directory called source, output files into
 * // data directory
 *
 * $file = new split_file('data');
 * $result = $file->file_split('source/randomdata.csv', 'split', 45);
 * echo $result . ' number of files split';
 *
 */
class split_file {

	/*
	 * @string
	 * Full path or relative path to where the output file will be created
	 */
	private $dest_path;

	/*
	 * Constructor
	 */
	public function __construct($dest_path = '') {

		if($dest_path == '') {
			$this->log_path = '.';
		} else {
			$this->log_path = $dest_path;
		}
	}

	/*
	 ****************************************************************************
	 * Split the input (text) file into smaller files by number of lines
	 *
	 * @params
	 * (string) source_file		|		File path of the source text file
	 * (string) output_prefix	|		File prefix for the output files
	 * (int) split_count		|		Number of lines per split file
	 *
	 * @returns
	 * (string) file_string		|		The original parsed text file string
	 *									if number of lines was less than the
	 *									split count
	 *
	 * (array) return_files		|		Array containing the file path of
	 *							|		splitted files.
	 */
	public function file_split($source_file, $output_prefix, $split_count) {

		if($file_string = file_get_contents($source_file)) {

			// convert line breaks into 
			$_file_string = nl2br($file_string);
			$total_line_count = substr_count($_file_string, "&lt;br /&gt;");

			// if not enough lines to split, we just return the csv string back
			if($total_line_count <= $split_count) {
				return $file_string;
			} else {
				$return_files = array();

				// turn the huge file into a 1D array
				$data = explode("&lt;br /&gt;", $_file_string);
				// file name append increment counter
				$x = 0;
				// split increment counter
				$y = 0;

				// walk through the new data array
				for($i = 0; $i< count($data); $i++) {

					$buffer .= $data[$i];

					$y++;
					if($y >= $split_count) {
						$x++;
						$buffer = trim($buffer);
						$this->_write($buffer, $output_prefix . $x . '.csv');
						$return_files[] = $this->log_path . '/' . $output_prefix . $x . '.csv';

						// start over
						unset($y, $buffer);
					}

					// when we reach the end
					if(count($data) - $i == 1) {
						$x++;
						$buffer = trim($buffer);
						$this->_write($buffer, $output_prefix . $x . '.csv');
						$return_files[] = $this->log_path . '/' . $output_prefix . $x . '.csv';
					}

				}

				return $return_files;

			}
		}
	}

	/***************************************************************
	 * Internal function that writes lines into files (appending)
	 *
	 * @params
	 * (string) message		|	content to be written
	 * (string) file_name	|	just the file name of the file to be written
	 *
	 * @returns
	 * TRUE					|	write successful
	 * FALSE				|	write unsuccessful
	 */
	private function _write($message, $file_name) {

		if(!is_dir($this->log_path)) {
			mkdir($this->log_path, 777);
		}

		$_file_name = $this->log_path . '/' . $file_name;

		if($handle = fopen($_file_name, 'a')) {
			$re = fwrite($handle, $message);
			$re2 = fclose($handle);
			if ( $re != false &#038;&#038; $re2 != false ) return true;
		}
		return false;
	}
}
</pre>
<p>You can download the class file here <a href='http://www.chang2chang.com/wp-content/uploads/2010/06/split_file.class.php_.zip'>split_file.class.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2010/06/split-text-file-by-line-numbers-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful PHP class: ezSQL</title>
		<link>http://www.chang2chang.com/2009/11/useful-php-class-ezsql/</link>
		<comments>http://www.chang2chang.com/2009/11/useful-php-class-ezsql/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 04:31:14 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=139</guid>
		<description><![CDATA[I first used this class 3 years ago, I found it still to be one of the best php class you can find on the web. the ezSQL class enables you to use php to connect to many different databases including MySQL MSSQL PostgreSQL It provides many methods to retrieve single data value, data sets [...]]]></description>
			<content:encoded><![CDATA[<p>I first used this class 3 years ago, I found it still to be one of the best php class you can find on the web.</p>
<p>the ezSQL class enables you to use php to connect to many different databases including</p>
<ul>
<li>MySQL</li>
<li>MSSQL</li>
<li>PostgreSQL</li>
</ul>
<p>It provides many methods to retrieve single data value, data sets and rows of data.</p>
<p>I especially find the following method useful</p>
<pre name="code" class="php">
// get n number of rows of result set based on your query
// can return a standard object, associate array or numeric (index) array
$db->get_results(string "query string", [OBJECT | ARRAY_N | ARRAY_A]);

// returns a single variable from database
// very useful for select count or other aggregate value SQL statements
$db->get_var(string "query string");

// execute a query without return, gives true/false if the query succeed or fails
// useful for create table, insert, update queries
$db->query(string "query string");
</pre>
<p>You can download it <a href="http://www.woyano.com/jv/ezsql">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/11/useful-php-class-ezsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iphone and Flash, (not) a match made in heavens</title>
		<link>http://www.chang2chang.com/2009/09/iphone-and-flash-not-a-match-made-in-heavens/</link>
		<comments>http://www.chang2chang.com/2009/09/iphone-and-flash-not-a-match-made-in-heavens/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 20:48:51 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Entertainment]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=135</guid>
		<description><![CDATA[As a fan of the iPhone, I have always had one problem with the device: its inability to display reach media contents, namely flash applications. Other articles on the web has stated some of the reasons why flash will not exist on iPhone, including battery life, security flaws, memory insufficiency and the biggest of them [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chang2chang.com/wp-content/uploads/2009/09/flash-iphone1.jpg"><img src="http://www.chang2chang.com/wp-content/uploads/2009/09/flash-iphone1-150x150.jpg" alt="flash-iphone1" title="flash-iphone1" width="150" height="150" class="alignleft size-thumbnail wp-image-136" /></a>As a fan of the iPhone, I have always had one problem with the device: its inability to display reach media contents, namely flash applications. Other articles on the web has stated some of the reasons why flash will not exist on iPhone, including battery life, security flaws, memory insufficiency and the biggest of them all, direct threat to the iPhone app store. Most of the points were valid and perhaps that flash is the biggest threat to iPhone app store in the following sense: Most popular iPhone programs has been games, and there are thousands of flash gaming websites that delivers equal quality games if not better. It would have threatened the paid iPhone games even though most of them are under $1. However, even if iPhone is able ran flash games, it would still had problems because most flash games are programmed to interface with the keyboard and mouse. However, I believe that the biggest problems stand between iPhone and Flash compatibility is the 3G networks. The fact is, the highly tauted 3G network is simply not mature enough to handle the data transmitted through all the smart phones, and of course the most data intensive device: iPhone. Not to name that AT&#038;T&#8217;s questionable 3G network which has came under criticism from many users around the world. Just think about one example, say you download a iPhone game that&#8217;s 5 MB. You will only have to download the game once to play it over and over again. Not so with flash applications, because flash games have to be loaded in a browser it will transmit 5 MB of data every time the user wish to play the game. Not to mention popular TV program streaming websites such as Hulu which uses flash video.</p>
<p>Given the instability of the 3G network (especially AT&#038;T), it is unlikely that iPhone and Flash will make a union anytime soon. It is reported that even though 3G network is most widely implemented in metropolitan areas, it is also the most intensive data usage areas. We can all cross our fingers and pray someday smart phone will run as fast as our desktops. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/09/iphone-and-flash-not-a-match-made-in-heavens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php func_get_args</title>
		<link>http://www.chang2chang.com/2009/09/php-func_get_args/</link>
		<comments>http://www.chang2chang.com/2009/09/php-func_get_args/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 01:37:35 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[func_get_args]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=115</guid>
		<description><![CDATA[Recently looking in Drupal&#8217;s source code I found the func_get_args function. It is quite a powerful function for newer version of php It basically takes in a random number of arguments and parses them in an argument array. Basically, here&#8217;s what how it works function foo_bar() { $args = func_get_args; for($i = 0; $i< count($args; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently looking in Drupal&#8217;s source code I found the func_get_args function. It is quite a powerful function for newer version of php</p>
<p>It basically takes in a random number of arguments and parses them in an argument array.</p>
<p>Basically, here&#8217;s what how it works</p>
<pre name="code" class="php">function foo_bar() {

$args = func_get_args;

for($i = 0; $i< count($args; $i++)
{
       echo $args[$i] . '&lt; br/ &gt; ';
}

foo_bar('monday', 'tuesday', 'wednesday');
</pre>
<p>The above function call will return</p>
<p>monday<br />
tuesday<br />
wednesday</p>
<p>It works very much like passing in an array as a parameter except it's less clunky.</p>
<pre name="code" class="php">
function foo_bar($args = array())
{
     for($i = 0; $i < count($args); $i++)
     {
          echo $args[$i] . '&lt; br/ &gt; ';
     }

}

foo_bar(array('Monday', 'Tuesday', 'Wednesday'));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/09/php-func_get_args/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why is pandora&#8217;s business model not working</title>
		<link>http://www.chang2chang.com/2009/08/why-is-pandoras-business-model-not-working/</link>
		<comments>http://www.chang2chang.com/2009/08/why-is-pandoras-business-model-not-working/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 06:39:19 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Music Royalty]]></category>
		<category><![CDATA[Pandora]]></category>
		<category><![CDATA[Web 2.0 Business Model]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=104</guid>
		<description><![CDATA[Don&#8217;t get me wrong, I have been in love with pandora since its inception. This might just be my gripe. Pandora has always had the song skipping limit in the past, which was fine if you understand the whole royalty pay-per-song arrangement the company had with the record companies. However, you could always get around [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chang2chang.com/wp-content/uploads/2009/08/pandora1.jpg"><img class="alignnone size-thumbnail wp-image-105" style="margin: 8px;" title="pandora" src="http://www.chang2chang.com/wp-content/uploads/2009/08/pandora1-150x150.jpg" alt="pandora" width="150" height="150" align="left" /></a>Don&#8217;t get me wrong, I have been in love with pandora since its inception. This might just be my gripe.</p>
<p>Pandora has always had the song skipping limit in the past, which was fine if you understand the whole royalty pay-per-song arrangement the company had with the record companies. However, you could always get around by go to another station or another quick mix. Lately, the song skipping limit has become time restricted so it doesn&#8217;t matter if you switch station or create new quick mix. Another piece of news, pandora is also starting subscription for the &#8220;heavy users&#8221; who listen to more than 40 hours a month. The rate is not bad itself, 99 cents for the rest of month overage or upgrade to pandora one for $36, the premium non-ad pandora.</p>
<p>Once again, the reason for the overage charge and subscription is understandable. In the end, no one likes the big record company anyways, right? What it begs the question that pandora is not monetizing as well as they could. These are just some of the initial signs to come.</p>
<p>Here are some reasons why pandora&#8217;s business model is not working.</p>
<ol>
<li>It is at the mercy of the big record company. Unlike another popular free media provider Hulu which is formed/backed by major telecom corporations, pandora started out as a private venture, which limited its corporate backing and bargain power</li>
<li>Its advertisement is not effective. Unlike hulu, which can advertise with 15 or 30 second video spot, pandora lacks the visual elements. People often ignore the ads and just continue to work, therefore making video ads ineffective. Furthermore, pandora is as equally popular on mobile devices, which lacks advertising potentials.</li>
<li>Its lack of offering for upgrade to Pandora one subscription service. Pandora one offers ads free, a desktop application and 192 kb streaming quality. That&#8217;s good and all, once again, most computers have web browsers,  desktop app offers nothing new. Most people can&#8217;t notice difference between 192kb streaming quality from 128kb (or whatever quality it&#8217;s streaming on) unless you have high quality audio devices.</li>
</ol>
<p>Here are some suggestion I have, of course what do I know?</p>
<ol>
<li>More effective advertisement, more radio style advertisement. Pandora has a huge listener base, if it can just figure out how to isolate and broadcast radio styled local ads for listeners in different geographic area, they can definitely generate more revenue. That way it can leverage its huge listener base better.</li>
<li>Revenue sharing, sell songs. It can track users favorite songs, package them into &#8220;digital albums&#8221; and sell them to the listeners. That way the listeners can build a good song collection and come back to pandora and discover more. In the process Pandora can charge a percentage of the revenue of the sale.</li>
<li>Add more features to the subscription service. For example, maybe they can offer songs that free users can&#8217;t listen such as remixes, live concert performances, etc.</li>
</ol>
<p>In the end, it must strike the balance between maintaining its image of the free music provider, not alienate its free listener base. At the same time, it have generate enough revenue and profit to stay afloat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/08/why-is-pandoras-business-model-not-working/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding javascript to specific node/url in drupal</title>
		<link>http://www.chang2chang.com/2009/07/adding-javascript-to-specific-nodeurl-in-drupal/</link>
		<comments>http://www.chang2chang.com/2009/07/adding-javascript-to-specific-nodeurl-in-drupal/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 04:53:48 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open source development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=69</guid>
		<description><![CDATA[This was in one of the module I&#8217;ve written in Drupal and I thought it would be useful to share. The Problem: I wanted to dynamically add javascript file to a specific url under Drupal. The benefit would been that I did not have to include the .js file for the whole site therefore optimize [...]]]></description>
			<content:encoded><![CDATA[<p>This was in one of the module I&#8217;ve written in Drupal and I thought it would be useful to share.</p>
<p><strong>The Problem:</strong> I wanted to dynamically add javascript file to a specific url under Drupal. The benefit would been that I did not have to include the .js file for the whole site therefore optimize the performance of site. Not to mention that it by including the javascript file in a specific url, it will not interfere with other scripts, etc.</p>
<p>To review, the function to add javascript in drupal is </p>
<p>drupal_add_js() (http://api.drupal.org/api/function/drupal_add_js/)</p>
<p>However, this function will add a javascript file or script to the head section on all of the drupal path/urls, making it clunky. </p>
<p><strong>The Solution:</strong></p>
<pre name="code" class="php">

// The function passes in a parameter which is the url you want to check
// It will return true if the url the user is browsing matches the url you are trying to
// act on
function module_name_helper_is_page($check_url)
{
	global $base_url;

	$page_url = module_name_helper_get_curl_url();

	if(!stristr($page_url, $check_url))
	{
		return FALSE;
	}
	else
	{
		return TRUE;
	}
}

/*
 * This function simply returns the current url of the web page
*/
function module_name_helper_get_curl_url()
{
	$pageURL = 'http';
	if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
	$pageURL .= "://";
	if ($_SERVER["SERVER_PORT"] != "80") {
	$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} else {
	$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	}

	return $pageURL;
}
</pre>
<p>To put it into action, say we wanted to only add a javascript file to the user registration page, here would be what it looks like. (By the way, module_name stands for the module you are writing)</p>
<pre name="code" class="php">
if(module_name_helper_is_page($base_url . 'user/register'))
{
     drupal_add_js(drupal_get_path('module', 'module_name') .'/yourjavascript.js', 'module', 'header');
}
</pre>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/07/adding-javascript-to-specific-nodeurl-in-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom 403 module on Drupal.org</title>
		<link>http://www.chang2chang.com/2009/06/custom_403_drupal/</link>
		<comments>http://www.chang2chang.com/2009/06/custom_403_drupal/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 04:02:40 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Open source development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[403]]></category>
		<category><![CDATA[access denied]]></category>
		<category><![CDATA[module]]></category>

		<guid isPermaLink="false">http://www.chang2chang.com/?p=64</guid>
		<description><![CDATA[This is a module I have worked on a while back. I have recently had the time to finish it and it is now released and hosted on drupal.org, which is very exciting. You can view the module project page here, to see a demo page, please visit here The module was made with one [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chang2chang.com/wp-content/uploads/2009/06/custom_403_screen.jpg"><img class="alignleft size-thumbnail wp-image-63" style="margin: 6px;" title="custom_403_screen_shot" src="http://www.chang2chang.com/wp-content/uploads/2009/06/custom_403_screen-150x150.jpg" alt="custom_403_screen_shot" width="150" height="150" /></a>This is a module I have worked on a while back. I have recently had the time to finish it and it is now released and hosted on drupal.org, which is very exciting.</p>
<p>You can view the module project page <a href="http://drupal.org/project/custom_403">here</a>, to see a demo page, please <a href="http://www.chang2chang.com/drupal/node/1">visit here</a></p>
<p>The module was made with one thing specifically in mind, giving the users more information when they encounter a 403 on a website. Since drupal uses various role based node access privileges, I thought a module that provides custom information based on the roles allowed or disallowed on any specific node will be more helpful.</p>
<p>The module works with the content access module to give the visitors information on what roles are allowed to access the nodes and maybe the admins can also give more information on how to obtain these roles. Anyways, please enjoy the module, if you have questions and comments, please let me know</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2009/06/custom_403_drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a Database</title>
		<link>http://www.chang2chang.com/2008/06/add-a-database/</link>
		<comments>http://www.chang2chang.com/2008/06/add-a-database/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 15:53:04 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[MSSQL2005]]></category>
		<category><![CDATA[VB.net]]></category>

		<guid isPermaLink="false">http://chang.jaysondesigns.net/?p=18</guid>
		<description><![CDATA[The first step in adding a database to visual basic project is going to Project -&#62; Add New Item&#8230; Select SQL Database Right Click Tables -&#62; Add New Table Add the colums and their data types Primary key &#8211; foreign key relationship can be found under the menu-relationship After adding the database connection to the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.chang2chang.com/wp-content/uploads/2008/06/image002.jpg" alt="Chapter3_Prog1_001" /><br />
The first step in adding a database to visual basic project is going to <strong>Project -&gt; Add New Item&#8230;</strong></p>
<h3>Select SQL Database</h3>
<p>Right Click <strong>Tables -&gt; Add New Table<br />
</strong><img src="http://www.chang2chang.com/wp-content/uploads/2008/06/image004.jpg" alt="Chapter3_Prog1_002" border="1" /><strong><br />
</strong>Add the colums and their data types</p>
<p>Primary key &#8211; foreign key relationship can be found under the menu-relationship<br />
<img src="http://www.chang2chang.com/wp-content/uploads/2008/06/image006.jpg" alt="Chapter3_Prog1_003" /></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%">After adding the database connection to the data source, you can now drag tables or do other manipulation with the data<o:p></o:p></span></p>
<p><img src="http://www.chang2chang.com/wp-content/uploads/2008/06/image008.jpg" alt="Chapter3_Prog1_004" /><br />
To download the source code for this program, <a href="http://www.chang2chang.com/wp-content/uploads/2008/06/chapter3_prog1.zip" title="Source Code" target="_blank">click here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2008/06/add-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lessons learned: code optmization</title>
		<link>http://www.chang2chang.com/2008/06/lessons-learned-code-optmization/</link>
		<comments>http://www.chang2chang.com/2008/06/lessons-learned-code-optmization/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:50:43 +0000</pubDate>
		<dc:creator>Chang</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://chang.jaysondesigns.net/?p=15</guid>
		<description><![CDATA[Have you ever written a piece of code that works, but the amount of redundancy and inefficiency drove you nuts? Always had the itch to go back and pretty it up? Well, that&#8217;s exactly what I did. I recently wrote a script for a people directory, it contained 3 parts An database storing the information [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever written a piece of code that works, but the amount of redundancy and inefficiency drove you nuts? Always had the itch to go back and pretty it up? Well, that&#8217;s exactly what I did.  I recently wrote a script for a people directory, it contained 3 parts</p>
<ol>
<li>An database storing the information of the people (i.e. name, states, country, etc etc.)</li>
<li>the html input file (see example below) <label></label></li>
<li>The data processor using PHP</li>
</ol>
<p>input file (input.html)</p>
<select name="last_name" id="last_name">
<option selected="selected">Last Name</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
<option>H</option>
<option>I</option>
<option>J</option>
<option>K</option>
<option>L</option>
<option>M</option>
<option>N</option>
<option>O</option>
<option>P</option>
<option>Q</option>
<option>R</option>
<option>S</option>
<option>T</option>
<option>U</option>
<option>V</option>
<option>W</option>
<option>X</option>
<option>Y</option>
<option>Z</option>
</select>
<select name="state" id="state">
<option selected="selected">State</option>
<option>Alabama</option>
<option>Alaska</option>
<option>Arizona</option>
<option>Arkansas</option>
<option>California</option>
<option>Colorado</option>
<option>Connecticut</option>
<option>Delaware</option>
<option>D.C.</option>
<option>Florida</option>
<option>Georgia</option>
<option>Hawaii</option>
<option>Idaho</option>
<option>Illinois</option>
<option>Indiana</option>
<option>Iowa</option>
<option>Kansas</option>
<option>Kentucky</option>
<option>Louisiana</option>
<option>Maine</option>
<option>Maryland</option>
<option>Massachusetts</option>
<option>Michigan</option>
<option>Minnesota</option>
<option>Mississippi</option>
<option>Missouri</option>
<option>Montana</option>
<option>Nebraska</option>
<option>Nevada</option>
<option>New Hampshire</option>
<option>New Jersey</option>
<option>New Mexico</option>
<option>New York</option>
<option>North Carolina</option>
<option>North Dakota</option>
<option>Ohio</option>
<option>Oklahoma</option>
<option>Oregon</option>
<option>Pennsylvania</option>
<option>Rhode Island</option>
<option>South Carolina</option>
<option>South Dakota</option>
<option>Tennessee</option>
<option>Texas</option>
<option>Utah</option>
<option>Vermont</option>
<option>Virginia</option>
<option>Washington</option>
<option>West Virginia</option>
<option>Wisconsin</option>
<option>Wyoming</option>
</select>
<p>The idea is that you will be able to select a last name or a state and find the corresponding results. For example, finding someone in the state of Virginia, finding someone with last name start with W, or a combination of both.</p>
<p>This was the first attempt for selecting the matching last name:</p>
<p>HERE</p>
<p>HERE</p>
<p>By using arrays, here are the code for selecting the matching last name and state and generate the SQL query</p>
<p>HERE</p>
<p>HERE</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chang2chang.com/2008/06/lessons-learned-code-optmization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
