Category: Programming
-
Math Editor in C#
When you are acquiring to integrate a math editor into your application in WPF (Windows Presentation Foundation), I recommend you to use this math editor project called OOP in the Real World – Creating an Equation Editor in Code Project platform. However, the source code put in Code Project is out of date. If you…
-
Resource Scheduler , Calculator, Short-Circuit in Hadoop YARN and HDFS
In order to execute the next-year plan, I search the research topics and technologies in Hadoop YARN and HDFS, then make a note as follows: Since Hadoop YARN was proposed, the new generation technology are continusly discussed. For knowing the work of YARN, please refer to the post [1]. The capacity scheduler of YARN[2][3] provides…
-
Process SequenceFile without Enabling Hadoop Platform
Recently I got a requirement for reading Hadoop’s SequenceFile without enabling Hadoop Platform. However, most examples introduce the read/write SequenceFile with Hadoop Platform. How do I read such files without hadoop? There’s a tricky solution in this case. 1. Download Hadoop binary file from hadoop site. For Linux/Unix please directly download it; for Windows, there’s…
-
Print output while Processing HTML/XML data in Jsoup Project
Currently, I encountered one problem while retrieving XML data from one website. In my case, assume that the original XML document is like <result><device /><name>Allen’s device</name></result> If I use Jsoup.parse(File, “UTF-8”); without additional options, the returned document object will be like: <result><device><name>Allen’s device</name></result> The weired result is <device> is just an open tag but without close…
-
How to fast calculate ( I mod N)?
Given integer I and an integer N which is power of 2, how does it work faster to calculate “I mod N”? OpenJDK’s java.util.HashMap.indexFor method gives us a best solution for it. It simply calculates ” I (bitwise AND) (N-1) “. Reference 1. “HashMap.” Available: [Online] http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/util/HashMap.java#HashMap.indexFor%28int%2Cint%29 2. “HashMap implementation in Java. How does the…
-
The Problem of Ternary Operators in PHP
How do you think of the ternary operators in PHP? Recently, I’’ve used the code written as below: echo (1?”Y”:0?”N”:””); The code returns “N” but not “Y”. How does it work? It shoud be like: echo ((1?”Y”:0)?”N”:””); Finally, please follow the advice from PHP docs: It is recommended that you avoid “stacking” ternary expressions. PHP’s…
-
[PHP] Be discreet to use crypt function
Recently, the PHP’s crypt function crashed in my designed new system. In fact, in my database design, the length of password field is 64. It ran fine at CentOS 5.5 with PHP 5.2.x. However, when I moved this system to Debian 7.3.0 with PHP 5.4.x, it was failed to generate the password. In CentOS 5.5,…
-
Lucene中文斷詞
如果要使用Lucene的斷詞程式,最好看一下 1. Lucene介紹投影片 (推薦) 2. Lucene簡介 (推薦) 3. 當前幾個主要的Lucene中文分詞器的比較 4. Lucene 3.0的中文分詞系統 (推薦) 5. Lucene 最新版4.6.1 內建的Smart中文斷詞 (推薦) 6. IKAnalyzer for Lucene 4.x版本 目前的Lucene斷詞系統都以支援簡體中文為先,如果要用繁體的話,就是用繁體轉簡體的API來製作。 JCC: A Java Chinese Covertor 懶得研究這麼多的話,可以直接使用Solr (基於Lucene實現的一個production) 1. Apache Solr 介紹(有寫說怎麼設定使用Solr斷詞,但還是以簡體字為主)