Skip to content

Instantly share code, notes, and snippets.

View wellic's full-sized avatar

Valerii Savchenko wellic

View GitHub Profile
@wellic
wellic / db_utils.py
Created October 22, 2021 23:14 — forked from obeattie/db_utils.py
Exposes SQLAlchemy's sessions and transactions as context managers (so they will be managed automatically inside blocks), and also provides a transaction decorator, which wraps an entire function in a transaction
"""Utilities for managing database sessions."""
from __future__ import with_statement
import contextlib
import functools
@contextlib.contextmanager
def temp_session(session_cls, **kwargs):
"""Quick and dirty context manager that provides a temporary Session object
to the nested block. The session is always closed at the end of the block.
@Icaruk
Icaruk / multipleGitProfiles.md
Last active April 2, 2025 09:40
How to have multiple profiles on git

Last update: 30-01-2024
Last view: 01-05-2025

Step 1

Go to your work folder, mine is located at: F:/Work/EnterpriseName/

And then create a .gitconfig-work with the following data:

@drts01
drts01 / dict_merge.py
Last active April 18, 2020 10:31 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
# Recursive dictionary merge
# Copyright (C) 2016 Paul Durivage <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
#!/bin/sh
PATH_TO_ACCOUNT="/path/to/account"
PATH_TO_FILE="/path/to/file"
ACCOUNT_NAME="[email protected]"
ISSUER="Somewhere Org"
KEEPASS_PASSWORD="the secret password"
echo "$KEEPASS_PASSWORD" | keepassxc-cli show -a "TOTP Seed" "$PATH_TO_FILE" "$PATH_TO_ACCOUNT" | grep -v "Insert password" | while read i;do echo "otpauth://totp/$ACCOUNT_NAME?secret=$i&issuer=$ISSUER" | qr;done;
@emmanueltissera
emmanueltissera / git-apply-patch.md
Created September 13, 2017 02:34
Generate a git patch for a specific commit

Creating the patch

git format-patch -1 <sha>
OR
git format-patch -1 HEAD

Applying the patch

git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying

#!/usr/bin/env
# coding: utf-8
import asyncio
import requests
import tornado.gen as gen
import tornado.httpclient as httpclient
import tornado.httpserver as httpserver
import tornado.options as options
@ldez
ldez / gmail-github-filters.md
Last active March 15, 2025 21:57
Gmail and GitHub - Filters

Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

Pull Request

Filter Label
@lobster1234
lobster1234 / localstack.md
Last active August 8, 2023 20:06
Working with localstack on command line

Starting localstack

C02STG51GTFM:localstack mpandit$ make infra
. .venv/bin/activate; exec localstack/mock/infra.py
Starting local dev environment. CTRL-C to quit.
Starting local Elasticsearch (port 4571)...
Starting mock ES service (port 4578)...
Starting mock S3 server (port 4572)...
Starting mock SNS server (port 4575)...
@JoshTheWanderer
JoshTheWanderer / .eslint.json
Created November 15, 2016 13:59
A rough linting boilerplate
{
"extends": "airbnb",
"plugins": [
"react"
],
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,