JavaScript 添加活动

function hazCosasMaravillosasConElDOM() {}

    //addEvent() by John Resig
    function addEvent( obj, type, fn ){ 
        if (obj.addEventListener){ 
            obj.addEventListener( type, fn, false );
        }
        else if (obj.attachEvent){ 
            obj["e"+type+fn] = fn; 
            obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
            obj.attachEvent( "on"+type, obj[type+fn] ); 
        } 
    } 

    addEvent(window, 'load', hazCosasMaravillosasConElDOM);

Ruby 适用于Ruby 1.8的Array#产品

class Array

  # Array#product
  # -------------
  # Returns the cartesian product of the receiver and the arrays given as arguments.
  # 
  # Usage:
  #   [1, 2, 3].product([4, 5])     # => [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]
  #   [1, 2].product([1, 2])        # => [[1, 1], [1, 2], [2, 1], [2, 2]]
  #   [1, 2].product([3, 4],[5, 6]) # => [[1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], 
  #                                 #     [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
  #   [1, 2].product()              # => [[1], [2]]
  #   [1, 2].product([])            # => []
  #
  #   [1] * [2, 3]                  # => [[1, 2], [1, 3]]
  #   [1, 2] * [3, 4]               # => [[1, 3], [1, 4], [2, 3], [2, 4]]
  #
  def product(*others)
    arrays = [ self.map {|i| [i] } ].concat(others)
    arrays.inject do |result, item|
      (result * item).map do |t| 
        t[0].dup << t[1] 
      end
    end
  end
  
  def multiplication_operator_with_product(other)
    unless other.kind_of? Array 
      multiplication_operator_without_product(other)
    else 
      self.inject([]) do |ret, i|
        ret.concat( other.map {|j| [i, j]} )
      end
    end
  end
  
  alias_method :multiplication_operator_without_product, :*
  alias_method :*, :multiplication_operator_with_product

end

Objective C 运行预装的AppleScript

#define runScriptName @"checknewnow"
#define runScriptType @"scpt"


- (IBAction)runScript:(id)sender
{
    /* Locate that darn thing*/
    NSString *scriptPath = [[NSBundle mainBundle]
                               pathForResource: runScriptName
                               ofType: runScriptType];
    NSURL *scriptURL = [NSURL fileURLWithPath: scriptPath];

    NSAppleScript *as = [[NSAppleScript alloc]
                            initWithContentsOfURL: scriptURL
                            error: nil];
    [as executeAndReturnError: NULL];
    [as release];
}

HTML 即有条件的评论

