Skip to content

Instantly share code, notes, and snippets.

@odan
odan / splitting-pdf.md
Last active March 25, 2023 11:26
Spliting a PDF file into multiple PDF files

Spliting a PDF file into multiple PDF files

This function extracts all of the pages from a larger PDF file into single-page PDF files.

Installation

composer require setasign/fpdi-fpdf

Remove HTML tags

<?php

$html = '<div class="cc">
    Explore the use of simple 
    <a class="keyword_w_elaboration">technologies</a>
    <div class="elaboration" style="text-decoration:none">
 
@odan
odan / slim4-cors-with-preflight-request.md
Last active May 18, 2020 21:01
Slim 4 - CORS with preflight request
@odan
odan / mock-ramsey-uuid.md
Last active February 16, 2022 16:53
Mock Ramsey\Uuid

Mock Ramsey\Uuid

The mock trait

<?php

namespace App\Test\Traits;

use Ramsey\Uuid\Generator\RandomGeneratorInterface;
@odan
odan / mock-flysystem-with-vfsStream.md
Last active July 2, 2020 12:02
Creating a mocked local filesystem adapter with vfsStream

Creating a mocked local Flysystem adapter with vfsStream

Note: In this example I doesn't use the flysystem Memory or Null adpater, because the Memory adapter doesn't implement the getPathPrefix method, like the AbstractAdapter does. For this reason I use the Local adapter in LOCK_NB mode in combination with vfsStream to simulate the filesystem in-memory.

Setup

composer require mikey179/vfsstream --dev
@odan
odan / twitter-images.md
Last active March 25, 2023 11:26
Twitter images

Twitter Images (2020)

  • Header photo: 1500 x 500 px

  • Profile photo: 400 x 400 px

  • Tweet image: Recommended: 1200 x 628

  • Image types include: JPG, GIF or PNG.

Source

@odan
odan / Slim 4 Tutorial.md
Last active January 15, 2022 11:22
Slim 4 Tutorial
@odan
odan / mysq_uuid_v4.md
Last active January 12, 2024 01:11
Generating UUID v4 in MySQL

Generating UUID v4 in MySQL

SELECT
  LOWER(
    CONCAT(
      # 1th and 2nd block are made of 6 random bytes
      HEX(RANDOM_BYTES(4)),
      '-',
 HEX(RANDOM_BYTES(2)),
@odan
odan / nginx-php-windows-setup.md
Last active April 23, 2024 05:23
Nginx and PHP Setup on Windows

Nginx and PHP Setup on Windows

For local development you could also use Nginx with PHP as an replacement for XAMPP.

Install Nginx