躺在沙滩上的小猪

快乐的每一天

#

酸酸甜甜就是我





曲名:酸酸甜甜就是我     歌手:张含韵 

耳朵里塞着小喇叭
躲在被窝里看漫画
虽然我还在象牙塔
我多么想一夜长大
亲爱的爸爸妈妈
别叫我小傻瓜
虽然我很听话
不代表我没有想法

喜欢酸的甜这就是真的我
每一天对于我都非常新鲜
我挑剔的味觉
有最独特的区别
我喜欢酸的甜这就是真的我
青春期的我有一点点自恋
大人们的世界
等待着我去冒险

耳朵里塞着小喇叭
躲在被窝里看漫画
虽然我还在象牙塔
我多么想一夜长大
亲爱的爸爸妈妈
别叫我小傻瓜
虽然我很听话
不代表我没有想法

喜欢酸的甜这就是真的我
每一天对于我都非常新鲜
我挑剔的味觉
有最独特的区别
我喜欢酸的甜这就是真的我
青春期的我有一点点自恋
大人们的世界
等待着我去冒险

哈~~~~~快长大
快快长大
对这个世界say hi
我要我自我最像我的自我
人群之中我有最最的独特
唱我自己的歌
要唱出我的性格
我要我自我
最爱我的自我
笑过哭过我会全部都记得
梦想总会有沙漠
梦想就是种快乐

posted @ 2005-10-20 18:49 martin xus| 编辑 收藏

统计合计和明细。

今天遇到一个需求:

假如我有这几个数字:
用户:       user
消费:       fee

现在数据库里面可能一个用户有多条数据。
例如:

id  user     fee
1  张三    100
1  张三    50
1  张三    20

2  李四    30
2  李四    20

3  小王    1000

现在我需要这样的结果:

不仅要统计出明细而且要总和,并且按 fee,id排序

小王    1000

张三  170
张三    100
张三    50
张三    20

李四    50
李四    30
李四    20


用union all,在计算出来的结果上再order by就达到了最初的效果了。

select *
  
from (select t.id, '' name, sum(t.fee) fee, '' fff, '' ff, sum(t.fee) fee2
          
from
 tt_test t
         
group by
 t.id
        
union all

        
         (
select a.*, b.fee2
           
from
 tt_test a,
                (
select sum(t.fee) fee2, t.id from tt_test t group by
 t.id) b
          
where a.id =
 b.id)) s

 
order by s.fee2 desc, s.id

感觉有点麻烦,不知道有好的方法没

posted @ 2005-10-20 16:40 martin xus| 编辑 收藏

Get started with Geronimo

http://www-128.ibm.com/developerworks/opensource/library/os-ag-starthere/

posted @ 2005-10-13 10:48 martin xus| 编辑 收藏

Commons IO 1.1 released

Commons IO:
http://jakarta.apache.org/commons/io/

Download:
http://jakarta.apache.org/site/downloads/downloads_commons-io.cgi

---------------------------------------------------------------------

Commons IO 1.1 release notes


Commons IO is a package of Java utility classes for java.io's hierarchy.
Classes in this package are considered to be so standard and of such high
reuse as to justify existence in java.io.

Commons IO contains utility classes, stream implementations, file filters,
and endian transformation classes.


Incompatible changes from 1.0
-----------------------------
Binary compatible - Yes

Source compatible - Yes

Semantic compatible - Yes, except:
- FileUtils.writeStringToFile()
A null encoding previously used 'ISO-8859-1', now it uses the platform default
Generally this will make no difference

- LockableFileWriter
Improved validation and now create directories if necesssary

plus these bug fixes may affect you semantically:
- FileUtils.touch() (Bug fix 29821)
Now creates the file if it did not previously exist

- FileUtils.toFile(URL) (Bug fix 32575)
Now handles escape syntax such as %20

- FileUtils.sizeOfDirectory() (Bug fix 36801)
May now return a size of 0 if the directory is security restricted


Deprecations from 1.0
---------------------
- CopyUtils has been deprecated.
Its methods have been moved to IOUtils.
The new IOUtils methods handle nulls better, and have clearer names.

