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
var winston = require('winston'); | |
var fs = require('fs'); | |
var dateUtil = require('date-utils'); | |
var LOGPATH = './log/'; | |
var DOMAIN = 'www.labi.com'; | |
// 测试用对日志文件的切割,所以`maxsize`设的很小 | |
var MAXSIZE = 100; | |
var latest_ex_filename = null; |
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
// 题目: | |
// 假设有字符串 'i am a programmer' | |
// 实现方法全部颠倒,转成 'remmargorp a ma i' | |
var str = 'i am a programmer'; | |
// 函数式递归调用方法实现 | |
function reverseStrByChar(str) { | |
if (!str || Object.prototype.toString.call(str).toLowerCase().indexOf('string') < 0) { | |
throw new Error('reverseStrByChar: Invalid argument ' + str); |
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
// var times = 0; | |
// 快速排序算法 | |
function quickSort(arr) { | |
if (!arr || Object.prototype.toString.call(arr).toLowerCase().indexOf('array') < 0) { | |
throw new Error('quickSort(): First arguments must be an Array.'); | |
} | |
if (arr.length <= 1) { | |
return arr; | |
} |
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 a() { | |
// some operations | |
} // #1: 到这里会报错吗? | |
*/ | |
// a(); // #2: 到这里会报错吗? |
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
// 先定义一个Person类 | |
var Person = function (name, age) { | |
this.name = name; | |
this.age = age; | |
this.tmp = 'this.tmp'; | |
this.sayName = function() { | |
console.log('this.sayName(): ', this.name); | |
} | |
} |
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
/** | |
Returns a copy of the specified string with special regular expression | |
characters escaped, allowing the string to be used safely inside a regex. | |
The following characters, and all whitespace characters, are escaped: | |
- $ ^ * ( ) + [ ] { } | \ , . ? | |
If _string_ is not already a string, it will be coerced to a string. | |
@method regex |
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
<!-- content to be placed inside <body>…</body> --> |
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
var source ='\ | |
{{#each types.type}}\ | |
<h2>{{this}}</h2>\ | |
<p>{{#test ../this }}{{/test}}</p>\ | |
{{/each}}\ | |
' | |
var data = { | |
types: { | |
type: [ | |
'o', '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
/* mkdir -p for node */ | |
var fs = require('fs'), | |
path = require('path'); | |
function mkdirpSync (pathes, mode) { | |
mode = mode || 0777; | |
var dirs = pathes.trim().split('/'); | |
if (dirs[0] == '.') { | |
// ./aaa | |
dirs.shift(); |
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
// Combine JS and CSS files | |
// --- | |
// | |
// Make sure you install the npm dependencies | |
// > cd YOUR_PROJECT_FOLDER | |
// > npm install | |
// | |
// Than run: | |
// > node build |
OlderNewer