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
'use strict'; | |
var LRU = require('lru-cache'); | |
function getArgs() { | |
var i = arguments.length, args = new Array(i); | |
while (i--) { args[i] = arguments[i]; } | |
return args; | |
} |
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 sendMailAsync(opts) { | |
return new Promise(function (resolve, reject) { | |
sendMailAsync(opts, function (err, res) { | |
if (err) { | |
err.response = res; | |
reject(err); | |
} else { | |
resolve(res); | |
} | |
}); |
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
# -*- coding: utf-8 -*- | |
import re | |
p = re.compile('^[\x20-\x7F]*$') | |
print p.match('abc') | |
print p.match('ä') | |
print p.match('äbc') | |
print p.match('bcä') |
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
# -*- coding: utf-8 -*- | |
import re | |
p = re.compile('.*[^\x20-\x7F]') | |
print p.match('abc') | |
print p.match('ä') | |
print p.match('äbc') | |
print p.match('bcä') |
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
[kris.re@krisre ~]$ python test.py | |
None | |
<_sre.SRE_Match object at 0x7fa97562a238> | |
<_sre.SRE_Match object at 0x7fa97562a238> | |
<_sre.SRE_Match object at 0x7fa97562a238> |
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
Service.prototype.selectArray = function (query, column, asName) { | |
var formatter = new query.client.Formatter(); | |
var fromStr = this.table + '.' + this.pkey; | |
var q = knex.select(column) | |
.from(this.table) | |
.whereRaw(formatter.wrap(this.idName) + ' = ' + formatter.wrap(fromStr)); | |
return query.select( knex.raw(q).wrap('ARRAY(', ') AS ' + formatter.wrap(asName)) ); | |
}; |
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
{#data} | |
<li><a href="{url}">{item}</a></li> | |
{/data} | |
<% data.forEach(function (i) { -%> | |
<li><a href="<%=url%>"><%=item%></a></li> | |
<% }); -%> |
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
'use strict'; | |
var arr = [ ]; | |
for (var i = 0; i < 100000; i++) { | |
arr.push(i); | |
} | |
console.log(arr); | |
process.exit(); | |
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
'use strict'; | |
var Transform = require('stream').Transform, | |
inherits = require('util').inherits, | |
fs = require('fs'); | |
function ConcatStream() { | |
Transform.call(this, { | |
writableObjectMode: 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
// controller | |
exports.likePost = function (req, res) { | |
// validate the input | |
req.checkBody('post_id', 'Post id is required').notEmpty(); | |
req.checkBody('post_id', 'Post id is needs to be an integer').isInt(); | |
req.checkBody('post_username', 'Post username is required').notEmpty(); | |
req.checkBody('like_username', 'Like username is required').notEmpty(); | |
var errors = req.validationErrors(); |