<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[A Hu Qiang Blog]]></title>
  <link href="http://Qiang.Hu/atom.xml" rel="self"/>
  <link href="http://Qiang.Hu/"/>
  <updated>2016-09-13T21:30:53+08:00</updated>
  <id>http://Qiang.Hu/</id>
  <author>
    <name><![CDATA[Qiang Hu]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Exploited Safari Reading List by Advertisers]]></title>
    <link href="http://Qiang.Hu/2014/06/exploited-safari-reading-list-by-advertisers.html"/>
    <updated>2014-06-03T20:29:09+08:00</updated>
    <id>http://Qiang.Hu/2014/06/exploited-safari-reading-list-by-advertisers</id>
    <content type="html"><![CDATA[<p><a href="" title="https://www.apple.com/safari/">Safari&rsquo;s Reading List</a> is really a nice feature and I have been frequently using it to quickly pin webpages and read across Apple devices.</p>

<p>It is so annoying when I find there is some links to webpages I would never be interested in my Reading List, e.g. links to stupid online flash games. I know it must be online advertisers by I really don&rsquo;t know how they do so. I thought there would be some APIs to Reading List, but I could not find one. After carefully digging the code of the site that adds links to my Reading List, I finally found out the trick.</p>

<!-- more -->


<p>
<a href="" title="http://jsfiddle.net/3x8wq">A running example on jsfiddle.net</a>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">a</span><span class="p">.</span><span class="nx">hrefopen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">a</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">try</span> <span class="p">{</span>
</span><span class='line'>            <span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">&quot;a&quot;</span><span class="p">);</span>
</span><span class='line'>            <span class="nx">c</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="s2">&quot;__qiqi_popup__&quot;</span><span class="p">;</span>
</span><span class='line'>            <span class="nx">c</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;href&quot;</span><span class="p">,</span> <span class="nx">a</span><span class="p">);</span>
</span><span class='line'>            <span class="c1">//c.setAttribute(&quot;target&quot;, &quot;_self&quot;);</span>
</span><span class='line'>            <span class="nx">c</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;style&quot;</span><span class="p">,</span> <span class="s2">&quot;display:none;&quot;</span><span class="p">);</span>
</span><span class='line'>            <span class="kd">var</span> <span class="nx">b</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;MouseEvents&quot;</span><span class="p">);</span>
</span><span class='line'>            <span class="nx">b</span><span class="p">.</span><span class="nx">initMouseEvent</span><span class="p">(</span><span class="s2">&quot;click&quot;</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">window</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="kc">true</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="kc">null</span><span class="p">);</span>
</span><span class='line'>            <span class="nx">c</span><span class="p">.</span><span class="nx">dispatchEvent</span><span class="p">(</span><span class="nx">b</span><span class="p">);</span>
</span><span class='line'>            <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
</span><span class='line'>        <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">q</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>    <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Basically, this code simulate a <code>Shift + mouse click</code> on a link to the target webpage, that shortcut in Safari is to add a link to Reading List, while in Chrome, is to open a link in a new window.</p>

<p>Ashamedly, as a developer, I did not know such a API to simulate a mouse event. I personally I do think this API is too powerful. I could not see a very good solution to this problem, but filling a ticket to Apple. I may write a extension to overrides the <code>initMouseEvent</code> to totally get rid of the annoying ads.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Xiaomi Singapore Is Facing Payment Issues (Updated)]]></title>
    <link href="http://Qiang.Hu/2014/03/xiaomi-singapore-is-facing-payment-issues.html"/>
    <updated>2014-03-28T09:57:07+08:00</updated>
    <id>http://Qiang.Hu/2014/03/xiaomi-singapore-is-facing-payment-issues</id>
    <content type="html"><![CDATA[<p><img src="https://lh5.googleusercontent.com/-K29I6ZPBl1U/UzTYXwwVCrI/AAAAAAAABkE/SKDas003qWs/s640/Readmi%2520Hot%2520Sell.jpg"><br/>
At 1200pm Singapore time, March 27 2014, Xiaomi started a new round sell of its Redmi Phone. According to its statement, 5000 sets were sold out in 4 min 42 sec. Very soon after paying via PayPal, happy customers found xiaomi is still waiting for payment on their website.</p>

<!-- more -->


<p><img src="https://lh6.googleusercontent.com/-RcEq6Z3rze0/UzTYRaYwFxI/AAAAAAAABjs/hlYJQk5IuOQ/s640/Xiaomi%2520Waiting%2520Payment.png"><br/>
Some people love Redmi so much that they made multiple payments in afraid of losing it, some Mi fans saied they made 4 times payments on Xiaomi Singapore&rsquo;s <a href="" title="https://www.facebook.com/pages/Xiaomi-Singapore/535405486500557">Facebook page</a>.<br/>
Xiaomi stated that there were issues with Paypal, who was not able to pass back right information to confirm the payments. Xiaomi created the hash tag <code>#PayPal27Mar</code>, indicating PayPal is liable. However, it seems Xiaomis is the only affected company. No user complained on <a href="" title="https://www.facebook.com/PayPal">PayPal&rsquo;s fan page</a>.<br/>
The issue is unsolved after 22 hours.</p>

<h4>Update 1</h4>

<p>PayPal credited 75 SGD to my account as a token of appreciation.</p>

<h4>Update 2</h4>

<p>Xiaomi gave a red RedMi case.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[PHP Apache MySQL Set-up Note]]></title>
    <link href="http://Qiang.Hu/2014/03/php-apache-mysql-set-up-note.html"/>
    <updated>2014-03-25T13:09:31+08:00</updated>
    <id>http://Qiang.Hu/2014/03/php-apache-mysql-set-up-note</id>
    <content type="html"><![CDATA[<ul>
<li>Apache is pre-installed in Mac OS X, and it can be started by running <code>sudo apachectl start</code> in terminal. After this, <blockquote><p>It works!</p></blockquote> is shown when visiting <code>localhost</code> in browser. Create a <code>Sites</code> folder in your home folder, then this folder is accessible through <code>localhost/~yourusername</code>.</li>
<li>Enable PHP by uncommenting <code>LoadModule php5_module libexec/apache2/libphp5.so</code> in <code>/etc/apache2/httpd.conf</code>. Then restart Apache via <code>sudo apachectl restart</code>. To verify if php works, creating a <code>phpinfo.php</code> in the <code>Sites</code> folder:</li>
</ul>


<figure class='code'><figcaption><span>php phpinfo.php  </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="o">&lt;?</span><span class="nx">php</span>
</span><span class='line'>  <span class="nb">phpinfo</span><span class="p">();</span>
</span><span class='line'><span class="cp">?&gt;</span><span class="x">  </span>
</span></code></pre></td></tr></table></div></figure>




<!-- more -->


<p>When visiting <code>localhost/~yourusername/phpinfo.php</code> you should see php mata information instead of plain text of the code.<br/>
&ndash; Install MySQL and phpMyAdmin
&ndash; Set MySQL root password <code>mysqladmin -u root password PASSWORD</code><br/>
If you&rsquo;re getting <code>#2002 Cannot log in to the MySQL server</code> when logging in to phpmyadmin, try editing <code>phpmyadmin/config.inc.php</code> and change:<br/>
<code>$cfg['Servers'][$i]['host'] = 'localhost';</code><br/>
to:
<code>$cfg['Servers'][$i]['host'] = '127.0.0.1';</code><br/>
&ndash; Create VirtualHost by adding to the end of <code>/etc/apache2/extra/httpd-vhosts.conf</code></p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>&lt;VirtualHost *:80>
</span><span class='line'>        DocumentRoot "PATH TO SITE ROOT"
</span><span class='line'>        ServerName "SERVER.local"
</span><span class='line'>        ErrorLog "/private/var/log/apache2/jason.local-error_log"
</span><span class='line'>        CustomLog "/private/var/log/apache2/jason.local-access_log" common
</span><span class='line'>
</span><span class='line'>        &lt;Directory "PATH TO SITE ROOT">
</span><span class='line'>                AllowOverride All
</span><span class='line'>                Order allow,deny
</span><span class='line'>                Allow from all
</span><span class='line'>        &lt;/Directory>
</span><span class='line'>&lt;/VirtualHost>
</span><span class='line'>&lt;VirtualHost *:80>
</span><span class='line'>  DocumentRoot "PATH TO SITE ROOT"
</span><span class='line'>  ServerName "SERVER.local"
</span><span class='line'>  ErrorLog "/private/var/log/apache2/"SERVER.local"-error_log"
</span><span class='line'>  CustomLog "/private/var/log/apache2/"SERVER.local"-access_log" common
</span><span class='line'>  &lt;Directory "PATH TO SITE ROOT">
</span><span class='line'>      Options +Indexes
</span><span class='line'>      AllowOverride All
</span><span class='line'>      Order allow,deny
</span><span class='line'>      Allow from all
</span><span class='line'>  &lt;/Directory>
</span><span class='line'>&lt;/VirtualHost></span></code></pre></td></tr></table></div></figure>


<ul>
<li>Edit <code>/etc/hosts</code> to append <code>127.0.0.1  SERVER.local</code></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Solve SMTP Offline on Mac OS X Mail]]></title>
    <link href="http://Qiang.Hu/2013/07/solve-smtp-offline-on-mac-os-x-mail.html"/>
    <updated>2013-07-09T09:53:00+08:00</updated>
    <id>http://Qiang.Hu/2013/07/solve-smtp-offline-on-mac-os-x-mail</id>
    <content type="html"><![CDATA[<p>Recent days, I have problems sending out email in Mail App, on Mac OS X Mountain Lion. Little invistigation shows that the accounts information for SMTP server are messed, wrong accounts are used for different servers.
The solution is simple and straightforward:</p>

<ol>
<li>In Mail, open <code>Preferences</code>;</li>
<li>In <code>Accounts</code> tap, select the account whose <code>Outgoing Mail Server(SMTP)</code> is labeled as <code>offline</code>;</li>
<li>Click the SMTP server, and select <code>Edit SMTP Server List</code> from the list;</li>
<li>Then you need to fill in the correct username and password.</li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Mount entire DD image]]></title>
    <link href="http://Qiang.Hu/2013/06/mount-entire-dd-image.html"/>
    <updated>2013-06-06T10:56:00+08:00</updated>
    <id>http://Qiang.Hu/2013/06/mount-entire-dd-image</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://lh3.googleusercontent.com/-djwgkFfBKn8/UcJhWb4HAWI/AAAAAAAABXk/ymN8GQccjlk/s800/Linux-OS-images.jpg" title="Linux logo" alt="This is a linux logo">Yesterday, my Raspberry Pi running Arch Linux was not able to boot with error: <code>Kernel Panic, not syncing: no init found</code>. I spent a night on it, but could not find a working solution. The last option is easy: reinstall the system. That is really the last resort, for I do not want to re-setup everything I have done: <a href="http://Qiang.Hu/2013/03/life-of-pi-samba-server.html">samba server</a>, Time Machine server, Xunlei Offline Downloader&hellip;</p>

<h4>Unable to mount the SD card</h4>

<p>The system does not boot, so I need to find a way to get into the file system to identify what is wrong, or at least backup all the configuration files.</p>

<!--more-->


<p>I cannot directly mount it on my Mac, due to the unsupported Ext4 format, although the boot partition can be mounted, as it is in FAT format. I did tried with ext4fuse and fuse-ext2 without luck.
I could neither connect the inter SD card reader to Parallel Desktop VM running Ubuntu, what a pity!</p>

<h4>Use DD to make the SD card to an image</h4>

<p>This is really a workaround, but it indeed is the best solution I am having.<br/>
*   Locate the SD card by running <code>diskutil list</code>. It is <strong>disk2</strong><br/>
*   Make image file using dd:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo dd <span class="k">if</span><span class="o">=</span>/dev/disk2 <span class="nv">of</span><span class="o">=</span>~/Desktop/pi.img <span class="nv">bs</span><span class="o">=</span>1m
</span></code></pre></td></tr></table></div></figure>


<h4>Mount the image in Ubuntu</h4>

<p><em>I did this in my Parallel Desktop running Ubuntu.</em><br/>
Use <code>fdisk</code> to list partition information of the image.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>fdisk -u -l pi.img
</span></code></pre></td></tr></table></div></figure>


<p>the result I got was:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>Disk pi.img: 15.9 GB, 15931539456 bytes
</span><span class='line'>255 heads, 63 sectors/track, 1936 cylinders, total 31116288 sectors
</span><span class='line'><span class="nv">Units</span> <span class="o">=</span> sectors of 1 * <span class="nv">512</span> <span class="o">=</span> 512 bytes
</span><span class='line'>Sector size <span class="o">(</span>logical/physical<span class="o">)</span>: 512 bytes / 512 bytes
</span><span class='line'>I/O size <span class="o">(</span>minimum/optimal<span class="o">)</span>: 512 bytes / 512 bytes
</span><span class='line'>Disk identifier: 0x0004f23a
</span><span class='line'>
</span><span class='line'> Device Boot      Start         End      Blocks   Id  System
</span><span class='line'>pi.img1   *        2048      186367       92160    c  W95 FAT32 <span class="o">(</span>LBA<span class="o">)</span>
</span><span class='line'>pi.img2          186368    31116287    15464960   83  Linux
</span></code></pre></td></tr></table></div></figure>


<p>We will be using this command to mount the image:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>mount -o loop, <span class="nv">offset</span><span class="o">=[</span>offset value<span class="o">]</span> <span class="o">[</span>path to image file<span class="o">]</span> <span class="o">[</span>path to mount point<span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>


<p>Take note of the unit size, <strong>512</strong> byte here and the Start sector for each partition, which are used to calculate the offset.
Here I want to mount the second partition, pi.img2. With a simple calculation: 512 * 186368 = 95420416</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo mount -o loop,offset<span class="o">=</span>95420416 pi.img /media/pi
</span></code></pre></td></tr></table></div></figure>


<p>Ok, that&rsquo;s it. Now I am able to explore the files.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My printer friendly CSS(updated)]]></title>
    <link href="http://Qiang.Hu/2013/06/my-printer-friendly-css.html"/>
    <updated>2013-06-02T13:15:00+08:00</updated>
    <id>http://Qiang.Hu/2013/06/my-printer-friendly-css</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://lh6.googleusercontent.com/-lCoo_0HpStY/UcJg9O7HVJI/AAAAAAAABXA/HicEQ0DGzuI/s800/css-logo.jpg">I do want my webpages printed out nicely, especially my <a href="http://Qiang.Hu/resume">Resume</a>, which should not contain the unnecessary elements, e.g. site title, side bar, comments&hellip; According to w3schools.com, <a href="http://www.w3schools.com/css/css_mediatypes.asp">CSS Media Type</a> can help me achieve the goal by providing different sets of CSS for various outputs.