- IOUtils.toByteArray(String) - Use {@link String#getBytes()}
- IOUtils.toString(byte[]) - Use {@link String#String(byte[])}
- IOUtils.toString(byte[],String) - Use {@link String#String(byte[],String)}


Bug fixes from 1.0
------------------
- FileUtils - touch() [29821]
Now creates the file if it did not previously exist

- FileUtils - toFile(URL) [32575]
Now handles escape syntax such as %20

- FileFilterUtils - makeCVSAware(IOFileFilter) [33023]
Fixed bug that caused method to be completely broken

- CountingInputStream [33336]
Fixed bug that caused the count to reduce by one at the end of the stream

- CountingInputStream - skip(long) [34311]
Bytes from calls to this method were not previously counted

- NullOutputStream [33481]
Remove unecessary synchronization

- AbstractFileFilter - accept(File, String) [30992]
Fixed broken implementation

- FileUtils [36801]
Previously threw NPE when listing files in a security restricted directory
Now throw IOException with a better message

- FileUtils - writeStringToFile()
Null encoding now correctly uses the platform default


Enhancements from 1.0
---------------------
- FilenameUtils - new class [33303,29351]
A static utility class for working with filenames
Seeks to ease the pain of developing on Windows and deploying on Unix

- FileSystemUtils - new class [32982,36325]
A static utility class for working with file systems
Provides one method at present, to get the free space on the filing system

- IOUtils - new public constants
Constants for directory and line separators on Windows and Unix

- IOUtils - toByteArray(Reader,encoding)
Handles encodings when reading to a byte array

- IOUtils - toCharArray(InputStream) [28979]
- toCharArray(InputStream,encoding)
- toCharArray(Reader)
Reads a stream/reader into a charatcter array

- IOUtils - readLines(InputStream) [36214]
- readLines(InputStream,encoding)
- readLines(Reader)
Reads a stream/reader line by line into a List of Strings

- IOUtils - toInputStream(String) [32958]
- toInputStream(String,encoding)
Creates an input stream that uses the string as a source of data

- IOUtils - writeLines(Collection,lineEnding,OutputStream) [36214]
- writeLines(Collection,lineEnding,OutputStream,encoding)
- writeLines(Collection,lineEnding,Writer)
Writes a collection to a stream/writer line by line

- IOUtils - write(...)
Write data to a stream/writer (moved from CopyUtils with better null handling)

- IOUtils - copy(...)
Copy data between streams (moved from CopyUtils with better null handling)

- IOUtils - contentEquals(Reader,Reader)
Method to compare the contents of two readers

- FileUtils - toFiles(URL[])
Converts an array of URLs to an array of Files

- FileUtils - copyDirectory() [32944]
New methods to copy a directory

- FileUtils - readFileToByteArray(File)
Reads an entire file into a byte array

- FileUtils - writeByteArrayToFile(File,byte[])
Writes a byte array to a file

- FileUtils - readLines(File,encoding) [36214]
Reads a file line by line into a List of Strings

- FileUtils - writeLines(File,encoding,List)
writeLines(File,encoding,List,lineEnding)
Writes a collection to a file line by line

- FileUtils - EMPTY_FILE_ARRAY
Constant for an empty array of File objects

- ConditionalFileFilter - new interface [30705]
Defines the behaviour of list based filters

- AndFileFilter, OrFileFilter [30705]
Now support a list of filters to and/or

- WildcardFilter [31115]
New filter that can match using wildcard file names

- FileFilterUtils - makeSVNAware(IOFileFilter)
New method, like makeCVSAware, that ignores Subversion source control directories

- ClassLoaderObjectInputStream
An ObjectInputStream that supports a ClassLoader

- CountingInputStream,CountingOutputStream - resetCount() [28976]
Adds the ability to reset the count part way through reading/writing the stream

- DeferredFileOutputStream - writeTo(OutputStream) [34173]
New method to allow current contents to be written to a stream

- DeferredFileOutputStream [34142]
Performance optimizations avoiding double buffering

- LockableFileWriter - encoding support [36825]
Add support for character encodings to LockableFileWriter
Improve the validation
Create directories if necesssary

- IOUtils and EndianUtils are no longer final [28978]
Allows developers to have subclasses if desired
---------------------------------------------------------------------
best practices
user guide

posted @ 2005-10-12 08:45 martin xus| 编辑 收藏

[Z]常用的匹配正则表达式和实例

来自:蓝色理想

匹配中文字符的正则表达式:

[\u4e00-\u9fa5]

匹配双字节字符(包括汉字在内):

[^\x00-\xff]

应用:计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)

String.prototype.len=function(){return this.replace([^\x00-\xff]/g,"aa").length;}

匹配空行的正则表达式:

\n[\s| ]*\r

匹配HTML标记的正则表达式:

/<(.*)>.*<\/\1>|<(.*) \/>/ 


匹配首尾空格的正则表达式:

(^\s*)|(\s*$)


应用:javascript中没有像vbscript那样的trim函数,我们就可以利用这个表达式来实现,如下:

String.prototype.trim = function(){
  
return this.replace(/(^\s*)|(\s*$)/g, "");
}


利用正则表达式分解和转换IP地址:

下面是利用正则表达式匹配IP地址,并将IP地址转换成对应数值的Javascript程序:

function IP2V(ip){
     re
=/(\d+)\.(\d+)\.(\d+)\.(\d+)///匹配IP地址的正则表达式
  if(re.test(ip)){
        
return RegExp.$1*Math.pow(255,3))+RegExp.$2*Math.pow(255,2))+RegExp.$3*255+RegExp.$4*1
  }
else{
       
throw new Error("Not a valid IP address!")
  }

}


不过上面的程序如果不用正则表达式,而直接用split函数来分解可能更简单,程序如下:

var ip="10.100.20.168"
ip
=ip.split(".")
alert(
"IP值是:"+(ip[0]*255*255*255+ip[1]*255*255+ip[2]*255+ip[3]*1))


匹配Email地址的正则表达式:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*


匹配网址URL的正则表达式:

http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?


利用正则表达式去除字串中重复的字符的算法程序:[注:此程序不正确,原因见本贴回复]

var s="abacabefgeeii"
var s1=s.replace(/(.).*\1/g,"$1")
var re=new RegExp("["+s1+"]","g")
var s2=s.replace(re,""
alert(s1
+s2) //结果为:abcefgi


我原来在CSDN上发贴寻求一个表达式来实现去除重复字符的方法,最终没有找到,这是我能想到的最简单的实现方法。思路是使用后向引用取出包括重复的字符,再以重复的字符建立第二个表达式,取到不重复的字符,两者串连。这个方法对于字符顺序有要求的字符串可能不适用。

得用正则表达式从URL地址中提取文件名的javascript程序,如下结果为page1

s="http://www.9499.net/page1.htm"
s
=s.replace(/(.*\/){0,}([^\.]+).*/ig,"$2")
alert(s)

利用正则表达式限制网页表单里的文本框输入内容:

用正则表达式限制只能输入中文:

onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))"


用正则表达式限制只能输入全角字符:

onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))"


用正则表达式限制只能输入数字:

onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"


用正则表达式限制只能输入数字和英文:

onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"  

posted @ 2005-10-11 19:31 martin xus| 编辑 收藏

仅列出标题
共28页: First 上一页 17 18 19 20 21 22 23 24 25 下一页 Last