Skip to content

Instantly share code, notes, and snippets.

View diegofcornejo's full-sized avatar
🪄
randomtechguy

Diego Cornejo diegofcornejo

🪄
randomtechguy
View GitHub Profile
@diegofcornejo
diegofcornejo / README.md
Created April 11, 2024 06:21
Elasticsearch: Snapshot and Restore

Create repository for snapshots

  • The location is the path where the snapshots will be stored, this path need to be set in the elasticsearch.yml file in the path.repo property
  • example: path.repo: ["/usr/share/elasticsearch/backup"]
  • After setting the path.repo property in the elasticsearch.yml file, restart the elasticsearch service
curl -XPUT -k -u elastic:changeme "https://localhost:9200/_snapshot/repository_backups" -H 'Content-Type: application/json' -d '{
  "type": "fs",
  "settings": {
    "location": "/usr/share/elasticsearch/backup"
 }
@diegofcornejo
diegofcornejo / buildspec.yml
Created March 19, 2024 15:30
AWS: Build spec file for Docker build and Push to ECR
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
@diegofcornejo
diegofcornejo / 1. KUBECONFIG.md
Last active March 6, 2024 14:00
Kubernetes: Load multiple config files

Kubernetes: Load multiple config files

Add this line in your .bashr or .zshrc

## Kubernetes: Load config files dinamically (conf.yml)
export KUBECONFIG=$(find $HOME/.kube -name "*.conf.yml" -print0 | tr '\0' ':' | sed 's/:$//')

Then reload it

@diegofcornejo
diegofcornejo / diegocornejo.com.txt
Created March 3, 2024 04:43
diegocornejo.com ascii logo
▒▓
▒█████████████████████████▓░
████████████████████████████▒
▓████████████████████████████░
░██░█░▒█ ░▒████████░
▒██▒ ▒█ ▒█ ░██████▓
███▓ █▒ ▒█ ▒█████░
░████▒ ░█░ ▒█ █████▓
█████▒ ░█ ▒█ ▓█████░
@diegofcornejo
diegofcornejo / weblogic14c-on-rhel9.md
Last active March 1, 2024 17:53
Install Oracle WebLogic Server 14c (14.1.1.0) on RHEL 9.3 (AWS EC2)

Install Oracle WebLogic Server 14c (14.1.1.0) on RHEL 9.3 (AWS EC2)

Prerequisites

  1. Create Swap Space
[ec2-user@hostname ~] sudo su -
[root@hostname ~] dd if=/dev/zero of=/swapfile bs=1M count=1024
[root@hostname ~] chmod 600 /swapfile
[root@hostname ~] mkswap /swapfile
@diegofcornejo
diegofcornejo / deploy_to_s3.yml
Created February 18, 2024 17:00
Github Action - Deploy to S3 and Invalidate CloudFront Cache
name: Deploy to S3 and Invalidate CloudFront Cache
on:
push:
branches:
- main
- develop
jobs:
build-and-deploy:
@diegofcornejo
diegofcornejo / SYSTEMD-SERVICES-EXAMPLES.md
Created February 18, 2024 16:53
SYSTEMD - Services files examples

Systemd Service Examples

Add a new service to systemd

sudo nano /etc/systemd/system/my-service.service

NOTE: And add the following content from section Service File Examples

Some useful commands

@diegofcornejo
diegofcornejo / README.md
Last active March 12, 2024 05:46
Redis: Create docker containers dinamically with secure connection using stunnel

Redis Container with stunnel Secure Access

This script automates the setup of a Redis container with secure access via stunnel. It generates a unique ID for the Redis instance, a secure password, and finds free ports for Redis and stunnel.

Features

  • Starts a Redis container with a unique volume and password.
  • Sets up a stunnel container to provide secure access to the Redis instance.
  • Assumes the availability of a wildcard certificate, key, and CA file for your domain.
@diegofcornejo
diegofcornejo / cloudclusters-backup-db.sh
Last active November 17, 2023 02:53
Cloudclusters.io: Backup postgresql db and upload to AWS S3
#! /bin/bash
CLOUDCLUSTERS_HOME="/cloudclusters"
LOG_FILE="$CLOUDCLUSTERS_HOME/logs/db-backup.log"
SCRIPT_DIR="$CLOUDCLUSTERS_HOME/scripts"
BACKUP_DIR="$CLOUDCLUSTERS_HOME/backups"
S3_BUCKET="s3://<bucket_name>"
DB_NAME="<dbname>"
DB_USER="<dbuser>"
@diegofcornejo
diegofcornejo / Dockerfile
Last active October 23, 2023 05:15
Dockerize: Build (Vite) React App inside Turborepo and serve on ASMTTPD
# Base image
FROM alpine:3.18.4 as base
RUN apk update && apk upgrade
RUN apk add --no-cache make yasm binutils git nodejs npm
RUN npm install -g yarn
# Compile asmttpd http server
from base as build-asmttpd
RUN git clone --depth 1 https://github.com/nemasu/asmttpd