Skip to content

Instantly share code, notes, and snippets.

View ohvitorino's full-sized avatar

Bruno Pinto Vitorino ohvitorino

View GitHub Profile
@ohvitorino
ohvitorino / laravel-queue.service
Created April 26, 2024 09:34 — forked from thomasjsn/laravel-queue.service
Laravel queue worker using systemd.
# Laravel queue worker using systemd
# ----------------------------------
#
# /lib/systemd/system/queue.service
#
# run this command to enable service:
# systemctl enable queue.service
[Unit]
Description=Laravel queue worker
@ohvitorino
ohvitorino / ut8_to_utf8mb4_conversion.sql
Last active February 7, 2020 10:23
Generate ALTER statements to convert a database from utf8 to utf8mb4
use information_schema;
SELECT concat("ALTER DATABASE `",table_schema,"` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;") as _sql
FROM `TABLES` where table_schema like "database-name" group by table_schema;
SELECT concat("ALTER TABLE `",table_schema,"`.`",table_name,"` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") as _sql
FROM `TABLES` where table_schema like "database-name" group by table_schema, table_name;
SELECT concat("ALTER TABLE `",table_schema,"`.`",table_name, "` CHANGE `",column_name,"` `",column_name,"` ",data_type,"(",character_maximum_length,") CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci",IF(is_nullable="YES"," NULL"," NOT NULL"),";") as _sql
FROM `COLUMNS` where table_schema like "database-name" and data_type in ('varchar','char');

Symfony 4 - cookbook

Initial installation

composer create-project symfony/website-skeleton ~/Sites/client/project

composer req encore

Add to config/services.yaml

<?php
// Pre-load all locale files to have a cache
function loadOtherTranslations() {
$existingTranslations = [];
$iterator = new RecursiveDirectoryIterator('src');
/** @var \SplFileInfo $file */
foreach(new RecursiveIteratorIterator($iterator) as $file){
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
@ohvitorino
ohvitorino / translation_helper.php
Created February 3, 2018 20:20
ForkCMS translation helper.
<?php
$document = new DOMDocument();
$document->load($argv[1]);
$existingTranslations = [];
function getUserInput() {
return readline("\nTranslation PT: ");
}
@ohvitorino
ohvitorino / jekyll-and-liquid.md
Created January 8, 2018 08:05 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@ohvitorino
ohvitorino / curl_basic_auth.php
Created August 10, 2017 07:19
This a example of a curl request with basic authentication and x-www-form-urlencoded.
<?php
$curl = curl_init();
$header = [];
$header[] = 'Content-type: application/x-www-form-urlencoded';
// user:password in base64
$header[] = 'Authorization: Basic xxxxxx';
curl_setopt($curl, CURLOPT_URL, 'http://url/user/add');
@ohvitorino
ohvitorino / CreateProduct.php
Last active May 19, 2017 11:58
Generator for entities
<?php
namespace ProductsBundle\Command;
final class CreateProduct extends ProductDataTransferObject
{
}
@ohvitorino
ohvitorino / analysis.md
Last active September 6, 2016 14:18
Postgresql - Shared buffers analysis
CREATE EXTENSION pg_buffercache;
select usagecount, count(*), isdirty from pg_buffercache
group by isdirty, usagecount order by isdirty, usagecount;
usagecount | count  | isdirty