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
@fmasanori
fmasanori / super salários USP.py
Created July 4, 2017 23:27
Super Salários USP
"""
Autores:
Tiago Henrique da Cruz Pereira
João Felipe de Moraes Borges
"""
import threading
import time
import os
from urllib.request import urlopen
@edwjusti
edwjusti / settimeout.php
Created April 27, 2017 17:28
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);
@CMCDragonkai
CMCDragonkai / PDOMySQL.php
Last active July 14, 2023 15:46
PDO Wrappers #php #mysql
<?php
/**
* This wraps PDO, and exposes a PDO class.
* It ends up as a drop-in replacement for MySQL-specific PDO classes.
* This improves the transaction handling and enables extra capabilities specific to MySQL.
* TODO:
* Connection pooling (this is required for event-loop applications).
* Multi-connection queries (to avoid conflicts during PDO streaming queries).
* Transactional RAII.
@jdeathe
jdeathe / php-cachetool-usage.md
Last active January 11, 2023 23:46
How to Clear PHP Opcache without Restarting PHP-FPM.

PHP CacheTool - Manage cache in the CLI

Use CacheTool to view stats for and manage PHP's APC or Zend Opcache opcode cache.

Using CacheTool you can clear the PHP opcache without reloading PHP-FPM.

In this example, CacheTool is to be installed alongside a demonstration PHP-FPM Docker container.

Prerequisites

@mustafaturan
mustafaturan / network-tweak.md
Last active March 27, 2025 17:28
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@felipecsl
felipecsl / code-of-conduct.md
Last active November 17, 2023 23:34
Brazil Tech Expats Slack group Code of Conduct

Código de Conduta

O Brazil Tech Expats se esforça para criar um espaço confortável para todos os membros da nossa comunidade em crescimento. Nós acreditamos em respeito, compaixão, compreensão e inclusão, e esperamos que todos os membros da comunidade se comportem em concordância com estes valores.

Não toleramos qualquer espécie de assédio. Qualquer pessoa que for identificada participando de comportamentos de assédio será contactada por uma pessoa da administração, que solicitará a interrupção de quaisquer atividades inapropriadas ou que a pessoa se desligue imediatamente da nossa comunidade.

Assédio inclui, mas não se limita a:

  • Comentários ofensivos sobre a identidade de uma pessoa;
  • Comentários indesejados sobre as escolhas e práticas de estilo de vida de uma pessoa;
@cviebrock
cviebrock / ElasticLoggingProvider.php
Created September 29, 2016 14:57
Log Laravel to Elastic/Logstash
<?php namespace App\Providers;
use Elastica\Client;
use Illuminate\Support\ServiceProvider;
use Monolog\Formatter\LogstashFormatter;
use Monolog\Handler\ElasticSearchHandler;
class ElasticLoggingProvider extends ServiceProvider
{
@guilhermeblanco
guilhermeblanco / debug-fpm-segfaut.md
Created June 8, 2016 15:59
Debugging PHP-FPM segfaults

Assuming PHP is compiled with debug enabled.

$ gdb /usr/sbin/php-fpm

Then:

r --nodaemonize --fpm-config /etc/php7/fpm/php-fpm.conf
function telefone_validation(telefone) {
//retira todos os caracteres menos os numeros
telefone = telefone.replace(/\D/g, '');
//verifica se tem a qtde de numero correto
if (!(telefone.length >= 10 && telefone.length <= 11)) return false;
//Se tiver 11 caracteres, verificar se começa com 9 o celular
if (telefone.length == 11 && parseInt(telefone.substring(2, 3)) != 9) return false;
@guiwoda
guiwoda / AR_Cache_Repository.php
Last active February 25, 2023 21:11
AR (Eloquent) vs DM (Doctrine) gist
<?php
namespace App\ActiveRecord;
class PostRepository
{
private $cache;
public function __construct(Cache $cache)
{
// Any set() / get() cache implementation.