Skip to content

Instantly share code, notes, and snippets.

View vlntsolo's full-sized avatar
:octocat:
Full stack web developer from Ukraine

Valentyn Solonechnyi vlntsolo

:octocat:
Full stack web developer from Ukraine
View GitHub Profile
@vlntsolo
vlntsolo / log.py
Last active June 18, 2024 22:28
GCP FastAPI improved exception logging (prevent truncated exceptions)
import logging
import random
import string
import sys
import traceback
from os import environ
import orjson
from loguru import logger
@vlntsolo
vlntsolo / .env
Created July 23, 2022 16:51
CloudSQL postgres connection string
# For async driver user postgresql+asyncpg
DB_URL=postgresql://<DB_USER>:<DB_USER_PASS>@/<DB_NAME>?host=/cloudsql/<INSTANCE_CONNECTION_NAME>/
# <INSTANCE_CONNECTION_NAME> has the following format <cloud_project>:<region_>:<db_instance_name> (e.g. cloudproject_demo:europe-west2:cloudrun-test-db
@vlntsolo
vlntsolo / sqlmodel.py
Last active July 21, 2024 16:43
SQLModel cheat sheet
"""
MIT License
Copyright (c) 202X Valentyn Solonechnyi
===========================================
"""
"""
Created/updated timestamp fields similar to
Django's db models.DateTimeField(auto_now_add=True)
and models.DateTimeField(auto_now=True)
@vlntsolo
vlntsolo / index.js
Last active July 12, 2022 21:33
CryptoJS AES256 Python decode (working code snippets)
/**
Generates cipher based on AES256 algorithm with CBC mode.
Sources: [ https://stackoverflow.com/questions/59488728/aes-encrypt-in-cryptojs-decrypt-in-pycrypto ]
**/
var CryptoJS = require("crypto-js");
var originalString = "thisIsAnOriginalString";
var passPhrase = "cRfUjXn2r5u8x/A?D(G-KaPdSgVkYp3s"; // NEVER MAKE PASSWORDS OR SECRETS PUBLIC
@vlntsolo
vlntsolo / postgres-cheatsheet.md
Created September 22, 2021 13:49 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@vlntsolo
vlntsolo / multiprocessing_webscraper.py
Last active September 16, 2021 11:07
Async webscraper with native multiprocessing and multithreading
import asyncio
import logging
from multiprocessing import Queue, Process, cpu_count
import queue
from threading import Thread
import time
import aiohttp
import aiosqlite
from bs4 import BeautifulSoup
@vlntsolo
vlntsolo / mysql-commands.md
Last active May 23, 2021 13:31
Simple MySQL cheatsheet (personal use/not comprehensive)

Short MySQL Cheatsheet

Command Description
SHOW DATABASES; List all databases
USE database; Choose database on which next commands will be performed
SHOW TABLES; List all tables in the database
SHOW TABLES LIKE pattern; Show tables that match the pattern i.e. permissions%
DESCRIBE table; Show all table column names and their types.
SELECT column FROM tabel; Basic SELECT statement to retieve rows from selected column
@vlntsolo
vlntsolo / svelte-summit-2020-summary.md
Created May 15, 2021 19:03 — forked from vedam/svelte-summit-2020-summary.md
links and ressources from the svelte-summit-2020 talks

You'll find the talks here


Morgan Williams @mrgnw

The Zen of Svelte

Approaching frontend as a backend developer, Svelte feels surprisingly pythonic. Let's take a quick look at what's familiar, what's foreign, and how to explore the gap.

@vlntsolo
vlntsolo / 01_set_env.sh
Last active October 30, 2022 15:39
Bash script to install Django Q with Supervisor on Amazon Linux 2 (AL2 / Elastic Beanstalk) - UPD with Procfile in the comments
#!/bin/bash
#Create a copy of the environment variable file.
sudo cp /opt/elasticbeanstalk/deployment/env /opt/elasticbeanstalk/deployment/custom_env_var
#Set permissions to the custom_env_var file so this file can be accessed by any user on the instance. You can restrict permissions as per your requirements.
sudo chmod 644 /opt/elasticbeanstalk/deployment/custom_env_var
#Remove duplicate files upon deployment.
sudo rm -f /opt/elasticbeanstalk/deployment/*.bak
@vlntsolo
vlntsolo / usaid-ua.csv
Last active July 26, 2020 18:42
USAID funding to Ukraine
Identifier Purpose Amount Type Date
US-GOV-1-121-110-0005-C-00-4050-19 UKR SO 1.3 PRIVATE ENTERPRISE GROWTH -39082.03 2 2018-03-31
US-GOV-1-121-121-C-00-00-00823-15 UKR SO 1.41 - Improved Investment Climate -36767.7 2 2014-09-30
US-GOV-1-121-121-C-00-00-00832-1 Assistance For the Independent States Of the Former Soviet Union -1709.69 2 2015-06-30
US-GOV-1-121-121-C-00-00-00834-1 UKR SO 3.4 SOCIAL TRANSITIONS -74541 3 2013-03-31
US-GOV-1-121-121-C-00-00-00834-1 UKR SO 3.4 SOCIAL TRANSITIONS -19915 2 2014-06-30
US-GOV-1-121-121-C-00-00-00834-1 UKR SO 3.4 SOCIAL TRANSITIONS 54626 3 2014-06-30
US-GOV-1-121-A-00-00-00819 Justice System -21592.26 3 2013-06-30
US-GOV-1-121-A-00-00-00819 Justice System -29337.44 2 2013-09-30
US-GOV-1-121-A-00-03-00002 Agricultural Sector Productivity -11900.06 2 2015-06-30