This file contains 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 isType(type) { | |
return function(obj) { | |
return Object.prototype.toString.call(obj) === "[object " + type + "]" | |
} | |
} | |
var isObject = isType("Object") | |
var isString = isType("String") | |
var isArray = Array.isArray || isType("Array") | |
var isFunction = isType("Function") |
This file contains 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
// While you can edit this file, it's best to put your changes in | |
// "User/Preferences.sublime-settings", which overrides the settings in here. | |
// | |
// Settings may also be placed in file type specific options files, for | |
// example, in Packages/Python/Python.sublime-settings for python files. | |
{ | |
// Sets the colors used within the text area | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
// Note that the font_face and font_size are overriden in the platform |
This file contains 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
{ | |
"auto_complete": true, | |
"auto_complete_commit_on_tab": false, | |
"auto_complete_delay": 50, | |
"auto_complete_selector": "source - comment", | |
"auto_complete_size_limit": 4194304, | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", |
This file contains 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
7 组导航快捷键 | |
使用下列快捷键方便在文字中快速定位: | |
跳至行首 – Control+A | |
跳至行尾 – Control+E | |
跳至下一行 – Control+N | |
跳至上一行 – Control+P | |
删除上一个单词 – Control+W | |
删除当前光标位置到行首的文字 – Control+U | |
删除当前光标位置到行尾的文字 – Control+K |
This file contains 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
// Map over jQuery in case of overwrite | |
_jQuery = window.jQuery, | |
// Map over the $ in case of overwrite | |
_$ = window.$, //前面有引入其他库时,为它的$,没有引入时,则为undefined | |
noConflict: function( deep ) { | |
if ( window.$ === jQuery ) { | |
window.$ = _$; | |
} |
This file contains 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
兼容多种模块规范代码(Node, AMD, CMD以及常见浏览器环境): | |
;(function(name, definition) { | |
//检测上下文环境是否为AMD或CMD | |
var hasDefine = typeof define === 'function', | |
//检测上下文环境是否为Node | |
hasExports = typeof module !== 'undefined' && module.exports; | |
if (hasDefine) { | |
//AMD环境或CMD环境 |
This file contains 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
//父进程和子进程同时开启 | |
//parent.js | |
var cp = require('child_process'); | |
var child1 = cp.fork('child.js'); | |
var child2 = cp.fork('child.js'); | |
//open up the server object and send the handle | |
var server = require('net').createServer(); | |
server.on('connection', function(socket) { | |
socket.end('handled by parent\n'); |
This file contains 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
// Node.js请求 CSRF防范 | |
var generateRandom = function(len) { | |
return crypto.randomBytes(Math.ceil(len * 3 / 4)) | |
.toString('base64') | |
.slice(0, len); | |
}; | |
// 为每个请求的用户,在Session中赋予一个随即值 | |
<form id="test" method="POST" action="http://domain_a.com/guestbook"> |
This file contains 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模块化,css模块化,像nodejs一样编码 | |
组件化开发,js、css、handlebars维护在一起 | |
部署规范 | |
采用nodejs后端,基本部署规范应该参考 express 项目部署 | |
按版本号做非覆盖式发布 | |
公共模块可发布给第三方共享 | |
框架 | |
js模块化框架,支持请求合并,按需加载等性能优化点 |
This file contains 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
<div style="display:table-cell; vertical-align:middle"><img></div> |
OlderNewer