Skip to content

Instantly share code, notes, and snippets.

View raykipkorir's full-sized avatar
👨‍💻
Progress, not perfection!

Raymond Kipkorir raykipkorir

👨‍💻
Progress, not perfection!
View GitHub Profile
@raykipkorir
raykipkorir / python_tcp_connection_pool.py
Created September 27, 2026 15:07
python_tcp_connection_pool
import requests
from requests.adapters import HTTPAdapter
session = requests.Session()
adapter = HTTPAdapter(
pool_connections=10, # number of host pools to cache
pool_maxsize=50, # connections kept per host
max_retries=3,
)
session.mount("https://", adapter)
@raykipkorir
raykipkorir / go_tcp_connection_pool.go
Created September 27, 2026 14:52
go_tcp_connection_pool
package main
import (
"context"
"fmt"
"io"
"net/http"
"time"
)
import socket
HOST = "127.0.0.1"
PORT = 2000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:

Linux commands

Basic commands

ls [options] [directory] -> list contents of a directory
  ls -a
  ls -la
pwd
cat
echo
@raykipkorir
raykipkorir / docker-compose.yml
Created January 16, 2024 07:46
Docker compose file - for production
version: "3.8"
services:
app:
build:
context: .
dockerfile: ./compose/production/django/Dockerfile
command: ["sh", "-c", "/start-app.sh"]
image: django_prod
container_name: django_prod
# project/settings.py
import os
from pathlib import Path
from decouple import config
BASE_DIR = Path(__file__).resolve().parent.parent
DATABASES = {
@raykipkorir
raykipkorir / django_aws_settings.py
Created December 1, 2023 13:04
Example configuration for AWS s3 bucket which serves Django static and media files.
"""
Dependencies:
pip install django
pip install django-storages[s3]
pip install python-decouple
"""
# proj/settings.py
from decouple import config
@raykipkorir
raykipkorir / uwsgi_params
Created September 5, 2023 03:26
This is the default example configuration of uwsgi_params provided by nginx. It is located under: /etc/nginx/uwsgi_params
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
@raykipkorir
raykipkorir / proxy_params
Created September 5, 2023 03:23
This is the default example configuration of proxy_params provided by nginx. It is located under: /etc/nginx/proxy_params
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
@raykipkorir
raykipkorir / .dockerignore
Created August 30, 2023 07:07
Sample .dockerignore file
# git
**/.git
**/.gitignore
# vscode
**/.vscode
# docker
Dockerfile
docker-compose-deploy.yml