Skip to content

Instantly share code, notes, and snippets.

View ProvoK's full-sized avatar
:octocat:

Vittorio Camisa ProvoK

:octocat:
View GitHub Profile
@ProvoK
ProvoK / install-docker-mint.sh
Last active October 24, 2017 05:10 — forked from mmcc/install-docker-mint.sh
Install Docker on Linux Mint 17
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sh -c 'echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list'
echo 'deb http://cz.archive.ubuntu.com/ubuntu trusty main' >> /etc/apt/sources.list
# Install docker
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-get install -y linux-image-extra-$(uname -r)
sudo apt-get install -y libsystemd-journal0
@ProvoK
ProvoK / git_utils.sh
Last active March 18, 2019 16:34
Git Utils
# Clean all local tags and fetch from remote
git tag | xargs -n 1 -I% git tag -d % && git fetch
# Remove from history deleted files. For wrongly committed BIG files that makes repository heavy
# Reference https://superuser.com/questions/1191186/remove-large-file-from-several-commits-ago-in-git
git filter-branch --tree-filter 'rm -f <filepath>' HEAD
import pytest
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
engine = create_engine('DB_CONNECTION_URL')
Session = sessionmaker()
@pytest.fixture(scope='module')
def connection():
connection = engine.connect()
@ProvoK
ProvoK / user_factory_basic.py
Last active March 10, 2018 17:30
Factory boy simple example
import factory
class User:
def __init__(self, name, email):
self.name = name
self.email = email
class UserFactory(factory.Factory):
name = factory.Faker('name')
email = factory.Faker('email')
class UserModel(Base):
__tablename__ = 'account'
id = Column(BigInteger, primary_key=True)
name = Column(String, nullable=False)
email = Column(String, nullable=False)
class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
id = factory.Sequence(lambda n: '%s' % n)
name = factory.Faker('name')
import pytest
import factory
from sqlalchemy import create_engine, Column, String, BigInteger
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine('DB_CONNECTION_URL')
Base = declarative_base(bind=engine)
Session = sessionmaker()
@pytest.fixture(scope='function')
def session(connection):
transaction = connection.begin()
session = Session(bind=connection)
UserFactory._meta.sqlalchemy_session = session # NB: This line added
yield session
session.close()
transaction.rollback()
def my_func_to_delete_user(session, user_id):
@ProvoK
ProvoK / bookmark.min.js
Created October 24, 2018 20:44 — forked from zaydek-old/bookmark.min.js
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();