Skip to content

Instantly share code, notes, and snippets.

View anton-petrov's full-sized avatar
:octocat:
🥷

Anton Petrov anton-petrov

:octocat:
🥷
View GitHub Profile
@anton-petrov
anton-petrov / postgres_queries_and_commands.sql
Created March 4, 2023 11:25 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@anton-petrov
anton-petrov / gist:f1cdea5b713f79a112a7898c33ec699b
Created February 13, 2023 17:30
Copy SSH Public Key from Windows to Ubuntu
Windows host:
cp C:\Users\anton\.ssh\id_rsa.pub C:\Users\anton\authorized_keys
cd C:\Users\anton\
scp authorized_keys [email protected]:~/.ssh
Ubuntu host:
service ssh status Start sshd if necessary
mkdir ~/.ssh/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
@anton-petrov
anton-petrov / .gitconfig
Created November 17, 2022 18:15
Git config for mac
credential.helper=osxkeychain
init.defaultbranch=master
user.name=Anton Petrov
[email protected]
user.signingkey=/Users/anton/.ssh/id_ed25519.pub
core.pager=delta
core.editor=nano
interactive.difffilter=delta --color-only
delta.navigate=true
delta.light=false
@anton-petrov
anton-petrov / extend.sh
Created November 16, 2022 06:45
Resize llvm partition in Linux
#!/bin/bash
# This script will increse the size of the LVM disk partition so that you can take advantage of additional space after increasing the virtual
# disk size either through virtualbox, openstack, or some other virtualization tool
if [ -z "$1" ] ; then
echo "You must specify the disk device being extended, eg: /dev/sda or /dev/vda";
echo "Example Usage: ./extend-lvm.sh /dev/sda";
echo "Run 'fdisk -l' to see the existing devices and partitions. If there are more than one, this will also give you a clue as to which one has grown and needs to be modified";
exit 1
fi
@anton-petrov
anton-petrov / .zshrc
Last active August 24, 2022 15:05
My zshrc environment
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@anton-petrov
anton-petrov / install_docker_buildx.sh
Created August 22, 2022 08:52
Install docker buildx plugin in Ubuntu 22.04
# See https://docs.docker.com/build/buildx/install/
mkdir -p $HOME/.docker/cli-plugins
wget -O $HOME/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.9.1/buildx-v0.9.1.linux-amd64
chmod +x $HOME/.docker/cli-plugins/buildx
@anton-petrov
anton-petrov / uvicorn-gunicorn-fastapi.docker
Created May 12, 2022 09:10
Dockerfile for uvicorn + gunicorn + fastapi
FROM antonapetrov/uvicorn-gunicorn-fastapi:miniforge3.9
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get upgrade -y && apt-get install curl -y && apt-get clean
# For conda, uncomment if needed
# RUN conda update --all --yes
# RUN conda install -c conda-forge psycopg2=2.9.3 --yes && conda clean --all
WORKDIR /app/
@anton-petrov
anton-petrov / JupyterHub.service
Last active February 28, 2022 09:18
Installing JupyterHub on Linux Ubuntu (Debian)
[Unit]
Description=JupyterHub
[Service]
Type=simple
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/anaconda3/bin"
ExecStart=/usr/bin/env jupyterhub --port=10001
User=root
Group=root
@anton-petrov
anton-petrov / centerline.py
Created December 8, 2021 12:53
Test centerline fork
import pickle
from shapely.geometry import Polygon
from centerline.geometry import Centerline
import time
def st_time(func):
"""
st decorator to calculate the total time of a func
"""
@anton-petrov
anton-petrov / texteditor.py
Created November 23, 2021 14:23
Текстовый редактор на Tkinter
import tkinter as tk
from tkinter.filedialog import askopenfilename, asksaveasfilename
def open_file():
filepath = askopenfilename(
filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")]
)
if not filepath:
return
txt_edit.delete(1.0, tk.END)