Skip to content

Instantly share code, notes, and snippets.

@eduardosilva
eduardosilva / Makefile
Last active April 10, 2024 20:08
Makefile template
################################################################################
# Makefile Configuration for Debugging
################################################################################
# This Makefile configuration allows for conditional debugging output during the
# execution of 'make' commands. Debugging output includes information such as
# the start of Makefile execution, the goals being executed, and the current date
# and time. When not in debug mode, the Makefile suppresses echoing of recipes.
# Set DBG_MAKEFILE to 1 to enable debugging output.
@eduardosilva
eduardosilva / git
Created February 5, 2024 18:39
wip & rewip git alias
# This is Git's per-user configuration file.
[alias]
wip = "!sh -c \"WIP_STRING=\\\"wip: version\\\"; DEFAULT_VERSION=1; LAST_COMMIT_MSG=\\$(git log -1 --pretty=%B); LAST_VERSION=\\$(echo \\\"\\$LAST_COMMIT_MSG\\\" | grep -oP \\\"\\$WIP_STRING \\\\K\\\\d+\\\"); if [[ -z \\$LAST_VERSION ]]; then LAST_VERSION=\\$DEFAULT_VERSION; else LAST_VERSION=\\$((LAST_VERSION + 1)); fi; git add --all; git rm \\$(git ls-files --deleted) 2> /dev/null; git commit --message \\\"\\$WIP_STRING \\$LAST_VERSION\\\" --no-verify; echo \\\"wip commit created with version \\$LAST_VERSION\\\";\""
rewip = !git rebase -i HEAD~$(git log --grep=\"^wip\" --format=%h | wc -l)
@eduardosilva
eduardosilva / High_Performance_Redis.md
Created November 29, 2023 20:25 — forked from neomantra/High_Performance_Redis.md
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@eduardosilva
eduardosilva / gcloud-query-executor.sh
Last active November 7, 2023 13:54
GCloud scripts
#!/usr/bin/env bash
#-------------------------------------------------------------
# Title: GCP Computer Instance Query Executor
# Description: This is a script template that follows some
# best practices for shell scripting. It includes features
# such as named parameters (required or optional), date and
# time handling, logging, colored output, and error handling.
# Author: Eduardo Silva
#
@eduardosilva
eduardosilva / Makefile
Created November 1, 2023 17:37
Makefile Kind + ArgoCD + Crossplane
Makefile
# Vars
KIND_CLUSTER_NAME ?= my-kind-cluster
ARGOCD_VERSION ?= v2.0.5
ARGOCD_NAMESPACE ?= argocd
KIND_VERSION ?= v0.20.0
CROSSPLANE_NAMESPACE ?= crossplane-system
CROSSPLANE_VERSION ?= latest
@eduardosilva
eduardosilva / commit-msg
Created April 24, 2023 13:58
This script validates Git commit messages to ensure they are in Angular commit message format.
#!/bin/bash
#############################################################################################
# This script validates Git commit messages to ensure they are in Angular #
# commit message format. #
# #
# Angular commit message format: #
# type(scope): subject #
# <BLANK LINE> #
# body #
@eduardosilva
eduardosilva / watcher.sh
Created September 14, 2022 17:40
A polling based script to watch a directory and execute a command if something change.
#!/bin/bash
# A polling based script to watch a directory and execute a command if something change.
# Reference: https://www.baeldung.com/linux/command-execute-file-dir-change
# Example: ./watcher.sh ~/Documents "echo 'Detected the modification of a file or directory'"
DIR_TO_WATCH=${1}
COMMAND=${2}
trap "echo Exited!; exit;" SIGINT SIGTERM
// example on find the class attribute with any value.
\*class=".*?"\s?
@eduardosilva
eduardosilva / killer_oneliners_javascript.md
Created May 11, 2022 12:43
Killers One-Liners in JavaScript

Killer one-liners Javascript

Shuffle Array

const shuffleArray = (arr) => arr.sort(() => Math.random() - 0.5);
// Testing
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(shuffleArray(arr));
using System;
public class Program
{
public static void Main()
{
var n = 124123;
var countArray = new int[10];
do {