Skip to content

Instantly share code, notes, and snippets.

View richhh7g's full-sized avatar
🌟
Veni, vidi, vici

<Richhh /> richhh7g

🌟
Veni, vidi, vici
View GitHub Profile
@richhh7g
richhh7g / install_languages.sh
Created May 28, 2024 11:00
Shell - Install programming language
#!/bin/bash
node_version=""
php_version=""
global_flag=false
while [[ "$#" -gt 0 ]]; do
case $1 in
--node=*) node_version="${1#*=}"; shift ;;
--php=*) php_version="${1#*=}"; shift ;;
@richhh7g
richhh7g / product_crud.go
Created March 21, 2024 22:31
Go Lang - Product CRUD CLI
// go run product_crud.go --action Get --product '{"id": "uuid"}'
// go run product_crud.go --action All
// go run product_crud.go --action Create --product '{"name": "Example product", "price": 1000.0}'
// go run product_crud.go --action Update --product '{"id": "uuid", "name": "Example product", "price": 1000.0}'
// go run product_crud.go --action Delete --product '{"id": "uuid"}'
package main
import (
"bytes"
@richhh7g
richhh7g / search_cep.go
Last active March 18, 2024 12:58
Go Lang - Search CEP
// go run search_cep.go 00000000
// Or
// go build search_cep.go
// ./search_cep 00000000
package main
import (
"encoding/json"
"fmt"
@richhh7g
richhh7g / cleanup.sh
Last active March 9, 2024 03:13
Shell - Erase logs 🤫
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 <minutes_to_keep_logs> <commands_to_keep_in_history>"
exit 1
fi
logs_dir="/var/log"
minutes_to_keep_logs=$1
commands_to_keep_in_history=$2
@richhh7g
richhh7g / slack_online_mode.sh
Created February 15, 2024 13:27
Shell - Slack online mode
#!/bin/bash
ANGLE=0
RADIUS=100
CENTER_X=1000
CENTER_Y=1000
INTERVAL=1
ANGULAR_VELOCITY=1
while true; do
@richhh7g
richhh7g / kill_process_port.sh
Last active February 14, 2024 21:46
Shell - Kill process
#!/bin/bash
port=3000
if [ $# -gt 0 ]; then
port=$1
fi
process_pid=$(lsof -i :$port | grep "LISTEN" | awk '{print $2}')
@richhh7g
richhh7g / generate-keys.ts
Created February 11, 2024 18:52
NodeJs - Create PrivateKey and PublicKey
// npx ts-node generate-keys.ts
import crypto, { KeyObject } from "crypto";
import fs from "fs";
import { isKeyObject } from "util/types";
enum EncryptionAlgorithm {
AES_128_CBC = "aes-128-cbc",
AES_192_CBC = "aes-192-cbc",
AES_256_CBC = "aes-256-cbc",