Skip to content

Instantly share code, notes, and snippets.

dg3feiko dg3feiko

  • Hong Kong
View GitHub Profile
View maclock.js
const isCharging = require('is-charging');
const bluebird = require('bluebird');
const exec = require('child_process').exec;
(async () => {
while (true) {
let charging = await isCharging()

Ryan Dahl - Author of Node.js

Things I Regret About Node.js

John Nagle - Nagle Algorithm

If I'd still been working on networking at the time, that never would have happened. But I was off doing stuff for a startup called Autodesk.

View parquet-go-nest.go
package main
import (
func main() {
View bsi.js
var BoostSpatialIndex = require('boost-geospatial-index');
var _ = require("lodash");
var bsi = new BoostSpatialIndex();
var districts = require("/Users/feikolai/Downloads/hkpolygon.json");
bsi.addBoundingBox('Hong Kong', 113.5932, 22.1022, 114.7104, 22.6188); => {
View co-nothrow with


Generally, there are two kinds of error handling among all programming langauges:

  • Create a scope, anything does wrong during execution will ternimate the scope and jump to the error handling part, e.g. try-catch, superviser with actors. This style is usually preferrable with scripting.
  • Error is explicitly passed to caller, and encourage explicit handling of every single error, e.g. Go, C, node.js with callbacks. And this is very useful in critical systems as every error matters.


View benchmark_singleflight_test.go
package main
import (
func BenchmarkSingleFlight(b *testing.B) {
group := &singleflight.Group{}
dg3feiko / singleflight.go
Created Aug 12, 2017
SingleFlight Benchmark
View singleflight.go
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package singleflight provides a duplicate function call suppression
// mechanism.
package singleflight
import "sync"
View noop-bench.js
function foo(cb) {
console.time("anonymous function");
for (var i = 0; i < 10000000; i++) {
View gist:3948e98ab887ab2161f66674d7976012
1) 4G版3台核武卡(42-150Mbps 4G)$119.1/5GB FUP/30日(原價$188) )(可MNP轉台)
2) 3G版3台核武卡(42Mbps 3G)$119.1/5GB FUP/30日(原價$188) )(可MNP轉台)
3) 中國移動 4G/3G數據及話音儲值卡 $88卡 (384kbps-7XXkbps 3G/4G) $69.3/30日(原價$90)(可MNP轉台)
4) 數碼通 $48卡*15張 =$360/30日(原價$720)
5) 數碼通限速Plan 3G測試卡(384kbps 3G)=$87.5~ 96.2/30日(原價$98)
6) 數碼通4G限速卡(1Mbps 4G,10GB FUP後512kbps)= $96.4~106.1/30日(原價$108)
7) 數碼通42.2Mbps 3G 30日儲值卡 =$198.4~$217.3/30日
8) 數碼通100Mbps 4G半日全速及1Mbps 4G半日限速 30日儲值卡 =$151~157.9/30日
9) 大檸樂卡4G 全速30日儲值卡(16Mbps 4G) $195/15GB FUP+無限分鐘/30日
View benchmark_chan.go
package hello
import (
func benchmarkChannel(b *testing.B, nProducer int) {
ch := make(chan int)
var wg sync.WaitGroup
You can’t perform that action at this time.