Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
@fhferreira
fhferreira / functions.php
Last active November 11, 2020 04:46
Helpers PHP
<?php
function minify_output($buffer){
$search = array('/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s');
$replace = array('>','<','\\1');
if (preg_match("/\<html/i",$buffer) == 1 && preg_match("/\<\/html\>/i",$buffer) == 1) {
$buffer = preg_replace($search, $replace, $buffer);
}
return $buffer;
}
@fhferreira
fhferreira / bench.php
Created October 23, 2020 21:21 — forked from BenMorel/bench.php
(Medium) BulkInserter benchmark
<?php
/**
* Benchmarks BulkInserter at various batch sizes.
*
* Before running this script, make sure to:
*
* - set your PDO parameters in this file
* - run composer install
* - import setup.sql into your database
@fhferreira
fhferreira / settimeout.php
Created October 12, 2020 18:28 — forked from edwjusti/settimeout.php
setTimeout for php
<?php
class TimeoutClass extends Thread {
public function __construct(callable $cb, int $time, $args){
$this->callback = $cb;
$this->args = $args;
$this->time = $time * 1000;
}
public function run(){
usleep($this->time);
<?php
namespace App\Casts;
use Carbon\Carbon;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class LocalizedDateTime implements CastsAttributes
{
/**
<?php
use Closure;
class RemoveEmoji
{
/**
* Clean not allowed UTF-8 chars
*
* @param $text
@fhferreira
fhferreira / Configurations for Laravel app on Kubernetes - Dockerfile
Created September 3, 2020 04:12 — forked from CodingMonkTech/Configurations for Laravel app on Kubernetes - Dockerfile
Deploying laravel on kubernetes cluster - Ready to use configuration Files
FROM php:7.2-fpm
COPY app /var/www/
EXPOSE 9000
artifacts:
when: on_failure
paths:
- tests/Browser/screenshots
@fhferreira
fhferreira / Install.sh
Created September 1, 2020 19:05 — forked from jeffturcotte/Install.sh
Laravel Mix / Echo Server / Docker / Traefik Examples
# clone repo
git clone https://github.com/imarc/laravel-echo-example
cd laravel-echo-example
# install php dependencies
composer install
composer run-script install-tasks
# install npm dependencies and build
npm install
@fhferreira
fhferreira / watch.php
Created August 28, 2020 20:15 — forked from leocavalcante/watch.php
Watch script for Swoole HTTP server restarts.
<?php declare(strict_types=1);
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\Process\Process;
$process = new Process(['php', 'index.php']);
echo "Starting process\n";
$process->start();
<?php
/**
alfabeto fonético internacional
Definição1
Alfabeto para fins aeronáuticos, que se destina a padronizar o processo de soletrar certas expressões.
Fonte1
BRASIL. Comando da Aeronáutica. Departamento de Controle do Espaço Aéreo. CNS/ATM Glossário. Disponível em: http://www.decea.gov.br/cnsatm/glossario. Acesso em: 14 mar. 2012. (texto adaptado)
Nota adicional1
Este alfabeto encontra-se normatizado pela Organização de Aviação Civil Internacional - OACI e pela legislação brasileira, de acordo com a seguinte correspondência: A – Alfa B – Bravo C – Charlie D – Delta E – Echo F – Foxtrot G – Golf H – Hotel I – India J – Juliett K – Kilo L – Lima M – Mike N – November O – Oscar P – Papa Q – Quebec R – Romeo S – Sierra T – Tango U – Uniform V – Victor W – Whiskey X – X-Ray Y -Yankee Z – Zulu