Skip to content

Instantly share code, notes, and snippets.

View wrfly's full-sized avatar
💻
enjoy coding

Shaun wrfly

💻
enjoy coding
View GitHub Profile
@wrfly
wrfly / gist:64d8881b90e1a5ff9e658db15530ba35
Created June 5, 2021 15:46
golang dynamic rate limiter
package main
import (
"fmt"
"sync"
"time"
"go.uber.org/ratelimit"
)
@wrfly
wrfly / etcd-cluster.yml
Created June 17, 2019 02:56
docker compose etcd cluster
version: '2'
services:
etcd1:
image: quay.io/coreos/etcd:v3.1.13
restart: always
ports:
- 23791:2379
- 23801:2380
environment:
@wrfly
wrfly / es-cluster.yml
Created April 15, 2019 03:57
docker compose for es 6.7
version: "3.6"
services:
elasticsearch1:
image: elasticsearch:6.7.1
environment:
- node.name=es01
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms5g -Xmx5g"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
@wrfly
wrfly / fnv.go
Created April 2, 2019 07:26
fnv.example
package main
import (
"bufio"
"hash/fnv"
"log"
"os"
)
func main() {
@wrfly
wrfly / golang-sample.go
Last active March 26, 2019 10:43
simple sample
package main
import (
"fmt"
"math/rand"
"sync"
"time"
"github.com/wrfly/gua"
)
@wrfly
wrfly / docker.md
Created March 25, 2019 04:19
some commands about docker, just in case I forget them
# create a sub network
docker network create --subnet 10.23.33.0/24 -o "com.docker.network.bridge.host_binding_ipv4=10.65.136.76" network_23

AGG

返回某一字段的所有值

{
    "aggs": {
      "item_id": {
        "terms": {
@wrfly
wrfly / fork_and_daemon.go
Last active March 22, 2023 08:08
golang fork and exec and handle signals
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
)
@wrfly
wrfly / unsafe_converter.go
Created December 12, 2018 03:35
use unsafe to convert two different types and modify them
package main
import (
"fmt"
"unsafe"
)
type A struct {
ID int
Name string
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
# -- navigation ----------------------------------------------------------------
# if you're running tmux within iTerm2
# - and tmux is 1.9 or 1.9a