This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var router, middlewares, before, after, app | |
app = express() | |
router = require('./router') | |
app.configure(function(){ | |
app.set('controllers', require('YOUR_CONTROLLERS')) | |
}) | |
middlewares = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 完成滚动信息的简短代码 | |
~function ($) { | |
/* 浮动信息插件 | |
* @author sofish, [email protected] | |
* @param options {Object} 加下的参数 | |
* { | |
* data: 传入的 JSON 数据 | |
* tmpl: 显示信息的格式模板 `{json 数组中 object 的 key 名} 发布了 {dataName}` | |
* 为了更快的匹配,{dataName} 中的 dataName 只支持除中文外的 js 变量名命名方法中支持的内容 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 仅支持 8 种类型的 day | |
// 20120409 | 2012-04-09 | 2012/04/09 | 2012.04.09 | 以上各种无 0 的状况 | |
var isDate = function (text) { | |
var reg = /^([1-2]\d{3})([-/.])?(1[0-2]|0?[1-9])([-/.])?([1-2]\d|3[01]|0?[1-9])$/ | |
, taste, validDate, yyyy, mm, dd; | |
if (!reg.test(text)) return false; | |
taste = reg.exec(text); | |
year = taste[1], month = taste[3], day = taste[5]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1,2,3,4,5,6,7,8,9]; | |
arr.reduce(function(prev, cur, i, index){ | |
// 奇葩 | |
console.log(prev,cur,i,index, arr[--i] === prev) | |
}) | |
arr.reduce(function(prev, cur, i, index){ | |
// 正常 | |
console.log(prev,cur,i,index, arr[--i] === prev) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! copyright: sofish, https://github.com/sofish, licensed under MIT */ | |
var util = {}; | |
// detect object type | |
// note that everything is a object in javascript | |
util.type = function(obj) { | |
var str = Object.prototype.toString.call(obj); | |
return str.replace(/^\[object (\w+)\]$/, '$1'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!Doctype html> | |
<html> | |
<meta charset="utf-8"/> | |
<title>they recognize \9 hack(IE only???)</title> | |
<style> | |
html{background:#000;color:#fff;} | |
pre{font:60px monospace\9;} | |
</style> | |
<body> | |
理论上应该只在ie才会显示 60px 大的字体: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 大家写在评论中吧,代码高亮可以这样写: | |
// ```js | |
// your code | |
// ``` | |
// update: Fri Aug 31 08:39:21 | |
// copyright: https://gist.github.com/3549352 | |
// 加个性能测试:http://jsperf.com/get-dom-s-first-element | |
var util = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = {}; | |
/* now: we use this one */ | |
util.first = function(element) { | |
if(!element) return; | |
return element[element.firstElementChild ? 'firstElementChild' : 'firstChild']; | |
} | |
/* former: */ | |
util.first = function(element) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Loader</title> | |
<link href="http://typo.sofish.de/typo.css" rel="stylesheet" /> | |
<style type="text/css"> | |
code{padding:0 2px;border:1px solid #eee;background:#f7f7f7;border-radius:3px;} | |
#geo{color:#08c;} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hack the ie on resetting the height | |
t.on('click', function(){ | |
$('textarea').focus(); | |
}); | |
t.on('focus', function(){ | |
t.css('height', dest); | |
}) |