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!"
public function findDataByProductId(int $productId)
{
$qb = $this->createQueryBuilder('p');
$qb
->select('p, pmmp')
->leftJoin('p.contractsRenovation', 'pmmp')
->where('p.id = :productId')
->setParameter('productId', $productId);
$qb = $this->createQueryBuilder('p');
$qb
->select('partial p.{id, name}, partial pmmp.{id}')
->leftJoin('p.contractsRenovation', 'pmmp')
->where('p.id = :productId')
->setParameter('productId', $productId);
return $qb->getQuery()->getResult(Query::HYDRATE_ARRAY);
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
class ProductDto
{
/**
@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;
const DEFAULT_PREFIX = 'R$ ';
const DEFAULT_SUFFIX = '';
function prepend(value = 0) {
if (value < 10) {
return '00';
}
if (value < 100) {
return '0';