Skip to content

Instantly share code, notes, and snippets.

View poying's full-sized avatar
🏠
I may be slow to respond.

Po-Ying Chen poying

🏠
I may be slow to respond.
View GitHub Profile
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
import time
n = range(50000)
def test_tuple():
data = ()
for i in n:
data += (1, 2) + (3, 4)
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') {
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;
'use strict';
var domify = require('component/domify');
'use strict';
var expect = require('chai').expect;
var myModule = require('../my-module');
describe('myModule', function () {
it('should xxx', function () {
// ...
});
});
'use strict';
var myModule = module.exports;
myModule.ping = function () {
return 'pong';
};
@poying
poying / .zuul
Created November 22, 2014 02:58
name: quickstart
ui: mocha-qunit
browsers:
- name: firefox
platform: linux
version: 30..latest
- name: chrome
version: 30..beta
@poying
poying / Makefile
Last active August 29, 2015 14:10
# 當前目錄位置
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):
@poying
poying / Makefile
Last active August 29, 2015 14:10
# 本地執行檔放置的目錄
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")