Skip to content

Instantly share code, notes, and snippets.

package main
import (
"sync"
"testing"
"singleflight"
)
func BenchmarkSingleFlight(b *testing.B) {
group := &singleflight.Group{}

Intro

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.

Async/Await

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);
districts.features.map(f => {
package main
import (
"fmt"
"github.com/xitongsys/parquet-go/ParquetFile"
"github.com/xitongsys/parquet-go/Plugin/JSONWriter"
"log"
)
func main() {
@dg3feiko
dg3feiko / confessions.md
Last active August 26, 2018 04:02
Confessions

Ryan Dahl - Author of Node.js

Things I Regret About Node.js

https://www.youtube.com/watch?v=M3BM9TB-8yA

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.

@dg3feiko
dg3feiko / maclock.js
Created November 10, 2018 15:51
Mac Lock
const isCharging = require('is-charging');
const bluebird = require('bluebird');
const exec = require('child_process').exec;
(async () => {
while (true) {
let charging = await isCharging()
console.log(charging)
if(!charging){