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
PM := python_modules | |
CMD := docker run --rm -it -w /app -v $(shell pwd):/app \ | |
-e PYTHONPATH=/app/$(PM)/lib/python3.4/site-packages python:3.4.2 | |
init: | |
@mkdir -p $(PM) | |
@$(CMD) pip install --install-option="--prefix=/app/$(PM)" -r ./requirements.txt |
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
import time | |
n = range(50000) | |
def test_tuple(): | |
data = () | |
for i in n: | |
data += (1, 2) + (3, 4) |
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 Duo = require('duo'); | |
// 因為需要使用 app 上的屬性, | |
// 所以這邊把 middleware 包在一個 function 內, | |
// 這也是 Express、Koa 上標準的 Middleware 寫法。 | |
module.exports = function (app) { | |
var isProduction = app.env === 'production'; | |
return function *duoScript(next) { | |
if (this.path !== '/build/build.js') { |
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 Duo = require('duo'); | |
// 以 js 為例,css 作法相同 | |
function *duoScript(next) { | |
// 如果有使用 koa-router 之類的 module 就不需要自行判斷 path | |
// 目前先以最單純的 koa 為例 | |
if (this.path !== '/build/build.js') { | |
// yield* 後面直接接 generator function | |
yield* next; | |
return; |
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
'use strict'; | |
var domify = require('component/domify'); |
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
'use strict'; | |
var expect = require('chai').expect; | |
var myModule = require('../my-module'); | |
describe('myModule', function () { | |
it('should xxx', function () { | |
// ... | |
}); | |
}); |
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
'use strict'; | |
var myModule = module.exports; | |
myModule.ping = function () { | |
return 'pong'; | |
}; |
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
name: quickstart | |
ui: mocha-qunit | |
browsers: | |
- name: firefox | |
platform: linux | |
version: 30..latest | |
- name: chrome | |
version: 30..beta |
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
# 當前目錄位置 | |
PREFIX = $(shell pwd) | |
WATCH = $(PREFIX)/bin/watch | |
watch: $(WATCH) | |
# 用 -s 來讓 make 安靜,不顯示 `make: Nothing to be done for `all'.` 這種訊息 | |
$(WATCH) -i 300ms make -s | |
# 安裝 watch 指令 | |
$(WATCH): |
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
# 本地執行檔放置的目錄 | |
NW = ./node_modules/.bin | |
DUO = $(NW)/duo | |
# 取得所有 js、html 檔案路徑 | |
# 因為 duo 會把 html 轉成 js 字串,所以除了間看 js 外也要監看 html | |
JS_FILES = $(shell find lib -name "*.js" -o -name "*.html") | |
# 取得所有 css 還有使用到的檔案路徑,像是圖片 | |
CSS_FILES = $(shell find lib -name "*.css" -o -name "*.png" -o -name "*.svg") |