Skip to content

Instantly share code, notes, and snippets.

View pablohdzvizcarra's full-sized avatar
🛏️
Need Sleep

Pablo Hernandez pablohdzvizcarra

🛏️
Need Sleep
View GitHub Profile
@pablohdzvizcarra
pablohdzvizcarra / osi_model.go
Created April 19, 2024 03:24
Representation fo the OSI Model with golang code
package main
// OSI Model Open System Intercommunication Model
// You can see the OSI Model as an standard for applications.
// Each layer in the OSI model is decoupled from the other layers.
// ## SENDER
// 7 layers each describe a specific networking component
// Layer 7 - Application: HTTP/FTP/gRPC.
// Layer 6 - Presentation: Encoding, serialization.
@pablohdzvizcarra
pablohdzvizcarra / validate_pass_sh
Created February 29, 2024 04:14
Validates if a password was introduce two times equals
#!/bin/bash
# Program to validate a password
if read -t 10 -sp "Enter secret phrase > " secret_pass; then
echo -e "\nSecret passphrase was configured"
if read -t 10 -sp "Enter the secret phrase again > " secret_pass_two; then
if [[ "$secret_pass" == "$secret_pass_two" ]]; then
echo -e "\nThe password was validated"
@pablohdzvizcarra
pablohdzvizcarra / RunningTaskWithExecutor.java
Created December 3, 2023 19:50
Tutorial: what is an executor in Java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
public class RunningTaskWithExecutor {
@pablohdzvizcarra
pablohdzvizcarra / ExecuteTaskInSeparedThread.java
Created December 3, 2023 19:42
Tutorial: What is a Java Executor
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ExecuteTaskInSeparateThread {
private static final Logger logger = Logger.getLogger("App");
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker container prune # Remove all stopped containers
docker volume prune # Remove all unused volumes
docker image prune # Remove unused images
docker system prune # All of the above, in this order: containers, volumes, images
docker system df # Show docker disk usage, including space reclaimable by pruning
@pablohdzvizcarra
pablohdzvizcarra / rabbitmq.repo
Created August 31, 2022 21:07
File to add RabbitMQ dependencies to RedHat 8 server
# In /etc/yum.repos.d/rabbitmq.repo
##
## Zero dependency Erlang
##
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/8/$basearch
repo_gpgcheck=1
@pablohdzvizcarra
pablohdzvizcarra / EmployeeWebSecurityConfig.java
Created May 14, 2022 14:04
create bean with spring security configuration
package com.baeldung.springreactivebaeldungseries.lesson01;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@EnableWebFluxSecurity
public class EmployeeWebSecurityConfig {
@pablohdzvizcarra
pablohdzvizcarra / Dockerfile-kotlin-app
Created May 10, 2022 03:38
Dockerfile to how depoy kotlin application with two phases
FROM openjdk:11.0.15-oracle as build
RUN mkdir -p /app/source
COPY . /app/source
WORKDIR /app/source
RUN ./mvnw clean package -DskipTests
FROM openjdk:11.0.15-oracle as runtime
COPY --from=build /app/source/target/*.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
@pablohdzvizcarra
pablohdzvizcarra / TestSwitchStatement.java
Created April 24, 2022 14:04
diferents ways to execute switch statement in Java
package jvm.pablohdz.restapidesignpatterns;
public class TestSwitchStatement {
public void classicVersion(int number) {
switch (number) {
case 1:
callMethod("one");
break;
case 2:
@pablohdzvizcarra
pablohdzvizcarra / BasicEngineering.java
Created April 23, 2022 12:05
application a hook in a class using a method
package jvm.pablohdz.restapidesignpatterns.example.template;
public abstract class BasicEngineering {
public final void completeCourse() {
// the course must be completed in order to pass
// 1. Math
// 2. Soft Skills
// 3. Special Paper
completeMath();
completeSoftSkills();