Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Coding...

Guilherme Biff Zarelli gbzarelli

💻
Coding...
View GitHub Profile
@gbzarelli
gbzarelli / thread_pool_executor.py
Created Nov 13, 2020
Python - Executando processos paralelos em Threads - Executing parallel process with Threads
View thread_pool_executor.py
from multiprocessing.pool import ThreadPool as Pool
data_values = [
"b33d45d1-0107-471d-882b-70a445c43d50",
"06a55ef1-bc02-4115-91d8-783173ab4eda",
"580a171a-2007-41d2-9ba4-e24bb068c2bd"
]
def worker(some_arg1):
@gbzarelli
gbzarelli / _FSM_SIMPLE_IMPL.md
Last active Nov 9, 2020
Article about Finite State Machine - Step 2 - The simple implementation
View .profile-MonitorSheets
#PRIMARY DISPLAY = EXTENDED DISPLAY CONNECTED TO THE HDMI PORT
#SECONDARY DISPLAY = BUILT IN DISPLAY
PRIMARY_DISPLAY=$(xrandr | grep -w HDMI | awk -F'[ \+]' '{print $1}')
SECONDARY_DISPLAY=$(xrandr | grep -w eDP | awk -F'[ \+]' '{print $1}')
MODE1408=$(cvt 1408 792 60 | sed -n '2p' | awk '{gsub(/Modeline /,"")}1')
MODE1440=$(cvt 1440 810 60 | sed -n '2p' | awk '{gsub(/Modeline /,"")}1')
MODE1536=$(cvt 1536 864 60 | sed -n '2p' | awk '{gsub(/Modeline /,"")}1')
MODE1600=$(cvt 1600 900 60 | sed -n '2p' | awk '{gsub(/Modeline /,"")}1')
@gbzarelli
gbzarelli / AspectSpringBootEndpoints
Last active Oct 24, 2020
Aspect Spring Boot Endpoints
View AspectSpringBootEndpoints
https://stackoverflow.com/questions/33744875/spring-boot-how-to-log-all-requests-and-responses-with-exceptions-in-single-pl
Currently Spring Boot has the Actuator feature to get the logs of requests and responses.
But you can also get the logs using Aspect(AOP).
Aspect provides you with annotations like: @Before, @AfterReturning, @AfterThrowing etc.
@Before logs the request, @AfterReturning logs the response and @AfterThrowing logs the error message, You may not need all endpoints' log, so you can apply some filters on the packages.
@gbzarelli
gbzarelli / E2ETest.java
Created Jul 30, 2020
Used in Medium article about Tests
View E2ETest.java
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class SampleE2ETests {
@Autowired
private TestRestTemplate restTemplate;
@Autowired
private PersonRepository personRepository;
@AfterEach
@gbzarelli
gbzarelli / IntegrationControllerTest.java
Created Jul 30, 2020
Used in Medium article about Tests
View IntegrationControllerTest.java
@SpringBootTest
@WebMvcTest(controllers = ExampleController.class)
class ExampleControllerAPITest {
@Autowired
private MockMvc mockMvc;
@MockBean
private PersonRepository personRepository;
@gbzarelli
gbzarelli / IntegrationExternalApiTest.java
Created Jul 30, 2020
Used in Medium article about Tests
View IntegrationExternalApiTest.java
@SpringBootTest
class WeatherClientIntegrationTest {
@Autowired
private WeatherClient subject;
@Rule
public WireMockRule wireMockRule = new WireMockRule(8089);
@Test
@gbzarelli
gbzarelli / IntegrationDatabaseTest.java
Created Jul 30, 2020
Used in Medium article about Tests
View IntegrationDatabaseTest.java
@SpringBootTest
@DataJpaTest
class PersonRepositoryIntegrationTest {
@Autowired
private PersonRepository subject;
@AfterEach
void tearDown() throws Exception {
subject.deleteAll();
@gbzarelli
gbzarelli / UnitTest.java
Last active Jul 30, 2020
Used in Medium article about Tests
View UnitTest.java
@Test
void shouldReturnFullNameOfAPersonWithSuccess() {
//given
Person peter = new Person("Peter", "Pan");
when(personRepo).findByLastName("Pan"))
.doReturn(Optional.of(peter));
//when
String greeting = subject.hello("Pan");
You can’t perform that action at this time.