文章分类

站点统计

  • 分类总数: 13 个
  • 文章总数: 145 篇
  • 评论总数: 35 条
  • 附件总数: 59 个
  • 建站日期: 2008-08-18
  • 访问总数: 388498 人次
  • RSS订阅: 文章|评论

小巧独立的Javascript库(1):Events.js

KY8 于 2009-03-01 16:07:11 发表JavaScript

Dean Edwards实现的Javascript Events管理:http://dean.edwards.name/weblog/2005/10/add-event/。特性:

  • it performs no object detection
  • it does not use the addeventListener/attachEvent methods
  • it keeps the correct scope (the this keyword)
  • it passes the event object correctly
  • it is entirely cross-browser (it will probably work on IE4 and NS4)
  • and from what I can tell it does not leak memory
  1. // written by Dean Edwards, 2005 
  2. // http://dean.edwards.name/ 
  3.  
  4. function addEvent(element, type, handler) { 
  5.   // assign each event handler a unique ID 
  6.   if (!handler.$guid) handler.$guid = addEvent.guid++; 
  7.   // create a hash table of event types for the element 
  8.   if (!element.events) element.events = {}; 
  9.   // create a hash table of event handlers for each element/event pair 
  10.   var handlers = element.events[type]; 
  11.   if (!handlers) { 
  12.     handlers = element.events[type] = {}; 
  13.     // store the existing event handler (if there is one) 
  14.     if (element["on" + type]) { 
  15.       handlers[0] = element["on" + type]; 
  16.     } 
  17.   } 
  18.   // store the event handler in the hash table 
  19.   handlers[handler.$guid] = handler; 
  20.   // assign a global event handler to do all the work 
  21.   element["on" + type] = handleEvent; 
  22. }; 
  23. // a counter used to create unique IDs 
  24. addEvent.guid = 1; 
  25.  
  26. function removeEvent(element, type, handler) { 
  27.   // delete the event handler from the hash table 
  28.   if (element.events && element.events[type]) { 
  29.     delete element.events[type][handler.$guid]; 
  30.   } 
  31. }; 
  32.  
  33. function handleEvent(event) { 
  34.   // grab the event object (IE uses a global event object) 
  35.   event = event || window.event; 
  36.   // get a reference to the hash table of event handlers 
  37.   var handlers = this.events[event.type]; 
  38.   // execute each event handler 
  39.   for (var i in handlers) { 
  40.     this.$handleEvent = handlers[i]; 
  41.     this.$handleEvent(event); 
  42.   } 
  43. }; 

下面是一个改进版(防止内存泄漏):
 

  1. function addEvent(element, type, handler) { 
  2.     // assign each event handler a unique ID 
  3.     if (!handler.$guid) handler.$guid = addEvent.guid++; 
  4.   // assign each element a unique ID 
  5.   if (!element.$guid) element.$guid = addEvent.guid++; 
  6.     // create a hash table of event types for the element 
  7.   if (!addEvent.handlers[element.$guid]) addEvent.handlers[element.$guid] = {}; 
  8.     // create a hash table of event handlers for each element/event pair 
  9.     var handlers = addEvent.handlers[element.$guid][type]; 
  10.     if (!handlers) { 
  11.         handlers = addEvent.handlers[element.$guid][type] = {}; 
  12.         // store the existing event handler (if there is one) 
  13.         if (element["on" + type]) { 
  14.             handlers[0] = element["on" + type]; 
  15.         } 
  16.     } 
  17.     // store the event handler in the hash table 
  18.     handlers[handler.$guid] = handler; 
  19.     // assign a global event handler to do all the work 
  20.     element["on" + type] = handleEvent; 
  21. }; 
  22. // a counter used to create unique IDs 
  23. addEvent.guid = 1; 
  24. // a global hash table containing all handlers 
  25. addEvent.handlers = {}; 
  26.  
  27. function removeEvent(element, type, handler) { 
  28.   // check if the element has a guid 
  29.   if (!element.$guid) return
  30.     // delete the event handler from the hash table 
  31.     if (addEvent.handlers[element.$guid] && addEvent.handlers[element.$guid][type]) { 
  32.         delete addEvent.handlers[element.$guid][type][handler.$guid]; 
  33.     } 
  34. }; 
  35. function handleEvent(event) { 
  36.     // grab the event object (IE uses a global event object) 
  37.     event = event || window.event; 
  38.     // get a reference to the hash table of event handlers 
  39.     var handlers = addEvent.handlers[this.$guid][event.type]; 
  40.     // execute each event handler 
  41.     for (var i in handlers) { 
  42.         this.$handleEvent = handlers[i]; 
  43.         this.$handleEvent(event); 
  44.     } 
  45. }; 
