2014年2月12日星期三

This is from StackEdit

Welcome document

Markdown powered blogs!


Here is the cookbook introduced the how-to.

Here is sample code block with markdown

    public class test {
        public static void main(String[] args) {
            String me = "";
        }
    }

2013年12月2日星期一

Underscore collection and array useful API

1. reduce 参数 (array, memo, val, default) 以memo为初始值遍历数组array每一个值val,可以传入function参数操作memo和val, default为memo初始值 如果default不传入或者不定义,使用array第一和第二个值作为function的初始参数.
array = [0,2,4,6,8]

var x = _.reduce(array, function(memo,val){
  if(val>memo) {return val}
  return memo
},0) 
2. map, flatten, pluck map:将目标映射入新的集合,可以附带function预操作 flatten: 去掉多维数组的维度 还原为1维, 如果附带第二个boolean参数false则只减掉一个维度 pluck: 将指定key的值从json格式的数据集合中拔出
    groupA = [{"name":"a1","data":101},{"name":"a2","data":102},{"name":"a3","data":103},{"name":"a4","data":104},]

    _.map(_.flatten(_.pluck(groupA,"data")),function(d){return d})


2013年10月28日星期一

[转贴]链接文件

  链接文件有点类似于Windows 的所谓快捷方式,但并不完全一样。链接有两种方式,软链接和硬链接。  软链接文件   软链接又叫符号链接,这个文件包含了另一个文件的路径名。可以是任意文件或目录,可以链接不同文件系统的文件。链接文件甚至可以链接不存在的文件,这就产生一般称之为"断链"的问题(或曰“现象",链接文件甚至可以循环链接自己。类似于编程语言中的递归。  
   [yaoyao@linux236 yaoyao]$ ls -l 
  total 0 
  lrwxrwxrwx 1 yaoyao yaoyao  5 Aug 6 17:39 1.txt ->; 3.txt 
  lrwxrwxrwx 1 yaoyao yaoyao  5 Aug 6 17:38 2.txt ->; 1.txt 
  lrwxrwxrwx 1 yaoyao yaoyao  5 Aug 6 17:39 3.txt ->; 2.txt  
上面的三个文件形成了一个递归,实质上没有任何作用。系统管理员应该避免系统出现断链或循环链接。  用ln -s 命令可以生成一个软连接,如下:  [root@linux236 test]# ln -s source_file softlink_file  在对符号文件进行读或写操作的时候,系统会自动把该操作转换为对源文件的操作,但删除链接文件时,系统仅仅删除链接文件,而不删除源文件本身。  硬链接文件   info ln 命令告诉您,硬链接是已存在文件的另一个名字(A "hard link" is another name for an existing file),这多少有些令人困惑。硬连接的命令是  ln -d existfile newfile  硬链接文件有两个限制  1、不允许给目录创建硬链接;   2、只有在同一文件系统中的文件之间才能创建链接。  对硬链接文件进行读写和删除操作时候,结果和软链接相同。但如果我们删除硬链接文件的源文件,硬链接文件仍然存在,而且保留了愿有的内容。这时,系统就“忘记”了它曾经是硬链接文件。而把他当成一个普通文件。

2013年10月20日星期日

Angular.js egghead tutorial outline

1. create a service, which can be initialised from a node
var app = angular.module("myApp", [dependencies]);

2. app exists, create a controller, controlling a node and its children
app.controller("nameCtrl", function($scope){  //xxxCtrl is naming convention
   //$scope can have function and attributes in json favor
   $scope.content = {message:"I am content"}
   $scope.foo=function(){...}
})
3. app, controler exist, directive is customised node/attribute
app.directive("name",function(){
   return {
     restrict: "E || A || M",
     $scope{ 

        element/attr : "@ || & || = ", // @attr, &attr, =attr


     }, //isolated scope, used in multiple instances of the directive

     template: '
Here is returned inner html, can do {{bindModule or value}}
', link:function(scope,element,attrs,[depended controller]) {...} //like the constructor controller: function() { foo1 = function(){} } // an API controller that other directive will depend on } }) app.directive("anotherName", function(){ require : 'name' link: function(scope,element,attrs, nameCtrl){...can invoke nameCtrl foo1} //nameCtrl - naming convention })

2013年10月10日星期四

Set proxy for npm behind corporate proxy

Use this line for http connections
$ npm config set proxy http://login:pass@host:port
Https connection simply use:
$ npm config set https-proxy http://login:pass@host:port

2013年10月9日星期三

Setting Maven behind corporate proxy

Under windows based infrastructure, the proxy setting can be found with opening  
Internet Explorer -> Tools -> Internet Options -> Connection -> LAN Settings

and there normally be a "xxxxx.xxxxx.pac' file in an entry field of the pane.

Open the file with browser and notepad if it prompts asking for what to open with and find this line at the bottom:

return "PROXY 10.65.32.100:8080";

This is the proxy setting that Maven needs to know, therefore, find the Maven setting.xml file under %M2_REPO% and add such section:


  
 
  amp
  true
  http
  JNGJSQ
  Welcome1
  10.65.32.100
  8080
  www.google.com|hub.amp.com.au
 
  
Thus the Maven should be able to connect to its central repository and starting downloading dependencies.