<p><!--[if IE]>
According to the conditional comment this is Internet Explorer<br />
<![endif]-->
<!--[if IE 5]>
According to the conditional comment this is Internet Explorer 5<br />
<![endif]-->
<!--[if IE 5.0]>
According to the conditional comment this is Internet Explorer 5.0<br />
<![endif]-->
<!--[if IE 5.5]>
According to the conditional comment this is Internet Explorer 5.5<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is Internet Explorer 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]-->
<!--[if gte IE 5]>
According to the conditional comment this is Internet Explorer 5 and up<br />
<![endif]-->
<!--[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6<br />
<![endif]-->
<!--[if lte IE 5.5]>
According to the conditional comment this is Internet Explorer lower or equal to 5.5<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6<br />
<![endif]-->
</p>
Note the special syntax:

gt: greater than
lte: less than or equal to

Other PHP SymfonysfManyToMany多対多

<?php
// sfPropelManyToMany
/**
* 
*/
class ClassName extends AnotherClass
{
	
	public function getHogehoge($name)
	{
		$c = new Criteria();
		$c->add(HogehogePeer::ID, $id);
		$hogehoge = HogehogePeer::doSelectOne($c);
		if($hogehoge){
			return sfPropelManyToMany::getRelatedObjects($hogehoge,'中間テーブル名');
		}
	}
}

Assembler sfasdfå“æ〜å??å”æ-¶é-'æμ<试

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;舞王回一 - 百科网 www.vBaiKe.com&lt;/title&gt;
&lt;link href=&quot;css/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;link href=&quot;css/font.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;!--top--&gt;

    &lt;div id=&quot;newtop&quot;&gt;
	          &lt;div id=&quot;newtop_left&quot;&gt;&lt;img src=&quot;images/newtop_03.jpg&quot; width=&quot;61&quot; height=&quot;78&quot; /&gt;&lt;/div&gt;
			  &lt;div id=&quot;newtop_r&quot;&gt;
					  &lt;div id=&quot;newtop_r_w&quot;&gt;
					  
					       &lt;div id=&quot;newtop_r_logow&quot;&gt;&lt;img src=&quot;images/newlogo_04.jpg&quot; width=&quot;339&quot; height=&quot;46&quot; /&gt;&lt;/div&gt;
					   &lt;div id=&quot;newtop_r_user&quot;&gt;
					   &lt;div id=&quot;newtop_r_userlogin&quot;&gt;
					 &lt;span class=&quot;topbz&quot;&gt;&lt;a href=&quot;../user/login.jsp&quot;&gt;登录&lt;/a&gt; | &lt;a href=&quot;../user/userreg.jsp&quot;&gt;注册&lt;/a&gt; | 
					   &lt;span style=&quot;CURSOR:pointer&quot; onclick=&quot;window.external.addFavorite('http://www.fgav.net','百科网')&quot; title=&quot;收藏百科网&quot;&gt;&lt;a href=&quot;#&quot; &gt;加入收藏&lt;/a&gt; &lt;/span&gt;| &lt;a href=&quot;../help/hellp_gd.jsp&quot; target=&quot;_blank&quot;&gt;用户帮助&lt;/a&gt;&lt;/span&gt; &lt;/div&gt;
					   &lt;div id=&quot;newtop_r_soso&quot; align=&quot;right&quot;&gt;
					     &lt;input type=&quot;text&quot; id=&quot;newtop_r_sosoinput&quot; name=&quot;textfield&quot; /&gt; 
					     &lt;select name=&quot;select&quot;&gt;
					       &lt;option&gt;视频&lt;/option&gt;
				         &lt;/select&gt; 
					     &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; id=&quot;newtop_r_sosobutton&quot;   value=&quot;百科搜索&quot; /&gt;
					   &lt;/div&gt;
					   &lt;/div&gt;
					   
					 
					   
					   
					   
					  &lt;/div&gt;
					
					    &lt;div id=&quot;newtop_r_t&quot;&gt;
						             &lt;div id=&quot;newtop_r_t_logoimg&quot;&gt;&lt;img src=&quot;images/newlogo_13.jpg&quot; width=&quot;121&quot; height=&quot;43&quot; /&gt;&lt;/div&gt;
						&lt;div id=&quot;newnav&quot;&gt;
						    &lt;ul&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;首页&lt;/a&gt; |&lt;/li&gt; 
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;视频&lt;/a&gt; |&lt;/li&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;音像&lt;/a&gt; |&lt;/li&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;专家&lt;/a&gt; |&lt;/li&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;找找&lt;/a&gt; |&lt;/li&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;社区&lt;/a&gt; |&lt;/li&gt;
						&lt;li&gt; &lt;a href=&quot;#&quot;&gt;旅游&lt;/a&gt; |&lt;/li&gt;
						
						&lt;/ul&gt;&lt;/div&gt;
						&lt;div id=&quot;newsc&quot;&gt;&lt;img src=&quot;images/newsc_17.jpg&quot; width=&quot;110&quot; height=&quot;43&quot; border=&quot;0&quot; usemap=&quot;#Map&quot; /&gt;
&lt;map name=&quot;Map&quot; id=&quot;Map&quot;&gt;&lt;area shape=&quot;rect&quot; coords=&quot;3,5,90,30&quot; href=&quot;#&quot; /&gt;&lt;/map&gt;&lt;/div&gt;
						
						
						
						
					  &lt;/div&gt;
					  
					  
					  
      &lt;/div&gt;
					   
	      
	 
	&lt;/div&gt;

&lt;!---内容--&gt;
&lt;div class=&quot;ly&quot;&gt;
       &lt;div id=&quot;skc&quot;&gt;
         &lt;div id=&quot;skccenten&quot;&gt;
		 
		 &lt;div class=&quot;fvs&quot;&gt;
			     &lt;ul class=&quot;fvfens&quot;&gt;
				     &lt;h1&gt;::所有访客::&lt;/h1&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
					 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/groups_user_39.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;a href=&quot;#&quot;&gt;dafadfadf&lt;/a&gt;&lt;/i&gt;&lt;/li&gt;
				
				 &lt;/ul&gt;
			    &lt;ul  class=&quot;fvfy&quot;&gt;上一页 1 2 3 4 5 6  下一页&lt;/ul&gt;
			   
			   &lt;/div&gt;
		 
		 
		 &lt;/div&gt;
	   
       &lt;/div&gt;
&lt;/div&gt;
&lt;!-- è„š--&gt;
&lt;div id=&quot;foot&quot;&gt;&lt;div id=&quot;newfoot&quot;&gt;
           &lt;div id=&quot;newfoot_left&quot;&gt;&lt;span class=&quot;cqpd&quot; &gt;常去频道:&lt;/span&gt;&lt;a href=&quot;#&quot;&gt;最热视频&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;最新视频&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;热点&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;原创&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;电视&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;电影&lt;/a&gt;&lt;br /&gt;
             &lt;br /&gt;
		   &lt;span class=&quot;cqpd&quot; &gt;
    帮助说明:&lt;/span&gt;&lt;a href=&quot;#&quot;&gt;如何上传&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;如何录制&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;相册视频&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;如何订阅&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;如何分享&lt;/a&gt;&lt;/div&gt;
    &lt;div id=&quot;newfoot_right&quot;&gt;     &lt;input type=&quot;text&quot; id=&quot;newtop_r_sosoinput&quot; name=&quot;textfield&quot; /&gt; 
					     &lt;select name=&quot;select&quot;&gt;
					       &lt;option&gt;视频&lt;/option&gt;
				         &lt;/select&gt; 
					     &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; id=&quot;newtop_r_sosobutton&quot;   value=&quot;百科搜索&quot; /&gt;&lt;br&gt;&lt;br&gt;
					    &lt;span class=&quot;cqpd&quot; &gt; 热门搜索:&lt;/span&gt;  &lt;a href=&quot;#&quot;&gt;美女&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;搞笑&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;翻唱&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;自拍&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;热舞&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;原创&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;东方神起&lt;/a&gt;  &lt;a href=&quot;#&quot;&gt;神话&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
                    &lt;div id=&quot;newfoot_bout&quot;&gt;
&lt;a href=&quot;#&quot;&gt;关于我们&lt;/a&gt;  |  &lt;a href=&quot;#&quot;&gt;联系我们&lt;/a&gt;  |  &lt;a href=&quot;#&quot;&gt;友情连接&lt;/a&gt;   
&lt;br&gt;&lt;br&gt;&lt;span class=&quot;bqxx&quot;&gt;&amp;copy;&lt;/span&gt;2007 FGAV.net, all rights reserved.   互联网出版许可证号: 网文许可证[2005]040号     经营许可证号: 粤B2-20050480                     &lt;/div&gt;

&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

Groovy CSV格式化程序

class CsvFormat {
	
	def convertListToCsv(list) {
		def result = ''
		list.each{row -&gt;
			row.each{col -&gt; result += col + ','}
			result = result[0..-2]
			result += '\n'
		}
		result
	}
	
}



class CsvFormatTest extends GroovyTestCase {

	void testConvertsListToCsv() {
		assertEquals '1,2\n3,4\n', new CsvFormat().convertListToCsv([[1,2],[3,4]])
	}

}

Groovy 表集合

class Table {

	def colNames = []
	def rowNames = []
	def cells = [:]
	def topLeft = ''
	
	def addCol(colName) {
		if (!(colName in colNames)) colNames &lt;&lt; colName
	}
	
	def addRow(rowName) {
		if (!(rowName in rowNames)) rowNames &lt;&lt; rowName
	}
	
	def get(rowName, colName) {
		cells.get( computeKey(rowName, colName) )
	}
	
	def put(rowName, colName, value) {
		if (!(rowName in rowNames)) rowNames &lt;&lt; rowName
		if (!(colName in colNames)) colNames &lt;&lt; colName
		def endValue = value
		if (value instanceof Closure) {
			endValue = value.call(get(rowName, colName))
		}
		cells.put(computeKey(rowName, colName), endValue)
	}
	
	def fill(value) {
		rowNames.each{rowName -&gt;
			colNames.each{colName -&gt; put(rowName, colName, value)}
		}
	}
	
	def fillIfNull(value) {
		rowNames.each{rowName -&gt;
			colNames.each{colName -&gt; put(rowName, colName){ it ?: value } }
		}
	}
	
	def getRowCount() {
		rowNames.size()
	}
	
	def getColCount() {
		colNames.size()
	}
	
	def toListOfLists(withRowNames=true, withColNames=true) {
		def result = withColNames ? [[topLeft, *colNames]] : []
		rowNames.each{rowName -&gt;
			def row = withRowNames ? [rowName] : []
			colNames.each{colName -&gt;
				row &lt;&lt; get(rowName, colName)
			}
			result &lt;&lt; row
		}
		result
	}
	
	def each(Closure closure) {
		rowNames.each{rowName -&gt;
			colNames.each{colName -&gt;
				closure.call(rowName, colName, get(rowName, colName))
			}
		}
	}
	
	private computeKey(rowName, colName) {
		[rowName, colName]
	}
	
}



class TableTests extends GroovyTestCase {

	def table = new Table(colNames: ['c1', 'c2'], rowNames: ['r1', 'r2'])
	
	void testHasNullAsDefaultCellValue() {
		assertNull table.get('r1', 'c1')
	}

	void testCountsRows() {
		assertEquals 2, table.rowCount
	}		
	
	void testCountsColumns() {
		assertEquals 2, table.colCount
	}		
	
	void testAddsRow() {
		table.addRow('r3')
		assertEquals 3, table.rowCount
	}
		
	void testAddsColumn() {
		table.addCol('c3')
		assertEquals 3, table.colCount
	}
	
	void testHasUniqueColumnNames() {
		table.addCol('c1')
		assertEquals(['c1', 'c2'], table.colNames)
	}
	
	void testHasUniqueRowNames() {
		table.addRow('r1')
		assertEquals(['r1', 'r2'], table.rowNames)
	}
	
	void testAddsColumnOnDemand() {
		table.put('r1', 'c3', '')
		assertEquals(['c1', 'c2', 'c3'], table.colNames)
	}
	
	void testAddsRowOnDemand() {
		table.put('r3', 'c1', '')
		assertEquals(['r1', 'r2', 'r3'], table.rowNames)
	}
	
	void testHasNullDefaultValueInCells() {
		assertNull table.get('r1', 'c1')
	}
	
	void testPutsValueInCell() {
		table.put('r1', 'c1', 'value')
		assertEquals 'value', table.get('r1', 'c1')
	}
	
	void testPutsClosureResultInCell() {
		table.put('r1', 'c1', 'value')
		table.put('r1', 'c1'){ it + '2'}
		assertEquals 'value2', table.get('r1', 'c1')
	}

	void testFillsCells() {
		table.fill(1)
		assertEquals( [[1, 1], [1, 1]], table.toListOfLists(false, false) )
	}
	
	void testFillsNullCells() {
		table.put('r1', 'c1', 2)
		table.fillIfNull(1)
		assertEquals( [[2, 1], [1, 1]], table.toListOfLists(false, false) )
	}
	
	void testConvertsContentToListOfLists() {
		table.put('r1', 'c1', 'r1c1')
		table.put('r1', 'c2', 'r1c2')
		table.put('r2', 'c1', 'r2c1')
		table.put('r2', 'c2', 'r2c2')
		table.topLeft = 'x'
		assertEquals( [['x', 'c1', 'c2'], ['r1', 'r1c1', 'r1c2'], ['r2', 'r2c1', 'r2c2']], table.toListOfLists() )
	}
	
	void testIteratesOverCells() {
		table.fill(1)
		def result = []
		table.each{rowName, colName, value -&gt; result &lt;&lt; [rowName, colName, value]}
		assertEquals( [['r1', 'c1', 1], ['r1', 'c2', 1], ['r2', 'c1', 1], ['r2', 'c2', 1]], result)
	}
	
}

HTML Drupal jquery tabset

&lt;div class=&quot;drupal-tabs&quot;&gt;
      &lt;!-- These are the actual tab labels. They are always visible, the current tab's a will have an 'active' class  --&gt;
      &lt;ul class=&quot;anchors&quot;&gt;
        &lt;li&gt;&lt;a href=&quot;#bodoni&quot;&gt;Bodoni&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#frutiger&quot;&gt;Frutiger&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#helvetica&quot;&gt;Helvetica&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#univers&quot;&gt;Univers&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;!-- These are the individual tabs. All but the currently selected tab will be hidden --&gt;
      &lt;div id=&quot;bodoni&quot;&gt;
        &lt;?php print $bodoni ?&gt;
      &lt;/div&gt;
      &lt;div id=&quot;frutiger&quot;&gt;
        &lt;?php print $frutiger ?&gt;
      &lt;/div&gt;
      &lt;div id=&quot;helvetica&quot;&gt;
        &lt;?php print $helvetica ?&gt;
      &lt;/div&gt;
      &lt;div id=&quot;univers&quot;&gt;
        &lt;?php print $univers ?&gt;
      &lt;/div&gt;
    &lt;/div&gt;

C# 包括Tag C Sharp XML文档评论

// compile with: /doc:DocFileName.xml 

/// &lt;include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name=&quot;test&quot;]/*' /&gt;
class Test
{
    static void Main()
    {
    }
}

/// &lt;include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name=&quot;test2&quot;]/*' /&gt;
class Test2
{
    public void Test()
    {
    }
}