Skip to content

Instantly share code, notes, and snippets.

@andybeak
andybeak / mov2mp4
Created August 11, 2021 16:15 — forked from cockok/mov2mp4
#!/bin/sh
BASENAME=$(basename $1)
ffmpeg -i $1 -s hd480 -c:v libx264 -crf 22 -c:a libfdk_aac -vsync passthrough ${BASENAME%.*}.mp4
@andybeak
andybeak / Dockerfile
Created September 4, 2020 11:19
Include xdebug in Dockerfile
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.
<?php
declare(strict_types=1);
namespace App\Common\Enum;
use ReflectionException;
use ReflectionClass;
use InvalidArgumentException;
<?php
declare(strict_types=1);
namespace App\Common\Enum;
use ReflectionException;
use ReflectionClass;
use InvalidArgumentException;
@andybeak
andybeak / TestBase.php
Created June 1, 2020 12:18
An attempt to try and test CodeIgnitor library
<?php
namespace Test;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionException;
class TestBase extends TestCase
{
@andybeak
andybeak / recreate_database.sh
Created May 13, 2020 16:03
Symfony recreate database
#!/bin/bash
echo "-----------------------------------------------------------------------------------------------"
echo " 💣This command will move your Migration PHP files to /tmp, drop the database, and recreate it"
echo "-----------------------------------------------------------------------------------------------"
read -r -p "Are you sure you want to do this? [y/N] " response
echo ""
if [[ "$response" =~ ^[Yy]$ ]]
then
mv ../src/Migrations/*.php /tmp
../bin/console doctrine:database:drop --force
@andybeak
andybeak / ExampleTest.php
Last active February 24, 2020 16:24
Test protected and private methods in PHPUnit
// -----------------------------------------------------------------------------------------------------------------
protected function getMethod($methodName, $object)
{
try {
$class = new \ReflectionClass(get_class($object));
$method = $class->getMethod($methodName);
$method->setAccessible(true);
return $method;
} catch (\ReflectionException $e) {
@andybeak
andybeak / create_certs_for_mysql.sh
Last active December 12, 2019 08:11
Create MySQL certificates
#!/bin/bash
# https://dev.mysql.com/doc/refman/5.7/en/creating-ssl-files-using-openssl.html
# Create clean environment
rm -rf newcerts
mkdir newcerts && cd newcerts
# Create CA certificate
# Use default values for everything except common name
openssl genrsa 2048 > ca-key.pem
@andybeak
andybeak / Dockerfile
Created December 4, 2019 10:02
Lab 4 - Laravel in ECS
FROM php:7.2-apache
COPY --chown=www-data:www-data . /var/www/html/
COPY Docker/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY Docker/php.ini-development /usr/local/etc/php/php.ini
WORKDIR /var/www/html/
@andybeak
andybeak / fingerscrossed.php
Created December 3, 2019 19:54
Monolog fingerscrossed handler
<?php
// composer require monolog/monolog
require('vendor/autoload.php');
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;