被阅667次, 1票event 发表评论

14 CSS 工具及 n 个CSS框架

KY8 于 2009-03-01 13:54:19 发表HTML

Optimizer/Formatter

  • CSSTidy - CSS Tidy is an open source CSS parser and optimiser.
  • CleanCSS - CleanCSS is a powerful CSS optimizer and formatter. Based on CSSTidy
  • CSS Optimizer - CSS Optimizer reduces the file size of cascading style sheets.
  • CSS Analyzer - CSS Analyzer allows you to check the validity of your CSS against the W3C’s validation service

Font

Forms

Navigation/Buttons

  • CSS Buttons - Css Button and Text field Generator.
  • CSS Menu Generator - CSS Menu Generator will generate both the CSS and the HTML code required to produce a text-based yet appealing set of navigation buttons.

Generator

  • CSS Creator - Css Creator is a layout generator that will create a fluid or fixed width floated column layout, with up to 3 columns and with header and footer.
  • QrONE CSS Designer - QrONE is an online CSS generator and editor.
  • Web 2.0 Generator - Web 2.0 Generator creates a full website layout with HTML and CSS.
  • CSS Mate - CSS Mate is an online CSS editor.

 

  • - Blueprint CSS framework created by Olav Bjorkoy is a framework that offers an easily customizable grid, sensible typography, and even a stylesheet for printing. A lot of the CSS in this project is completely based on work by other people, like: Jeff Croft , Nathan Borror, Christian Metts, and Eric Meyer. The Blueprint CSS Framework is available for use in all personal or commercial projects, under both the MIT and the GPL license.
  • - YAML aka “Yet Another Multicolumn Layout”, is an (X)HTML/CSS framework for creating modern and flexible floated layouts. YAML created by Dirk Jesse fully supports all IE versions. The YAML framework is published under the Creative Commons Attribution 2.0 License, which permits both private and commercial use. YAML is also very flexible and comes with a bilingual documentation. YAML even has a layout/css builder, that allows visual configuration of the basic layout elements, that is very cool.
  • - 960 Grid System created by Nathan Smith is a CSS framework for grids. The 960 Grid System’s purpose is to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. The reason for 960 pixels is because 960 is divisible by 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40, 48, 60, 64, 80, 96, 120, 160, 192, 240, 320 and 480. This makes it a highly flexible base number to work with.
  • UI Grid CSS - The entire YUI CSS foundation includes the Reset, Fonts, and Grids packages. It even contains a grid builder to allow for faster development. The Yahoo! UI Grid CSS supports easy customization of the width for fixed-width layouts.
  • - Logic CSS framework is a collection of CSS files and PHP utilities to cut development times for web-standards compliant xHTML layouts.
  • - ESWAT is web project framework kit that contains a folder structure and some pre-written components. The ESWAT framework is meant to remove the hassle of recreating the same folders, HTML tags, CSS rules, Photoshop guides, etc.
  • - Elements is a CSS Framework that was developed by Ben Henschel. It lets you write CSS easier, faster, more efficient, and allows you to organize all of your project files. Elements goes beyond being just a framework, it’s its own project workflow.

YUI CSS库
http://developer.yahoo.com/yui/

YAML(Yet Another Multicolumn Layout)
http://www.yaml.de/en/

Content with Style: A CSS Framework
http://www.contentwithstyle.co.uk/Articles/17/

Blueprint
http://code.google.com/p/blueprintcss/

tripoli
http://monc.se/tripoli/

Elements
http://elements.projectdesigns.org/index.html

WYMstyle: a CSS framework
http://www.wymstyle.org/en/

taffy-css-framework
http://code.google.com/p/taffy-css-framework/


See Also:
CSS Framework CSS框架入门教程
blueprint--css framework研究
理解Web框架,和如何构建一个CSS框架

Wildcard Matching in C#

KY8 于 2009-02-06 07:24:46 发表.Net

  1. public static bool Wildcard(string pattern, string input) 
  2.     return Wildcard(pattern, 0, input, 0, false); 
  3.  
  4. public static bool Wildcard(string pattern, string input, bool insensitive) 
  5.     return Wildcard(pattern, 0, input, 0, insensitive); 
  6.  
  7. private static bool Wildcard(string pattern, int p, string input, int i, bool insensitive) 
  8.     for(; ; ) 
  9.     { 
  10.         char ic = input[i]; 
  11.         char pc = pattern[p]; 
  12.         switch(pc) 
  13.         { 
  14.             case '?'
  15.                 break
  16.  
  17.             case '*'
  18.                 p++; 
  19.                 for(int j = i; j < input.Length; j++) 
  20.                 { 
  21.                     if(Wildcard(pattern, p, input, j, insensitive)) 
  22.                     { 
  23.                         return true
  24.                     } 
  25.                 } 
  26.                 return false
  27.  
  28.             default
  29.                 if(insensitive) 
  30.                 { 
  31.                     ic = char.ToLower(ic); 
  32.                     pc = char.ToLower(pc); 
  33.                 } 
  34.                 if(ic != pc) 
  35.                 { 
  36.                     return false
  37.                 } 
  38.                 break
  39.         } 
  40.         i++; 
  41.         p++; 
  42.         if(p >= pattern.Length) 
  43.         { 
  44.             if(i >= input.Length) 
  45.             { 
  46.                 return true
  47.             } 
  48.             return false
  49.         } 
  50.         else if(i >= input.Length) 
  51.         { 
  52.             return false
  53.         } 
  54.     } 
