2010年3月1日 星期一

W3C CSS3 overflow-x, overflow-y tests

Partially supported in Gecko 1.8, Safari 3, Opera 9.5, IE.

In all the following test cases the green box has fixed dimensions (80px × 80px, with padding 9px, border 10px.) The blue bar (width 119px, border 1px) should overflow at the right, and the red one (height 119px, border 1px) at the bottom. When one of the two properties is ‘auto’ there are four cases: two with only one overflowing bar at a time, one with both overflowing, one with no overflow (the third case should behave as with ‘scroll’ instead of ‘auto’).

According to the spec ... some combinations with ‘visible’ are not possible: if one is specified as ‘visible’ and the other is ‘scroll’ or ‘auto’, then ‘visible’ is set to ‘auto’ ....

All browsers seem to further reduce the number of combinations giving different results:

  • In Gecko, Safari, Opera, ‘visible’ becomes ‘auto’ also when combined with ‘hidden’ (in other words: ‘visible’ becomes ‘auto’ when combined with anything else different from ‘visible’). Gecko 1.8, Safari 3, Opera 9.5 are pretty consistent among them.
  • In IE7, IE8 ‘visible’ becomes ‘hidden’ when combined with ‘hidden’.
  • IE6 seems to render all combinations differently, but of course here ‘visible’ means ‘expand’ the box (in the specified direction) to enclose the content.
overflow-x: visibleoverflow-x: hiddenoverflow-x: scrolloverflow-x: auto
overflow-y:
visible
overflow-y:
visible
overflow-y:
hidden
overflow-y:
hidden
overflow-y:
scroll
overflow-y:
scroll
overflow-y:
auto
overflow-y:
auto
overflow-x: visibleoverflow-x: hiddenoverflow-x: scrolloverflow-x: auto

Neglecting the cases with ‘auto’ (which depend on content), there are 9 (= 3 × 3) possible combinations of values of overflow-x and overflow-y, but only five distinct results in Gecko, Safari, Opera. These correspond to:

  1. visible,visible
  2. hidden,hidden
  3. scroll,scroll; visible,scroll; scroll,visible (3 combinations)
  4. scroll,hidden; visible,hidden (2 combinations)
  5. hidden,scroll; hidden,visible (2 combinations)

In IE7, IE8 there are also the same five distinct results, but they correspond to a different grouping of values:

  1. visible,visible
  2. hidden,hidden; visible,hidden; hidden,visible (3 combinations)
  3. scroll,scroll; visible,scroll; scroll,visible (3 combinations)
  4. scroll,hidden
  5. hidden,scroll


css test home http://www.brunildo.org/test/

2010年2月26日 星期五

MySQL: Rewriting Subqueries as Joins

Although MySQL 5.1 supports subqueries, it is still true that there are sometimes other ways to test membership in a set of values. It is also true that on some occasions, it is not only possible to rewrite a query without a subquery, but it can be more efficient to make use of some of these techniques rather than to use subqueries. One of these is the IN() construct:

For example, this query:

SELECT * FROM t1 WHERE id IN (SELECT id FROM t2); 

Can be rewritten as:

SELECT DISTINCT t1.* FROM t1, t2 WHERE t1.id=t2.id; 

The queries:

SELECT * FROM t1 WHERE id NOT IN (SELECT id FROM t2); SELECT * FROM t1 WHERE NOT EXISTS (SELECT id FROM t2 WHERE t1.id=t2.id); 

Can be rewritten as:

SELECT table1.*   FROM table1 LEFT JOIN table2 ON table1.id=table2.id   WHERE table2.id IS NULL; 

A LEFT [OUTER] JOIN can be faster than an equivalent subquery because the server might be able to optimize it better — a fact that is not specific to MySQL Server alone. Prior to SQL-92, outer joins did not exist, so subqueries were the only way to do certain things. Today, MySQL Server and many other modern database systems offer a wide range of outer join types.



source:http://dev.mysql.com/doc/refman/5.1/en/rewriting-subqueries.html

2010年2月10日 星期三

XPath On C#

首先~~

在.Net中要先Useing System.XML

