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 / cassandra-rust-example.rs
Last active May 25, 2024 00:52
Cassandra - Rust example (scylladb/scylla-rust-driver)
use scylla::{SessionBuilder, IntoTypedRows};
use std::error::Error;
use std::env;
use std::time::Instant;
use dotenv::dotenv;
const QUERY_LIMIT: i32 = 5000;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
@diegofcornejo
diegofcornejo / cassandra-nodejs-example.js
Last active May 25, 2024 00:49
Cassandra - NodeJS example (datastax/nodejs-driver)
const cassandra = require('cassandra-driver');
const CASSANDRA_HOST = process.env.CASSANDRA_HOST || 'localhost';
const CASSANDRA_NODES = [`${CASSANDRA_HOST}:9042`, `${CASSANDRA_HOST}:9043`, `${CASSANDRA_HOST}:9044`]
const CASSANDRA_USER = process.env.CASSANDRA_USER || 'cassandra';
const CASSANDRA_PASSWORD = process.env.CASSANDRA_PASSWORD || 'cassandra';
const CASSANDRA_DATA_CENTER = process.env.CASSANDRA_DATA_CENTER || 'datacenter1';
const KEYSPACE = 'mykeyspace';
const TABLE = 'event';
const QUERY_LIMIT = 50000;
const FETCH_SIZE = 5000;
@diegofcornejo
diegofcornejo / . CASSANDRA_CLUSTER.md
Last active May 25, 2024 23:21
Cassandra Cluster Setup: Configuration to set up a three-node Cassandra cluster using Docker Compose and the Bitnami Cassandra image.

Cassandra Cluster with Docker Compose

This project sets up a multi-node Cassandra cluster using Docker Compose. The configuration includes three Cassandra nodes with a centralized logging setup using Loki.

Prerequisites

  • Docker
  • Docker Compose

Project Structure

@diegofcornejo
diegofcornejo / docker_backup_volumes_to_r2.sh
Created May 13, 2024 15:03
Backup Docker volumes to Cloudflare R2 using AWS CLI
#!/bin/bash
# Constants
S3_BUCKET="<YOUR_BUCKET_NAME>"
HOST_NAME="$(hostname)"
DATE=$(date +%F-%H%M%S) # Format as 'YYYY-MM-DD-HHMMSS'
MAX_BACKUPS=5
AWS_PROFILE="<YOUR_AWS_PROFILE>"
R2_ACCOUNT_ID="<YOUR_R2_ACCOUNT_ID>"
@diegofcornejo
diegofcornejo / 1. GRAFANA.md
Last active May 14, 2024 18:29
Setting Up a Monitoring Stack with Grafana, Prometheus, Node Exporter, and cAdvisor in Docker Compose, Exposed via NGINX

Setting Up a Monitoring Stack with Grafana, Prometheus, Node Exporter, cAdvisor and Loki in Docker Compose, Exposed via NGINX

This guide provides instructions on setting up a comprehensive monitoring stack using Grafana, Prometheus, Node Exporter, cAdvisor and Loki. These components are orchestrated with Docker Compose and exposed via an NGINX reverse proxy, making them accessible through a single domain.

Components

  • Grafana: The analytics and monitoring solution with support for multiple data sources, including Prometheus.
  • Prometheus: The monitoring and alerting toolkit, collecting metrics from configured targets at specified intervals.
  • Node Exporter: A Prometheus exporter for hardware and OS metrics exposed by *NIX kernels.
  • cAdvisor: Analyzes resource usage and performance characteristics of running containers.
@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