被阅511次, 0票WildCard 发表评论

几个支持Asp.net的小巧的Web Server

KY8 于 2009-02-06 07:16:49 发表.Net

Cassini,是Asp.net上的一个项目。但是好像只有.Net 1.0 的。最新的叫 WebDev.WebServer2.  在.NET 安装包下面就有(不知道是否可以随意发布?). Codeplex 上有一个 Cassini 的包装器,支持.NET2.0, 可以让你在计算机内针对任意目录,右键支持直接将其转变为虚拟目录,进行Web服务.

以下为几个有用的链接,有心进行Asp.net程序桌面移植的朋友,可以看看.

http://www.codeplex.com/WebServiceHoster  自己在桌面程序中支持 Asp.net Host, 基于Cassini

http://www.codeplex.com/CassiniWrapper

UltiDev Cassini Web Server: 不同与微软的那个 Cassini, 但是支持 .NET 目前所有的版本(1.0-3.5)

http://ultidev.com/products/Cassini/index.htm

其他应用文章

http://zhq.ahau.edu.cn/blog/article.asp?id=288

http://zhq.ahau.edu.cn/blog/article/297.htm

http://tv9.cnblogs.com/articles/73176.html

Mono XSP

http://www.mono-project.com/ASP.NET

Small and Reliable C++ HTTP Server with Complete ASP.NET Support

C# WebServer

被阅668次, 0票Asp.net Web Server 发表评论

5 Open source MP3 decoder in C/C++

KY8 于 2009-01-30 00:48:49 发表C/C++

1. MAD: MPEG Audio Decoder
http://www.underbit.com/products/mad/ or http://sourceforge.net/projects/mad/

MAD is a high-quality fixed-point MPEG audio decoder with 24-bit output. The implementation is entirely new, based on the ISO/IEC standards, and performs especially well on systems without native floating-point support.

2. Mpadec
http://sourceforge.net/projects/mpadec

Mpadec is a high-quality portable MPEG audio decoder library. It supports MPEG-1, MPEG-2 Layer I, Layer II and Layer III audio streams, including free-format streams.

3.MPG321
http://mpg321.sourceforge.net/

mpg321 is a Free replacement for mpg123, a very popular command-line mp3 player. mpg123 is used for frontends, as an mp3 player and as an mp3 to wave file decoder (primarily for use with CD-recording software.) In all of these capacities, mpg321 can be used as a drop-in replacement for mpg123.

4.MGP123
http://sourceforge.net/projects/mpg123

mpg123 is the fast and Free (LGPL since version 0.60) console based real time MPEG Audio Player for Layer 1, 2 and 3. It uses floating point math (unlike libmad). Starting with version 1.0, in also contains an up-to-date decoding library usable by 3rd party.

5.FOOBAR2000
http://www.foobar2000.org/

The foobar2000 SDK contains a bugfixed C++ version of the mpg123 C code

被阅1113次, 0票MP3 Decoder 发表评论

判断当前ASP.NET的.NET Framework(CLR)版本

KY8 于 2009-01-29 02:02:42 发表.Net

可通过System.Environment.Version.ToString()取得当前CLR版本号,然后对照下表得到Revision版本:

.NET Framework version Revision Version
3.5 Original release 3.5.21022.8
3.5 Service Pack 1 3.5.30729.1
3.0 Original release 3.0.4506.30
3.0 Service Pack 1 3.0.4506.648
3.0 Service Pack 2 3.0.4506.2152
2.0 Original release 2.0.50727.42
2.0 Service Pack 1 2.0.50727.1433
2.0 Service Pack 2 2.0.50727.3053
1.1 Original release 1.1.4322.573
1.1 Service Pack 1 1.1.4322.2032
1.1 Service Pack 1 (Windows Server 2003 32-bit version*) 1.1.4322.2300
1.0 Original release 1.0.3705.0
1.0 Service Pack 1 1.0.3705.209
1.0 Service Pack 2 1.0.3705.288
1.0 Service Pack 3 1.0.3705.6018
*The Microsoft .NET Framework 1.1 is included with the 32-bit version of Windows Server 2003.

