Skip to content

Instantly share code, notes, and snippets.

View myndzi's full-sized avatar

Kris Reeves myndzi

  • Sigma Bold
  • Olympia, WA
View GitHub Profile
'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;
}
function sendMailAsync(opts) {
return new Promise(function (resolve, reject) {
sendMailAsync(opts, function (err, res) {
if (err) {
err.response = res;
reject(err);
} else {
resolve(res);
}
});
# -*- 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ä')
# -*- 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ä')
[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>
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)) );
};
{#data}
<li><a href="{url}">{item}</a></li>
{/data}
<% data.forEach(function (i) { -%>
<li><a href="<%=url%>"><%=item%></a></li>
<% }); -%>
'use strict';
var arr = [ ];
for (var i = 0; i < 100000; i++) {
arr.push(i);
}
console.log(arr);
process.exit();
'use strict';
var Transform = require('stream').Transform,
inherits = require('util').inherits,
fs = require('fs');
function ConcatStream() {
Transform.call(this, {
writableObjectMode: true
});
@myndzi
myndzi / foo.js
Last active August 29, 2015 14:23
// 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();