<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.cellopoint.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Newest Blogs on Cellopoint</title>
 <link>http://www.cellopoint.com/rss/blogs</link>
 <description>RSS for Blogs</description>
 <language>en</language>
<item>
 <title>Login with Facebook and retrieve user identities</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/11/fb</link>
 <description>&lt;p&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;!--
.c1 {background: #FFCC66;}
.c2 {background: #CCFF99;}
.c3 {background: #99CCFF;}
--&gt;&lt;/style&gt;&lt;/p&gt;
&lt;p&gt;Facebook, which is abbreviated as FB, is a social-network website. Many websites integrate FB for promotions. How to integrate FB into your website? There are &lt;br /&gt;
1.Your options for API:&lt;br /&gt;
Facebook official API can be divide to two parts: one part is web programming, which is implemented by JavaScript or PHP; another port is mobile programming for iOS or android. Because FB is so popular recently, many program languages also develop APIs for FB, such as SilverLight, Flash, .Net or Java. And this article choose JavaScript for example.&lt;br /&gt;
2.Before developing:&lt;br /&gt;
2.1.Sign up for a Facebook account.&lt;br /&gt;
2.2.Login your Facebook account and sign up for &amp;ldquo;Developer&amp;rdquo;. You can get information from following URL:&lt;br /&gt;
http://sofree.cc/fb-app-1/&lt;br /&gt;
3.Start creating your Facebook APP:&lt;br /&gt;
3.1.After complete Step 2, click the button &amp;ldquo;Create New APP&amp;rdquo;, to get your App ID and APP secret, just like the following screenshot with red box. Then, fill out the &amp;ldquo;Basic Info&amp;rdquo; form, like the following screenshot with blue box. For example, our website for testing is &amp;ldquo;me.cellpoint.com&amp;rdquo;, so you fill &amp;ldquo;me.cellpoint.com&amp;rdquo; in the field &amp;ldquo;App Domain&amp;rdquo;, and fill &amp;ldquo;http://me.cellpoint.com&amp;rdquo; in &amp;ldquo;URL&amp;rdquo;. Finally, click &amp;ldquo;Save&amp;rdquo; for complete your work.&lt;br /&gt;
&lt;img alt=&quot;&quot; width=&quot;584&quot; height=&quot;501&quot; src=&quot;/files/image/blogs/fb_001.jpg&quot; /&gt;&lt;/p&gt;
&lt;p&gt;3.2.In the folder &amp;ldquo;me.cellopoint.com&amp;rdquo;, add the new file &amp;ldquo;channel.html&amp;rdquo; and &amp;ldquo;index.html&amp;rdquo;, and open &amp;ldquo;channel.html&amp;rdquo; to add the JavaScript code as follows:&lt;/p&gt;
&lt;p&gt;&amp;lt;script src=&amp;quot;//connect.facebook.net/en_US/all.js&amp;quot;&gt;&amp;lt;/script&gt;&lt;br /&gt;
3.3.Open the file &amp;ldquo;index.html&amp;rdquo;, pasting the following codes into this file, and edit those two lines of code which is marked with red. Note if your JavaScript code paste after the &amp;lt;body&gt; tag.&lt;/p&gt;
&lt;p&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&gt;&lt;br /&gt;
&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;br /&gt;
xmlns:fb=&amp;quot;http://www.facebook.com/2008/fbml&amp;quot;&gt;&lt;br /&gt;
&amp;lt;head&gt;&lt;br /&gt;
&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=UTF-8&amp;quot;&gt;&lt;br /&gt;
&amp;lt;title&gt;Login&amp;lt;/title&gt;&lt;br /&gt;
&amp;lt;/head&gt;&lt;br /&gt;
&amp;lt;body&gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;fb-root&amp;quot;&gt;&amp;lt;/div&gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;//connect.facebook.net/en_US/all.js&amp;quot;&gt;&amp;lt;/script&gt;&lt;br /&gt;
&amp;lt;script&gt;&lt;br /&gt;
window.fbAsyncInit = function() {&lt;br /&gt;
FB.init({&lt;br /&gt;
&lt;span class=&quot;c1&quot;&gt;appId      : &#039;xxxxxxxxxxx&#039;, &lt;br /&gt;
// App ID, please replace it to the App ID which you retrieved from Step 3.1&lt;br /&gt;
channelURL : &#039;//me.cellopoint.com/channel.html&#039;, &lt;br /&gt;
// Please replace it to the real URL that you setup for the channel.html in Step 3.2&lt;/span&gt;&lt;br /&gt;
status     : true, // check login status&lt;br /&gt;
cookie     : true, // enable cookies to allow the server to access the session&lt;br /&gt;
oauth      : true, // enable OAuth 2.0&lt;br /&gt;
xfbml      : true  // parse XFBML&lt;br /&gt;
});&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/script&gt;&lt;br /&gt;
&amp;lt;/body&gt;&lt;br /&gt;
&amp;lt;/html&gt;&lt;br /&gt;
3.4.Login and retrieve member&amp;rsquo;s personal information&lt;br /&gt;
Add JavaScript code as follows, and all the property of callback described as follows:&lt;br /&gt;
a.userID: the login user&amp;rsquo;s ID, which is retrieved as the following code marked in red. If your website try to integrate FB for login, you can identity your member by this ID.&lt;br /&gt;
b.If you want to retrieve user&amp;rsquo;s email, you have to setup the following code which is marked in green.&lt;br /&gt;
c.You can retrieve user name and email by using &amp;ldquo;/me&amp;rdquo; from FB.api as following code which is marked in blue.&lt;br /&gt;
function FBLogin(){&lt;br /&gt;
FB.login(function(response) {	  &lt;br /&gt;
if (response.authResponse) {&lt;br /&gt;
alert(&#039;Success&#039;);&lt;br /&gt;
&lt;span class=&quot;c1&quot;&gt;alert(&#039;UserID&#039; + response.authResponse.userID);&lt;/span&gt;&lt;br /&gt;
FB.api(&lt;span class=&quot;c3&quot;&gt;&#039;/me&#039;&lt;/span&gt;, function(response) {&lt;br /&gt;
alert(&#039;UserName&#039; + response.name);&lt;br /&gt;
alert(&#039;UserEmail&#039; + response.email);&lt;br /&gt;
});&lt;br /&gt;
} else {&lt;br /&gt;
alert(&#039;Failed&#039;);&lt;br /&gt;
}&lt;br /&gt;
}, {&lt;span class=&quot;c2&quot;&gt;scope: &#039;email&#039;&lt;/span&gt;});&lt;br /&gt;
}&lt;br /&gt;
3.5.Logout: add JavaScript code as follows.&lt;br /&gt;
function FBLoginOut(){&lt;br /&gt;
FB.logout(function(response) {&lt;br /&gt;
alert(&#039;Logged out.&#039;);&lt;br /&gt;
});&lt;br /&gt;
}&lt;br /&gt;
4.If you want to remove this application, you can find out the option which is called &amp;ldquo;Apps&amp;rdquo; on your personal page, find out this application, and remove it.&lt;br /&gt;
5.Reference: http://developers.facebook.com/docs/reference/javascript/&lt;br /&gt;
&amp;nbsp; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/11/fb&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 09 Nov 2011 16:22:36 +0800</pubDate>
 <dc:creator>Hank Chen</dc:creator>
 <guid isPermaLink="false">293 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>Libgtop</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/10/libgtop</link>
 <description>&lt;p&gt;How to get the resource usage of Linux system, such as memory and CPU utilization, at the runtime of a process? We can read the file of system in the directory /proc/&amp;lt;process id&amp;gt;/stat, or we can use the &amp;ldquo;top&amp;rdquo; command in the shell; Howerver, extra effort is required with both approach because the file or interface need to be parsed before we use it. Here is another method to get the information about resource usage of entire system or a specific process: Ligbtop, a open source library based on C programming.&lt;/p&gt;
&lt;p&gt;Libgtop is a library of GNOME project, used to implement the &amp;ldquo;top&amp;rdquo; functionality of the desktop environment. It depends on Glib, another library of GNOME. The latest version of Libgtop is 2.28. Noticed that Glib 2.6.0 and Intltool 0.35.0 or later versions need to be installed before we install Libgtop.&lt;/p&gt;
&lt;p&gt;In general, the CPU utilization is caculated according the time CPU spend in different mode. These usually can be divided into user mode, nice mode, system(kernel) mode and idle mode. We can use the API of Libgtop to get the CPU time (clock clicks) of each mode from system boot. For example, the source code below can be used to caculate the CPU utilization.&lt;/p&gt;
&lt;p&gt;#include &amp;lt;glibtop&amp;gt;&lt;br /&gt;
#include &amp;lt;glibtop/cpu.h&amp;gt;&lt;/p&gt;
&lt;p&gt;double cpu_rate;&lt;br /&gt;
int dt, du, dn, ds;&lt;br /&gt;
glibtop_cpu cpu_begin,cpu_end;&lt;br /&gt;
glibtop_get_cpu(&amp;amp;cpu_begin);&lt;br /&gt;
sleep(1);&lt;br /&gt;
glibtop_get_cpu(&amp;amp;cpu_end);&lt;br /&gt;
dt = cpu_end.total - cpu.begin.total;&lt;br /&gt;
du = cpu_end.user - cpu.begin.user;&lt;br /&gt;
dn = cpu_end.nice - cpu.begin.nice;&lt;br /&gt;
ds = cpu_end.sys - cpu.begin.sys;&lt;br /&gt;
cpu_rate = 100.0 * (du+dn+ds) / dt&lt;/p&gt;
&lt;p&gt;Note that we need to get the clock click count at two different points in time, so the function glibtop_get_cpu is called twice. On the other hand, the monitor of memory utilization is much more simply, as:&lt;/p&gt;
&lt;p&gt;#include &amp;lt;glibtop&amp;gt;&lt;br /&gt;
#include &amp;lt;glibtop/mem.h&amp;gt;&lt;/p&gt;
&lt;p&gt;double mem_rate;&lt;br /&gt;
glibtop_mem memory;&lt;br /&gt;
glibtop_get_mem(&amp;amp;memory);&lt;br /&gt;
mem_rate = 100.0 * memory.used / memory.total;&lt;/p&gt;
&lt;p&gt;There are a variety of types of resource can be monitored by Libgtop. In addition to system CPU and memory utilization described above, also includes CPU and memory utilization of specific process, swap, file system, network interface, and so on. The Detail API and data structure can refer to GNOME&amp;rsquo;s official website: &lt;a href=&quot;http://developer.gnome.org/libgtop/&quot;&gt;http://developer.gnome.org/libgtop/&lt;/a&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/10/libgtop&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 03 Oct 2011 11:11:22 +0800</pubDate>
 <dc:creator>David Lee</dc:creator>
 <guid isPermaLink="false">292 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>Introduction of Google File System</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/08/gfs</link>
 <description>&lt;p&gt;Why can Google dominate the search engine market? One important reason is the excellent performance relies on the file system. Google has designed a unique distributed file system to meet its huge storage demand, known as Google File System (GFS). Google did not release GFS as open source software, but still released some technical details, including an official paper.&lt;/p&gt;
&lt;p&gt;There are two mainly differences between GFS and traditional distributed file system. First, component failures are the norm rather than the exception. The failures can be caused by application bugs, operating system bugs, human errors, and even hardware or network problems. Since even the expensive hard disk device can not completely exclude all failures, Google just simply builds its storage machine by  mutiple inexpensive comodity, and against  failures through integrate constant monitoring, error detection, fault tolerance, and automatic recovery to GFS.&lt;/p&gt;
&lt;p&gt;Second, most ﬁles are mutated by appending new data rather than overwriting or removing existing data. Once written, data are usually need only to be readable but not writable. And most reading operations are &amp;ldquo;large streaming reads&amp;rdquo;, where individual operations typically read hundreds of KBs, more commonly 1 MB or more. Notice that the system stores a modest number of large ﬁles, each typically 100 MB or larger in size. GFS support small files, but does not optimize for them.&lt;/p&gt;
&lt;p&gt;The architecture of GFS similar to the supernode (Master) and distributed nodes (chunkservers) approach. Real data will be stored in chunkservers, which report their state to Master periodically. When a client wants to read a file, it query to Master about the state of target chunkserver, and Master response the location of chunkserver if it is in idle stage. Hence the client can request chunk data to the chunkserver.&lt;/p&gt;
&lt;p&gt;GFS supports the large volume and flows for Google search engine. On the other hand, BigTable, a database system used by a number of Google applications such as Gmail, Google Maps, Youtube and other cloud services, also built on GFS. We can say that GFS is the killer technology in the cloud generation.&lt;/p&gt;
&lt;p&gt;More details can refer to the GFS: &lt;a href=&quot;http://labs.google.com/papers/gfs.html&quot;&gt;http://labs.google.com/papers/gfs.html&lt;/a&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/08/gfs&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 02 Aug 2011 10:38:25 +0800</pubDate>
 <dc:creator>David Lee</dc:creator>
 <guid isPermaLink="false">291 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>Semaphore functions in PHP</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/07/php</link>
 <description>&lt;p&gt;Semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment.&lt;/p&gt;
&lt;p&gt;A useful way to think of a semaphore is as a record of how many units of a particular resource are available, coupled with operations to safely (i.e. without race conditions) adjust that record as units are required or become free, and if necessary wait until a unit of the resource becomes available.&lt;/p&gt;
&lt;p&gt;Semaphores are a useful tool in the prevention of race conditions and deadlocks; however, their use is by no means a guarantee that a program is free from these problems. Semaphores which allow an arbitrary resource count are called counting semaphores, whilst semaphores which are restricted to the values 0 and 1 (or locked/unlocked, unavailable/available) are called binary semaphores.&lt;/p&gt;
&lt;p&gt;The following are semaphore functions in PHP:&lt;br /&gt;
int ftok (string $pathname, string $proj) - Convert a pathname and a project identifier to a System V IPC key.&lt;/p&gt;
&lt;p&gt;sem_acquire (resource $sem_identifier) - Acquire a semaphore.&lt;br /&gt;
&lt;br /&gt;
resource sem_get (int $key [,int $max_acquire = 1 [,int $perm = 0666 [,int $auto_release = 1]]]) - Get a semaphore id.&lt;br /&gt;
&lt;br /&gt;
bool sem_release (resource $sem_identifier) - Release a semaphore.&lt;/p&gt;
&lt;p&gt;bool sem_remove (resource $sem_identifier) - Remove a semaphore.&lt;/p&gt;
&lt;p&gt;resource shm_attach (int $key [, int $memsize [, int $perm]]) - Creates or open a shared memory segment.&lt;br /&gt;
&lt;br /&gt;
bool shm_detach (resource $shm_identifier) - Disconnects from shared memory segment.&lt;br /&gt;
&lt;br /&gt;
mixed shm_get_var (resource $shm_identifier, int $variable_key) - Returns a variable from shared memory.&lt;br /&gt;
&lt;br /&gt;
bool shm_has_var (resource $shm_identifier, int $variable_key) - Check whether a specific entry exists.&lt;/p&gt;
&lt;p&gt;bool shm_put_var (resource $shm_identifier, int $variable_key, mixed $variable) - Inserts or updates a variable in shared memory.&lt;br /&gt;
&lt;br /&gt;
bool shm_remove_var (resource $shm_identifier, int $variable_key) - Removes a variable from shared memory.&lt;br /&gt;
&lt;br /&gt;
bool shm_remove (resource $shm_identifier) - Removes shared memory from Unix systems.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://php.net/manual/en/book.sem.php&quot;&gt;http://php.net/manual/en/book.sem.php&lt;/a&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/07/php&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Fri, 15 Jul 2011 18:20:12 +0800</pubDate>
 <dc:creator>Ruby Lin</dc:creator>
 <guid isPermaLink="false">289 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>GNU libextractor</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/07/GNU</link>
 <description>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;GNU libextractor is GNU&amp;rsquo;s library for extracting meta data from files. Meta data includes format information (such as mime type, image dimensions, color depth, recording frequency), content descriptions (such as document title or document description) and copyright information (such as license, author and contributors). Currently, libextractor supports the following formats: HTML, PDF, PS, OLE2 (DOC, XLS, PPT), OpenOffice (sxw), StarOffice (sdw), DVI, MAN, FLAC, MP3 (ID3v1 and ID3v2), NSF(E) (NES music), SID (C64 music), OGG, WAV, EXIV2, JPEG, GIF, PNG, TIFF, DEB, RPM, TAR(.GZ), ZIP, ELF, S3M (Scream Tracker 3), XM (eXtended Module), IT (Impulse Tracker), FLV, REAL, RIFF (AVI), MPEG, QT and ASF. Also, various additional MIME types are detected.&lt;/p&gt;
&lt;p&gt;Libextractor is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. GNU libextractor uses plugins to handle various file formats. Technically a plugin can support multiple file formats; however, most plugins only support one particular format. By default, GNU libextractor will use all plugins that are available and found in the plugin installation directory. Applications can request the use of only specific plugins or the exclusion of certain plugins.&lt;/p&gt;
&lt;h3&gt;Example for using dynamic library&lt;/h3&gt;
&lt;table width=&quot;350&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;// hello.c&lt;br /&gt;
            #include &amp;lt;extractor.h&amp;gt;&lt;br /&gt;
            int main()&lt;br /&gt;
            {&lt;br /&gt;
            struct EXTRACTOR_PluginList *el;&lt;br /&gt;
            el = EXTRACTOR_plugin_load_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);&lt;br /&gt;
            // ...&lt;br /&gt;
            EXTRACTOR_plugin_remove_all (el);&lt;br /&gt;
            return 0;&lt;br /&gt;
            }&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;You can then compile the example using &lt;/strong&gt;&lt;br /&gt;
$ gcc \ -I/Library/Frameworks/Extractor.framework/Versions/Current/include \&lt;br /&gt;
-o hello hello.c \&lt;br /&gt;
-L/Library/Frameworks/Extractor.framework/Versions/Current/lib \&lt;br /&gt;
-lextractor&lt;/p&gt;
&lt;h3&gt;Plugin management&lt;/h3&gt;
&lt;p&gt;C Struct: EXTRACTOR_PluginList&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;A plugin list represents a set of GNU libextractor plugins.&lt;/p&gt;
&lt;p&gt;Function: void EXTRACTOR_plugin_remove_all (struct EXTRACTOR_PluginList *plugins)&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;Unload all of the plugins in the given list.&lt;/p&gt;
&lt;p&gt;Function: struct EXTRACTOR_PluginList * EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *plugins, const char*name)&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;Unloads a particular plugin. The given name should be the short name of the plugin, for example &amp;ldquo;mime&amp;rdquo; for the mime-type extractor or &amp;ldquo;mpeg&amp;rdquo; for the MPEG extractor.&lt;/p&gt;
&lt;p&gt;Function: struct EXTRACTOR_PluginList &lt;br /&gt;
* EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *plugins, const char* name,const char* options, enum EXTRACTOR_Options flags)&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;Loads a particular plugin.&lt;/p&gt;
&lt;p&gt;Function: struct EXTRACTOR_PluginList &lt;br /&gt;
* EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *plugins, const char* config, enum EXTRACTOR_Options flags)&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;Loads and unloads plugins based on a configuration string, modifying the existing list, which can be NULL. The string has the format &amp;ldquo;[-]NAME(OPTIONS){:[-]NAME(OPTIONS)}*&amp;rdquo;. Prefixing the plugin name with a &amp;ldquo;-&amp;rdquo; means that the plugin should be unloaded.&lt;/p&gt;
&lt;p&gt;Function: struct EXTRACTOR_PluginList&lt;br /&gt;
* EXTRACTOR_plugin_add_defaults (enum EXTRACTOR_Options flags)&lt;/p&gt;
&lt;p class=&quot;rteindent1&quot;&gt;Loads all of the plugins in the plugin directory.&lt;/p&gt;
&lt;h3&gt;Example for a minimal extract method&lt;/h3&gt;
&lt;p&gt;The following example shows how a plugin can return the mime type of a file.&lt;/p&gt;
&lt;table width=&quot;350&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;int&lt;br /&gt;
            EXTRACTOR_mymime_extract&lt;br /&gt;
            (const char *data,&lt;br /&gt;
            size_t data_size,&lt;br /&gt;
            EXTRACTOR_MetaDataProcessor proc,&lt;br /&gt;
            void *proc_cls,&lt;br /&gt;
            const char * options)&lt;br /&gt;
            {&lt;br /&gt;
            if (data_size &amp;lt; 4)&lt;br /&gt;
            return 0;&lt;br /&gt;
            if (0 != memcmp (data, &amp;quot;\177ELF&amp;quot;, 4))&lt;br /&gt;
            return 0;&lt;br /&gt;
            if (0 != proc (proc_cls, &lt;br /&gt;
            &amp;quot;mymime&amp;quot;,&lt;br /&gt;
            EXTRACTOR_METATYPE_MIMETYPE,&lt;br /&gt;
            EXTRACTOR_METAFORMAT_UTF8,&lt;br /&gt;
            &amp;quot;text/plain&amp;quot;,&lt;br /&gt;
            &amp;quot;application/x-executable&amp;quot;,&lt;br /&gt;
            1 + strlen(&amp;quot;application/x-executable&amp;quot;)))&lt;br /&gt;
            return 1;&lt;br /&gt;
            /* more calls to &#039;proc&#039; here as needed */&lt;br /&gt;
            return 0;&lt;br /&gt;
            }&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Internal utility functions&lt;/h3&gt;
&lt;p&gt;&amp;lsquo;convert_numeric.h&amp;rsquo; defines various conversion functions for numbers (in particular, byte-order conversion for floating point numbers).&lt;/p&gt;
&lt;p&gt;&amp;lsquo;unzip.h&amp;rsquo; defines an API for accessing compressed files.&lt;/p&gt;
&lt;p&gt;&amp;lsquo;pack.h&amp;rsquo; provides an interpreter for unpacking structs of integer numbers from streams and converting from big or little endian to host byte order at the same time.&lt;/p&gt;
&lt;p&gt;&amp;lsquo;convert.h&amp;rsquo; provides a function for character set conversion described below.&lt;/p&gt;
&lt;p&gt;Function: char * EXTRACTOR_common_convert_to_utf8(const char *input, size_t len, const char * charset)&lt;br /&gt;
which can be used to easily convert text from any character set to UTF-8.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In short, for us doing frequent message analyses, GNU libextractor not only helped us to find the correct file format, you can also write a variety of plugin tools, analysis of various text formats, find the corresponding MIME type. In terms of email, it can be said to be an indispensable tool. &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/07/GNU&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 04 Jul 2011 00:00:00 +0800</pubDate>
 <dc:creator>Shawn Lin</dc:creator>
 <guid isPermaLink="false">288 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>What is memcache?</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/06/memcache</link>
 <description>&lt;p&gt;Today, I will introduce an useful technique in fetching database - Memcache. it is a distributed memory caching system, we can build a highly efficient cloud system with it. The basic concept behind this method is to use key-based structure to fetch and store data into memory. The original idea comes from Brad Fitzpatrick who used this method to enhance LiveJournal.com(2003). There are lots of website which use this method: LiveJournal, Wikipedia, Flickr, Twitter, Youtube, Digg, WordPress.com&amp;hellip;etc. It can reduce almost all the databases loading time, and has better access and resource utilization to the database when a Memcache miss happened. It got key-based cache &amp;amp; distributed memory object caching system, but the authentication needs to control by the users.&lt;/p&gt;
&lt;p&gt;It is good to store frequently used information to reduce the need to retrieve. The simplest example is like when you browsing on the Internet, most of the website contents will be downloaded into your folder, it is used to improve the speed when you browsing same website in the next time. Memcache system use the same viewpoint. It takes part of your computer memory to make your computer faster access, deployed and accessed from anywhere over a network, and you can create more and more cache as you want(of course, you need enough memory), and even more, it treats all cache as one single node which means you can combine several computer memory and use together!! What a wonderful mechanism. All operations should run in O(1) time.&lt;/p&gt;
&lt;p&gt;Here is a simple example to illustrate the usefulness in combing memory together. We fetch data from a server every day, and we want to speed up, so we add one more server, how to use it efficiently?&lt;/p&gt;
&lt;p class=&quot;rtecenter&quot;&gt;&lt;img width=&quot;500&quot; height=&quot;258&quot; alt=&quot;&quot; src=&quot;/files/image/blogs/memcache.jpg&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In pic(1), we got two server two memory, in order to ensure same results when you stored and retrieved from any server, you need to copy every data into another server&#039;s memory, it wastes time and memory, not a good setup. In Pic(2), we use Memcache method, then you can store and retrieve from same location in your web servers, there will be no in-consonance happened. More memory, more cache!!&lt;/p&gt;
&lt;p&gt;When should we use Memcache? when you use lots of &amp;ldquo;SELECT * from XXX&amp;rdquo; from database, and have high probability to use and use again, you can use it happily. Here is an easy analysis, when you start to use Memcache, you can consider the following situations: 1. The search timing(How often) 2. The hit timing(What accuracy) 3. Validate?(How long). Of course you need to pay a little extra works to handle this, this should be included.&lt;/p&gt;
&lt;p&gt;I give a brief procedure for how to implement your code with your database. Assuming you have lots of servers need to connect to each other for better memory using. Here&#039;s an simple example flow: Your clients ask servers for data, and your servers ask Memcache first, if the data is not in your Memcache does not have this data, then you go to fetch your database. Once you got the new data, remember store it into Memcache to increase the hit rate in the next time.&lt;/p&gt;
&lt;p class=&quot;rtecenter&quot;&gt;&lt;img width=&quot;450&quot; height=&quot;529&quot; align=&quot;middle&quot; alt=&quot;&quot; src=&quot;/files/image/blogs/flow.jpg&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In the above example, you can understand Memcache is implemented as a network daemon. Most people use PHP or C/C++ to communicate with Memcache. I use it in the Linux system, if you wants to use it with C/C++, you need to install some basic package in your Linux: 1. libevent 2. Memcache 3. libmemcache.&lt;/p&gt;
&lt;p&gt;The other details are all in the Official website: &lt;a href=&quot;http://memcached.org/&quot;&gt;http://memcached.org/&lt;/a&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/06/memcache&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 23 Jun 2011 16:08:32 +0800</pubDate>
 <dc:creator>HH Tu</dc:creator>
 <guid isPermaLink="false">287 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>What is Node.js?</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/06/Node_js</link>
 <description>&lt;p&gt;JavaScript has traditionally only run in the web browser, but recently there has been considerable interest in bringing it to the server side as well, thanks to the CommonJS project. Other server-side JavaScript environments include Jaxer and Narwhal. However, Node.js is a bit different from these solutions, because it is event-based rather than thread based. Web servers like Apache that are used to serve PHP and other CGI scripts are thread based because they spawn a system thread for every incoming request. While this is fine for many applications, the thread based model does not scale well with many long-lived connections like you would need in order to serve real-time applications like Friendfeed or Google Wave.&lt;/p&gt;
&lt;p&gt;Node.js, uses an event loop instead of threads, and is able to scale to millions of concurrent connections. It takes advantage of the fact that servers spend most of their time waiting for I/O operations, like reading a file from a hard drive, accessing an external web service or waiting for a file to finish being uploaded, because these operations are much slower than in memory operations. Every I/O operation in Node.js is asynchronous, meaning that the server can continue to process incoming requests while the I/O operation is taking place. JavaScript is extremely well suited to event-based programming because it has anonymous functions and closures which make defining inline callbacks a cinch, and JavaScript developers already know how to program in this way. This event-based model makes Node.js very fast, and makes scaling real-time applications very easy.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://docs.pylonsproject.org/projects/pyramid/1.0/narr/introduction.html&quot;&gt;http://docs.pylonsproject.org/projects/pyramid/1.0/narr/introduction.html&lt;/a&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/06/Node_js&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Fri, 17 Jun 2011 10:17:45 +0800</pubDate>
 <dc:creator>Paul Chien</dc:creator>
 <guid isPermaLink="false">282 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>LDAP</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/06/LDAP</link>
 <description>&lt;p&gt;Consider two different issues: First, a huge organization with thousands of members, many departments and IT resources. How to maintain an updatable and accessible online address book for it? Second, a MIS staff need to maintain different sets of username and password for a number of different systems, such as linux login, apache, samba, mail service, etc.) How to make his work easily? These two issues seem irrelevant, but can be served by the same solution: LDAP (Lightweight Directory Access Protocol).&lt;/p&gt;
&lt;p&gt;LDAP is a protocol for accessing online directory service, based on X.500. It omitted many complicated details of X.500 protocol to be a flexible and lightweight network application protocol  build on IP networks. For the first issue above, with the flexible design LDAP allows us to catalog different type of resources to be a distributed online database. And, for the second issue, it also provides a standardized interface for referring to difference applications, thus integration with different configuration of those applications can be easily.&lt;/p&gt;
&lt;p&gt;With the macro perspective, LDAP constructs multiple data to be a  tree structure, called DIT (Directory Information Tree). A DIT can be cut into many sub-trees,  each of them can be stored in a different LDAP server to achieve the distributed architecture. Each record in DIT can be replaced by a unique distinguished name (DN). As the &amp;ldquo;absolute path&amp;rdquo; in general file systems, DN is used to identifier the address in DIT.&lt;/p&gt;
&lt;p&gt;And with the micro perspective, each record in the LDAP are consistent with a schema, which can be converted to LDIF (LDAP Data Interchange Format) for human-readable (notice that the real data storing may be binary.) In LDIF, each record will have multiple &amp;ldquo;attributes&amp;rdquo;, and each attribute is composed by multiple values.   Which attributes a record can have is defined by its &amp;ldquo;objectClass&amp;rdquo;. For example, a record with objectClass &amp;ldquo;employee&amp;rdquo; may have attributes such as name, department, and email address, while another record with objectClass &amp;ldquo;department&amp;rdquo; may have attributes such as administrator and member. Every record have at least two attributes: DN and objectClass, while other required and optional attributes are determined according to the value of objectClass.&lt;/p&gt;
&lt;p&gt;To retrieval information on the LDAP server, we can make queries packeaged into LDAP URL format:&lt;/p&gt;
&lt;p&gt;ldap://&amp;quot; [ &amp;lt;host&amp;gt; ]&amp;quot;/&amp;quot; &amp;lt;dn&amp;gt; [ &amp;quot;?&amp;quot; &amp;lt;attributes&amp;gt;[ &amp;quot;?&amp;quot; &amp;lt;scope&amp;gt; &amp;quot;?&amp;quot; &amp;lt;filter&amp;gt; ] ]&lt;br /&gt;
&amp;lt;host&amp;gt; ::= &amp;lt;hostname&amp;gt;[ &amp;quot;:&amp;quot; &amp;lt;port&amp;gt; ]					&lt;br /&gt;
&amp;lt;attributes&amp;gt; ::= NULL | &amp;lt;attributelist&amp;gt;		&lt;br /&gt;
&amp;lt;attributelist&amp;gt; ::= &amp;lt;attributetype&amp;gt;| &amp;lt;attributetype&amp;gt;[ &amp;quot;,&amp;quot; &amp;lt;attributelist&amp;gt; ]&lt;br /&gt;
&amp;lt;scope&amp;gt; ::= &amp;quot;base&amp;quot; | &amp;quot;one&amp;quot; | &amp;quot;sub&amp;quot;&lt;br /&gt;
●	host: IP address of the server&lt;br /&gt;
●	dn: DN of the search starting point&lt;br /&gt;
●	attributes: which attributes of matching entry will be returned&lt;br /&gt;
●	scope: search scope (single node, the first generation of child nodes, or entire sub-tree)&lt;br /&gt;
●	filter: search criteria&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
For example: ldap://cellopoint.com/ou=rd,ou=unit,ou=company,dc=cellopoint,dc=com?mail?sub?uid=david will return email address of every employee that ID is David  and is at RD department of Cellopoint.&lt;/p&gt;
&lt;p&gt;Currently, the most popularly LDAP software are openldap and Microsoft Active Directory. While the former is a open source software, people can try it to experience the convenience of LDAP. &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/06/LDAP&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 09 Jun 2011 10:10:30 +0800</pubDate>
 <dc:creator>David Lee</dc:creator>
 <guid isPermaLink="false">281 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>Web Application Frameworks</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/05/Web_Application_Frameworks</link>
 <description>&lt;p&gt;Due to the growing use of the Web and web services, web sites in the Web 2.0 era no longer support only static content. Site content has become dynamic so that users can perform real-time tasks such as checking and sending mail. The scale of our web projects becomes vast and it becomes complex to maintain as new features are continually added.&lt;/p&gt;
&lt;p&gt;Web application frameworks provide a software architectural model that aid us to organize and manage the different components of our web application. They also provide some useful libraries for example: accessing the database, rendering templates and managing sessions.&lt;/p&gt;
&lt;p&gt;Many web application frameworks use a Model-View-Controller (MVC) architecture that defines the logical components of the web application. The following are the explanations of each model, view and controller:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;br /&gt;
The application model is used to handle the data of the system. In other words, it includes the data and functions that are used to manipulate the data. Controllers and views obtain and change data with the model.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;View&lt;/strong&gt;&lt;br /&gt;
The view is the rendered component of the application that is seen by the user, in other words, the user interface. The user uses the user interface to interact with the application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Controller&lt;/strong&gt;&lt;br /&gt;
Controllers are used to handle requests from the user and returns the response to the user. It obtains the required data from the model, prepares it into a suitable format, inserts the data in the view and renders the view for the user.&lt;/p&gt;
&lt;p&gt;A typical request to the server happens as follows: The user interacts with user interface and a request is sent to the server. The main controller handles the request by determining the appropriate delegate controller and passes the control to that controller. The delegate controller interacts with the model to gather or update data for the view, renders the view and returns the control to the main controller. The main controller responds with the rendered view. The cycle repeats when the user interacts with the user interface and sends a new request.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
References:&lt;br /&gt;
[1] Web application framework. (2011, May 28). In Wikipedia, The Free Encyclopedia. Retrieved 15:23, May 30, 2011, from http://en.wikipedia.org/w/index.php?title=Web_application_framework&amp;amp;oldid=431373642&lt;br /&gt;
[2] Model&amp;ndash;view&amp;ndash;controller. (2011, May 26). In Wikipedia, The Free Encyclopedia. Retrieved 17:12, May 30, 2011, from http://en.wikipedia.org/w/index.php?title=Model%E2%80%93view%E2%80%93controller&amp;amp;oldid=430946706 &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/05/Web_Application_Frameworks&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 31 May 2011 14:26:36 +0800</pubDate>
 <dc:creator>June Huang</dc:creator>
 <guid isPermaLink="false">280 at http://www.cellopoint.com</guid>
</item>
<item>
 <title>Protocol Buffers</title>
 <link>http://www.cellopoint.com/media_resources/blogs/2011/05/Protocol_Buffers</link>
 <description>&lt;p&gt;&lt;strong&gt;&amp;nbsp;Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;flexible, efficient, automated mechanism for serializing structured data.&lt;/li&gt;
    &lt;li&gt;think XML, but smaller, faster, and simpler.&lt;/li&gt;
    &lt;li&gt;use special generated source code to easily write and read your structured data.&lt;/li&gt;
    &lt;li&gt;update your data structure without breaking deployed programs that are compiled against the &amp;quot;old&amp;quot; format.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Why not just use XML?&lt;/strong&gt;&lt;br /&gt;
Protocol buffers have many advantages over XML for serializing structured data. Protocol buffers:&lt;/p&gt;
&lt;p&gt;* are simpler&lt;br /&gt;
* are 3 to 10 times smaller&lt;br /&gt;
* are 20 to 100 times faster&lt;br /&gt;
* are less ambiguous&lt;br /&gt;
* generate data access classes that are easier to use programmatically&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How do they work? &lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;You specify how you want the information you&#039;re serializing to be structured by defining protocol buffer message types in .proto files.&lt;/li&gt;
    &lt;li&gt;Each protocol buffer message is a small logical record of information, containing a series of name-value pairs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br /&gt;
package tutorial;&lt;br /&gt;
message Person {&lt;br /&gt;
required string name = 1;&lt;br /&gt;
required int32 id = 2;&lt;br /&gt;
optional string email = 3;&lt;/p&gt;
&lt;p&gt;enum PhoneType {&lt;br /&gt;
MOBILE = 0;&lt;br /&gt;
HOME = 1;&lt;br /&gt;
WORK = 2;&lt;br /&gt;
}&lt;br /&gt;
message PhoneNumber {&lt;br /&gt;
required string number = 1;&lt;br /&gt;
optional PhoneType type = 2 [default = HOME];&lt;br /&gt;
}&lt;br /&gt;
repeated PhoneNumber phone = 4;&lt;br /&gt;
}&lt;br /&gt;
message AddressBook {&lt;br /&gt;
repeated Person person = 1;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Three type&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;required: a value for the field must be provided, otherwise the message will be considered &amp;quot;uninitialized&amp;quot;&lt;/li&gt;
    &lt;li&gt;optional: the field may or may not be set. If an optional field value isn&#039;t set, a default value is used.&lt;/li&gt;
    &lt;li&gt;repeated: the field may be repeated any number of times (including zero). &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Start working&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;protoc -I=$SRC_DIR --cpp_out=$DST_DIR $SRC_DIR/addressbook.proto&lt;/li&gt;
    &lt;li&gt;This generates the following files in your specified destination directory:&lt;/li&gt;
    &lt;li&gt;addressbook.pb.h, the header which declares your generated classes.&lt;/li&gt;
    &lt;li&gt;addressbook.pb.cc, which contains the implementation of your classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br /&gt;
Person person;&lt;br /&gt;
person.set_name(&amp;quot;John Doe&amp;quot;);&lt;br /&gt;
person.set_id(1234);&lt;br /&gt;
person.set_email(&amp;quot;jdoe@example.com&amp;quot;);&lt;br /&gt;
fstream output(&amp;quot;myfile&amp;quot;, ios::out | ios::binary);&lt;br /&gt;
person.SerializeToOstream(&amp;amp;output);&lt;/p&gt;
&lt;p&gt;fstream input(&amp;quot;myfile&amp;quot;, ios::in | ios::binary);&lt;br /&gt;
Person person;&lt;br /&gt;
person.ParseFromIstream(&amp;amp;input);&lt;br /&gt;
cout &amp;lt;&amp;lt; &amp;quot;Name: &amp;quot; &amp;lt;&amp;lt; person.name() &amp;lt;&amp;lt; endl;&lt;br /&gt;
cout &amp;lt;&amp;lt; &amp;quot;E-mail: &amp;quot; &amp;lt;&amp;lt; person.email() &amp;lt;&amp;lt; endl;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Entire message, including:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;bool IsInitialized() const;: checks if all the required fields have been set.&lt;/li&gt;
    &lt;li&gt;string DebugString() const;: returns a human-readable representation of the message, particularly useful for debugging.&lt;/li&gt;
    &lt;li&gt;void CopyFrom(const Person&amp;amp; from);: overwrites the message with the given message&#039;s values.&lt;/li&gt;
    &lt;li&gt;void Clear();: clears all the elements back to the empty state.&lt;/li&gt;
    &lt;li&gt;bool SerializeToString(string* output) const;: serializes the message and stores the bytes in the given string. Note that the bytes are binary, not text; we only use the string class as a convenient container.&lt;/li&gt;
    &lt;li&gt;bool ParseFromString(const string&amp;amp; data);: parses a message from the given string.&lt;/li&gt;
    &lt;li&gt;bool SerializeToOstream(ostream* output) const;: writes the message to the given C++ ostream.&lt;/li&gt;
    &lt;li&gt;bool ParseFromIstream(istream* input);: parses a message from the given C++ istream.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;http://code.google.com/intl/zh-TW/apis/protocolbuffers/docs/overview.html&quot;&gt;http://code.google.com/intl/zh-TW/apis/protocolbuffers/docs/overview.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.cppprog.com/2010/0908/207_4.html&quot;&gt;http://www.cppprog.com/2010/0908/207_4.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;span class=&#039;read-more&#039;&gt;&lt;a href=&quot;http://www.cellopoint.com/media_resources/blogs/2011/05/Protocol_Buffers&quot;&gt;&amp;nbsp;read&amp;nbsp;more&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 19 May 2011 10:07:12 +0800</pubDate>
 <dc:creator>Shawn Lin</dc:creator>
 <guid isPermaLink="false">279 at http://www.cellopoint.com</guid>
</item>
</channel>
</rss>

