Skip to content

Instantly share code, notes, and snippets.

View nyamsprod's full-sized avatar
😎

Ignace Nyamagana Butera nyamsprod

😎
View GitHub Profile
@nyamsprod
nyamsprod / version3.php
Created February 23, 2022 08:22
evolution of Period string representation API
<?php
use League\Period\Period;
$period = new Period('2021-01-01', '2021-04-01');
echo $period; //displays 2021-01-01T00:00:00.000000Z/2021-04-01T00:00:00.000000Z
@nyamsprod
nyamsprod / csv2markdown.php
Last active May 21, 2022 19:45
Convert a CSV document into a Markdown document containing a table representing the original CSV
<?php
declare(strict_types=1);
use League\BooBoo;
use League\CLImate;
use League\Csv;
use League\Container;
use League\Flysystem;
use League\HTMLToMarkdown;
<?php
function getReport(CarbonInterface $start, CarbonInterface $end): Report
{
return Report::query()
->whereDate('status_date', '>=', $start)
->whereDate('status_date', '<', $end)
}
<?php
declare(strict_types=1);
use League\Uri\UriTemplate;
use League\Uri\Components\Query;
require 'vendor/autoload.php';
$template = 'https://api.twitter.com/{version}/{?q*}';
@nyamsprod
nyamsprod / calendar.php
Created February 18, 2023 15:19
Create a Calendar in PHP using League Period
<?php
declare(strict_types=1);
require 'autoload.php';
use League\Period\DatePoint;
use League\Period\Period;
/**
<?php
/**
* @template T
*/
class Maybe
{
/**
* @param T|null $value
*/
<?php
use League\Uri\Idna\Converter as IdnConverter;
use League\Uri\IPv4\Converter as Ipv4Converter;
echo IdnConverter::toAscii('bΓ©bΓ©.be')->domain(), PHP_EOL; //display "xn--bb-bjab.be"
echo Ipv4Converter::fromEnvironment()->toDecimal('192.87.125'); //display "192.87.0.125"
<?php
declare(strict_types=1);
namespace League\Uri;
use Closure;
use Countable;
use Iterator;
use IteratorAggregate;
@nyamsprod
nyamsprod / table-parsed.txt
Last active September 29, 2023 07:13
using Html Table to parse a bbc table
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”
β”‚ Team β”‚ P β”‚ W β”‚ D β”‚ L β”‚ F β”‚ A β”‚ GD β”‚ Pts β”‚ Rank β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€
β”‚ Man City β”‚ 6 β”‚ 6 β”‚ 0 β”‚ 0 β”‚ 16 β”‚ 3 β”‚ 13 β”‚ 18 β”‚ 1 β”‚
β”‚ Liverpool β”‚ 6 β”‚ 5 β”‚ 1 β”‚ 0 β”‚ 15 β”‚ 5 β”‚ 10 β”‚ 16 β”‚ 2 β”‚
β”‚ Brighton β”‚ 6 β”‚ 5 β”‚ 0 β”‚ 1 β”‚ 18 β”‚ 8 β”‚ 10 β”‚ 15 β”‚ 3 β”‚
β”‚ Tottenham β”‚ 6 β”‚ 4 β”‚ 2 β”‚ 0 β”‚ 15 β”‚ 7 β”‚ 8 β”‚ 14 β”‚ 4 β”‚
β”‚ Arsenal β”‚ 6 β”‚ 4 β”‚ 2 β”‚ 0 β”‚ 11 β”‚ 6 β”‚ 5 β”‚ 14 β”‚ 5 β”‚
β”‚ Aston Villa β”‚ 6 β”‚ 4 β”‚ 0 β”‚ 2 β”‚ 12 β”‚ 10 β”‚ 2 β”‚ 12 β”‚ 6 β”‚
β”‚ West Ham β”‚ 6 β”‚ 3 β”‚ 1 β”‚ 2 β”‚ 11 β”‚ 10 β”‚ 1 β”‚ 10 β”‚ 7 β”‚
<?php
/**
* @implements ArrayAccess<BackedEnum|array-key, mixed>
*/
class Foobar implements ArrayAccess
{
/**
* @param array<array-key, mixed> $members
*/