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 / thread_example.c
Created October 7, 2013 15:20
Threads Creation and Execution Example
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void initArray(int* array, int N)
{
int i = 0;
for(i = 0; i < N; i++)
{
array[i] = (int)random();
@siddontang
siddontang / encoding_detect.py
Created October 8, 2013 15:30
string encoding detect
import chardet
BOM_UTF8 = '\xef\xbb\xbf'
def detect(raw):
if raw.startswith(BOM_UTF8):
return 'utf-8-sig'
else:
result = chardet.detect(raw)
return result['encoding']
@siddontang
siddontang / .vimrc
Last active December 25, 2015 01:19
my vim config
set smartindent
set tabstop=4
set shiftwidth=4
"set expandtab
set softtabstop=4
syntax on
filetype plugin on
autocmd FileType * set expandtab
autocmd FileType make set noexpandtab
@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"
#!/bin/bash
header="// Copyright 2016 PingCAP, Inc. \
\n// \
\n// Licensed under the Apache License, Version 2.0 (the \"License\"); \
\n// you may not use this file except in compliance with the License. \
\n// You may obtain a copy of the License at \
\n// \
\n// http://www.apache.org/licenses/LICENSE-2.0 \
\n// \
/usr/local/lib/rustlib/uninstall.sh
curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
@siddontang
siddontang / docker-compose.yml
Created July 27, 2016 01:44
An example for TiDB cluster with docker compose
version: '2'
services:
pd1:
image: pingcap/pd
ports:
- "1234"
- "9090"
- "2379"
- "2380"
export HostIP=10.9.76.72
nmz container run --nmz-autopilot config.toml -d --name pd1 \
-p 12379:2379 \
-p 12380:2380 \
-v /data/bin/var/pd1:/tidata/pd1 \
pingcap/pd \
--cluster-id=1 \
--name="pd1" \
--data-dir="/tidata/pd1" \
package main
import (
"database/sql"
"flag"
"fmt"
"log"
"math/rand"
"os"
"os/signal"
package main
import (
"bytes"
"flag"
"fmt"
"sync"
"sync/atomic"
"time"