發表文章

目前顯示的是 9月, 2012的文章

Mac Spotlight disable/enable

今天發現Mac中mds服務一直佔掉大部份cpu 搜尋一下原來這是Mac中的index service mds = metadata server 目的是讓Spotlight服務可以更快更準確找到要找的東西 不過...他讓風扇轉太久了...@@ 下面有關閉與開啓的指令,給大家參考 關閉: sudo mdutil -a -i off 開啟: sudo mdutil -a -i on 參考網站: http://osxdaily.com/2009/09/20/disable-spotlight-in-mac-os-x-10-6-snow-leopard/  

Simple node.js reverse proxy to Google sites service

圖片
沈溺在Google服務的玩家,對Google Sites服務應該不陌生 但是最近Google的Sites DNS轉址服務暫停了... 是否意味著這個進階服務會開始收費了呢?? 不得而知拉... 不過如果可以透過簡單的設定把Sites服務轉到自己的Domain下的話.... 這邊介紹"幾行"Node.js程式,可以把sites的所有網頁都轉到你要的網址上... 透過 mikeal   /   request   的pipe request/response的功能 可以輕易地把sites的網頁都經由寫好的這隻程式來轉址噢... PS: 安裝就.... npm install request # vi test-request.js   1 var http = require('http')   2   , request = require('request');   3    4  //google site url   5 var url = ' https://sites.google.com/site/ ';   6  //google site domain (change to yours)   7 url += 'simonsumail';   8    9 http.createServer(function (req, resp) {  10   console.log(req.url);  11   if (req.method === 'PUT') {  12     req.pipe(request.put(url + req.url))  13   } else if (req.method === 'GET' || req.method === 'HEAD') {  14     request.get(url + req.url).pipe(resp);  15   }  16 }).listen(80, '211.78.255.92');  //ipaddress that the node server host #

Node.js Report Server

這是一個下午想到的,簡單的Node.js Report Server 目的是讓懂SQL又不太懂後端程式的人可以利用這個Report Server來產出一些基本的報表 當然,他要會使用ajax接json的資料,這邊的報表只有吐json出來而已 概念是: Step 1. user簡單定義report config,將預執行的report sql配置於config file中,並可以動態配置where子句來作查詢 Step 2. 將report config放在指定資料夾($REPORT_SERVER_HOME/report)內 Step 3. 然後就可以透過REST GET的方式取得該report的json output curl -sS http://yout_ip:your_port /report/rest/simple.rpt?MEMBER_ID=0066f7b4&USER_ID= xxxx@oooo.com.tw -X GET PS. 附加提供整體report的查看,如果要看有哪些configured report,則可以透過下面REST GET呼叫 curl -sS http://yout_ip:your_port /report/restdoc -X GET 實作部分,專案資料結構: $  |____routes | |____index.js.......................router管理 |____views | |____(Skip) |____report | |____simple.rpt....................report config file |____lib | |____db-manager.js.............資料庫聯結程式,將來可以修改為連接不同資料庫 | |____db-config.js.................資料庫設定檔案,目前為mysql |____public | |____(Skip) |____node_modules | |____(Skip) |____app.js............................server啟動點 |____package.json 先來看config file的配置,透過

Bash中for loop的continue...

#!/bin/bash export aa=$1 for i in {1..10} do   if [ ! -z "$aa" ] ; then     if [ $aa == $i ] ; then       echo "exist... will break:"$i       continue     fi   fi   echo $i..... done # bash /tmp/test.sh 3 1..... 2..... exist... will break:3 4..... 5..... 6..... 7..... 8..... 9..... 10.....

Ant deploy war file to Tomcat server

雖然離開Java有段時間了 不過還是難忘Java在一些地方的好處 這邊簡介如何透過ANT來作Tomcat的部署 Tomcat主機資訊如下: Tomcat version: 6.0.32 Server IP: xxx.xxx.xxx.xxx Tomcat Port: 8080 Script Deployer: tomcat (password: tomcatpassword) 特殊設定: 1. ant需要把catalina-ant.jar放到ant家目錄的lib中 2. tomcat-user.xml(位於$TOMCAT_HOME/conf下)需要加入manager-script的角色 下面是deploy的ant script 裡面有hard code部署時候需要的 1. application name: /TestWeb2 2. server deploy endpoint: http://xxx.xxx.xxx.xxx:8080/manager 3. deployer username, password: tomcat / tomcatpassword 當然,這些變數也可以透過-Dkeyname=keyvalue的方式在執行時候帶入 build.xml <project name="My Application" default="compile" basedir=".">   <!-- Configure the context path for this application -->   <property name="path"     value="/ TestWeb2 "/>   <!-- Configure properties to access the Manager application -->   <property name="url"      value=" http://xxx.xxx.xxx.xxx:8080/manager "/>   &l

Mac Routing Table

連內、連外切來切去很麻煩@@,可以透過routing table來搞定喔∼ 這邊有兩個網段 1. 192.168.142.254 (內部區網IP網段Gateway) 2. 192.168.15.1 (WiMAX網段Gateway) 預計要讓 192.168.0.0/16 的連線都走內部(1)網段,其他則走外部連線 下面試設定,參考一下: # 砍掉default route sudo route delete default 192.168.142.254 # 重設default route sudo route add default 192.168.15.1 # 設定route到內部的ip(如果有其他網斷要route的話,可以加這邊這段...) sudo route add -net 192.168.0.0/16 192.168.142.254