CodePlex.com上的三个ISO读写类库

KY8 于 2009-01-18 18:37:10 发表.Net

.NET DiscUtils

纯C#实现读写ISO和VHD文件的类库,以Stream进行文件读写,无需将整个文件加载到内存中。当前支持的文件系统格式:FAT、NTFS(只读)、VHD和VDI。范例:

①、新建一个ISO文件:

  1. CDBuilder builder = new CDBuilder(); 
  2. builder.UseJoliet = true
  3. builder.VolumeIdentifier = "A_SAMPLE_DISK"
  4. builder.AddFile(@"Folder\Hello.txt", Encoding.ASCII.GetBytes("Hello World!")); 
  5. builder.Build(@"C:\temp\sample.iso"); 

可以像上面那样以byte数组添加文件,也可以直接从Windows文件系统中加载,或者也可以是个Stream。生成的结果保存到Stream中,也可以直接保存到Windows的文件系统中。
②、从ISO文件中读取文件

  1. using (FileStream isoStream = File.Open(@"C:\temp\sample.iso")) 
  2.   CDReader cd = new CDReader(isoStream, true); 
  3.   Stream fileStream = cd.OpenFile(@"Folder\Hello.txt", FileMode.Open); 
  4.   // Use fileStream... 
  5.  

目录结构以cd.Root为起点。
③、新建一个虚拟硬盘:

  1. long diskSize = 30 * 1024 * 1024; //30MB 
  2.  
  3. using (Stream vhdStream = File.Create(@"C:\TEMP\mydisk.vhd")) 
  4.     Disk disk = Disk.InitializeDynamic(vhdStream, diskSize); 
  5.     BiosPartitionTable.Initialize(disk, WellKnownPartitionType.WindowsFat); 
  6.     using (FatFileSystem fs = FatFileSystem.FormatPartition(disk, 0, null)) 
  7.     { 
  8.         fs.CreateDirectory(@"TestDir\CHILD"); 
  9.         // do other things with the file system... 
  10.  
  11.     } 

文件系统以fs.Root作为起点。
④、新建一个虚拟软盘:

  1. using (FileStream fs = File.Create(@"myfloppy.vfd")) 
  2.     using (FatFileSystem floppy = FatFileSystem.FormatFloppy(fs, FloppyDiskType.HighDensity, "MY FLOPPY  ")) 
  3.     { 
  4.         using (Stream s = floppy.OpenFile("foo.txt", FileMode.Create)) 
  5.         { 
  6.             // Use stream... 
  7.  
  8.         } 
  9.     } 

Image Master
用于读写iso文件的.Net应用程序,主要特性:
    * Read the contents of image files before burning them to disc.
    * Extract the contents of image files without burning them to disc.
    * Burn an image file to disc.
    * Burn files and/or folders directly to disc.
    * Supports multi-session burning.
    * Create image files for archiving.
    * Convert Bin Image Files (.bin), Nero Image Files (.nrg), Alcohol Image Files (.mdf), CloneCd Image Files (.img), DiscJuggler Image Files (.cdi) to iso images.


在Windows XP SP2刻录光盘需要安装Imapi v2.0,在Windows Vista默认就已经安装了。


GomuISO9660

C#实现的一个类库,用于操作ISO9660映像(.iso/.bin/.mdf...) ,主要特性:
    * Read ISO9660 discs images (supported formats are .iso/.bin/.mdf and CloneCd image).
    * Extract from discs images are by file or full.
    * Create an iso disc image file from CD/DVD source.
    * Convert from several disc image format to iso disc image file (supported formats are .bin/.mdf/.nrg/.img/.cdi).
    * Create iso disc image file from a source directory (not available yet).
    * Burn iso file.

被阅664次, 1票ISO CodePlex 发表评论

7个汇编开发环境

KY8 于 2009-01-17 16:07:01 发表其它

1、radasm
http://www.radasm.com/
2、masm32
http://www.masm32au.com/masm32/m32v10r.zip
3、masmplus
http://www.aogosoft.com/masmplus/idesetup.exe
4、nasm
http://sourceforge.net/projects/nasm
5、TASM 5.0
http://www.programfan.com/download/down.asp?id=214&url=1
6、WINASM
http://www.winasm.net/
7、Visual ASM 6.0
http://blog.ednchina.com/visualasm/80011/message.aspx

被阅905次, 0票ASM 发表评论
2 / 19 / 145 | « 1 2 3 4 5 » |
Powered by MiniBoke v2.0.0.8 Build 0828

Copyright © 2008 开源吧!. All rights reserved.

粤ICP备07500939号