Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@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 && \
package main
import (
"flag"
"log"
"net/http"
"strings"
)
func main() {
#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);
## 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!
#!/bin/bash -e
protobuf_directories=$(find . -not -path ./.git/ -not -path ./.idea/ -type d -name "pb")
googleapis_path=$(go list -m -f '{{.Dir}}' github.com/googleapis/googleapis)
while read -r p; do
echo "generating protobuf for $p"
protoc -I. -I$googleapis_path --go_out=plugins=grpc:. $p/*.proto
done <<< "$protobuf_directories"
@smallnest
smallnest / fanout_test.go
Created January 29, 2019 03:57 — forked from crast/fanout_test.go
Benchmarking Reflect Channel Ops
// This is a test where I was trying to isolate how much we lost to `reflect`
// with channel operations in a tight loop.
//
// PREAMBLE
// We do a lot of processing of stream data where ordering with respect to a
// shard indicator like user ID matters. We've done this a few times where we
// implement fanout based on hashing into an slice/array of channels, and it's
// lightning fast but it ends up leaving a lot of boilerplate in your code.
//
// So I started writing a library that would do the non-critical boilerplate
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@smallnest
smallnest / LowPrioritySystem_linux.go
Created February 16, 2019 00:58 — forked from jpramirez/LowPrioritySystem_linux.go
Fast & Furious (And extremely dirty) way to low the priority value of a process for windows and linux
package components
import "syscall"
func setpriority() {
syscall.Setpriority(syscall.PRIO_PGRP, 0, 9)
}
@smallnest
smallnest / go-os-arch.md
Created February 27, 2019 03:58 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin