<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Admun&#039;s Tech Journey</title>
    <link>https://edmondhui.ddns.net/tech</link>
    <description>thoughts, ideas, projects, and discoveries on technologies</description>
    <language>en-us</language>           
    <generator>LMNucleus CMS v3.66</generator>
    <copyright>�</copyright>             
    <category>Weblog</category>
    <docs>http://backend.userland.com/rss</docs>
     
<cloud domain="rpc.rsscloud.org" port="5337" path="/rsscloud/pleaseNotify" registerProcedure="" protocol="http-post" />
    <image>
      <url>https://edmondhui.ddns.net/tech/nucleus/nucleus2.gif</url>
      <title>Admun&#039;s Tech Journey</title>
      <link>https://edmondhui.ddns.net/tech</link>
    </image>
              <item>
 <title><![CDATA[MySQL skips foreign key check]]></title>
 <link>https://edmondhui.ddns.net/tech/item/mysql-skips-foreign-key-check</link>
 <guid>https://edmondhui.ddns.net/tech/item/mysql-skips-foreign-key-check</guid>
 <description><![CDATA[I keep forgeting this when need to flush the table in MySQL<br />
<br />
<pre><br />
SET foreign_key_checks = 0;<br />
</pre><br/>]]></description>
<category>mysql</category><category>tips</category> 
 <category>General</category>
 <comments>https://edmondhui.ddns.net/techitem/mysql-skips-foreign-key-check#c</comments>
 <pubDate>Wed, 1 May 2013 23:52:00 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[svn + meld...]]></title>
 <link>https://edmondhui.ddns.net/tech/item/</link>
 <guid>https://edmondhui.ddns.net/tech/item/</guid>
 <description><![CDATA[The easiest way to setup code diff on command-line I can <a href="https://mail.gnome.org/archives/meld-list/2008-April/msg00010.html">found</a>.<br />
<br />
I modify it a bit so it works on MacOS X.<br />
<br />
First, you need to install meld from homebrew.<br />
<br />
Then create a shell script "svn-diff-meld" in ~/bin:<br />
<pre><br />
#!/bin/sh<br />
# SVN Diff Wrapper for Meld<br />
# KOG 2008-02<br />
<br />
# This line is only need if you use it on MacOS, assuming meld installed by homebrew <br />
export PYTHONPATH=/usr/local/lib/python2.7/site-packages<br />
<br />
left="$6"<br />
right="$7"<br />
<br />
meld "$left" "$right"<br />
</pre><br />
<br />
add alais to do svn diff w/ meld:<br />
<pre><br />
alias svn-diff='svn diff --diff-cmd=/Users/me/bin/svn-diff-meld'<br />
</pre><br/>]]></description>
<category>svn</category><category>tips</category> 
 <category>Me hacks</category>
 <comments>https://edmondhui.ddns.net/techitem/#c</comments>
 <pubDate>Fri, 8 Feb 2013 20:09:03 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Getting IP address from string]]></title>
 <link>https://edmondhui.ddns.net/tech/item/getting-ip-address-from-string</link>
 <guid>https://edmondhui.ddns.net/tech/item/getting-ip-address-from-string</guid>
 <description><![CDATA[I was in need for some shell magic to get the current NTP server IP address. After some Googling, found this:<br />
<br />
<pre><br />
ntpstat | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'<br />
</pre><br/>]]></description>
<category>ntp</category><category>tips</category><category>unix</category><category>shell</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/getting-ip-address-from-string#c</comments>
 <pubDate>Mon, 21 May 2012 22:32:19 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Pair up array key and value into string]]></title>
 <link>https://edmondhui.ddns.net/tech/item/pair-up-array-key-and-value-into-string</link>
 <guid>https://edmondhui.ddns.net/tech/item/pair-up-array-key-and-value-into-string</guid>
 <description><![CDATA[Saw a snippet in PHP doc, and applies it to display model validation error in cakePHP:<br />
<br />
<pre><br />
    $this->Somemodel->create();<br />
    if (!$this->Somemodel->save($data)) {<br />
      $errors = array_map(create_function('$key, $value', 'return $key.":".$value;'), array_keys($this->Somemodel->validationErrors), array_values($this->Somemodel->validationErrors));<br />
      echo ' - FAILED (rule: ' . implode(',', $errors) . ')';<br />
    }<br />
</pre><br/>]]></description>
<category>cakephp</category><category>php</category><category>tips</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/pair-up-array-key-and-value-into-string#c</comments>
 <pubDate>Wed, 10 Aug 2011 16:40:37 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Cake Control, we have no model!]]></title>
 <link>https://edmondhui.ddns.net/tech/item/cake-control-we-have-no-model</link>
 <guid>https://edmondhui.ddns.net/tech/item/cake-control-we-have-no-model</guid>
 <description><![CDATA[It's sort of obvious; To create a controller that has no model, simply:<br />
<br />
<pre><br />
        var $uses = array();<br />
</pre><br/>]]></description>
<category>cakephp</category><category>tips</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/cake-control-we-have-no-model#c</comments>
 <pubDate>Wed, 10 Aug 2011 16:35:39 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Finding out page load on IE6]]></title>
 <link>https://edmondhui.ddns.net/tech/item/finding-out-page-load-on-ie6</link>
 <guid>https://edmondhui.ddns.net/tech/item/finding-out-page-load-on-ie6</guid>
 <description><![CDATA[Yeah, we shouldn't need this piece of code anymore... but the world is not ideal.  <img src="https://edmondhui.ddns.net/blog/nucleus/plugins/emoticons/default/icon_cool.gif" alt="cool" /> <br />
<br />
<pre><br />
var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);<br />
</pre><br />
<br />
With this, then I can conditional deal with IE6 throughout my javascript.<br/>]]></description>
<category>javascript</category><category>ie6</category><category>tips</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/finding-out-page-load-on-ie6#c</comments>
 <pubDate>Mon, 11 Jul 2011 12:22:28 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Reading Current URL from jQuery]]></title>
 <link>https://edmondhui.ddns.net/tech/item/reading-current-url-from-jquery</link>
 <guid>https://edmondhui.ddns.net/tech/item/reading-current-url-from-jquery</guid>
 <description><![CDATA[I'm working on a piece of jQuery code that need to read a parameter from the current URL to perform work. First step is to read the URL. Here's how to do it:<br />
<br />
<pre><br />
url_path = window.location.pathname;<br />
</pre><br/>]]></description>
<category>jquery</category><category>javascript</category><category>tips</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/reading-current-url-from-jquery#c</comments>
 <pubDate>Tue, 28 Jun 2011 15:29:10 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Dump all tables in MySL]]></title>
 <link>https://edmondhui.ddns.net/tech/item/dump-all-tables-in-mysl</link>
 <guid>https://edmondhui.ddns.net/tech/item/dump-all-tables-in-mysl</guid>
 <description><![CDATA[Another trick I saw a while back using mysqldump. This come in handy when you want to drop everything in a database:<br />
<br />
<pre><br />
mysqldump -u[uesr] -p[passwd] --add-drop-table --no-data [database] | grep DROP | mysql -u[user] -p[passwd] [database]<br />
</pre><br/>]]></description>
<category>mysql</category><category>tips</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/dump-all-tables-in-mysl#c</comments>
 <pubDate>Thu, 12 May 2011 13:20:48 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[Counting Days and Hours in PHP]]></title>
 <link>https://edmondhui.ddns.net/tech/item/counting-days-and-hours-in-php</link>
 <guid>https://edmondhui.ddns.net/tech/item/counting-days-and-hours-in-php</guid>
 <description><![CDATA[Just come up with some code to calculate how many days + hours since a particular date/time.<br />
<br />
<pre><br />
            $time = time() - strtotime($created_at); // $created_at is a string of time i.e. Fri Mar 18 17:24:35 PDT 2011<br />
            $days = floor($time/24/60/60);<br />
            if ($days > 0) {<br />
                $days_out = "$days day";<br />
                $days_out .= $days > 1 ? 's' : '' .", ";<br />
            }<br />
            $hours = floor(($time % (24*60*60))/60/60);<br />
            $hours_out = "{$hours} hour";<br />
            $hours_out .= $hours > 1 ? 's' : '' . " ago";<br />
            echo "{$days_out}{$hours_out}";<br />
</pre><br/>]]></description>
<category>php</category><category>coding</category> 
 <category>Note to self</category>
 <comments>https://edmondhui.ddns.net/techitem/counting-days-and-hours-in-php#c</comments>
 <pubDate>Fri, 18 Mar 2011 17:26:41 +0000</pubDate>
 
