<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Johnny Huang</title><link>https://hzqtc.github.io/categories/programming/</link><description>Recent content in Programming on Johnny Huang</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 13 Dec 2013 00:00:00 +0000</lastBuildDate><atom:link href="https://hzqtc.github.io/categories/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Android Custom Layout: FlowLayout</title><link>https://hzqtc.github.io/2013/12/android-custom-layout-flowlayout.html</link><pubDate>Fri, 13 Dec 2013 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2013/12/android-custom-layout-flowlayout.html</guid><description>&lt;p&gt;Hello, Android devs! This is my first blog about Android. We know Android SDK provides you a bunch&#10;of useful layouts: &lt;code&gt;FrameLayout&lt;/code&gt;, &lt;code&gt;LinearLayout&lt;/code&gt;, &lt;code&gt;RelativeLayout&lt;/code&gt;, etc. So where is &lt;code&gt;FlowLayout&lt;/code&gt;,&#10;which works like a multiline &lt;code&gt;TextView&lt;/code&gt; but holding views instead of texts? Developers can just add&#10;views to a &lt;code&gt;FlowLayout&lt;/code&gt; and each view is put to the right of the previous one and wraps to a new row&#10;when the current row is full. I&amp;rsquo;m gonna show you how you could implement your own &lt;code&gt;FlowLayout&lt;/code&gt; with&#10;less than 100 lines of code.&lt;/p&gt;</description></item><item><title>Image Duplication Detection</title><link>https://hzqtc.github.io/2013/04/image-duplication-detection.html</link><pubDate>Fri, 19 Apr 2013 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2013/04/image-duplication-detection.html</guid><description>&lt;p&gt;In my &lt;a href="https://hzqtc.github.io/2013/04/event-based-html-parsing.html"&gt;last post&lt;/a&gt;, I downloaded&#10;thounsands of images from &lt;a href="http://jandan.net/ooxx" target="_blank" rel="noreferrer"&gt;Jiandan OOXX&lt;/a&gt;. (What a cool&#10;site!) When I was enjoying this amazing collection, I found there are many&#10;duplicate images. I don&amp;rsquo;t want my disk space wasted on duplicate images, so I&#10;need to figure out a way to deal with them.&lt;/p&gt;&#10;&lt;p&gt;Detecting duplication images is totally different from detecting duplicate&#10;normal files, because two same image may be in different formats, of different&#10;dimensions, have different sizes. Hash values can&amp;rsquo;t be relied to detect image&#10;duplications, other image features should be taken into consideration.&lt;/p&gt;</description></item><item><title>Event Based HTML Parsing with Python</title><link>https://hzqtc.github.io/2013/04/event-based-html-parsing.html</link><pubDate>Thu, 18 Apr 2013 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2013/04/event-based-html-parsing.html</guid><description>&lt;p&gt;HTML parsing is a useful technique for crawlers. Three major techniques to parse&#10;HTML are regular expression, tree-model based parsing and event based parsing.&#10;Regular expression is universally applicable for all parsings, but it&amp;rsquo;s tricky&#10;and hard for other people to understand or even maintain.&lt;/p&gt;&#10;&lt;p&gt;Tree-model based parsing is powerful and popular, a lot of HTML/XML parsing&#10;libraries construct an in-memory tree-like model to represent the structure of&#10;the parsed HTML. The first drawback of this kind of parsing is obvious,&#10;constructing tree-models in memory requires memory for the entire HTML even if&#10;we only need a small part of it. The second problem of tree-model based parsing&#10;is the cost of CPU time. If a big HTML file is parsed and the in-memory model is&#10;huge, a lot of CPU time is cost to build the model and travel in the model.&lt;/p&gt;</description></item><item><title>Linux IPC with Pipes</title><link>https://hzqtc.github.io/2012/07/linux-ipc-with-pipes.html</link><pubDate>Fri, 27 Jul 2012 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2012/07/linux-ipc-with-pipes.html</guid><description>&lt;p&gt;Inter-Process Communication (IPC) is a set of methods for exchanging data among multiple processes. IPC is a very common mechanism in Linux and Pipe maybe one of the most widely used IPC methods. When you type &lt;code&gt;cat foo | grep bar&lt;/code&gt;, you create a pipe to connect &lt;em&gt;stdout&lt;/em&gt; of &lt;code&gt;cat&lt;/code&gt; to &lt;em&gt;stdin&lt;/em&gt; of &lt;code&gt;grep&lt;/code&gt;. A pipe, as its name states, can be understood as a channel with two ends. Pipe is actually implemented using a piece of kernel memory. The system call &lt;code&gt;pipe&lt;/code&gt; always create a pipe and two associated file descriptions, &lt;code&gt;fd[0]&lt;/code&gt; for reading from the pipe and &lt;code&gt;fd[1]&lt;/code&gt; for writing to the pipe.&lt;/p&gt;</description></item><item><title>Play MP3 with libmpg123 and libao</title><link>https://hzqtc.github.io/2012/05/play-mp3-with-libmpg123-and-libao.html</link><pubDate>Thu, 24 May 2012 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2012/05/play-mp3-with-libmpg123-and-libao.html</guid><description>&lt;p&gt;I&amp;rsquo;m rewriting some of my python applications using C. One of them plays online mp3 audio. I used gstreamer to play mp3 and I&amp;rsquo;m considering switching to a more lightweight solution. Finally, I choose &lt;a href="http://www.mpg123.de/" target="_blank" rel="noreferrer"&gt;libmpg123&lt;/a&gt; and &lt;a href="http://xiph.org/ao/" target="_blank" rel="noreferrer"&gt;libao&lt;/a&gt;. Libmpg123 is used to decode mp3 and libao is then used to make the sound.&lt;/p&gt;</description></item><item><title>Poppler vs MuPDF</title><link>https://hzqtc.github.io/2012/04/poppler-vs-mupdf.html</link><pubDate>Sun, 15 Apr 2012 00:00:00 +0000</pubDate><guid>https://hzqtc.github.io/2012/04/poppler-vs-mupdf.html</guid><description>&lt;p&gt;I&amp;rsquo;m looking for a lightweight and fast PDF viewer recently. I tried some &lt;a href="http://poppler.freedesktop.org/" target="_blank" rel="noreferrer"&gt;Poppler&lt;/a&gt; based PDF viewers, but they are all very slow when opening large PDF documents. Then I found &lt;a href="http://mupdf.com/" target="_blank" rel="noreferrer"&gt;MuPDF&lt;/a&gt;. MuPDF is a lightweight PDF library and viewer. It amazed me that it&amp;rsquo;s extremly fast. I becomes interseted in finding out how faster MuPDF actually is than Poppler.&lt;/p&gt;</description></item></channel></rss>