先叫用 XmlDocument xd = new XmlDocument();

xd.Load("XML路徑");//載入XML 或用xd.LoadXML("XML字串")

XmlNode xn = xd.FirstChild;//我的習慣會先以Root的Node往下走

接下來就用SelectSingleNode 或者 SelectNodes這兩個Method來進行XPath查詢

一個是回傳一個Node,一個是回傳Node的陣列,各取所需

先大概說明一下XPath語法

符號"/"代表的是絕對路徑,"//"代表的是全部

意思是說當我語法下/A/B/C,此查詢就一定會依循先找到A再找A底下的B再找B底下的C

當語法下//C,此查詢就會把所有C的節點找出來,即是在不同層級的節點

接下來符號*及代表此節點以下全部的節點

當語法下/A/*,則會把節點A底下全部的節點找出來

那如果是下/A/*/C,則會把節點A底下全部含有C子節點的節點找出來

語法為/A/B[1],代表節點A底下的第一個B節點

也可以下/A/B[last()] 或者/A/B[last()-1]取出A節點底下最後一個B節點或倒數第二個B節點

還可以/A[B=123]取出A節點底下B節點內容為123的節點

當然也有邏輯~類似/A/B | /A/C這樣就會取出節點A底下B和C的節點

最後一個就是查詢屬性..當如果我要查詢 name="123"的tag時可以下@name=123

查A節點name=123 時可以下/A[@name=123]


Source:
http://www.wretch.cc/blog/fredxxx123/9959025
http://www.cnblogs.com/lovelace821/archive/2010/01/20/1652223.html
http://www.dotblogs.com.tw/jacky19819/archive/2009/03/25/7691.aspx
http://www.dotblogs.com.tw/yilinliu/archive/2009/01/17/6849.aspx


2010年2月4日 星期四

Java Class.getResource()用法

  
用JAVA获取文件,听似简单,但对于很多像我这样的新人来说,还是掌握颇浅,用起来感觉颇深,大常最经常用的,就是用JAVA的File类,如要取得c:/test.txt文件,就会这样用File file = new File("c:/test.txt");这样用有什么问题,相信大家都知道,就是路径硬编码,对于JAVA精神来说,应用应该一次成型,到处可用,并且从现实应用来讲,最终生成的应用也会部署到Windows外的操作系统中,对于linux来说,在应用中用了c:/这样的字样,就是失败,所以,我们应该尽量避免使用硬编码,即直接使用绝对路径。

  在Servlet应用中,有一个getRealPath(String str)的方法,这个方法尽管也可以动态地获得文件的路径,不秘直接手写绝对路径,但这也是一个不被建议使用的方法,那么,我们有什么方法可以更好地获得文件呢?

那就是Class.getResource()Class.getResourceAsStream()方法,但很多人还是不太懂它的用法,因为很多人(比如不久前的我)都不知道应该传怎么样的参数给它,当然,有些人己经用得如火纯青,这些人是不需要照顾的,在此仅给不会或者还不是很熟的人解释一点点。


比如我们有以下目录
|--project
____|--src
________|--javaapplication
____________|--Test.java
____________|--file1.txt
________|--file2.txt
____|--build
________|--javaapplication
____________|--Test.class
____________|--file3.txt
________|--file4.txt

在上面的目录中,有一个src目录,这是JAVA源文件的目录,有一个build目录,这是JAVA编译后文件(.class文件等)的存放目录.

那么,我们在Test类中应该如何分别获得
file1.txt, file2.txt, file3.txt, file4.txt 这四个文件呢?

首先讲file3.txt与file4.txt
file3.txt:
方法一:File file3 = new File(Test.class.getResource("file3.txt").getFile());
方法二:File file3 = new File(Test.class.getResource("/javaapplication/file3.txt").getFile());
方法三:File file3 = new File(Test.class.getClassLoader().getResource("javaapplication/file3.txt").getFile());

file4.txt:
方法一:File file4 = new File(Test.class.getResource("/file4.txt").getFile());
方法二:File file4 = new File(Test.class.getClassLoader().getResource("file4.txt").getFile());

