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
@rdehnhardt
rdehnhardt / api.dart
Last active August 16, 2023 08:36
Flutter App with Laravel Sanctum (XSRF TOKEN)
import 'package:dio/dio.dart';
import 'package:curl_logger_dio_interceptor/curl_logger_dio_interceptor.dart';
import 'interceptors/csrf_token_interceptor.dart';
class Api {
final Dio dio;
Api(this.dio) : super() {
dio.interceptors.addAll([
@ulcuber
ulcuber / RetryAllFailedJobsCommand.php
Created October 26, 2022 15:34
Laravel Horizon. Retry all of the failed jobs like one in the horizon dashboard
<?php
namespace App\Console\Commands\Horizon;
use Illuminate\Console\Command;
use Illuminate\Queue\Failed\FailedJobProviderInterface;
use Laravel\Horizon\Contracts\JobRepository;
use Laravel\Horizon\Jobs\RetryFailedJob;
class RetryAllFailedJobsCommand extends Command
<?php
Builder::macro('deferredPaginate', function ($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) {
$model = $this->newModelInstance();
$key = $model->getKeyName();
$table = $model->getTable();
$paginator = $this->clone()
// We don't need them for this query, they'll remain
// on the query that actually gets the records.
@tabacitu
tabacitu / .php-cs-fixer.dist.php
Created September 3, 2021 06:27
PHP-CS-Fixer Configuration File for the Laravel Code Style
<?php
/**
-----------------------------------------------------
Enforce the Laravel Code Style using PHP CS Fixer 3.x
-----------------------------------------------------
Credits go to Laravel Shift & Andreas Elia.
https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
@fhferreira
fhferreira / network-tweak.md
Created July 28, 2021 04:03 — forked from mustafaturan/network-tweak.md
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'
<?php
// Nodes.
abstract class Node implements Visitable {}
class Number extends Node {
public function __construct(public float $value){}
public function accept(Visitor $visitor) {
return $visitor->visitNumber($this);
}
@prologic
prologic / LearnGoIn5mins.md
Last active April 22, 2024 13:28
Learn Go in ~5mins
@derickr
derickr / bench-rdp.php
Created June 27, 2020 09:50
PHP RDP Simplify Benchmark
<?php
$rounds = (int) $argv[1];
$callback = 'rdp_simplify';
if (! function_exists( $callback ) )
{
include 'rdp.php';
$callback = [ 'RDP', 'simplify' ];
}
@evansims
evansims / Dockerfile
Last active February 14, 2024 10:09
Dockerfile: php-fpm 7.4-fpm alpine w/ gd bz2 intl mbstring redis mongodb xdebug opcache
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Install essential build tools
RUN apk add --no-cache \
git \
yarn \
autoconf \
g++ \
make \