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å“æ〜å??å”æ-¶é-'æμ<试
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>舞王回一 - 百科网 www.vBaiKe.com</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/font.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--top-->
<div id="newtop">
<div id="newtop_left"><img src="images/newtop_03.jpg" width="61" height="78" /></div>
<div id="newtop_r">
<div id="newtop_r_w">
<div id="newtop_r_logow"><img src="images/newlogo_04.jpg" width="339" height="46" /></div>
<div id="newtop_r_user">
<div id="newtop_r_userlogin">
<span class="topbz"><a href="../user/login.jsp">登录</a> | <a href="../user/userreg.jsp">注册</a> |
<span style="CURSOR:pointer" onclick="window.external.addFavorite('http://www.fgav.net','百科网')" title="收è—百科网"><a href="#" >åŠ å…¥æ”¶è—</a> </span>| <a href="../help/hellp_gd.jsp" target="_blank">用户帮助</a></span> </div>
<div id="newtop_r_soso" align="right">
<input type="text" id="newtop_r_sosoinput" name="textfield" />
<select name="select">
<option>视频</option>
</select>
<input type="submit" name="Submit" id="newtop_r_sosobutton" value="百科æœç´¢" />
</div>
</div>
</div>
<div id="newtop_r_t">
<div id="newtop_r_t_logoimg"><img src="images/newlogo_13.jpg" width="121" height="43" /></div>
<div id="newnav">
<ul>
<li> <a href="#">首页</a> |</li>
<li> <a href="#">视频</a> |</li>
<li> <a href="#">音åƒ</a> |</li>
<li> <a href="#">专家</a> |</li>
<li> <a href="#">找找</a> |</li>
<li> <a href="#">社区</a> |</li>
<li> <a href="#">旅游</a> |</li>
</ul></div>
<div id="newsc"><img src="images/newsc_17.jpg" width="110" height="43" border="0" usemap="#Map" />
<map name="Map" id="Map"><area shape="rect" coords="3,5,90,30" href="#" /></map></div>
</div>
</div>
</div>
<!---内容-->
<div class="ly">
<div id="skc">
<div id="skccenten">
<div class="fvs">
<ul class="fvfens">
<h1>::所有访客::</h1>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
<li><a href="#"><img src="images/groups_user_39.jpg" border="0" /></a><i><a href="#">dafadfadf</a></i></li>
</ul>
<ul class="fvfy">上一页 1 2 3 4 5 6 下一页</ul>
</div>
</div>
</div>
</div>
<!-- è„š-->
<div id="foot"><div id="newfoot">
<div id="newfoot_left"><span class="cqpd" >常去频é“:</span><a href="#">最çƒè§†é¢‘</a> <a href="#">最新视频</a> <a href="#">çƒç‚¹</a> <a href="#">原创</a> <a href="#">电视</a> <a href="#">电影</a><br />
<br />
<span class="cqpd" >
帮助说明:</span><a href="#">å¦‚ä½•ä¸Šä¼ </a> <a href="#">如何录制</a> <a href="#">相册视频</a> <a href="#">如何订阅</a> <a href="#">如何分享</a></div>
<div id="newfoot_right"> <input type="text" id="newtop_r_sosoinput" name="textfield" />
<select name="select">
<option>视频</option>
</select>
<input type="submit" name="Submit" id="newtop_r_sosobutton" value="百科æœç´¢" /><br><br>
<span class="cqpd" > çƒé—¨æœç´¢ï¼š</span> <a href="#">美女</a> <a href="#">æžç¬‘</a> <a href="#">翻唱</a> <a href="#">自æ‹</a> <a href="#">çƒèˆž</a> <a href="#">原创</a> <a href="#">东方神起</a> <a href="#">神è¯</a></div>
</div>
<div id="newfoot_bout">
<a href="#">关于我们</a> | <a href="#">è”系我们</a> | <a href="#">å‹æƒ…连接</a>
<br><br><span class="bqxx">&copy;</span>2007 FGAV.net, all rights reserved. 互è”网出版许å¯è¯å·ï¼š 网文许å¯è¯[2005]040å· ç»è¥è®¸å¯è¯å·ï¼š 粤B2-20050480 </div>
</div>
</body>
</html>
Groovy CSV格式化程序
class CsvFormat {
def convertListToCsv(list) {
def result = ''
list.each{row ->
row.each{col -> 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 << colName
}
def addRow(rowName) {
if (!(rowName in rowNames)) rowNames << rowName
}
def get(rowName, colName) {
cells.get( computeKey(rowName, colName) )
}
def put(rowName, colName, value) {
if (!(rowName in rowNames)) rowNames << rowName
if (!(colName in colNames)) colNames << 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 ->
colNames.each{colName -> put(rowName, colName, value)}
}
}
def fillIfNull(value) {
rowNames.each{rowName ->
colNames.each{colName -> 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 ->
def row = withRowNames ? [rowName] : []
colNames.each{colName ->
row << get(rowName, colName)
}
result << row
}
result
}
def each(Closure closure) {
rowNames.each{rowName ->
colNames.each{colName ->
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 -> result << [rowName, colName, value]}
assertEquals( [['r1', 'c1', 1], ['r1', 'c2', 1], ['r2', 'c1', 1], ['r2', 'c2', 1]], result)
}
}
HTML Drupal jquery tabset
<div class="drupal-tabs">
<!-- These are the actual tab labels. They are always visible, the current tab's a will have an 'active' class -->
<ul class="anchors">
<li><a href="#bodoni">Bodoni</a></li>
<li><a href="#frutiger">Frutiger</a></li>
<li><a href="#helvetica">Helvetica</a></li>
<li><a href="#univers">Univers</a></li>
</ul>
<!-- These are the individual tabs. All but the currently selected tab will be hidden -->
<div id="bodoni">
<?php print $bodoni ?>
</div>
<div id="frutiger">
<?php print $frutiger ?>
</div>
<div id="helvetica">
<?php print $helvetica ?>
</div>
<div id="univers">
<?php print $univers ?>
</div>
</div>
C# 包括Tag C Sharp XML文档评论
// compile with: /doc:DocFileName.xml
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
static void Main()
{
}
}
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
public void Test()
{
}
}