mvn dependency:sources
下載 source code
mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail
pmd
mvn pmd:pmd -DtargetJdk=1.6
2012年12月16日 星期日
2012年12月9日 星期日
[CLI] jar - 指令說明
jar 指令
terminate 裡面說明如下:
用法: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] 檔案 ...
選項:
-c 建立新的歸檔
-t 列出歸檔的目錄
-x 從歸檔中擷取已命名的 (或所有) 檔案
-u 更新現有歸檔
-v 在標準輸出中產生詳細輸出
-f 指定歸檔檔案名稱
-m 包含指定資訊清單中的資訊清單資訊
-e 為獨立應用程式指定應用程式進入點,已隨附於可執行 jar 檔案中
-0 僅儲存; 不使用 ZIP 壓縮方式
-M 不為項目建立資訊清單檔案
-i 為指定的 jar 檔案產生索引資訊
-C 變更至指定目錄並包含後面所列的檔案
如果有任何檔案是目錄,則會對其進行遞迴處理。
清單檔案名稱、歸檔檔案名稱和進入點名稱的指定順序與指定 'm' 旗標、'f' 旗標和 'e' 旗標的順序相同。
範例 1: 將兩個類別檔案歸檔至名為 classes.jar 的歸檔中:
jar cvf classes.jar Foo.class Bar.class
範例 2: 使用現有資訊清單檔案 'mymanifest' 並將
foo/ 目錄中的所有檔案歸檔至 'classes.jar' 中:
jar cvfm classes.jar mymanifest -C foo/ .
簡單版本翻譯如下:
cutxi是必要且只能唯一的參數
-C 指定c和u指令的來源目錄
最後則是所有要被壓縮的檔案,如果是資料夾則會遞迴進入
---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線----
至於解壓縮到指定的目錄
sorry~ 要用unzip
unzip targetFile.jar -d targetDir
terminate 裡面說明如下:
用法: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] 檔案 ...
選項:
-c 建立新的歸檔
-t 列出歸檔的目錄
-x 從歸檔中擷取已命名的 (或所有) 檔案
-u 更新現有歸檔
-v 在標準輸出中產生詳細輸出
-f 指定歸檔檔案名稱
-m 包含指定資訊清單中的資訊清單資訊
-e 為獨立應用程式指定應用程式進入點,已隨附於可執行 jar 檔案中
-0 僅儲存; 不使用 ZIP 壓縮方式
-M 不為項目建立資訊清單檔案
-i 為指定的 jar 檔案產生索引資訊
-C 變更至指定目錄並包含後面所列的檔案
如果有任何檔案是目錄,則會對其進行遞迴處理。
清單檔案名稱、歸檔檔案名稱和進入點名稱的指定順序與指定 'm' 旗標、'f' 旗標和 'e' 旗標的順序相同。
範例 1: 將兩個類別檔案歸檔至名為 classes.jar 的歸檔中:
jar cvf classes.jar Foo.class Bar.class
範例 2: 使用現有資訊清單檔案 'mymanifest' 並將
foo/ 目錄中的所有檔案歸檔至 'classes.jar' 中:
jar cvfm classes.jar mymanifest -C foo/ .
簡單版本翻譯如下:
cutxi是必要且只能唯一的參數
分別對應 c新增 u修改 t列表 x解開 i產生索引(還沒研究)vfm0Me是可選的參數,可有可無(但是有些如果沒有也是不能用啊!!)
v詳細訊息
f指定檔案(新增 修改 列表 解壓縮等)
m指定manifest.mf檔案
0檔案不壓縮
M不建立MANIFEST.MF檔案
e設定程式進入點
fme都會需要另外的參數就直接加在後面就可以了,加入的順序與fme出現順序一致即可
-C 指定c和u指令的來源目錄
最後則是所有要被壓縮的檔案,如果是資料夾則會遞迴進入
---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線---分隔線----
至於解壓縮到指定的目錄
sorry~ 要用unzip
unzip targetFile.jar -d targetDir
2012年12月7日 星期五
jquery - prop vs attr
<html>
<head>
<title></title></head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<body>
<form>
<label>default 123</label><input id="a" type="text" value="123" />
<label>no default</label><input id="b" type="text" />
<label>no default jquery</label><input id="c" type="text" />
<input type="reset" value="reset" />
<input type="submit" value="submit" />
</form>
</body>
<script type="text/javascript"></html>document.getElementById("a").value = 234 ;</script>
document.getElementById("b").value = 'bcd' ;
$("#c").val("098");
//document.getElementById("a").value = 234 ;
document.getElementById("b").defaultValue = 'abc' ;
$("#c").prop('defaultValue', "987");
2012年11月26日 星期一
Oracle筆記 = =
Oracle 建立 Tablespace
create tablespace dbf
datafile '/home/app/path/to/dbf/dbfname.dbf'
size 800M
autoextend on
next 50M
maxsize UNLIMITED;
sqlplus 使用description登入(一定要是單引號 雙引號就gg了)
sqlplus user_id/p@ssw0rd'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.123)(PORT=1521))(CONNECT_DATA=(SID=sid)(SERVER=dedicated)))'
設定能夠讀取中文日期格式
alter session set NLS_DATE_LANGUAGE = 'Traditional Chinese'
create tablespace dbf
datafile '/home/app/path/to/dbf/dbfname.dbf'
size 800M
autoextend on
next 50M
maxsize UNLIMITED;
sqlplus 使用description登入(一定要是單引號 雙引號就gg了)
sqlplus user_id/p@ssw0rd'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.123)(PORT=1521))(CONNECT_DATA=(SID=sid)(SERVER=dedicated)))'
設定能夠讀取中文日期格式
alter session set NLS_DATE_LANGUAGE = 'Traditional Chinese'
2012年11月22日 星期四
js note!! 資料類型
javascript裡面的資料儲存
可以直接建立 instance(也就是直接的使用資料)
例如:
var data1 = 0 ;
var data2 = 'test' ;
var data3 = {
var1: '123',
var2: '234'
};
var data4 = ['arr1', 'arr2'];
另外一種就是function 而裡面就開始遞迴的結構 重複做instance與function的建立
var func1 = function(){
var data = 'data';
var func = function(){
console.log("function called");
};
console.log(data);
func();
}
可以直接建立 instance(也就是直接的使用資料)
例如:
var data1 = 0 ;
var data2 = 'test' ;
var data3 = {
var1: '123',
var2: '234'
};
var data4 = ['arr1', 'arr2'];
另外一種就是function 而裡面就開始遞迴的結構 重複做instance與function的建立
var func1 = function(){
var data = 'data';
var func = function(){
console.log("function called");
};
console.log(data);
func();
}
2012年10月27日 星期六
三天前到手 我這輩子買過最貴的東西!!!
我有Mac了!!!!!!!
MacBook Pro with Retina 15" 16G記憶體 512G SSD
http://www.apple.com/tw/macbook-pro/features-retina/
爽啊!!!!
2012年9月17日 星期一
windows 刪除 已建立的windows service
sc.exe
sc query service_name
sc delete service_name
要記得用管理員權限操作command
2012年9月10日 星期一
2012年8月19日 星期日
好用連結
好用連結
工具連結
Free Online Tools For Developers http://www.freeformatter.com/
DBDesigner http://dbdsgnr.appspot.com/
JS Code Snippet http://scriptsrc.net/
Google Code Playground https://code.google.com/apis/ajax/playground/
Code Paste
http://paste.ideaslabs.com
http://codepad.org/
JS Loader
http://requirejs.org/
http://headjs.com/
https://developers.google.com/loader/?hl=zh-TW
JS Render
JS Render https://github.com/BorisMoore/jsrender
JS Component
Bootstrap http://twitter.github.com/bootstrap/
Maven Q&A
Maven
http://maven.apache.org/index.htmlhttp://maven.apache.org/plugins/index.html
Maven實在是個很方便的東西,管好了library寫程式的心情大悅 XDD
目前都是用Eclipse所以也就很自然的用Eclipse的Plugin,又所以更自然的遇到了一些問題!!
調整預設的Compiler版本
pom.xml <project> 裡面加入設定自動把Maven library放進WEB-INF/lib資料夾
先在 project>build 中加入再到 project > build > plugins 裡面加入
2012年8月12日 星期日
JavaScript小筆記
分類 :
- Primitive types, Object types
- Methods, Types
- Mutable types, immutable types
Number
- 0, -0 (0 == -0, 1/0 != 1/-0)
- Infinity, -Infinity
- NaN
Function
function func(){
this.x = 0;
this.getX = function(){ return this.x; }
this.setX = function(x){ this.x = x; }
}
var a = func(); //此時執行的this是javascript最頂層的global object
var b = new func(); //此時執行的this是javascript最頂層的global object
Log4j PatternLayout
好吧 = =
等我英文夠好 我會把他記起來的
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
重要的部分節錄如下
The recognized conversion characters are
By default the relevant information is output as is. However, with the aid of format modifiers it is possible to change the minimum field width, the maximum field width and justification.
The optional format modifier is placed between the percent sign and the conversion character.
The first optional format modifier is the left justification flag which is just the minus (-) character. Then comes the optional minimum field width modifier. This is a decimal constant that represents the minimum number of characters to output. If the data item requires fewer characters, it is padded on either the left or the right until the minimum width is reached. The default is to pad on the left (right justify) but you can specify right padding with the left justification flag. The padding character is space. If the data item is larger than the minimum field width, the field is expanded to accommodate the data. The value is never truncated.
This behavior can be changed using the maximum field width modifier which is designated by a period followed by a decimal constant. If the data item is longer than the maximum field, then the extra characters are removed from the beginning of the data item and not from the end. For example, it the maximum field width is eight and the data item is ten characters long, then the first two characters of the data item are dropped. This behavior deviates from the printf function in C where truncation is done from the end.
Below are various format modifier examples for the category conversion specifier.
Below are some examples of conversion patterns.
等我英文夠好 我會把他記起來的
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
重要的部分節錄如下
The recognized conversion characters are
Conversion Character | Effect |
---|---|
c | Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed. By default the category name is printed in full. For example, for the category name "a.b.c" the pattern %c{2} will output "b.c". |
C | Used to output the fully qualified class name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form. For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". WARNING Generating the caller class information is slow. Thus, use should be avoided unless execution speed is not an issue. |
d | Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed.The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat . Although part of the standard JDK, the performance of SimpleDateFormat is quite poor.For better results it is recommended to use the log4j date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormat , DateTimeDateFormat and respectivelyISO8601DateFormat . For example, %d{ISO8601} or %d{ABSOLUTE}.These dedicated date formatters perform significantly better than SimpleDateFormat . |
F | Used to output the file name where the logging request was issued.WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
l | Used to output location information of the caller which generated the logging event.The location information depends on the JVM implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses. The location information can be very useful. However, its generation is extremely slow and should be avoided unless execution speed is not an issue. |
L | Used to output the line number from where the logging request was issued.WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
m | Used to output the application supplied message associated with the logging event. |
M | Used to output the method name where the logging request was issued.WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
n | Outputs the platform dependent line separator character or characters.This conversion character offers practically the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator. |
p | Used to output the priority of the logging event. |
r | Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event. |
t | Used to output the name of the thread that generated the logging event. |
x | Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. |
X | Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The X conversion character must be followed by the key for the map placed between braces, as in %X{clientNumber} whereclientNumber is the key. The value in the MDC corresponding to the key will be output.See MDC class for more details. |
% | The sequence %% outputs a single percent sign. |
The optional format modifier is placed between the percent sign and the conversion character.
The first optional format modifier is the left justification flag which is just the minus (-) character. Then comes the optional minimum field width modifier. This is a decimal constant that represents the minimum number of characters to output. If the data item requires fewer characters, it is padded on either the left or the right until the minimum width is reached. The default is to pad on the left (right justify) but you can specify right padding with the left justification flag. The padding character is space. If the data item is larger than the minimum field width, the field is expanded to accommodate the data. The value is never truncated.
This behavior can be changed using the maximum field width modifier which is designated by a period followed by a decimal constant. If the data item is longer than the maximum field, then the extra characters are removed from the beginning of the data item and not from the end. For example, it the maximum field width is eight and the data item is ten characters long, then the first two characters of the data item are dropped. This behavior deviates from the printf function in C where truncation is done from the end.
Below are various format modifier examples for the category conversion specifier.
Format modifier | left justify | minimum width | maximum width | comment |
---|---|---|---|---|
%20c | false | 20 | none | Left pad with spaces if the category name is less than 20 characters long. |
%-20c | true | 20 | none | Right pad with spaces if the category name is less than 20 characters long. |
%.30c | NA | none | 30 | Truncate from the beginning if the category name is longer than 30 characters. |
%20.30c | false | 20 | 30 | Left pad with spaces if the category name is shorter than 20 characters. However, if category name is longer than 30 characters, then truncate from the beginning. |
%-20.30c | true | 20 | 30 | Right pad with spaces if the category name is shorter than 20 characters. However, if category name is longer than 30 characters, then truncate from the beginning. |
- %r [%t] %-5p %c %x - %m%n
- This is essentially the TTCC layout.
- %-6r [%15.15t] %-5p %30.30c %x - %m%n
- Similar to the TTCC layout except that the relative time is right padded if less than 6 digits, thread name is right padded if less than 15 characters and truncated if longer and the category name is left padded if shorter than 30 characters and truncated if longer.
2012年8月11日 星期六
xml定義 DTD & XSD
iBatis
iBatis Config
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
iBatis SqlMap
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
Struts2
<!DOCTYPE struts
PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
Web-app (web.xml)
XML Doctype Definition (dtd before servlet 2.3)
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD WebApplication 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
XML Schema Definition (xsd after servlet 2.4)
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<web-app
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
Spring
PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
beans (2.0 xsd)
<beans
beans (3.0 xsd)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
2012年7月31日 星期二
LDAP基本查詢語法
LDAP基本查詢語法
開始工作真的在搞一些有的沒有
而且每個客戶的做法也都不一樣 太有趣了 ="=
先前我們使用的方式是使用帳號密碼 試著登入ldap server如果能登入就是合法的使用者
今天看到某客戶(!!!!)的demo code
事先使用一個類似admin的帳號 可以取得(查詢)所有的user
再連線至LDAP比較密碼 是否相同 (很怪吧!!!)
總之 今天有用到在LDAP的查詢語法 XDD
Ref: http://technet.microsoft.com/zh-tw/library/dd159860.aspx
Ref: http://www.novell.com/documentation/developer/jldap/jldapenu/api/
開始工作真的在搞一些有的沒有
而且每個客戶的做法也都不一樣 太有趣了 ="=
先前我們使用的方式是使用帳號密碼 試著登入ldap server如果能登入就是合法的使用者
今天看到某客戶(!!!!)的demo code
事先使用一個類似admin的帳號 可以取得(查詢)所有的user
再連線至LDAP比較密碼 是否相同 (很怪吧!!!)
總之 今天有用到在LDAP的查詢語法 XDD
Ref: http://technet.microsoft.com/zh-tw/library/dd159860.aspx
Ref: http://www.novell.com/documentation/developer/jldap/jldapenu/api/
SQL Server中與Metadata相關的預設table
SQL Server 2000中(之後可以改用VIEW來完成相同的工作)
有一些系統的table來儲放資料的metadata
store database-level system information for each database.
查詢某TABLE的某COLUMN存不存在
use [DB_NAME]
GO
DECLARE @tb_name VARCHAR(512), @col_name VARCHAR(512)
SET @tb_name = 'TABLE_NAME'
SET @col_name = 'COL_NAME'
IF NOT EXISTS(
SELECT 1
from sys.sysobjects so
INNER JOIN sys.syscolumns sc ON sc.id = so.id
where so.name = @tb_name AND sc.name = @col_name
)
BEGIN
PRINT 'COLUMN ''' + @col_name+ ''' is NOT EXISTS!!'
END
ELSE
BEGIN
PRINT 'COLUMN ''' + @col_name+ ''' is EXISTS!!'
END
GO
http://msdn.microsoft.com/en-us/library/aa260604(v=sql.80)
有一些系統的table來儲放資料的metadata
System Tables in Every Database
store database-level system information for each database.
syscolumns
|
Sysindexkeys
|
syscomments
|
sysmembers
|
sysconstraints
|
sysobjects
|
sysdepends
|
syspermissions
|
sysfilegroups
|
sysprotects
|
sysfiles
|
sysreferences
|
sysforeignkeys
|
systypes
|
sysfulltextcatalogs
|
sysusers
|
sysindexes
|
查詢某TABLE的某COLUMN存不存在
use [DB_NAME]
GO
DECLARE @tb_name VARCHAR(512), @col_name VARCHAR(512)
SET @tb_name = 'TABLE_NAME'
SET @col_name = 'COL_NAME'
IF NOT EXISTS(
SELECT 1
from sys.sysobjects so
INNER JOIN sys.syscolumns sc ON sc.id = so.id
where so.name = @tb_name AND sc.name = @col_name
)
BEGIN
PRINT 'COLUMN ''' + @col_name+ ''' is NOT EXISTS!!'
END
ELSE
BEGIN
PRINT 'COLUMN ''' + @col_name+ ''' is EXISTS!!'
END
GO
SQL Server中與Metadata相關的預設View
SQL Server 2005, 2008, 2008 R2, 2012
在INFORMATION_SCHEMA中有一些預設的system view可以來查詢一些跟資料庫相關的資訊
像是table名稱、column名稱等
Ref: http://msdn.microsoft.com/en-us/library/ms186778.aspx
在INFORMATION_SCHEMA中有一些預設的system view可以來查詢一些跟資料庫相關的資訊
像是table名稱、column名稱等
CHECK_CONSTRAINTS
|
REFERENTIAL_CONSTRAINTS
|
COLUMN_DOMAIN_USAGE
|
ROUTINES
|
COLUMN_PRIVILEGES
|
ROUTINE_COLUMNS
|
COLUMNS
|
SCHEMATA
|
CONSTRAINT_COLUMN_USAGE
|
TABLE_CONSTRAINTS
|
CONSTRAINT_TABLE_USAGE
|
TABLE_PRIVILEGES
|
DOMAIN_CONSTRAINTS
|
TABLES
|
DOMAINS
|
VIEW_COLUMN_USAGE
|
KEY_COLUMN_USAGE
|
VIEW_TABLE_USAGE
|
PARAMETERS
|
VIEWS
|
Ref: http://msdn.microsoft.com/en-us/library/ms186778.aspx
2012年6月12日 星期二
用一維陣列解n皇后問題
用一維陣列解n皇后問題
使用 2 維的陣列來儲存棋盤 似乎是比較直覺的做法
所以我們會在 map[n][n] 這樣的陣列裡面填上0跟1來表示皇后放在哪裡
接著檢查的方式 就是檢查 每一個行、每一個列、斜角有沒有被放上皇后
OK~ 簡單Easy~
接下來 討論一下利用一維陣列 來儲存
直接將 map[i][j] = 1 取代成 arr[i] = j
檢查的方式呢
檢查map[i][j]第 i 列的部分 由於我們填入的時候 是一列一列的填入 (依照index) 所以可以跳過了
檢查map[i][j]第 j 行的部分 就檢查目前放入陣列的數字有沒有重複就可以了
至於斜角也很簡單 原先map[i][j]與map[[k][l]是否是在斜線的關系
原先使用 |i-k| == |j-l| if (i,j ) != (j, k)來檢查
現在改用 arr[i] = j 與 arr[k] = l 就會變成 |i - k| == |arr[i] - arr[k]| if (i,j ) != (j, k)
import java.util.Arrays; import java.util.Scanner; public class JAVA { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = 0 ; while (cin.hasNext()) { n = cin.nextInt(); if(n > 0) printQueen(n); else break ; } } static void printQueen(int n){ int count = 0 ; int map[] = new int[n]; int level = 0; Arrays.fill(map, -1); for(int i = 0 ; i < n ; i++){ map[i] = level; count += dfs(n, i, level, map); map[i] = -1 ; } System.out.println(count); System.out.println(); } // map[i] = j -->> map[i][j] -> checked // map[i][j], map[k][l] are conflicted >>> |i-k| == |j-l| private static int dfs(int n, int i, int level, int[] map) { if(level == n-1){ printQueenMap(n, map); return 1 ; }else{ int count = 0; for(int k = 0 ; k < n ; k++){ if(map[k] != -1) continue; boolean flag = true; for(int ii = 0 ; flag && ii < n ;ii++){ if(map[ii] != -1) if(Math.abs(ii-k) == Math.abs(map[ii]-level-1)){ flag = false ; } } if(flag){ map[k] = level+1; count += dfs(n,k,level+1, map); map[k] = -1; } } return count; } } private static void printQueenMap(int n, int[] map) { for(int x = 0 ; x < n ; x++){ int tmp = -1; for(int y = 0; y < n ; y++){ if(map[y] == x){ tmp = y ; break; } } String XX = repeat("x",n); System.out.print(XX.substring(n-tmp)); System.out.print("Q"); System.out.println(XX.substring(tmp+1)); } System.out.println(); } public static String repeat(String s, int times) { if (times <= 0) return ""; else return s + repeat(s, times-1); } }
2012年3月4日 星期日
Closures
JavaScript - Closures are means through which inner functions can refer to the variables present in their outer enclosing function after their parent functions have already terminated.
2012年2月10日 星期五
歷史紀錄
原始資料表
歷史資料表 << 原始資料表
+ 更新序號
+ 更新時間
+ 更新方式 (A, U, D)
(+ 更新人)
(+ 更新原因)
trigger
新增
insert into 原始資料表
修改
update 原始資料表
刪除
delete from 原始資料表
------------------
歷史資料表只能新增 再 藉由trigger對 原始資料表作更動
由於所以無法指藉由資料來顯示是新增或是刪除
所以需要一個變更方式的欄位
------------------ update @ 2012/2/10 05:43
java 可以建立一個歷史紀錄的類別(介面)
public interface HistoricalData{
void setUpdateSeq(int updateSeq);
int getUpdateSeq();
void setUpdateDatetime(Date datetime);
Date getUpdateDatetime();
void setUpdateType(String updateType);
String getUpdateType();
}
------------------ update @ 2012/2/10 05:43
java 可以建立一個歷史紀錄的類別(介面)
public interface HistoricalData{
void setUpdateSeq(int updateSeq);
int getUpdateSeq();
void setUpdateDatetime(Date datetime);
Date getUpdateDatetime();
void setUpdateType(String updateType);
String getUpdateType();
}
訂閱:
文章 (Atom)