Skip to content

Instantly share code, notes, and snippets.

View nyamsprod's full-sized avatar
😴

ignace nyamagana butera nyamsprod

😴
View GitHub Profile
@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
declare(strict_types=1);
namespace League\Uri;
use Closure;
use Countable;
use Iterator;
use IteratorAggregate;
<?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
/**
* @template T
*/
class Maybe
{
/**
* @param T|null $value
*/
@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
declare(strict_types=1);
use League\Uri\UriTemplate;
use League\Uri\Components\Query;
require 'vendor/autoload.php';
$template = 'https://api.twitter.com/{version}/{?q*}';
<?php
function getReport(CarbonInterface $start, CarbonInterface $end): Report
{
return Report::query()
->whereDate('status_date', '>=', $start)
->whereDate('status_date', '<', $end)
}
@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;
@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 / geolocation-basic.php
Last active June 4, 2020 06:16
named-constructors to the rescue
<?php
declare(strict_types=1);
namespace Example;
final class Geolocation
{
private float $latitude;