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 log4js = require('log4js'); | |
| log4js.configure({ | |
| appenders: [ | |
| { type: 'console' }, | |
| { type: 'file', filename: 'cheese.log', category: 'cheese' }, | |
| { | |
| type: 'log4js-syslog-appender', | |
| tag: 'My API', | |
| facility: 'local0', |
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
| //npm install qrcode | |
| "use strict"; | |
| var _ = require('lodash'); | |
| var aid = require(__base + 'lib/aid'); | |
| var defaultNumber = aid.defaultNumber(); | |
| function resample_hermite(canvas, W, H, W2, H2) { | |
| var time1 = Date.now(); | |
| W2 = Math.round(W2); | |
| H2 = Math.round(H2); |
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 fs = require('fs'); | |
| var path = require('path'); | |
| var async = require('async'); | |
| var childProcess = require('child_process'); | |
| var walk = function (dir, done) { | |
| var results = []; |
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 testpage(req, res) { | |
| const Archiver = require('archiver'); | |
| const http = require('http'); | |
| const Stream = require('stream').Transform; | |
| const zip = Archiver('zip'); | |
| const ids = [1, 2, 3]; | |
| const merchant_id = 57; | |
| const store_id = 278; | |
| const gzid = 100123; | |
| res.writeHead(200, { |
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
| const crypto = require('crypto'); | |
| const cryptor = { | |
| encrypt(cryptkey, iv, cleardata) { | |
| cryptkey = crypto.createHash('sha256').update(cryptkey).digest(); | |
| const encipher = crypto.createCipheriv('aes-256-cbc', cryptkey, iv); | |
| let encryptdata = encipher.update(cleardata, 'utf8', 'binary'); | |
| encryptdata += encipher.final('binary'); | |
| return new Buffer(encryptdata, 'binary').toString('base64'); | |
| }, | |
| decrypt(cryptkey, iv, encryptdata) { |
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
| /** | |
| * from http://www.alloyteam.com/2013/12/js-calculate-the-number-of-bytes-occupied-by-a-string/ | |
| * 计算字符串所占的内存字节数,默认使用UTF-8的编码方式计算,也可制定为UTF-16 | |
| * UTF-8 是一种可变长度的 Unicode 编码格式,使用一至四个字节为每个字符编码 | |
| * | |
| * 000000 - 00007F(128个代码) 0zzzzzzz(00-7F) 一个字节 | |
| * 000080 - 0007FF(1920个代码) 110yyyyy(C0-DF) 10zzzzzz(80-BF) 两个字节 | |
| * 000800 - 00D7FF | |
| 00E000 - 00FFFF(61440个代码) 1110xxxx(E0-EF) 10yyyyyy 10zzzzzz 三个字节 | |
| * 010000 - 10FFFF(1048576个代码) 11110www(F0-F7) 10xxxxxx 10yyyyyy 10zzzzzz 四个字节 |
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
| #!/usr/bin/env python2 | |
| # usage python2 unwxapkg.py filename | |
| import sys, os | |
| import struct | |
| class WxapkgFile(object): | |
| nameLen = 0 | |
| name = "" |
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
| getDuration: function(audio, id) { | |
| const { | |
| durations = {}, | |
| retry = {} | |
| } = this.data; | |
| let { | |
| duration | |
| } = audio; | |
| console.info('audio.duration', audio.duration); | |
| if (duration == 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
| // # Mocha Guide to Testing | |
| // Objective is to explain describe(), it(), and before()/etc hooks | |
| // 1. `describe()` is merely for grouping, which you can nest as deep | |
| // 2. `it()` is a test case | |
| // 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run | |
| // before/after first/each it() or describe(). | |
| // | |
| // Which means, `before()` is run before first it()/describe() |
OlderNewer