Skip to content

Instantly share code, notes, and snippets.

View night-codes's full-sized avatar
🇺🇦

Oleksiy Chechel night-codes

🇺🇦
View GitHub Profile
@night-codes
night-codes / check.go
Created June 2, 2018 17:39 — forked from mattes/check.go
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); err == nil {
// path/to/whatever exists
}
@night-codes
night-codes / client.go
Created June 29, 2018 08:00 — forked from kenshinx/client.go
golang socket server & client ping-pong demo
package main
import (
"log"
"net"
"strconv"
"strings"
)
const (
@night-codes
night-codes / header_bar.py
Created December 15, 2020 18:18 — forked from KurtJacobson/header_bar.py
Custom GTK+ HeaderBar with fullscreen toggle button
#!/usr/bin/env python
# Copyright (c) 2017 Kurt Jacobson
# License: https://kcj.mit-license.org/@2017
import os
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
import (
"github.com/valyala/fasthttp"
)
var proxyClient = &fasthttp.HostClient{
Addr: "upstream.host:port",
// set other options here if required - most notably timeouts.
}
func ReverseProxyHandler(ctx *fasthttp.RequestCtx) {
@night-codes
night-codes / nginx-tuning.md
Created September 30, 2021 17:55 — forked from renankof/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@night-codes
night-codes / server.go
Created October 11, 2021 09:37 — forked from miguelmota/server.go
Golang TCP server example
package server
import (
"bufio"
"fmt"
"log"
"net"
)
// Server ...