發表文章

[develop] sublime設定sftp

sublime設定sftp 其中"ssh_key_file": "C:\/darren\/ec2-key\/hatemapkey.ppk" 只能用ppk不能用pem, 轉換方式參考 http://tkoyama1988.hatenablog.com/entry/2014/06/10/180729 {     // The tab key will cycle through the settings when first created     // Visit http://wbond.net/sublime_packages/sftp/settings for help         // sftp, ftp or ftps     "type": "sftp",     "sync_down_on_open": true,     "upload_on_save": true,     "sync_same_age": true,         "host": "xx.xxx.xx.x",     "user": "ec2-user",     //"password": "password",     "port": "22",         "remote_path": "/home/ec2-user/hatemap",     //"file_permissions": "664",     //"dir_permissions": "775",         //"extra_list_connections": 0,     "connect_timeout": 30,     //"keepalive": 120...

[leetcode] [36] [javascript] Valid Sudoku

效能很差 /** * @param {character[][]} board * @return {boolean} */ var isValidSudoku = function(board) { var check = function(ar){ var ob = {}; for(var j=0;j<9;j++){ if(ar[j] == '.'){ continue; } if(ob[ar[j]] === undefined){ ob[ar[j]] = 1; }else{ return false; } } return true; }; var getAr = function(i){ var r = parseInt(i/3); var c = i%3; var ar = []; ar.push(board[r*3+0][c*3+0]); ar.push(board[r*3+0][c*3+1]); ar.push(board[r*3+0][c*3+2]); ar.push(board[r*3+1][c*3+0]); ar.push(board[r*3+1][c*3+1]); ar.push(board[r*3+1][c*3+2]); ar.push(board[r*3+2][c*3+0]); ar.push(board[r*3+2][c*3+1]); ar.push(board[r*3+2][c*3+2]); return ar; }; var getcAr = function(i){ var ar = []; ar.pus...

[leetcode] [32] [javascript] Longest Valid Parentheses

這幾天困了我很久的ㄧ題 /**  * @param {string} s  * @return {number}  */ var longestValidParentheses = function(s) {          var i = 0;     var max = 0;     var stack = [];     var stack_ind = [];          while(i&amp;lt;=s.length-1){         var pop = 0;         if(s[i] == ')'){             if(stack.length &amp;gt; 0){                 pop = stack.pop();                 stack_ind[pop] = true;                 stack_ind[i] = true;             }else{                 stack_ind[i] = false;             }             i++;       ...

[leetcode] [30] [javascript] substr performance better than substring

/**  * @param {string} s  * @param {string[]} words  * @return {number[]}  */ var findSubstring = function(s, words) {           var counts = {};               //counts 記錄所有可用的pattern剩餘使用次數         for (var p in words){             counts[words[p]] = counts[words[p]] === undefined ? 1 : counts[words[p]] + 1;         }               var n = s.length, num = words.length, len = words[0].length;         var indexes = [];         //從頭開始比對 是否有可用pattern可以使用         //例如 s = abdegdsadf, counts= {'abd': 2, 'acc': 1}         //發現abd is match, 接下來就會檢察egd有沒有再counts裡面         //發現沒有就進入下一round, s = bdegdsadf, 開始檢察bde有沒有在count裡面         //每一round檢查完會看可用pattern是不是都用完了, 用完了代表成功match ...

[java] static

reference: http://www.inote.tw/2007/12/java-static.html

[c] fork

fork will return 0 when it is child process and a random positive number when it is parent.

[c] error: ‘exit’ was not declared in this scope

error: ‘exit’ was not declared in this scope it will be compiled without errors if you include in your code the statement: #include <cstdlib> error: ‘fork’ was not declared in this scope it will be compiled without errors if you include in your code the statement: #include <unistd.h>