很好,我们可以有多种方法选择,但是file1与file2文件呢?如何获得?
答案是,你只能写上它们的绝对路径,不能像file3与file4一样用class.getResource()这种方法获得,它们的获取方法如下:
假如整个project目录放在c:/下,那么file1与file2的获取方法分别为
file1.txt
方法一:File file1 = new File("c:/project/src/javaapplication/file1.txt");
方法二:。。。没有

file2.txt
方法一:File file2 = new File("c:/project/src/file2.txt");
方法二:。。。也没有

总结一下,就是你想获得文件,你得从最终生成的.class文件为着手点,不要以.java文件的路径为出发点,因为真正使用的就是.class,不会拿个.java文件就使用,因为java是编译型语言嘛.

至于getResouce()方法的参数,你以class为出发点,再结合相对路径的概念,就可以准确地定位资源文件了,至于它的根目录嘛,你用不同的IDE build出来是不同的位置下的,不过都是以顶层package作为根目录,比如在Web应用中,有一个WEB-INF的目录,WEB-INF目录里面除了web.xml文件外,还有一个classes目录,没错了,它就是你这个WEB应用的package的顶层目录,也是所有.class的根目录“/”,假如clasaes目录下面有一个file.txt文件,它的相对路径就是"/file.txt",如果相对路径不是以"/"开头,那么它就是相对于.class的路径

还有一个getResourceAsStream()方法,参数是与getResouce()方法是一样的,它相当于你用getResource()取得File文件后,再new InputStream(file)一样的结果.


source: http://gavin-chen.javaeye.com/blog/261151

2010年2月2日 星期二

Oracle PL/SQL做 "累加彙總" and "累加平均"

方式如下 :
全部累加彙總語法

SELECT ...
, Sum( column1 ) Over( Order by column2 ) as alias
FROM ...


分類累加彙總語法

SELECT ...
, Sum( column1 ) Over( partition by column2 Order by column3 ) as alias
FROM ...


範例
-- 建立 Temp Table
CREATE TABLE TOM_TEST (
EMPLOYEE_ID NUMBER
, DEPT_ID NUMBER
, MONEY NUMBER
);

-- 新增 Temp Data
INSERT INTO TOM_TEST VALUES( 1, 100, 10000 );
INSERT INTO TOM_TEST VALUES( 2, 100, 15000 );
INSERT INTO TOM_TEST VALUES( 3, 100, 20000 );
INSERT INTO TOM_TEST VALUES( 4, 200, 32000 );
INSERT INTO TOM_TEST VALUES( 5, 200, 40000 );
INSERT INTO TOM_TEST VALUES( 6, 200, 35000 );
INSERT INTO TOM_TEST VALUES( 7, 300, 30000 );
INSERT INTO TOM_TEST VALUES( 8, 300, 25000 );
INSERT INTO TOM_TEST VALUES( 9, 300, 10000 );
COMMIT;

-- 按 EMPLOYEE_ID 進行 MONEY 全部累加彙總
select EMPLOYEE_ID
, DEPT_ID
, MONEY
, sum(MONEY) over(order by EMPLOYEE_ID) as SUM
from TOM_TEST;


-- 以 DEPT_ID 分類, 按 EMPLOYEE_ID 進行 MONEY 分類累加彙總
select EMPLOYEE_ID
, DEPT_ID
, MONEY
, sum(MONEY) over(partition by DEPT_ID order by EMPLOYEE_ID) as SUM
from TOM_TEST;


-- 按 EMPLOYEE_ID 進行 MONEY 全部累加平均
select EMPLOYEE_ID
, DEPT_ID
, MONEY
, avg(MONEY) over(order by EMPLOYEE_ID) as AVG
from TOM_TEST;


-- 以 DEPT_ID 分類, 按 EMPLOYEE_ID 進行 MONEY 分類累加平均
select EMPLOYEE_ID
, DEPT_ID
, MONEY
, avg(MONEY) over(partition by DEPT_ID order by EMPLOYEE_ID) as AVG
from TOM_TEST;


-- 刪除 Temp Table
DROP TABLE TOM_TEST;

source: http://tomkuo139.blogspot.com