Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
@matteocaberlotto
matteocaberlotto / helper.cpp
Created June 19, 2024 07:31
An helper to cycle RGB colors in cpp
/**
* Example usage:
Color *colors[100] = {
new Color(255,0,0),
new Color(0,255,0),
new Color(0,0,255)
};
ColorLoop *loop = new ColorLoop(colors, 3, 50);
@matteocaberlotto
matteocaberlotto / Makefile
Created February 16, 2024 15:51
Deepspeech transcription test
.DEFAULT_GOAL := help
SHELL := /bin/sh
help: ## Display help message
@echo "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\1:\2/' | column -c2 -t -s :)"
venv: ## Create virtualenv if not exists
test -d .venv || python3 -m venv .venv
source: venv ## Source viirtualvenvv
@matteocaberlotto
matteocaberlotto / Makefile
Created December 11, 2023 12:25
A nice Makefile for C++ projects
CXX := -c++
CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror
LDFLAGS := -L/usr/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := thegame
INCLUDE := -Iinclude/
SRC := \
$(wildcard src/player/*.cpp) \
@matteocaberlotto
matteocaberlotto / passgen.php
Created September 25, 2023 15:19
Password generator PHP
<?php
$length = 32;
if ($argc > 1) {
$length = intval($argv[1]);
}
$token = '';
$rand_length = 4;
@matteocaberlotto
matteocaberlotto / cycle-files.sh
Created July 5, 2023 10:39
A php script to automate update of variables contained in environment file
#!/bin/bash
find . -name 'insert_filename_pattern_here' -exec php update.php {} $1 $2 $3 $4 \;
<?php
if ($argc < 5) {
echo <<<EOF
Use:
php modify.php <filename> <variable> <from> <to> <backup>
EOF;
exit(1);
}
@matteocaberlotto
matteocaberlotto / UpdateUserPasswordCommand.php
Created February 13, 2023 11:10
Basic Symfony command for password update
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Question\Question;
validate () {
return new Promise((resolve, reject) => {
try {
// Local check
var file = this.findLicense()
if (!file) {
reject('License key not found')
} else {
var data = fs.readFileSync(file, 'utf8')
@matteocaberlotto
matteocaberlotto / config.inc.php
Created June 20, 2018 15:39
phpmyadmin: no error reporting
<?php
// to be put in phpmyadmin source root (eg: /usr/share/phpmyadmin)
error_reporting(E_NONE);
ini_set('display_errors',0);
ini_set('display_startup_errors',0);
$cfg['SendErrorReports'] = 'never';