Skip to content

Instantly share code, notes, and snippets.

View yanmhlv's full-sized avatar

Ian Mikhailov yanmhlv

View GitHub Profile
@yanmhlv
yanmhlv / commit-message.instruction.md
Created May 7, 2025 08:05
🤖 Copilot commit messages instructions for VS Code
@yanmhlv
yanmhlv / update-macos-settings.sh
Last active April 17, 2025 07:31
adjusting macos
#!/usr/bin/env bash
#########################################################
# Dock Related Settings
#########################################################
# Переместить Dock справа
defaults write com.apple.dock orientation -string "right"
# Размер иконок в Dock (30px)
@yanmhlv
yanmhlv / example.go
Created February 8, 2016 14:49
JSONB in gorm
package main
import (
"database/sql/driver"
"encoding/json"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
@yanmhlv
yanmhlv / nginx-tuning.md
Created December 5, 2024 13:06 — forked from denji/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.

@yanmhlv
yanmhlv / gist:708e2c6b90f45964bab7057af2e88ed1
Last active November 26, 2024 19:28
git pull over all subdirectories(depth=1)
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
# or
find . -type d -not -path './.git*' -maxdepth 1 \( ! -name . \)
@yanmhlv
yanmhlv / cond.go
Last active January 4, 2024 17:45
Concurrency patterns
import "sync"
type Cond struct {
lock sync.RWMutex
changed chan struct{}
}
func (c *Cond) Listen() <-chan struct{} {
c.lock.RLock()
defer c.lock.RUnlock()
package main
import (
"bytes"
"errors"
"html/template"
"net/http"
"path/filepath"
)
@yanmhlv
yanmhlv / cond.go
Last active June 14, 2023 13:12
concurrency helpers
package cond
type Cond struct {
lock sync.RWMutex
changed chan struct{}
}
func newCond() *Cond {
return &Cond{changed: make(chan struct{})}
}
@yanmhlv
yanmhlv / System Design.md
Created March 6, 2019 14:58 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func handleResponse[T any](resp *http.Response, err error, t *T) error {
if err != nil {