Skip to content

Instantly share code, notes, and snippets.

@caiovncius
caiovncius / Enums.php
Created December 26, 2023 02:20
Trait with common functions for enums.
<?php
declare(strict_types=1);
namespace App\Traits\Components;
trait Enums
{
/**
* @return array

MySQL/MariaDB Tuning And Optimization For Best Performance

OS Level Optimization

Swappiness

sysctl -w vm.swappiness=1
echo "vm.swappiness = 1" | sudo tee -a /etc/sysctl.conf

noatime

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@caiovncius
caiovncius / php.ini
Created August 13, 2023 14:29
Cleaned php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
@caiovncius
caiovncius / object-cahe.php
Created May 31, 2023 11:09
Redis cache for WordPress
<?php
defined( '\\ABSPATH' ) || exit;
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact, Generic.WhiteSpace.ScopeIndent.Incorrect
if ( ! defined( 'WP_REDIS_DISABLED' ) || ! WP_REDIS_DISABLED ) :
/**
* Determines whether the object cache implementation supports a particular feature.
version: '2'
services:
mariadb:
container_name: ${NAME}-database
image: mariadb:10.6
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=moodle_user
- MARIADB_DATABASE=moodle
- MARIADB_CHARACTER_SET=utf8mb4
@caiovncius
caiovncius / vscode.json
Last active October 19, 2022 03:09
Personal vscode settings
{
"customizeUI.stylesheet": {
".decorationsOverviewRuler": "display: none;",
".editor-group-container .title *": "display: none;",
".editor-group-container .title": "pointer-events: none;",
".editor-group-container.empty": "-webkit-app-region: drag;",
".monaco-editor .scroll-decoration": "box-shadow: none;"
},
"customizeUI.titleBar": "inline",
"debug.console.fontFamily": "JetBrains Mono",
#!/bin/bash
curl -d "client_id=357213535355-egdrcg6pturbpb6672vma3kuea818ik1.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/drive.file" https://oauth2.googleapis.com/device/code
@caiovncius
caiovncius / up_gd.sh
Last active October 10, 2022 00:14
test.sh
#!/bin/bash
curl -X POST -L \
-H "Authorization: Bearer ya29.a0Aa4xrXNzBjX5F-QUqlBPn508LvaHCscbFmkGWfWb_uvHSqhwRmva-c7NqT9rV_ts5Ey9RtRB7jFuR7yiZ3hzASOtalKHd31bNuOUGKrPCiL0zkI4X9qmj2n6MMZRNfLxyXTAYBESH9oRORXINeDZogtxHX9BaCgYKATASARMSFQEjDvL9n-EgWQwkiIgrrpQcqWE98w0163" \
-F "metadata={name :'/var/www/backup_medicina_legal.zip'};type=application/json;charset=UTF-8" \
-F "file=@/var/www/backup_medicina_legal.zip;type=application/zip" \
"https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
UPDATE wp_users SET user_nicename = CONCAT(LEFT(user_login, INSTR(user_login, '@')), '') WHERE ID = 0;
UPDATE wp_users SET user_login = CONCAT(LEFT(user_login, INSTR(user_login, '@')), 'example.test') WHERE ID = 0;
UPDATE wp_users SET user_email = CONCAT(LEFT(user_login, INSTR(user_login, '@')), 'example.test') WHERE ID > = 0;