Skip to content

Instantly share code, notes, and snippets.

curl -XPUT 'http://localhost:9200/tube/'
curl -XPOST 'localhost:9200/tube/_close'
curl -XPUT 'localhost:9200/tube/_settings' -d '{
"analysis" : {
"tokenizer" : {
"comma" : {
"type" : "pattern",
@cheebo
cheebo / consul-client.service
Created April 17, 2017 12:34
consul service
[Unit]
Description=consul client
Requires=network-online.target
After=network-online.target
[Service]
User=consul
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=2
Restart=on-failure
package consul
import (
"strings"
"github.com/hashicorp/consul/api"
)
func GetKV(client *api.Client, key string, waitIndex uint64) (string, uint64, error) {
q := &api.QueryOptions{RequireConsistent: true, WaitIndex: waitIndex}
kvpair, meta, err := client.KV().Get(key, q)
@cheebo
cheebo / default
Created February 16, 2018 12:49
nginx websocket proxy (nginx version: nginx/1.10.3 (Ubuntu))
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 127.0.0.1:8080;
}
server {
@cheebo
cheebo / main.go
Created August 6, 2018 13:07
Replace router on the fly
package main
import (
"net/http"
"time"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@cheebo
cheebo / zap_test
Created April 27, 2023 17:02
zap_test.go
package internal
import (
"fmt"
"testing"
"time"
"go.uber.org/zap"
)
@cheebo
cheebo / ceph.go
Last active October 3, 2025 11:34
package s3linereader
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"math"
"math/rand"
@cheebo
cheebo / gw.go
Last active October 3, 2025 13:50
package main
import (
"bufio"
"bytes"
"context"
"crypto/rand"
"errors"
"fmt"
"io"
# Параметры — поменяй на свои ИМЕННО ЗДЕСЬ (без <> и прочего)
BUCKET="ceph-test-bucket"
PROFILE="ceph-local"
ENDPOINT="http://127.0.0.1:7480" # для AWS можно убрать весь --endpoint-url
aws --profile "$PROFILE" --endpoint-url "$ENDPOINT" \
s3api list-multipart-uploads --bucket "$BUCKET" --output json \
| jq -r '.Uploads[]? | @tsv "\(.Key)\t\(.UploadId)"' \
| while IFS=$'\t' read -r KEY UPID; do
echo "Abort: $KEY ($UPID)"