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
public function joinPaths() | |
{ | |
$args = func_get_args(); | |
$paths = array(); | |
foreach ($args as $arg) { | |
$paths = array_merge($paths, (array)$arg); | |
} | |
$paths = array_map(create_function('$p', 'return trim($p, "/");'), $paths); | |
if (substr($args[0], 0, 1) == '/') { | |
$paths[0] = '/' . $paths[0]; |
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
// seajs中正则,包括一些注释正则 | |
var REQUIRE_RE = /"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g; | |
// 注释正则 | |
var rComment = /\/\/.*|\/\*[\S\s]*?\*\//g; |
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 SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g; | |
function isUndefined(val){ | |
return typeof val === 'undefined'; | |
} | |
var sub = function(s, o) { | |
return s.replace ? s.replace(SUBREGEX, function(match, key){ | |
return isUndefined(o[key]) ? match : key; | |
}); | |
} |
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
/** | |
* - chrome为了安全考虑,设计的不支持js操作加入收藏夹, | |
* - 火狐23之后开始废止window.sidebar因为不是w3c标注 https://bugzilla.mozilla.org/show_bug.cgi?id=691647 | |
* - document.all 判断IE不够靠谱,因为现在许多浏览器也实现了document.all吗,并且IE11以后(document.all)为falsy | |
* - 参考 http://stackoverflow.com/questions/10033215/add-to-favorites-button | |
* - IE 中typeof window.external.addFavorite 为'unknown' [http://www.xdarui.com/archives/203.html]; | |
*/ | |
var url = 'https://gist.github.com/', | |
title = 'gist代码片段'; |
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
.mask { | |
position: absolute; | |
top:0; | |
right:0; | |
bottom:0; | |
left:0; | |
z-index: 2; | |
background:#000; | |
opacity:0.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
/** | |
* Array comparsion, ignore order | |
* 比较对象都是比较是否是指向同一个对象 | |
*/ | |
function inArray(array, input){ | |
for(var i=array.length; i--; ){ | |
if(array[i] === input) return true; | |
} | |
} |
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 months = "星期一_星期二_星期三_..._星期日".split('_'); // [ '星期一', '星期二', '星期三', '...', '星期日' ] |
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
// 占位,等待更新 |
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 isInProgress(){ | |
return $submit.prop('disabled') === true; | |
} | |
function markInProgress(){ | |
$submit.prop('disabled', true); | |
} | |
function markProgressDone(){ | |
$submit.prop('disabled', false); | |
} |
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
import sublime, sublime_plugin | |
import webbrowser | |
class OpenBrowserCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
# self.view.insert(edit, 0, "Hello, World!") | |
url = self.view.file_name(); | |
webbrowser.open_new(url); |