# Color defination
txtRed=$(tput setaf 1)
txtGreen=$(tput setaf 2)
txtYellow=$(tput setaf 3)
txtBlue=$(tput setaf 4)
txtPurple=$(tput setaf 5)
txtCyan=$(tput setaf 6)
txtWhite=$(tput setaf 7)
txtReset=$(tput sgr0)
# Style defination
txtBold=$(tput bold)
txtUL=$(tput smul)
# Example
echo "${txtRed}Red text"
echo "still Red text"
echo "$txtReset"
echo "Normal text"
Reference: How to echo colored text in linux shell script
方法一把輸出字串當javascript執行,方法二只是把方法一包到PhaseListener,為什麼要這樣包還不太清楚,所以先用方法一
try {
RWT.getResponse().getWriter().println("alert('123');");
} catch (IOException ex) {
ex.printStackTrace();
}
RWT.getLifeCycle().addPhaseListener(new PhaseListener() {
private static final long serialVersionUID = 1995219943700635190L;
@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER;
}
@Override
public void beforePhase(PhaseEvent event) {
try {
RWT.getResponse().getWriter().println("alert('1');");
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void afterPhase(PhaseEvent event) {
try {
RWT.getResponse().getWriter().println("alert('2');");
} catch (IOException e) {
e.printStackTrace();
}
RWT.getLifeCycle().removePhaseListener(this);
}
});
package org.gclin.core.web;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.HttpJspPage;
import javax.servlet.http.HttpServlet;
public abstract class HttpBaseJsp extends HttpServlet implements HttpJspPage {
private static final long serialVersionUID = 5971944450223631606L;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
jspInit();
_jspInit();
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
_jspService(request, response);
}
@Override
public void destroy() {
jspDestroy();
_jspDestroy();
}
@Override
public void jspInit() {}
public void _jspInit() {}
@Override
public void jspDestroy() {}
protected void _jspDestroy() {}
@Override
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
}
<%@page contentType="text/html; charset=BIG5"
extends="org.gclin.core.web.HttpBaseJsp"%>
...
Step 1. Install plugin from update site
Eclipse => Help => Install New Software => Add
Name: Google app Engine
Location: http://dl.google.com/eclipse/plugin/3.6
Step 2. Create GAE project
File => New => Project
type filter text: Web Application Project
type project name, package and uncheck "Use Google Toolkit"
Step 3. Specified applications for this project
Package Explorer => this project => war => WEB-INF => appengine-web.xml
<application>name of your application</application>
Step 4. Test and Deploy
Just click the button "Run" or "Deploy App engine project" on toolbar
Test URL: http://localhost:8888/ (Default)
GAE URL: http://name of your application.appspot.com
public class MyEntryPoint implements IEntryPoint {
public int createUI() {
Display display = PlatformUI.createDisplay();
LoginInfo info = null;
while (info == null) {
LogonDialog dialog = new LogonDialog(display.getActiveShell());
try {
info = checkLogin(dialog.getUsername(), dialog.getPassword());
} catch (Exception e) {
MessageDialog.openError(display.getActiveShell(), "Error", "Logon Fail:\n" + e.getMessage());
}
}
return PlatformUI.createAndRunWorkbench( display, new ApplicationWorkbenchAdvisor());
}
}
點擊選單 投影片放映 => 設定放映放式
1. 指定播放畫面
2. 顯示簡報者檢視畫面(感覺不錯)

Step 1. 啟動Cygwin
Step 2. 開啟視窗內容
標題列按右鍵 => 內容
Step 3. 勾選快速編輯模式
選項 => 快速編輯模式 => 確定
網站:Boost C++ Libraries(下載)
Step 1. 取得Boost libraries
到網站的Download去下載,然後解壓縮(D:/boost_1_42_0)
Step 2. 建置Bjam
進入D:/boost_1_42_0,然後執行bootstrap.bat
跑完之後在這個目錄就會多出一個bjam.exe
Step 3. 建置Boost Libraries
在D:/boost_1_42_0建立一個buildall_vc90.bat內容如下
bjam toolset=msvc-9.0 variant=debug threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION
bjam toolset=msvc-9.0 variant=release threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION
執行剛剛建立的那個buildall_vc90.bat,等他跑完在D:\boost_1_42_0\stage\lib應該有一堆*.lib、*.dll
Step 4. 設定Visual Studio 2008
開啟Visual Studio 2008,工具 => 選項 => 專案和方案 => VC++目錄
顯示目錄的那個下拉選單
選Include檔案加入D:\boost_1_42_0
選程式庫檔加入D:\boost_1_42_0\stage\lib
最近遇到的一個問題Stack overflow,不難解~改用new&delete就對了丫,結果還是錯,找了一下資料是用new&delete沒錯,但是為啥不行,最後發現原來還有別的地方有用一樣的數字來宣告,程式如下:
一開始找出來發生錯誤的地方(我一直以為是這錯@@a)
const unsigned int numSolution1 = 50;
// 掛
Solution sol1[numSolution1];
// 正常來說改成這樣就OK了,結果調成100還是會掛
Solution *sol1 = new Solution[numSolution1];
最後發現~另外還有幾個個檔案有類似下面的程式:
// 掛,因為這邊也要改用new
const unsigned int numSolution2 = numSolution1 * 2;
Solution sol2[numSolution2];
閱讀全文…