Open Jtalk 是一套可以把日文文字用電腦唸出來的軟體工具(Japanese text-to-speech system)

官網上並沒有文件說明要如何安裝,所以只得自己研究

最近使用了 express-unless 這套 package,發現 path 不管怎麼設定都不對

後來發現一定得用 new RegExp(); 來帶入 path,不然會沒辦法被認為是正確的

追到 lib/index.js 裡面的一行

lib/index.js
1
var ret = (typeof p === 'string' && p === url) || (p instanceof RegExp && !!p.exec(url));

因為這邊 p instanceof RegExp 如果使使用一般的 string expression 就不會通過 (ex. ‘/\/path/g’)

先查看 index.js 會輸出兩個模組,

其中 Strategy 需要實作 passport-strategy 的 authenticate 方法

index.js
1
2
3
4
module.exports = {
    Strategy: Strategy,
    ExtractJwt : ExtractJwt
};

在 authenticate 的部分

JwtStrategy.JwtVerifier 其實是引入 verify_jwt.js 這隻檔案的模組 事實上 verify_jwt 背後只是用 jsonwebtoken 這個 package 來做 verify 而已

index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
// 先取出 token
var token = self._jwtFromRequest(req);

// 如果 token 不存在就 fail
if (!token) {
    return self.fail(new Error("No auth token"));
}

// 見 JwtStrategy.JwtVerifier = require('./verify_jwt');
JwtStrategy.JwtVerifier(token, this._secretOrKey, this._verifOpts, function(jwt_err, payload) {
    if (jwt_err) { // 如果 validate 不過會 fail
        return self.fail(jwt_err);
    } // 剩下的就是驗證項目

在實際使用的時候發現 self.fail 不會呼叫 passport verify 的 callback,需要改成 self.error

因此我發了一筆 issues 在 gituhb 上 https://github.com/themikenicholson/passport-jwt/issues/56

Default SET format is “MMDDhhmm[[CC]YY][.ss]”, that’s (2 digits each) month, day, hour (0-23), and minute. Optionally century, year, and second.

Example

1
2
3
4
5
6
7
8
9
10
date -u 040714441916.00

# Explain:
# 04 : 四月
# 07: 七日
# 14: 下午兩點
# 44: 四十四分
# 19: 20世紀 (0-based)
# 16: 16年
# 00: 0 秒

Introduction

Summernote is an open source WYSIWYG editor like tinymce or ckeditor. I like it because it already implements almost the necessary features. However, it lacks of function to add ‘alt’ & ‘title’ attributes, which are important to SEO, on image elements. This articles is to tell you how to hack into summernote and implement this feature by yourself.

Android 主要有兩種 Animation System,這篇文章專注在介紹較新的 Property Animation

Overview

Android framework provides two animation systems: property animation (introduced in Android 3.0) and view animation.

研究了主要兩種 Solution, 第一種是 jekyll 另外一種是基於 jekyll 的框架 Octpress。

兩者架起來都不難,但是 jekyll 的初始版本比較陽春,octpress 則會先包好一些第三方的套件 (尤其是社交以及追蹤分析的部分)