</item>
          <item>
 <title><![CDATA[A simple web crawler in PHP]]></title>
 <link>https://edmondhui.ddns.net/tech/item/a-simple-web-crawler-in-php</link>
 <guid>https://edmondhui.ddns.net/tech/item/a-simple-web-crawler-in-php</guid>
 <description><![CDATA[I was talking to a colleague about how to write a web crawler, and spend an hour to split out this simple piece of code as a proof of concept.<br />
<pre><br />
<?php<br />
// a simple web crawler example<br />
// v1.1<br />
//<br />
<br />
$toplink = "http://edmondhui.homeip.net/blog";<br />
$depth = 2;<br />
<br />
walkIt($toplink,1);<br />
<br />
function walkIt($link, $level) {<br />
	global $depth;<br />
	if ($level <= $depth) {<br />
		$content = file($link);<br />
		if ($content != false) {<br />
			$content = html_entity_decode(implode($content));<br />
			//<br />
			// IF NEED, PAGE CONTENTS PROCESS AND SAVE TO DB HERE<br />
			//<br />
			preg_match_all("/href=\".*?\"/i", $content, $matches);<br />
			$matches = array_unique($matches[0]);<br />
			foreach ($matches as $idx => $url) {<br />
				$url = substr($url, 6, -1);<br />
				if (strstr($url, "http://") != false) {<br />
					for ($i = 0; $i < $level; $i++) { echo '  '; }<br />
					echo "$url\n";<br />
					walkIt($url, $level+1);<br />
				}<br />
			}<br />
		} else {<br />
			echo "failed to crawle - $link\n";<br />
		}<br />
	}<br />
}<br />
?><br />
<br />
</pre><br />
Next exercise, write this in python!<br/>]]></description>
<category>php</category><category>web</category><category>crawler</category> 
 <category>General</category>
 <comments>https://edmondhui.ddns.net/techitem/a-simple-web-crawler-in-php#c</comments>
 <pubDate>Tue, 21 Sep 2010 19:26:03 +0000</pubDate>
 
</item>

  </channel>
</rss>
