2011年12月6日 星期二

Using Linux command: awk to sum up a list of number

Linux Command Line
AWK

Example
> cat Text.txt
1
2
3
4
5

If you want to get the sum of this column, you can use the tool awk.
cat Text.txt | awk '{sum += $1} END {print sum}'

Output:
15

If you want to show the information of the file together with the sum, you can enter the command as below
cat Text.txt | awk '{sum += $1} {print} END {print sum}

Output:
1
2
3
4
5
15



AWK
The AWK utility is a data extraction and reporting tool


Reference: 
vbird:

2011年11月15日 星期二

Javascript Import Javascript

<script type="text/javascript">
 function importScript(url)
 {
  var tag = document.createElement("script");
  tag.type = 
  tag.src = url;
  document.getElementByTagName("head")[0].appedChild(tag);
 }
 
 window.onload = function()
 {
  importScript("testing.js");
 };
</script>

2011年11月7日 星期一

利用 Javascript 取得URL上的GET變數

var url = window.location.toString();
var str = "";
if (url.indexOf("?")[1] != -1)
{
  str = url.split("?")[1];
}

2011年10月31日 星期一

Eclipse: Content Assist

在Eclipse 上輸入 sysout
image
再按Alt + /
sysout 會變成 System.out.println();
image

更多的設置在
Window –> Preferences –> Java –> Editor –> Content Assist
Window –> Preferences –> Java –> Templates
Window –> Preferences –> General –> Keys