Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
## Building Blockchain in Go
https://jeiwan.cc/posts/building-blockchain-in-go-part-1/
https://github.com/Jeiwan/blockchain_go
## Code your own blockchain in less than 200 lines of Go!
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
package main
import (
"flag"
"log"
"net/http"
"strings"
)
func main() {
@smallnest
smallnest / Dockerfile
Created November 7, 2018 04:09 — forked from elasticjava/Dockerfile
tried to run Rocksdb under alpine linux inside Docker
FROM gliderlabs/alpine
RUN apk add --update git build-base linux-headers wget tar perl zlib zlib-dev bzip2 bzip2-dev && \
cd /tmp && \
wget https://gflags.googlecode.com/files/gflags-2.0-no-svn-files.tar.gz && \
tar -xzvf gflags-2.0-no-svn-files.tar.gz && \
cd gflags-2.0 && \
./configure && make && make install && \
cd /tmp && \
wget https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz && \
@smallnest
smallnest / diskinfo.go
Created November 2, 2018 02:48 — forked from lunny/diskinfo.go
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@smallnest
smallnest / exec.go
Created October 17, 2018 11:17
在exec使用linux管道
out, err := exec.Command("bash", "-c", "ps cax | grep myapp").Output()
@smallnest
smallnest / sse.go
Created October 15, 2018 00:49 — forked from schmohlio/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@smallnest
smallnest / sse.go
Created October 15, 2018 00:49 — forked from rugwirobaker/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream myappget {
server 127.0.0.1:3000;
@smallnest
smallnest / nginx-location
Created August 30, 2018 11:38 — forked from luxixing/nginx-location
nginx location 匹配规则
1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个
例如:
location /{
[matches]
}
location /test{
[matches]
}
2 精确匹配
location = /{