Skip to content

Instantly share code, notes, and snippets.

View fezfez's full-sized avatar
🏠
Working from home

Stéphane fezfez

🏠
Working from home
View GitHub Profile
@Majkl578
Majkl578 / ArbitraryRun.php
Last active September 10, 2018 12:26
typed factory
<?php
declare(strict_Types=1);
namespace Example;
(function () : void {
$requestFactory = new class implements ServerRequestFactory {
public function __invoke() : ServerRequest
{
@Ocramius
Ocramius / Caddyfile
Last active March 11, 2024 22:14
Example docker + docker-compose + caddy + traefik setup that routes to multiple apps from one exposed HTTP port
:80 {
root /serve
}
@michaelneu
michaelneu / Dockerfile
Last active October 17, 2022 05:37
docker-compose configuration for PHP with NGINX and MySQL, including sendmail, MailDev and phpmyadmin
# see https://github.com/cmaessen/docker-php-sendmail for more information
FROM php:5-fpm
RUN apt-get update && apt-get install -q -y ssmtp mailutils && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install mysql mysqli sysvsem
RUN pecl install xdebug-2.5.5 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@fredbenenson
fredbenenson / kickstarter_sql_style_guide.md
Last active October 14, 2025 15:32
Kickstarter SQL Style Guide
layout title description tags
default
SQL Style Guide
A guide to writing clean, clear, and consistent SQL.
data
process

Purpose

@Ocramius
Ocramius / find-missing-return-types.php
Last active September 5, 2018 10:27
Script to find classes/interfaces/traits with missing return types: ADD THEM TO YOUR SHIT.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$namespace = 'PutYourProjectNamespaceHere\\';
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/src')), '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH) as $file) {
require_once $file[0];
}
@cmerrick
cmerrick / bkadb-data-gen.sh
Last active December 19, 2022 03:31
Better Know a Database - Redshift Load Data Formats
#!/bin/sh
# OS: Ubuntu 14.01
# Generate data - produces about 200GB on disk, takes a while
DATADIR=tpch-dbgen
SCALE=1000
git clone https://github.com/electrum/tpch-dbgen.git
cd $DATADIR && make && ./dbgen -f -v -C 16 -S 1 -s $SCALE && cd -
@fezfez
fezfez / processIterator.php
Last active August 29, 2015 14:23
Iterate over process
<?php
class ProcessIterator implements Iterator
{
private $stream;
private $command;
private $iteration = 0;
public function __construct($command)
@denji
denji / nginx-tuning.md
Last active October 24, 2025 16:02
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

Proposal for a date system overhaul

The Problem

FullCalendar was initially designed without much notion of timezones. By default, it ignores timezone offsets in the dates it receives.

The original assumption was that if you received a date from Brussels, say "2013-09-01T12:00:00+02:00", which is noon, it would display as noon in every timezone.

However, FullCalendar shoehorns this value into a local date. With the same example, if you were in San Francisco, it internally stores the date as "2013-09-01T12:00:00-08:00". This is bad for two reasons:

@buddylindsey
buddylindsey / test.php
Last active January 7, 2016 21:19
Testing with PHPUnit_TextUI_TestRunner
<?php
require_once 'PHPUnit/Autoload.php';
use \PHPUnit_Framework_TestSuite;
use \PHPUnit_Framework_TestCase;
use \PHPUnit_TextUI_TestRunner;
class MyTestCase extends PHPUnit_Framework_TestCase {
public function testSubtraction() {