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 / golangDeploy.md
Last active March 3, 2024 03:55
Golang deploy

1) Создаем юзера под которым будет работать приложение, задаем пароль и переключаемся на него:

useradd -s /bin/bash <имя_пользователя>
passwd <имя_пользователя>
su <имя_пользователя>

2) Генерируем новый ключ для деплоя

ssh-keygen -t rsa -C "<имя_пользователя>@<домен_сервиса>"
@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 / 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 ...
@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.

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) {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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')
@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 / makeInsert.go
Created November 3, 2015 06:06
Golang slice insert func generator
package main
import (
"fmt"
"reflect"
)
func makeInsert(fptr interface{}) {
fn := reflect.ValueOf(fptr).Elem()
fn.Set(reflect.MakeFunc(fn.Type(), func(in []reflect.Value) []reflect.Value {
@night-codes
night-codes / MacPro system info
Last active August 30, 2017 15:42 — forked from anonymous/-
System: Host: mint Kernel: 4.8.0-53-generic x86_64 (64 bit gcc: 5.4.0)
Desktop: Cinnamon 3.4.3 (Gtk 3.18.9-1ubuntu3.3) dm: lightdm Distro: Linux Mint 18.2 Sonya
Machine: System: Apple product: MacPro6 1 v: 1.0 Chassis: type: 2 v: Mac-F60DEB81FF30ACF6
Mobo: Apple model: Mac-F60DEB81FF30ACF6 v: MacPro6 1
Bios: Apple v: MP61.88Z.0116.B46.1706200309 date: 06/20/2017
CPU: Multi core Intel Xeon E5-2695 v2 (-HT-MCP-) cache: 30720 KB
flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 57594
clock speeds: min/max: 1200/3200 MHz 1: 1626 MHz 2: 1440 MHz 3: 1650 MHz 4: 1304 MHz
5: 1335 MHz 6: 1559 MHz 7: 1264 MHz 8: 1402 MHz 9: 1498 MHz 10: 1319 MHz 11: 1547 MHz
12: 1495 MHz 13: 1269 MHz 14: 2102 MHz 15: 1409 MHz 16: 1669 MHz 17: 1732 MHz 18: 1672 MHz