Below is the CSS I have written, you can copy and save it if you want.</p>

<!--more-->


<p>You need to add this to your <code>/source/_includes/head.html</code>, or just header of your htmls if you are not using <strong>Octopress</strong>.</p>

<figure class='code'><figcaption><span>head.html  </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'>  <span class="nt">&lt;link</span> <span class="na">href=</span><span class="s">&quot;/stylesheets/print.css&quot;</span> <span class="na">media=</span><span class="s">&quot;print&quot;</span> <span class="na">rel=</span><span class="s">&quot;stylesheet&quot;</span> <span class="na">type=</span><span class="s">&quot;text/css&quot;</span><span class="nt">&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>PS: <code>#comments</code> and <code>#post_links</code> are IDs I put for comment section and posts navigation section, which are not originally included in Octopress, you may either ignore them or you can go to <code>/source/_includes/post.html</code> to add them.</p>

<figure class='code'><figcaption><span>print.css  </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
</pre></td><td class='code'><pre><code class='css'><span class='line'><span class="k">@media</span> <span class="nt">only</span> <span class="nt">print</span><span class="p">{</span>
</span><span class='line'>
</span><span class='line'><span class="c">/*</span>
</span><span class='line'><span class="c">Body</span>
</span><span class='line'><span class="c">*/</span>
</span><span class='line'><span class="nt">body</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">width</span><span class="o">:</span> <span class="m">100</span><span class="o">%</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'>  <span class="k">margin</span><span class="o">:</span> <span class="m">0</span> <span class="p">;</span>
</span><span class='line'>  <span class="k">padding</span><span class="o">:</span> <span class="m">0</span> <span class="p">;</span>
</span><span class='line'>  <span class="k">font-family</span><span class="o">:</span> <span class="n">Garamond</span><span class="o">,</span> <span class="n">Perpetua</span><span class="o">,</span> <span class="s2">&quot;Nimbus Roman No9 L&quot;</span><span class="o">,</span> <span class="s2">&quot;Times New Roman&quot;</span><span class="o">,</span> <span class="k">serif</span><span class="p">;</span>
</span><span class='line'>  <span class="k">color</span><span class="o">:</span> <span class="m">#000</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'>  <span class="k">background</span><span class="o">:</span> <span class="k">none</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'>  <span class="k">font-size</span><span class="o">:</span> <span class="m">11pt</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">h1</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">font-size</span><span class="o">:</span> <span class="m">18pt</span><span class="p">;</span>
</span><span class='line'>  <span class="k">float</span><span class="o">:</span> <span class="k">center</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'><span class="nt">h2</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">font-size</span><span class="o">:</span> <span class="m">16pt</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'><span class="nt">h3</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">font-size</span><span class="o">:</span> <span class="m">14pt</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'><span class="nt">h4</span><span class="o">,</span><span class="nt">h5</span><span class="o">,</span><span class="nt">h6</span><span class="p">{</span>
</span><span class='line'>  <span class="k">font-size</span><span class="o">:</span> <span class="m">12pt</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'><span class="nt">h1</span> <span class="nt">a</span><span class="o">,</span><span class="nt">h2</span> <span class="nt">a</span><span class="o">,</span><span class="nt">h3</span> <span class="nt">a</span><span class="o">,</span><span class="nt">h4</span> <span class="nt">a</span><span class="o">,</span><span class="nt">h5</span> <span class="nt">a</span><span class="o">,</span><span class="nt">h6</span> <span class="nt">a</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">text-decoration</span><span class="o">:</span> <span class="k">none</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">img</span><span class="nc">.right</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">float</span><span class="o">:</span> <span class="k">right</span><span class="p">;</span>
</span><span class='line'>  <span class="k">margin-right</span><span class="o">:</span> <span class="m">20px</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">img</span><span class="nc">.left</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">float</span><span class="o">:</span> <span class="k">left</span><span class="p">;</span>
</span><span class='line'>  <span class="k">margin-left</span><span class="o">:</span> <span class="m">20px</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">img</span><span class="nc">.center</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">margin</span><span class="o">:</span> <span class="m">0</span> <span class="k">auto</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">article</span><span class="o">&gt;</span><span class="nt">header</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">padding-top</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">article</span><span class="o">&gt;</span><span class="nt">header</span><span class="o">&gt;</span><span class="nc">.meta</span><span class="p">{</span>
</span><span class='line'>  <span class="k">display</span><span class="o">:</span> <span class="k">none</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">article</span><span class="o">&gt;</span><span class="nt">header</span><span class="o">&gt;</span><span class="nc">.entry-title</span><span class="p">{</span>
</span><span class='line'>  <span class="k">text-align</span><span class="o">:</span> <span class="k">center</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="c">/*</span>
</span><span class='line'><span class="c">remove border</span>
</span><span class='line'><span class="c">*/</span>
</span><span class='line'><span class="nt">body</span><span class="o">&gt;</span><span class="nt">div</span><span class="o">&gt;</span><span class="nt">div</span> <span class="p">{</span>
</span><span class='line'><span class="k">border</span><span class="o">:</span> <span class="k">none</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="nt">code</span> <span class="p">{</span>
</span><span class='line'><span class="n">word</span><span class="o">-</span><span class="n">wrap</span><span class="o">:</span> <span class="n">break</span><span class="o">-</span><span class="n">word</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="c">/*</span>
</span><span class='line'><span class="c">Removes unnecessary parts for print view: navigation and sidebar</span>
</span><span class='line'><span class="c">*/</span>
</span><span class='line'><span class="nt">body</span><span class="o">&gt;</span><span class="nt">header</span><span class="o">,</span> <span class="nt">body</span><span class="o">&gt;</span><span class="nt">nav</span><span class="o">,</span> <span class="nt">aside</span><span class="o">,</span> <span class="nt">article</span><span class="o">&gt;</span><span class="nt">footer</span><span class="o">&gt;</span><span class="nc">.sharing</span><span class="o">,</span> <span class="nt">article</span><span class="o">&gt;</span><span class="nt">section</span><span class="o">,</span>
</span><span class='line'><span class="nf">#comments</span><span class="o">,</span> <span class="nf">#post_links</span><span class="p">{</span>
</span><span class='line'>  <span class="k">display</span><span class="o">:</span> <span class="k">none</span> <span class="cp">!important</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<h4>UPDATE:</h4>

<p>Instead of having to CSS files, which will slow down site loading time, I have made use of Compass, to compile into one css file. and changes are reflected on the contents below:
1.  Change in <code>head.html</code>:</p>

<figure class='code'><figcaption><span>head.html  </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'>  <span class="nt">&lt;link</span> <span class="na">href=</span><span class="s">&quot;/stylesheets/screen.css&quot;</span> <span class="na">media=</span><span class="s">&quot;screen, projection, print&quot;</span> <span class="na">rel=</span><span class="s">&quot;stylesheet&quot;</span> <span class="na">type=</span><span class="s">&quot;text/css&quot;</span><span class="nt">&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<ol>
<li>Copy the <code>print.css</code> mentioned above to <code>sass/custom/print.scss</code></li>
<li>Modify <code>sass/screen.scss</code> as:</li>
</ol>


<figure class='code'><figcaption><span>sass/screen.scss  </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='scss'><span class='line'><span class="k">@import</span> <span class="s2">&quot;compass&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@include</span><span class="nd"> global-reset</span><span class="p">;</span>
</span><span class='line'><span class="k">@include</span><span class="nd"> reset-html5</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;custom/colors&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;custom/fonts&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;custom/layout&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;base&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;partials&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;custom/_styles.scss&quot;</span><span class="p">;</span>
</span><span class='line'><span class="k">@import</span> <span class="s2">&quot;custom/print.scss&quot;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>
One more thing I did was adding a print button in post, for not all people use shortcut to print.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fix Invalid URL to Google Calendar in Mountain Lion]]></title>
    <link href="http://Qiang.Hu/2013/05/fix-invalid-url-to-google-calendar-in-mountain-lion.html"/>
    <updated>2013-05-28T23:51:00+08:00</updated>
    <id>http://Qiang.Hu/2013/05/fix-invalid-url-to-google-calendar-in-mountain-lion</id>
    <content type="html"><![CDATA[<p>If you are much annoyed, I believe you are if you landed this page by Googling, by tenths or even hundreds error messages in Console of
<code>28/5/13 10:25:41.004 PM CalendarAgent[169]: AOSKit ERROR: (-) RAF: Invalid url -- https://USERNAME%40gmail.com@calendar.google.com/calendar/dav/USERNAME%40gmail.com/</code>
you might take a minute to read this post.</p>

<h3>The Cause: <em>Apple is the one to blame</em></h3>

<p>When we use <strong>System Preferences</strong> &ndash;> <strong>Mail, Contacts &amp; Calendars</strong> to add our google accounts, and enable <strong>Calendar &amp; Reminders</strong> Apple sets the CalDAV url to <code>https://USERNAME%40gmail.com@calendar.google.com/calendar/dav/USERNAME%40gmail.com/</code>, but what Google API accepts is <code>https://USERNAME@calendar.google.com/calendar/dav/USERNAME%40gmail.com/</code>. That is the reason the Invalid URL error happens.</p>

<!-- more -->


<h3>The Solution</h3>

<ol>
<li>Disable <strong>Calendar &amp; Reminders</strong> under <strong>System Preferences</strong> &ndash;> <strong>Mail, Contacts &amp; Calendars</strong>;</li>
<li>Open <strong>Calendar</strong> and add a account in <strong>Preferences</strong> &ndash;> <strong>Accounts</strong>: select Account Type to be <strong>CalDAV</strong>, input your Google <strong>USERNAME</strong>(without @google.com), and password; and <strong>Server Address</strong> as: <code>https://www.google.com/calendar/dav/</code><strong>USERNAME</strong><code>@gmail.com/user</code></li>
</ol>


<p>That&rsquo;s it and the error should be gone! Please feel free to post any comments.
:&ndash;)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Octopress SEO: Site Keywords and Description]]></title>
    <link href="http://Qiang.Hu/2013/04/octopress-seo-site-keywords-and-description.html"/>
    <updated>2013-04-05T09:34:00+08:00</updated>
    <id>http://Qiang.Hu/2013/04/octopress-seo-site-keywords-and-description</id>
    <content type="html"><![CDATA[<p>By default, the keywords and description generated by Octopress for site are those of the first post. However, what I want is to set more suitable keywords and description for my site.</p>

<p>First, we and keywords and descriptions for site in <code>_config.yml</code>:</p>

<figure class='code'><figcaption><span>_config.yml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>description:   <span class="c">#put your site description</span>
</span><span class='line'>keywords:     <span class="c">#put the keywords</span>
</span></code></pre></td></tr></table></div></figure>


<!-- more -->


<p>Then in <code>source/_includes/head.html</code>, change:</p>

<figure class='code'><figcaption><span>html source/_includes/head.html </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'>{% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
</span><span class='line'><span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;description&quot;</span> <span class="na">content=</span><span class="s">&quot;{{ description | strip_html | condense_spaces | truncate:150 }}&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>{% if page.keywords %}<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;keywords&quot;</span> <span class="na">content=</span><span class="s">&quot;{{ page.keywords }}&quot;</span><span class="nt">&gt;</span>{% endif %}
</span></code></pre></td></tr></table></div></figure>


<p>To:</p>

<figure class='code'><figcaption><span>html source/_includes/head.html </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'>{% capture description %}{% if page.url == &quot;/index.html&quot; %} {{ site.description }}{% elsif page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
</span><span class='line'><span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;description&quot;</span> <span class="na">content=</span><span class="s">&quot;{{ description | strip_html | condense_spaces | truncate:150 }}&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>{% if page.url == &quot;/index.html&quot; %}<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;keywords&quot;</span> <span class="na">content=</span><span class="s">&quot;{{ site.keywords }}&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>{% elsif page.keywords %}<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;keywords&quot;</span> <span class="na">content=</span><span class="s">&quot;{{ page.keywords }}&quot;</span><span class="nt">&gt;</span>{% endif %}
</span></code></pre></td></tr></table></div></figure>


<p>This should play the trick.
PS: To insert the code snippets, I do as below:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>{% codeblock html source/_includes/head.html %}
</span><span class='line'>{% raw %}
</span><span class='line'>
</span><span class='line'>{% capture description %}{% if page.url == "/index.html" %} {{ site.description }}{% elsif page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
</span><span class='line'>&lt;meta name="description" content="{{ description | strip_html | condense_spaces | truncate:150 }}">
</span><span class='line'>
</span><span class='line'>{% if page.url == "/index.html" %}&lt;meta name="keywords" content="{{ site.keywords }}">
</span><span class='line'>{% elsif page.keywords %}&lt;meta name="keywords" content="{{ page.keywords }}">{% endif %}
</span><span class='line'>
</span><span class='line'>{% endraw %}</span></code></pre></td></tr></table></div></figure>


<p>You do know how much effort I put to get the snippets above to show correctly!
<a href="http://jimpravetz.com/blog/2011/12/inserting-liquid-syntax-into-octopress-codeblock/">Link 1</a> and <a href="http://stackoverflow.com/questions/3426182/how-to-escape-liquid-template-tags/5866429#5866429">Link 2</a> as references.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Life of Pi -- Samba Server]]></title>
    <link href="http://Qiang.Hu/2013/03/life-of-pi-samba-server.html"/>
    <updated>2013-03-14T00:46:00+08:00</updated>
    <id>http://Qiang.Hu/2013/03/life-of-pi-samba-server</id>
    <content type="html"><![CDATA[<h3>Update:</h3>

<p>Fix the issue of not having writing permission on the mounted exFAT disk:
In <strong>/etc/fstab</strong> add:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>/dev/sda1  /media/Media    exfat   rw,async,umask<span class="o">=</span>0 0   0
</span></code></pre></td></tr></table></div></figure>


<p>And then mount the disk:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo mount -a
</span></code></pre></td></tr></table></div></figure>


<hr />

<hr />

<p>I have a 2T external hard disk that is partioned into:<br/>
*  1.5T of exFAT format to store media files<br/>
*  0.5T of HFS+ as TimeMachine</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>   Device Boot      Start         End      Blocks   Id  System
</span><span class='line'>/dev/sda1               2  2930667377  1465333688    7  HPFS/NTFS/exFAT
</span><span class='line'>/dev/sda2   *  2930667379  3906967727   488150174+  af  HFS / HFS+
</span></code></pre></td></tr></table></div></figure>


<p>What I want to do is to mount the hard disk to my Raspberry Pi running Arch Linux ARM, then it can be used wirelessly as media hub and TimeMachine.</p>

<h3>Mount the disk</h3>

<p>In order to mount exFAT formatted disks, we have to install <em>fuse-exfat</em> and <em>exfat-utils</em></p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo pacman -S fuse-exfat exfat-utils
</span></code></pre></td></tr></table></div></figure>


<!-- more -->


<p>After install the packages, we need to reboot the system:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo reboot
</span></code></pre></td></tr></table></div></figure>


<p><del>
After rebooting, we should be able to mount the exFAT formatted disk<br/>
sudo mount -t exfat-fuse /dev/sda1 /media/Media
</del></p>

<h3>Setup samba</h3>

<p>Install samba:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo pacman -S samba
</span></code></pre></td></tr></table></div></figure>


<p>Copy the default conf file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
</span></code></pre></td></tr></table></div></figure>


<p>Open the configuration file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo vim /etc/samba/smb.conf
</span></code></pre></td></tr></table></div></figure>


<p>Insert this after <strong>Share Definitions</strong>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="o">[</span>Media<span class="o">]</span>
</span><span class='line'>        <span class="nv">path</span><span class="o">=</span>/media/Media
</span><span class='line'>        valid <span class="nv">users</span>     <span class="o">=</span>       USERNAME
</span><span class='line'>        <span class="nv">public</span>          <span class="o">=</span>       no
</span><span class='line'>        <span class="nv">writable</span>        <span class="o">=</span>       yes
</span><span class='line'>        <span class="nv">printable</span>       <span class="o">=</span>       no
</span><span class='line'>        create <span class="nv">mask</span>     <span class="o">=</span>       0644
</span></code></pre></td></tr></table></div></figure>


<p>Add a user:
This is to add a user to Samba, and this user must exists in linux.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>pdbedit -a -u USERNAME
</span></code></pre></td></tr></table></div></figure>


<p>Start Samba:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo systemctl start smbd
</span></code></pre></td></tr></table></div></figure>


<p>I mounted and shared the TimeChine partition too. However, Mac OS X does not support TimeChine over Samba:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>sudo tmutil setdestination /Volumes/TM
</span><span class='line'>/Volumes/TM: Incompatible file system <span class="nb">type</span>: smbfs <span class="o">(</span>error 45<span class="o">)</span>
</span><span class='line'>The backup destination could not be set.
</span></code></pre></td></tr></table></div></figure>


<p>My next step is to setup TimeMachine over AFP</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Hello World]]></title>
    <link href="http://Qiang.Hu/2013/02/hello-world.html"/>
    <updated>2013-02-26T00:31:00+08:00</updated>
    <id>http://Qiang.Hu/2013/02/hello-world</id>
    <content type="html"><![CDATA[<p>Hello erveyone, this is my first post, which is served as my assignment to Markdown.</p>

<p>This is a code snipet:</p>

<figure class='code'><figcaption><span>Discover if a number is prime</span><a href='http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/'>Source Article</a></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">Fixnum</span>
</span><span class='line'>  <span class="k">def</span> <span class="nf">prime?</span>
</span><span class='line'>    <span class="p">(</span><span class="s1">&#39;1&#39;</span> <span class="o">*</span> <span class="nb">self</span><span class="p">)</span> <span class="o">!~</span> <span class="sr">/^1?$|^(11+?)\1+$/</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p><em>this is italic</em></p>

<figure class='code'><figcaption><span>Markdown syntax</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='text'><span class='line'>*this is italic*
</span></code></pre></td></tr></table></div></figure>


<!-- more -->


<p><strong>This is bold</strong></p>

<figure class='code'><figcaption><span>Markdown syntax</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='text'><span class='line'>**This is bold**
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Yes! I got Qiang.Hu]]></title>
    <link href="http://Qiang.Hu/2013/02/yes-i-got-qiang-hu.html"/>
    <updated>2013-02-23T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2013/02/yes-i-got-qiang-hu</id>
    <content type="html"><![CDATA[<h1></h1>

<p>Recently, I bought a new domain:Qiang.Hu</p>

<p>I want to try something new, so I will use Octopress, based on Jekyll, as my platform.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[PHP Notes]]></title>
    <link href="http://Qiang.Hu/2012/03/php-notes.html"/>
    <updated>2012-03-23T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2012/03/php-notes</id>
    <content type="html"><![CDATA[<h1></h1>

<ol>
<li>By default, mod_rewrite is not enabled in apache2, Ubuntu. Use this command to enable it:</li>
</ol>


<p><code>sudo a2enmod rewrite</code></p>

<p>Then reload apache configuration file:</p>

<p><code>sudo /etc/init.d/apache2 reload</code></p>

<ol>
<li>After running sudo apt-get remove XXX to remove a package. The following command is needed to remove all leftover files:</li>
</ol>


<p><code>sudo apt-get auto remove</code></p>

<p> </p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Make Free Calls on iOS]]></title>
    <link href="http://Qiang.Hu/2012/03/make-free-calls-on-ios.html"/>
    <updated>2012-03-08T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2012/03/make-free-calls-on-ios</id>
    <content type="html"><![CDATA[<h1></h1>

<p>Here some softwares I use on iPhone to make free phone calls. They are not like Skype, requiring both parties to install the software. Instead, you can call any landline or mobile phones directly, using these softwares, which is really good since my parents are only familiar with phones.</p>

<p>1 <a href="http://www.uwewe.com">Wewe</a>:</p>

<p>It was good when it provided with 60 minutes free call per day, but now it drops to 30 minutes — 0000-1800: 20 minutes, 1800  - 2400: 10 minutes.</p>

<p> 微微的免费网络电话政策的具体要求是什么？<br/>
-时间要求：微微免费网络电话拨打每天都可以使用30分钟，具体时长为0:00~18:00点之间可免费网络电话拨打20分钟，18:00~24:00点之间可免费网络电话拨打10分钟，邀请对方加入微微，微微免费语音视频通话无限制。<br/>
-地域要求：微微免费网络电话现在支持免费拨打中国，美国，加拿大，印度，新加坡等国家，其它国家微微正在努力开通，建议您推荐对方安装微微，这样 可以享受不受时间限制的免费通话和信息收发。</p>

<p>2 <a href="http://www.maaii.com/">maaii</a>:</p>

<p> I use this one most nowadays. It gives out 1.9 USD everyday, which is equivalent to 100 minutes call.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[iTunes accounts without credit card info are disabled in China]]></title>
    <link href="http://Qiang.Hu/2011/11/itunes-accounts-without-credit-card-info-are-disabled-in-china.html"/>
    <updated>2011-11-17T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/11/itunes-accounts-without-credit-card-info-are-disabled-in-china</id>
    <content type="html"><![CDATA[<h1></h1>

<p>Early today (2011-11-17), Apple customers in China found problems buying free apps from iTunes. All of them are using iTunes accounts without credit information.</p>

<p>[![][2]][2]<em>Picture is from internet</em></p>

<p>When people are buying free apps in iTunes, they are asked to update their account information. If they refuse to do so, they will not able to purchase.</p>

<p>The accounts with credit information or Apple gift cards are not affected.</p>

<p>Apple currently accepts Visa, MasterCard and American Express. However, credit cards are not widely used in China, and many people’s credit cards are issued by UniPay. Thus, this action will affect many Apple users in China, the second largest market, accounted for 16 percent of Apple’s fourth-quarter sales, or about $4.5 billion.</p>

<p>It is unseen what Apple will do next. I will keep updating on this.</p>

<p>[Updated] Now the China Appstore supports Chinese accounts to top-up. The cheapest price of Apps is 6 CNY, 0.95 USD.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[What I have learnt in CS3216]]></title>
    <link href="http://Qiang.Hu/2011/11/what-i-have-learnt-in-cs3216.html"/>
    <updated>2011-11-14T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/11/what-i-have-learnt-in-cs3216</id>
    <content type="html"><![CDATA[<h1></h1>

<p>CS3216 is really a life-change module. I have benefited from it much more than other modules, sincerely.</p>

<p>Firstly, let’s have a look at my expectations on this module before it started. I wrote in <a href="http://www.huqiangty.com/2011/08/what-i-want-to-learn-from-cs3216/">this post</a>.</p>

<p><strong>1, Building a software facilitating people’s life and work.</strong></p>

<p>In both assignment 2 and final project, I think we made something useful. Although Prof. Ben does not buy the idea of Book Venue, I think it is useful. It provides a better way for NUS students to trade used text books. To my surprise, someone wants to buy our final project, <a href="http://www.yunreading.com">YunReading</a>. The actual price does not matter that much, after all, it proves that we can make something with value.</p>

<p><strong>2. How to apply concepts learnt from school to the fast-changing IT world.</strong></p>

<p>****To be honest, this point is so abstract. My understanding is that the thinking process is more important than technical skills. One point I think will be important throughout my life is “Thinking about what the problem you are going to solve  before doing”. That will ensure the thing I am building will be of value to some extend.</p>

<p><strong>3. How to work in a team.</strong></p>

<p>****After working in different teams with different friends, I do think I have learnt much from all of them. Sai gave me the ideas of self-learning, I learnt how to think and come out with ideas from Kenneth, Peng Jun’s insistence on what he believes in, Yao Long, Yin Yue and Xiang Xin’s good design, Ziwei, Yingbo and Aldrian’s good coding, and Shaohuan’s passion to work…</p>

<p>As for myself, I tried doing different things in each assignment, so that I can experience and learn as much as possible.  By the way, CS3216 has gives me the best team-working atmosphere ever.</p>

<p><strong>4. How to think in advance.</strong></p>

<p>****This is really a long term process. I need to continue improving.</p>

<p> </p>

<p>I did get some bonus from CS3216.</p>

<p>1, learning ability:</p>

<p>Now, I am confident on my self-learning ability, at least for computing related topics. I have the interest to learn more, and I roughly know how to learn, Googling, referring to what I know and reading APIs.</p>

<p>2, video making:</p>

<p>This is really exclusive one for me. I am relatively familiar with FInal Cut Pro X now. :-p</p>

<p>3, making new friends:</p>

<p>One point Prof. Ben mentioned really impress me, “CS3216 is more like a community”. I have never experienced such good atmosphere for a module. I remember I post a question regarding configure mail server in CS3216 group, quirky I received many suggestions.</p>

<p>We will not be strings in the future, I am sure. I do look forward working with these friends in the future, maybe in coming CS3217 (Can I reserve a seat now :-p).</p>

<p>Unlike other modules that force students to learn, CS3216 focuses more on thinking, and let students decide what to explore. This is what education should be.</p>

<p>If you want to make a deference in your life, you should take CS3216. Unfortunately, you don’t have chance, hahaha! I made it.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Some thoughts about CS3216 final lecture]]></title>
    <link href="http://Qiang.Hu/2011/11/some-thoughts-about-cs3216-final-lecture.html"/>
    <updated>2011-11-14T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/11/some-thoughts-about-cs3216-final-lecture</id>
    <content type="html"><![CDATA[<h1></h1>

<p>During the past two days, I slept a lot, really a lot. While lying in bed, I was thinking a lot, too.</p>

<p>Here I am writing some of my thoughts on the topics Prof. Ben talked during the last lecture on CS3216.</p>

<p><strong>(i) The world today as we know it is broken</strong></p>

<p>****Actually, I am not worrying about the Greek Crisis. I think this is an inevitable stage on the developing of European Union. The crisis will not break down EU, but make it more united.</p>

<p>Germany and France have the ability to save Greece and other countries, and they will save Greece at the end. None wants to see UE breaks up. What they want is asking Grace to pass give up (partially or completely) financial powers to EU. This will be the way in which to dealing with other countries (e.g. Italy, Span…).</p>

<p>So when the crisis ends, EU is economically and finically united. Later, the same same process will happen in military and politics, resulting in a true united Europe that have the ability to fight against US and Russia…</p>

<p><strong>(ii)self mastery</strong></p>

<p>Self mastery( is in the tradition of Chinese culture. However, it has not been in Chinese people’s attention for long time. All of the attentions are paid materials: increasing GDP in the national level and making more money in individual’s focus.</p>

<p>We have (seem to) strong economy now, but we are really weak in culture! what a shame! We have lost the meaning of Chinese! I am so sad seeing what is happening in my motherland.</p>

<p><strong>(ii)Social mobility</strong></p>

<p>****I don’t think it is necessary in a society where resources are equally shared among individuals. However, governments need to ensure there is chance, if not equal, for every member to succeed/get resource.</p>

<p>I don’t think the situation in China is that good. Those born in rural areas hardly have the chance to get good education as those born in rich area. People fall behind because of their birth, and it is hardly for them to catch up. Those have strong family background can easily find good jobs: being cicil officials or working in national companies; if they want to run own businesses, they can easily borrow money from banks, or raise funds.</p>

<p>I think Singapore is doing well in this, at least every student can get education of same quality.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How much of iPhone&#8217;s increased price will go to Chinese workers?]]></title>
    <link href="http://Qiang.Hu/2011/10/how-much-of-iphones-increased-price-will-go-to-chinese-workers.html"/>
    <updated>2011-10-23T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/10/how-much-of-iphones-increased-price-will-go-to-chinese-workers</id>
    <content type="html"><![CDATA[<h1></h1>

<p>Yesterday, Apple Online Store in 22 countries, including Singapore started to take reservation of iPhone 4s, which is supposed to be in stock from 28 October onward in these countries. While checking on Apple Online Store, I found the price is S$ 948, while the iPhone 4 was S$ 888 when it came out last year.</p>

<p>I was a bit surprised, since I was expecting the price be lower. That is because the USD depreciates a lot in the past year, so if the price in US stays the same as last year, it should decrease in term of SGD. That happened to the new MacBook Pro, MacBook Air and iPad 2. The price of iPhone 4s, with 2-year plan, stays 199USD, so I made an assumption that the price of contact-free should keep the same.</p>

<p>As the title indicates, I am not writing to complaint the increase of price. Actually, the price does not matter to me, since I am not buying iPhone 4s. What I am wondering is how much of the increased price will go to Foxconn, and finally to the Chinese assembling workers.</p>

<p>Last year, there were 14 suicides in Foxconn, Apple’s main manufacture, factory in China, and a new one happened on 15 October 2011. It is believed those workers decided to end their life because of the long-hour working time but very small wage. This <a href="http://news.shangdu.com/203/2010/05/27/2010-05-27_451744_203__1.shtml">website</a> lists out some of the salary receipts, which shows the basic wage is 980 CNY (195.65 SGD), working 10 hours everyday per month with 2 days off. With more than 100 hours overtime, their wage can reach to 1800CNY(360 SGD). While the property price outside the main city of Shenzhen, where locates one of Foxconn’s largest factories, is more than 10,000CNY per meter square. The exact compensation to the victim’s family is known, but some says Foxconn’s policy is 100,000 CNY; and <a href="http://tech.qq.com/a/20100525/000430.htm">some workers would like to suicide to “make money” than to work.</a></p>

<p>We may blame Foxconn abusing workers, however, we should not ignore Apple. A <a href="http://www.chinalaborwatch.org/news/new-352.html">report</a> shows, “Apple only pays £3.99 to manufacture a £600 iPhone”.</p>

<p>That does not only happen in Foxconn, but its 14-jumps drew the attention. In fact, not only Apple, but also many other companies such as Dell, HP, Motorola are doing the same way: paying very little to factories in China to assemble their products.</p>

<p>There is none caring about the workers. The officials want to attract more foreign companies to increase GDP which will contribute to their political “score”, so they will not set the salary baseline as low as possible; the companies will only pay workers the minimum wage, stated by laws, to maximize their revenue. This is what globalization does, making the rich richer, the poor poorer!</p>

<p>Many people in other countries are complaining that Chinese have taken their jobs. But they never think about that the Chinese will never ask for such low price if they can have a better life. If you have shoes to ware, you will not chose to bare foot.</p>

<p>I remember in the last meeting with Steve Jobs, Obama praised Apple for its great products, and asked Jobs to create more jobs in US or even produce the products inside US. If Apple does so, what will the price of iPhone be? 2000USD?</p>

<p>The low-price Chinese products have been contributed to good live standard for the people over the world for a long time. This is surely going to change. Be prepared for the increasing price. And I do hope more of the increased price go to the workers, who is at my age and many are even younger than me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Post 3]]></title>
    <link href="http://Qiang.Hu/2011/10/post-3.html"/>
    <updated>2011-10-22T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/10/post-3</id>
    <content type="html"><![CDATA[<h1></h1>

<p>Time flies, here we are at the final phase of this semester. It comes the time, oral presentation three(OP3), to present our product, QuickDo, to tutors and our fellow friends. At this time, we are spending most time fine-tuning it, while less time thinking about the presentation. Although in real life presentation skills matter, a good product worth 10 thousand words.</p>

<p> </p>

<p>We have been through two presentations this semester. After learning from the mistakes we made in the last OPs, we now are familiar with most of the presenting skills and we are sure we can fully use them in the last OP. While we are preparing OP3, one question jumps into my mind: how are we positioning ourselves and audiences? Are we “acting” selling the product, or are we sharing what we have learnt with others?</p>

<p> </p>

<p>If we are selling, I will ask myself:”Would you buy it if you were a user?” The answer is obvious. There are numerous calendar clients or todo managers, and I am using Google Calendar, Apple’s iCal and the new Reminder. I also tried Things and Fantastical. All of them are quite good, and they satisfy Jim’s needs. Especially Fantastical, a new calendar application in mac, is just the right one Jim should use and the one we are trying to make QuickDo like. I remember at the beginning survey of CS2103, I wrote “I want to build something that can facilitate people’s work and life”. At this stage, I would like to say this project is a failure, based on the criteria– what problem does it solve. A product will definitely fail if its developers don’t use it or don’t believe in it. Moreover, the audiences are also selling the same kind of products which might be better than ours. Having this kind of attitude, how can  I be confident on the stage selling this product?</p>

<p> </p>

<p>If we are exchanging ideas, the difficulties we have been faced with and what we have learnt by solving the problems with other developers. I can say about the bugs and shortages of our product, and discussing and seeking advices from others. In this situation, I am telling the truth of the product, instead of saying it is perfect as a salesman. However, the discussion on techniques is supposed in CS2103. In CS2101, we are doing business–selling, thought I do not like it very much. This is life.</p>

<p> </p>

<p>We have do it, then we are going to do it well. The product is like our child, and we will think it is better than the others even if it has some bugs. The presentation will be a show time to present the features, and I believe I will perform well.</p>

<p> </p>

<p>PS: This is the last post that my teammates will definitely read, and they may not visit my blog in the future. So I will take this chance to express my appreciation to them. Thanks for your helps and I do enjoy the time with you. I apologize for any unsatisfying work I did. Good luck to your coming exams, and all the best for your future study and life. Hopefully we can work together in the future, too.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Provisioning for a Million Eyeballs]]></title>
    <link href="http://Qiang.Hu/2011/10/provisioning-for-a-million-eyeballs.html"/>
    <updated>2011-10-18T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/10/provisioning-for-a-million-eyeballs</id>
    <content type="html"><![CDATA[<h1></h1>

<p>This is my first time being so late for a post. Last week was not easy for me. I had too much work(coding) to do. I stayed up until 4am every night. Then I was sick, and still have not fully recovered yet. Now I am at the rehearsal of Eusoff Hall Talent Time, on duty for AudioWorks. I am using the iPad writing this post, for the first time I find it is useful.</p>

<p>As usual, last lecture was also very useful, especially for me, a webmaster. Some of the topics are still beyond my scope now, like multiple servers, load balancing. But I do have thought about some others, and even done some work on them. Here I would like to share some points.</p>

<p><strong>Loading time for website</strong><br/>
As social networking is playing a important role in our daily life, many websites have the social plugins, including Tweet, Facebook Like, to make the sites more wide-spread. For some well-known reasons, people in China, my who contribute the second most of the traffic for my site, cannot access either Facebook or Twetter. When they are visiting my site, the page keeps loading, to get the plugins, for more than one time, but ends with error messages. I thought it was really bad user experience. So I tried to look for way to remove/hide those plugins for them.<br/>
What I did was writing some php code, to get IPs of the visitors, and to locate their country based on the IPs. If you navigate to <a href="http://www.huqiangty.com/lab/getVisitorCountry.php">here</a>, you should see your country. If not, please drop me a message, so I can debug. It sounds easy, but I did have some trouble doing it, and I will write another post later to share that.</p>

<p><strong>Caching of reloading</strong><br/>
How good if this lecture had been before our first assignment!<br/>
In our first assignment, The Claw, I really did some naive things. To check if a user is logged in, we connect to Facebook on every page! Based o. Other conditions: it is a flash game and the server is at Virginia, the loading time for our app is really long! If we were doing it now, we would consider these and could do better.</p>

<p><strong>Application and database logging</strong><br/>
Only after our app in assignment one was hacked and I failed to trace the log of database, did I realize how crucial it is to log. Also, days ago, I fixed a serious bug on my Mac, by reading the log.<br/>
However, for most of the time, I find logs are really hard to find and harder to read! Some of them contain binary codes, low level language as well as English… Anyway, we need not only read but also write log in the future.</p>

<p>I just hope I can fully recovery soon, so that I can be dedicated to all my works. Everyone, do take care of yourself!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[iCloud has been opened for non-developers]]></title>
    <link href="http://Qiang.Hu/2011/10/icloud-is-opened-for-non-developers.html"/>
    <updated>2011-10-11T00:00:00+08:00</updated>
    <id>http://Qiang.Hu/2011/10/icloud-is-opened-for-non-developers</id>
    <content type="html"><![CDATA[<h1></h1>

<p><a href="http://www.icloud.com">iCloud</a>, Apple’s clouding service, which is supposed to be released on October 12th, now is opened for non-developers! You can just login with you Apple ID.</p>

<p>Below is what Apple says about iCloud:</p>

<blockquote><p>iCloud stores your music, photos, documents, and more and wirelessly pushes them to all your devices. Automatic, effortless, and seamless — it just works.</p></blockquote>

<p>You can go <a href="http://www.apple.com/iphone/icloud/">there</a> to learn more about it.</p>
]]></content>
  </entry>
  
</feed>
