Skip to content

Instantly share code, notes, and snippets.

View siddontang's full-sized avatar
🏠
Working from home

siddontang siddontang

🏠
Working from home
  • PingCAP
  • SunnyVale
View GitHub Profile
@siddontang
siddontang / rpc.go
Created February 19, 2014 09:07
a simple rpc test
package main
import (
"bytes"
"encoding/gob"
"reflect"
)
func RemoteOnline(id uint64) (uint64, string) {
return id, "abc"
@siddontang
siddontang / build_leveldb.sh
Last active May 23, 2022 03:24
leveldb build shell
#!/bin/bash
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
ROOT_DIR=$(pwd)
BUILD_DIR=/tmp/build_leveldb
mkdir -p $BUILD_DIR
@siddontang
siddontang / db.go
Created August 4, 2014 14:10
boltdb-coalescer
package boltdb
import (
"github.com/boltdb/bolt"
"github.com/boltdb/coalescer"
"github.com/siddontang/ledisdb/store/driver"
"os"
"path"
"time"
)
@siddontang
siddontang / raft.go
Last active August 29, 2015 14:06
raft example
package main
import (
"flag"
"fmt"
"github.com/hashicorp/raft"
"github.com/ugorji/go/codec"
"io"
"net"
"net/http"
#include <cstdio>
#include <string>
#include "rocksdb/db.h"
#include "rocksdb/slice.h"
#include "rocksdb/options.h"
#include <unistd.h>
#include <sys/time.h>
@siddontang
siddontang / docker
Created December 30, 2014 02:43
some userful docker script
stop all docker containers
docker stop $(docker ps -a -q)
remove all docker containers
docker rm $(docker ps -a -q)
remove all <none> docker images
docker images --no-trunc | grep none | awk '{print $3}' | xargs docker rmi
@siddontang
siddontang / gen-import-list.go
Created June 22, 2015 03:41
generate import list from Godeps.json
package main
// This program will read the Godeps.json and generate import list
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
@siddontang
siddontang / gen-redis-cmd-list.go
Created June 27, 2015 06:49
generate redis commands from official website
package main
import (
"flag"
"fmt"
"os"
"sort"
"strings"
"github.com/PuerkitoBio/goquery"
@siddontang
siddontang / rint.go
Created September 3, 2015 12:31
round implementation in go
package main
import "fmt"
import "math"
// see http://www.gnu.org/software/libc/manual/html_node/Rounding.html
func rint(x float64) float64 {
v, frac := math.Modf(x)
if x > 0.0 {
if frac > 0.5 || (frac == 0.5 && uint64(v)%2 != 0) {
@siddontang
siddontang / raftctl.go
Created March 24, 2016 11:08
A simple raft command line tool
package main
import (
"fmt"
"net"
"os"
"path"
"time"
"github.com/coreos/etcd/clientv3"