Skip to content

Instantly share code, notes, and snippets.

@vbogretsov
vbogretsov / docker-compose.override.yml
Last active January 11, 2024 09:37
Local volume mount for virtualenv
services:
app:
volumes:
- venv:/opt
volumes:
venv:
driver: local
driver_opts:
type: none
@vbogretsov
vbogretsov / Dockerfile
Created April 29, 2023 08:42
python docker
ARG PYTHON_VERSION=3.11
ARG ALPINE_VERSION=3.17
ARG POETRY_VERSION=1.3.2
ARG DEVBUILD
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} as build
ARG ALPINE_VERSION
ARG POETRY_VERSION
ARG DEVBUILD
RUN echo https://mirror.yandex.ru/mirrors/alpine/v${ALPINE_VERSION}/main > /etc/apk/repositories
@vbogretsov
vbogretsov / ca.md
Created February 28, 2023 19:35 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@vbogretsov
vbogretsov / docker-compose.yml
Created December 21, 2022 21:56
PostgreSQL in docker compose
version: '3.8'
services:
postgres:
# image: postgres:10.18-alpine
image: postgres:13.4
restart: "no"
# Performance tuning by http://pgtune.leopard.in.ua
# DB Version: 10
# OS Type: linux
@vbogretsov
vbogretsov / pkgsrc.sh
Last active April 21, 2023 08:16
pkgsrc
cd $pkgsrc/bootstrap
OSX_SDK_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk ./bootstrap --unprivileged --full --prefix=/opt/pkg --varbase /opt/pkg/var --make-jobs=10 --prefer-native=yes
# set in /opt/pkg/etc/mk.conf
# OSX_SDK_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
# MAKE_JOBS=10
# cyrus-sasl
cd $pkgsrc/net/libfetch
@vbogretsov
vbogretsov / heap.go
Created March 24, 2022 07:28
Indexed priority queue
package heap
import (
"math"
)
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
@vbogretsov
vbogretsov / tx.go
Created August 17, 2021 19:04
Gorm transaction wrapper
type GormTx struct {
stack []*gorm.DB
open int
clos int
}
func NewTransaction(db *gorm.DB) *GormTx {
return &GormTx{
stack: []*gorm.DB{db},
open: 0,
@vbogretsov
vbogretsov / totalmem
Created August 9, 2021 09:31
Get total memory on a linux host
free -m | grep Mem | awk '{print $2}'
@vbogretsov
vbogretsov / redis-maxmem
Last active August 9, 2021 13:03
Get maxmemory configured on redis host
redis-cli -p $1 -a $(grep -Po '(?<=^masterauth\s).*' ${2:-/etc/redis.conf} | sed 's/^\"//g' | sed 's/\"$//g') info | grep maxmemory_human
@vbogretsov
vbogretsov / docker.yml
Created December 2, 2020 15:11
LinuxKit docker image for Yandex Cloud
kernel:
image: linuxkit/kernel:5.4.39
cmdline: "console=ttyS0"
init:
- linuxkit/init:a68f9fa0c1d9dbfc9c23663749a0b7ac510cbe1c
- linuxkit/runc:v0.8
- linuxkit/containerd:a4aa19c608556f7d786852557c36136255220c1f
- linuxkit/ca-certificates:v0.8
onboot:
- name: sysctl