Skip to content

Instantly share code, notes, and snippets.

@ismiyati
ismiyati / middleware.go
Created June 4, 2020 09:31
#GOLANG . replace http server request body
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
)
type Middleware func(http.HandlerFunc) http.HandlerFunc
@ismiyati
ismiyati / golang-tls.md
Created May 1, 2020 02:25 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@ismiyati
ismiyati / network-tweak.md
Created April 16, 2020 06:33 — forked from mustafaturan/network-tweak.md
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@ismiyati
ismiyati / 00_etc-hosts.md
Created February 13, 2020 09:29 — forked from mul14/00_etc-hosts.md
/etc/hosts for Vimeo, Reddit, and Imgur.

Unblock Vimeo, Reddit, Imgur, dan Netflix

Saya support Internet Positif untuk memblokir porn, situs judi, dan hal-hal ilegal lainnya. Tapi pemerintah dan ISP sangat konyol karena tidak mengizinkan akses ke Vimeo, Reddit, Imgur, Netflix--yang mana bukanlah situs dengan konten utama ilegal.

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows

@ismiyati
ismiyati / main.go
Created February 13, 2020 01:58 — forked from creack/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"strconv"
@ismiyati
ismiyati / nginx.conf
Created February 12, 2020 17:59 — forked from atomaths/nginx.conf
This is a FastCGI example server in Go.
## FastCGI
server {
location ~ /app.* {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
## Reverse Proxy (이 방식으로 하면 http.ListenAndServe로 해야함)
server {
@ismiyati
ismiyati / go-stdlib-interface-selected.md
Created February 10, 2020 06:17 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

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

@ismiyati
ismiyati / latSSE.go
Last active November 25, 2019 06:08
#golang . latihan server sent event
package main
import (
"fmt"
"net/http"
"time"
)
func html(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html")
@ismiyati
ismiyati / latUintptr.go
Last active November 11, 2019 03:38
#golang . latihan uintptr : https://golang.org/pkg/builtin/#uintptr
package main
import (
"crypto/rand"
"fmt"
"net/http"
"unsafe"
"github.com/cespare/xxhash"
)