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 / docker-compose.yml
Created September 19, 2024 13:24
Docker compose file to override the default configuration for Apache airflow running with the astro CLI too.l
version: "3.1"
services:
webserver:
networks:
- ndsnet
scheduler:
networks:
- ndsnet
@pablohdzvizcarra
pablohdzvizcarra / create_mysql_connection.py
Created August 27, 2024 02:52
Python application to perform common operations in a SQL database using the mysql.connector client library
import mysql.connector
from mysql.connector import Error, MySQLConnection
def create_connection() -> MySQLConnection:
try:
connection: MySQLConnection = mysql.connector.connect(
host="",
database="example",
user="admin",
@pablohdzvizcarra
pablohdzvizcarra / ChapterTwoExercises.java
Created May 5, 2024 05:19
Binary Search and other algorithms implementations
public class ChapterTwoExercises {
/*
* Binary search implementation, to know the steps necessary only double the
* elements and plus 1
* Array 3 = 2 steps
* Array 7 = 3 steps
* array 15 = 4 steps
* array 31 = 5 steps
* array 63 = 6 steps
@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 {