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
config.set({
reporters: ['progress', 'coverage'],
frameworks: ['karma'],
files: [
// 主程式,不需要 include 到網頁裡
{ pattern: 'lib/*.js', included: false },
// 測試程式
'test/**/*.js'
ifeq ($(TRAVIS_BRANCH), $(filter $(TRAVIS_BRANCH), master develop))
# master/develop 的時候跑 saucelabs
# 檢查是不是所有指定 browser 都可以通過測試
travis: test-sauce
else
# 其他 branch 只跑 phantomjs
# 避免 saucelabs 噴錢...
travis: test-phantomjs
endif
@poying
poying / Makefile
Last active August 29, 2015 14:23
DUO := node_modules/.bin/duo
# 主要程式碼
SRC := $(shell find lib -type f -name '*.js')
# 所有 test 目錄下檔案,包含一些 util
TEST := $(shell find test -type f -name '*.js')
# 實際寫測試的檔案
TEST_SRC := $(shell find test -type f -name '*.test.js')
# Build 測試檔案
@poying
poying / results.md
Last active August 29, 2015 14:17
Node.js + NginX benchmarks

http

Running 30s test @ http://http.trynginx.com:8080/
  100 threads and 5000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   449.33ms  157.09ms 793.53ms   63.26%
    Req/Sec    18.36     34.73   463.00     92.53%
  50663 requests in 30.08s, 9.42MB read
  Socket errors: connect 244, read 5912, write 117, timeout 62001
PROJNAME = redis-mount
SERVICEPATH = github.com/poying
SOURCES = main.go help_template.go
GOPATH = $(shell pwd)
PROJPATH = src/$(SERVICEPATH)/$(PROJNAME)
BINFILE = ./$(PROJNAME)
define build
echo build $(PROJNAME)-$(1)-$(2); \
@poying
poying / bench.js
Created January 19, 2015 05:19
try-catch, domain.run
'use strict';
var domain = require('domain');
var EventEmitter = require('events').EventEmitter;
var Bench = require('async-bench');
console.log();
Bench()
.compare(tryCatch_)
echo "require('./test')" | duo --root . --type js > $@
@poying
poying / gist:e587fb4f394477de5390
Created December 21, 2014 08:12
diff children
index │ children │ remove
───────┼─────────────────────┼────────
0 │ [a] b c d e │ a
0 │ [d] b a f g h │
│ d b c d e │
───────┼─────────────────────┼────────
1 │ a [b] c d e │ a
1 │ d [b] a f g h │
│ d b c d e │
───────┼─────────────────────┼────────
h('div', {
style: {
textAlign: 'center',
verticalAlign: 'center',
lineHeight: (100 + count) + 'px',
border: '1px solid red',
width: (100 + count) + 'px',
height: (100 + count) + 'px'
}
}, [String(count)]);