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 / 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 / roundup.c
Last active October 13, 2015 09:17
round up
const int align = 8;
size_t round_up(size_t bytes)
{
return ((bytes) + align - 1) & ~(align - 1)
}
@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 / nginx.conf
Last active December 15, 2015 12:29
simple nginx example
worker_processes 1;
events {
use epoll;
}
http {
default_type text/html;
server {
listen 80;
server_name localhost;
@siddontang
siddontang / csp.cpp
Last active December 18, 2015 13:48
windows csp, rsa, certificate
#include "rsa.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <wincrypt.h>
#include "base64.h"
#pragma comment(lib, "crypt32.lib")