Skip to content

Instantly share code, notes, and snippets.

View f2r's full-sized avatar

Frederic Bouchery f2r

  • Rennes
View GitHub Profile
@f2r
f2r / generics-rfc.md
Created May 31, 2023 21:30
chatGPT prompt: create a PHP RFC for generics

Title: Generic Types and Type Parameters in PHP

  • Version: 1.0
  • RFC Type: Feature
  • Author: Your Name
  • Status: Draft

Introduction

The purpose of this RFC is to propose the addition of generic types and type parameters to the PHP language. Generics provide a powerful mechanism for writing reusable and type-safe code by allowing the definition of generic classes, interfaces, and functions that can operate on a variety of types.

@f2r
f2r / promises-rfc.md
Last active May 31, 2023 14:58
chatGPT 3.5 prompt: create a PHP RFC for promises

Title: Asynchronous PHP: Promises RFC

  • Version: 1.0
  • Date: 2023-05-31
  • Author: [Your Name]
  • Status: Draft
  • First Published at: [URL]

Introduction

This RFC proposes the addition of native promises to PHP, enabling developers to write asynchronous code in a more concise and readable manner. Promises are a well-established concept in other programming languages and can greatly simplify asynchronous programming, making it easier to manage and compose asynchronous operations.

@f2r
f2r / README.md
Last active October 1, 2020 18:01

Exercice de codage PHP

(date de fin du défit : 24 juin 2020 à minuit)

Vous disposez de 4 fichiers CSV contenant chacuns 2 colonnes : un index (unique et en ordre croissant) et une valeur.

Vous devez rassembler ces données dans un fichier CSV avec 5 colonnes :

  • index
  • valeur fichier data1
  • valeur fichier data2
@f2r
f2r / README.md
Last active December 17, 2021 09:23

Exercice PHP

Objectif:

Vous devez réaliser une commande en PHP qui prend en paramètre, un fichier CSV et génère un JSON.

Lors d'un live coding sur Twitch (https://www.twitch.tv/fredbouchery), je prendrai tout ou partie des codes réalisés pour les commenter et donner mon avis sur la réalisation qui me plait le plus. En fonction du nombre de réponses, je ferai peut-être plusieurs live.

Pour m'envoyer vos réalisations, contactez moi en DM sur twitter (https://twitter.com/fredbouchery/) avant le mercredi 22 avril 2020 à minuit.

<?php
function generatePassword(int $nbCharacters): string {
static $characters = [
'lower' => 'abcdefghijklmnopqrstuvwxyz',
'upper' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'number' => '0123456789',
'special' => '@#$%^&+=._-!',
];
// Password must have at least one character of each type
<?php
/**
* Classe permettant d'interagir avec un moteur de jeu
*/
final class Game
{
private const BASE_URL = 'https://code-challenge.webandcow.com';
private string $codeEngine;
<?php
require 'vendor/autoload.php';
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare("queue.test", false, true, false, false);
$channel->basic_publish(new \PhpAmqpLib\Message\AMQPMessage('unknow 1'), '', 'queue.test');
$channel->basic_publish(new \PhpAmqpLib\Message\AMQPMessage('ack 2'), '', 'queue.test');
$channel->basic_publish(new \PhpAmqpLib\Message\AMQPMessage('ack 3'), '', 'queue.test');