Skip to content

Instantly share code, notes, and snippets.

View caiaffa's full-sized avatar
🏠
Working from home

Luís Felipe caiaffa

🏠
Working from home
View GitHub Profile
@caiaffa
caiaffa / import.md
Created November 15, 2022 23:51 — forked from iamstoick/import.md
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p.

@caiaffa
caiaffa / keycloak_db_overview_4.0.0.CR1-SNAPSHOT.svg
Created April 19, 2022 13:18 — forked from thomasdarimont/keycloak_db_overview_4.0.0.CR1-SNAPSHOT.svg
Keycloak Database Overview 4.0.0.CR1-SNAPSHOT (06bb6f00e5)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@caiaffa
caiaffa / 1.srp.py
Created December 2, 2021 12:15 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
├── src
│ ├── Api # API layer
| | ├── UseCases # API business rules in use cases
| | | ├── GetTodos # Use Case to get all the todo tasks
| | | | ├── TodoController.cs # Todo Controller for the Get All
| | | | ├── GetTodosPresenter.cs # Presenter
│ ├── Application # Application layer
| | ├── Boundaries # Input and output ports helping us to cross boundaries
| | ├── Services # Application services to handle application business logic
| | ├── UseCases # Use cases interactors
@caiaffa
caiaffa / new_task.py
Created September 24, 2020 15:34 — forked from reedsa/new_task.py
RabbitMQ Retry using Dead Letter Exchange in Python/Pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@caiaffa
caiaffa / one-to-many-to-one.php
Created August 6, 2020 20:44 — forked from jaspernbrouwer/one-to-many-to-one.php
Basic Doctrine 2 one-to-many/many-to-one association setup
<?php
/*
* This is a basic setup for Doctrine 2 one-to-many/many-to-one associations.
*
* There are many alternative approaches, additions and optimizations possible,
* but this example is only meant to help people getting started with the concept.
*/
namespace My\Entity;
@caiaffa
caiaffa / Python Async Decorator.py
Created August 23, 2019 17:08 — forked from Integralist/Python Async Decorator.py
[Python Async Decorator] #python #asyncio #decorator
import asyncio
from functools import wraps
def dec(fn):
@wraps(fn)
async def wrapper(*args, **kwargs):
print(fn, args, kwargs) # <function foo at 0x10952d598> () {}
await asyncio.sleep(5)
@caiaffa
caiaffa / BSTNode.py
Created August 19, 2019 21:57 — forked from stummjr/BSTNode.py
BSTNode.py - Binary Search Tree
# -*- encoding:utf-8 -*-
from __future__ import print_function
class BSTNode(object):
def __init__(self, key, value=None, left=None, right=None):
self.key = key
self.value = value
self.left = left
@caiaffa
caiaffa / mock_requests.py
Created June 24, 2019 14:14 — forked from evansde77/mock_requests.py
Example of mocking requests calls
#!/usr/bin/env python
"""
mocking requests calls
"""
import mock
import unittest
import requests
from requests.exceptions import HTTPError
@caiaffa
caiaffa / cache.py
Created April 16, 2019 17:19 — forked from cloverstd/cache.py
tornado cache
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1