2016年6月22日 星期三

tmux



reload config:
tmux source-file ~/.tmux.conf

水平分割
ctrl+a , "

垂直分割
ctrl+a , %

重新命名
ctrl+a , ,

新增 window
ctrl+a , c
tux new -s server
跳到 window 1
ctrl+a , 1
tmux a -t server
看目前視窗
tmux ls

2016年6月19日 星期日

react-native run-android, error,


react-native run-android

Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment


solution:
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1


自訂 command

Valuable:
echo ${abc}
abc=iamabc
echo ${abc}


Export:
abc=iamabcecho ${abc}
//iamabc
bash
//進入到所謂的子程序
echo ${abc}
//null
exit
export abc
bash
echo ${abc}
//iamabc

alias:
alias react-native="node /path/to/this"
react-native

2016年5月29日 星期日

2016年5月25日 星期三

elasticesearch ubuntu linux



Installation 

  • Install Java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
java -version


  • Install elastic search

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.3/elasticsearch-2.3.3.deb

 dpkg -i elasticsearch-2.3.3.deb


  • Start elastic search

sudo service elasticsearch start



======================================

  • Open port


/etc/elasticsearch/elasticsearch.yml

network.host: 0.0.0.0 
http.cors.enabled: true 
http.cors.allow-origin: "/.*/"


======================================

2016年5月24日 星期二

node forever

sudo npm install forever -g

forever start filename.js
forever start -c "npm start" ./


forever list


forever stop pid

2016年4月25日 星期一

multipart/form-data File Upload with AngularJS


https://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs



angular.module('yoApp')

//uploadService
  .service('fileUpload',function ($q,$http) {

    this.uploadFileToUrl = function(file, uploadUrl){

        var deferred = $q.defer();

        var fd = new FormData();
        fd.append('file', file);
        $http.post(uploadUrl, fd, {
            transformRequest: angular.identity,
            headers: {'Content-Type': undefined}
        })
        .success(function(result){
        console.log(result);
            deferred.resolve(result);
        })
        .error(function(error){
        console.log(error);
            deferred.reject(error);
        });

        return deferred.promise;
    }
  })
  .directive('fileModel',function ($parse) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            var model = $parse(attrs.fileModel);
            var modelSetter = model.assign;
         
            element.bind('change', function(){
                scope.$apply(function(){
                    modelSetter(scope, element[0].files[0]);
                });
            });
        }
    };
  })
  .controller('uploadCtrl', function ($scope,fileUpload,$q,$timeout,buildingIndelFactory) {

    $scope.myFile;

    $scope.uploadFile = function(type,label){

        var file = $scope.myFile;
        var uploadUrl = "/upload";

   $q.all([
           fileUpload.uploadFileToUrl(file, uploadUrl)
       ]).then(function(value) {

   }, function(reason) {

   });
     
    };
 

  });