Skip to content

Instantly share code, notes, and snippets.

View blinkinglight's full-sized avatar
🏠
Working from home

M blinkinglight

🏠
Working from home
View GitHub Profile
@blinkinglight
blinkinglight / ordered_parallel.go
Created April 14, 2018 09:12 — forked from marianogappa/ordered_parallel.go
Parallel processing with ordered output in Go
/*
Parallel processing with ordered output in Go
(you can use this pattern by importing https://github.com/MarianoGappa/parseq)
This example implementation is useful when the following 3 conditions are true:
1) the rate of input is higher than the rate of output on the system (i.e. it queues up)
2) the processing of input can be parallelised, and overall throughput increases by doing so
3) the order of output of the system needs to respect order of input
- if 1 is false, KISS!
@blinkinglight
blinkinglight / ghjae.go
Last active March 22, 2018 20:05
Golang http json api example
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/asaskevich/govalidator"
"github.com/gorilla/mux"
"log"
"net/http"
@blinkinglight
blinkinglight / nagios-check_hls.go
Created January 2, 2018 08:22
nagios check hls
package main
import (
"fmt"
"github.com/grafov/m3u8"
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
@blinkinglight
blinkinglight / reflection.go
Created November 16, 2017 09:34 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@blinkinglight
blinkinglight / golang-apache-log-line-parser.go
Created November 11, 2017 09:37
golang apache log line parser into []string
package main
import (
"bufio"
"fmt"
"strings"
)
type Parts []string
type Params []Parts
@blinkinglight
blinkinglight / log.go
Created November 10, 2017 20:50 — forked from cespare/log.go
Golang apache logging
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
@blinkinglight
blinkinglight / systemd-alternative-simple-supervisord.go
Last active November 13, 2017 19:16
systemd alternative / simple supervisor
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"github.com/spx/llog"
"github.com/spx/pubsub"
"io"
@blinkinglight
blinkinglight / master-slave-election.go
Created November 5, 2017 15:45
golang master slave election
package main
import (
"flag"
"fmt"
"github.com/nats-io/go-nats"
"strconv"
"strings"
"sync"
"time"
@blinkinglight
blinkinglight / http buffered cache.go
Created November 5, 2017 13:10
http buffed restream cache
package main
import (
"fmt"
"io"
"net/http"
"runtime"
"sync"
"time"
)
@blinkinglight
blinkinglight / gist:cc139d69669fd509363ea90eff54e02b
Last active July 8, 2024 09:23
golang http context example
package main
import (
"context"
"fmt"
"github.com/nats-io/nuid"
"log"
"net/http"
)