Skip to content

Instantly share code, notes, and snippets.

View linxGnu's full-sized avatar

Linh Tran Tuan linxGnu

  • H2Corporation
  • Tokyo
  • 08:42 (UTC +09:00)
View GitHub Profile
@linxGnu
linxGnu / SolutionAlgoWeek2.txt
Last active December 14, 2017 08:51
Solution for week-2
`Bài 1: https://leetcode.com/problems/divide-two-integers/description`
Có 2 cách cơ bản để biểu diễn một số
1. N = a1^b1 a2^b2 ... an^bn trong đó a1 .. an là các số nguyên tố
2. N = 2^0 * a0 + 2^1 * a1 + ...
Để tính giá trị của phép chia X / Y chẳng hạn. Ta giả sử giá trị này là Z, vì vậy X = Y * Z + số dư.
Biểu diễn Z dưới dạng nhị phân Z = 2^0 * a0 + ... 2^n * an. Ta có: X = Y * (2^0 * a0 + ... + 2^n * an) + số dư.
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class bench {
public static int numRequest = 100000;
public static int numEndpoints = 500;
public static void main(String[] args) throws Exception {
package main
import (
"fmt"
"time"
)
const (
numberOperations = 100000000
)
@linxGnu
linxGnu / m3db.write.go
Created July 19, 2018 05:13
M3DB Standalone - Write Benchmark
package main
import (
"fmt"
"log"
"sync"
"time"
"github.com/m3db/m3db/src/dbnode/client"
"github.com/m3db/m3db/src/dbnode/sharding"
coordinator:
listenAddress: 0.0.0.0:7201
metrics:
scope:
prefix: "coordinator"
prometheus:
handlerPath: /metrics
listenAddress: 0.0.0.0:7203 # until https://github.com/m3db/m3db/issues/682 is resolved
sanitization: prometheus
reporting-disabled = true
[meta]
# Where the metadata/raft database is stored
dir = "/Users/gnu/.influxdb/meta"
# Automatically create a default retention policy when creating a database.
# retention-autocreate = true
# If log messages are printed for the meta service
package main
import (
"fmt"
"log"
"sync"
"time"
"github.com/influxdata/influxdb/client/v2"
)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"sync"
"time"
@linxGnu
linxGnu / grpclz4.go
Created February 16, 2019 04:11
lz4 encoding for gRPC (connection) encoding. We (at LINE Corp) will try to publish it soon.
// Copyright 2019 LINE Corporation
//
// LINE Corporation licenses this file to you under the Apache License,
// version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT