Skip to content

Instantly share code, notes, and snippets.

View MateusBMP's full-sized avatar
💙
In peace

Mateus Pereira MateusBMP

💙
In peace
  • Universidade Federal de Alagoas (UFAL)
  • Maceió, AL - Brazil
View GitHub Profile
@MateusBMP
MateusBMP / beep.sh
Created June 20, 2024 17:07
Play a sound using the speaker
#!/bin/bash
#
# Play a sound using the speaker
#
# Usage: ./play_sound.sh [time]
# time: time in seconds to play the sound (default: 0.1)
if ! command -v speaker-test &> /dev/null
then
echo "speaker-test could not be found"
@MateusBMP
MateusBMP / README.md
Created September 11, 2023 20:05
Simulação simples de base de dados

Simulação simples de base de dados

Implementação de uma base de dados simples, com o objetivo de simular o funcionamento de uma base de dados real. Para utilizar, compile o projeto com gcc -std=c99 *.c -o main e execute com ./main. Para fazer um teste e entender seu funcionamento, execute ./main database.cdb --example, que criará o arquivo database.cdb e o preencherá com alguns dados de exemplo.

O contrato base está no arquivo database.h, enquanto a implementação encontra-se no arquivo database.c. O arquivo main.c contém um exemplo de uso da base de dados, apenas, e pode ser alterado para implementar o que for necessário.

@MateusBMP
MateusBMP / mysql_avg_calculator.sh
Last active July 30, 2022 22:36
Calculate average mysql command duration
#!/usr/bin/env bash
# usage: progress_bar <current> <max>
# see: https://gist.github.com/darrenclark/1392848
progress_bar () {
output="\r"
output="$output ["
total=$1
count=0
@MateusBMP
MateusBMP / docker-php-ext-get
Created June 30, 2022 04:35
Build Docker images with PECL packages without using the PECL command
#!/usr/bin/env sh
# see: https://olvlvl.com/2019-06-docker-pecl-without-pecl
set -e
dir=/usr/src/php
if [ ! -f "$dir/.docker-extracted" ]; then
echo >&2 "error: PHP source required, run 'docker-php-source extract' first"
exit 1
fi
#!/usr/bin/bash
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
sudo apt update
sudo apt install collectd -y
touch /opt/aws/amazon-cloudwatch-agent/bin/config.json
cat <<- "EOF" >> /opt/aws/amazon-cloudwatch-agent/bin/config.json
@MateusBMP
MateusBMP / php.code-snippets
Last active April 9, 2024 05:20
New Code Snippet to PHP on VSCode
{
"Enable strict typing": {
"prefix": [ "strict_types", "strict" ],
"body": "declare(strict_types=1);",
"description": "Enable strict typing using the PHP strict_types directive"
},
"New php with strict typing": {
"prefix": [ "<?php-strict_types", "<?php-strict" ],
"body": [ "<?php", "", "declare(strict_types=1);", "", "$0" ],
"description": "Create new php file with strict typing enabled."
@MateusBMP
MateusBMP / root
Created January 31, 2022 05:11
Weekly update the server and restart it, via crontab
0 2 * * 0 apt update && apt -y upgrade && apt -y autoremove && /usr/sbin/shutdown -h -r now
@MateusBMP
MateusBMP / mysql-backup.sh
Last active June 26, 2022 10:05
Backup all database, clearing old data
#!/bin/bash
#----------------------------------------------
# OPTIONS
#----------------------------------------------
USER='user' # MySQL User
PASSWORD='pass' # MySQL Password
DAYS_TO_KEEP=7 # 0 to keep forever
GZIP=1 # 1 = Compress
BACKUP_PATH='/set/backup/path'
#----------------------------------------------
@MateusBMP
MateusBMP / print-mem.sh
Created June 18, 2021 01:38
Show memory usage of mysql, by Thomas Florelli
#!/bin/sh
# see: https://tech.labelleassiette.com/how-to-reduce-the-memory-usage-of-mysql-61ea7d1a9bd
# you might want to add some user authentication here
mysql -e "show variables; show status" | awk '
{
VAR[$1]=$2
}
END {
MAX_CONN = VAR["max_connections"]
@MateusBMP
MateusBMP / lista-encadeada.alg
Created March 16, 2021 22:58
Lista encadeada simples em Algol 68
# Create structs FAN and QUEUE #
MODE FAN = STRUCT(STRING name, INT ticket),
QUEUE = STRUCT(FAN fan, REF QUEUE next);
# Create NIL queue, default queue and tail and point both to NIL #
REF QUEUE nilq = NIL;
REF REF QUEUE head, tail;
head := tail := LOC REF QUEUE := nilq;
# Add FAN from QUEUE