Today's Question:  What weekend projects have you created?

#### Carriage return and line feed

In programming and document editing, we may frequently encounter carriage return and line feed, i.e the well known CRLF.  But do you know about the history and difference of carriage return and line feed? Before computer came out, there was a type of teleprinter called Teletype Model 33. It can print 10 characters each second. But there is one problem with this, after finishing printing each line, it will take 0.2 second to move to next line, which is time of printing 2 characters. If a new...

CR,CARRIAGE RETURN,LINE FEED,LF,NEW LINE,CRLF     2017-02-19 08:29:23

#### Accurate floating point number calculation in JavaScript

In JavaScript, since floating point is defined with IEEE754,there will be some accuracy issues while doing floating point number arithmetic. Here is a function which can resolve the accuracy issue. var calc = function(num1,operator,num2,len){    var numFixs = function(num){        var arr = num.toFixed(len).toString().split('.');        return parseInt(arr.join(''));    }    switch(operator){...

JavaScript, floating point,IEEE 754,accuracy     2012-12-27 11:07:49

#### How regular expression works

Rob Pike wrote 30 lines of codes to realize a simple regular expression matcher in his book The practice of Programming. This piece of code is really cool. Let's take a look at the code.Meaning of different characters.Character Meaning c General character . Match any single character ^ Match start of a string \$ Match end of a string * Match zero or many occurrences of a character /*match ：Test the regexp in text*/int match(char* regexp,char* text){    if(regexp[0] == '^') ...

Regular expression,Implementation,Rob Pike,C     2012-06-25 05:23:41

#### try { return } finally {}

Do you know what value will be printed when following program is ran? class Test { public int aaa() { int x = 1; try { return ++x; } catch (Exception e) { } finally { ++x; } return x; } public static void main(String[] args) { Test t = new Test(); int y = t.aaa(); System.out.println(y); } } And before answering the above question, do you have answers to following questions? If ther...

JAVA,JAVA INTERVIEW QUESTION     2016-09-26 08:06:28

At the Code Conference on Wednesday, Google CEO Sundar Pichai expressed his thought on Google's position in China. He expressed the openness of Google to return to China. "Google is in China....But Google Search is not there in China...But personally for me, I care about serving users globally in every corner. I always thought Google is for everyone, that applies to China, too. So wherever possible, we want to be in China to serve Chinese users....If we do it in a right and thoug...

#### C++ : string beginWith and endWith

C++ is an very powerful programming language. It is efficient and flexible. When writing C++ programs, we may often need to process strings and often we need to check whether a string begin with some substring or end with some substring. We can use following functions to ahieve these:     static bool beginWith(const std::string str,const std::string needle){        return (!str.compare(0,needle.length(),needle));    }    ...

C++,beginWith,endWith,     2012-08-31 06:53:44

#### Bill Gates to return as Microsoft's white knight?

Summary: Could and should Bill Gates return to day-to-day responsibilities at Microsoft? Fortune is reporting there’s a rumor to that effect. Fortune reported on December 8 that there’s talk Microsoft Chairman Bill Gates might be mulling a comeback, largely to help boost Microsoft’s stagnant stock price and employee morale. I have to say I am very, very, very skeptical on this one. First, it seems this is a single-sourced report. Fortune says: ...

Microsoft,Change,Bill Gates,Return,White Knight     2011-12-09 07:39:39

#### Arrays.equals() vs MessageDigest.isEqual()

Both Arrays.equals() and MessageDigest.isEqual() are used to compare the equality of two arrays. They can be interchangeably in many cases. However, they do have some differences which lead to different use cases in real applications. One difference is that the arrays passed to MessageDigest.isEqual() cannot be null while it's ok for Arrays.equals(). The one major difference between these two methods is that Arrays.equals() is not time-constant while MessageDigest.isEqual() is time-constant. Thi...

Arrays.equal(),MessageDigest.isEqual(),Java,Security     2015-05-14 22:03:29

#### Google will not hold press release in China next week

There is an invitation form spreading around the Chinese internet community which states that Google will hold press release at 1 PM on December 18 (Beijing time). On this press release, Google will announce its return to China and Google China CEO Jony will explain its strategies in China after return. But soon Google China public relation representative said this was a rumor. There is no plan for Google to hold press release next week in China. And there are some apparent suspicious parts ape...