Skip to content

Instantly share code, notes, and snippets.

View marcguyer's full-sized avatar

Marc Guyer marcguyer

View GitHub Profile
@marcguyer
marcguyer / opensearch-serverless-migration.template.yaml
Created November 3, 2023 09:08
Cloudformation Template for Migration to AWS OpenSearch Serverless Collection
AWSTemplateFormatVersion: '2010-09-09'
Description: An EC2 instance used to run a logstash batch job
Parameters:
KeyName:
Description: Key pair for SSH access
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: Must be a valid EC2 key pair name
SecurityGroups:
Type: List<AWS::EC2::SecurityGroup::Id>
@marcguyer
marcguyer / RedirectMiddleware.php
Created September 8, 2023 17:07
PSR7 Middleware supporting OAuth2 redirect flows
<?php
declare(strict_types=1);
namespace MyAuth\Middleware;
use \RuntimeException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
@marcguyer
marcguyer / currency_codes.php
Created May 16, 2022 12:03
Currency Code List
<?php
$currencyCodes = [
'AED' => '784', // United Arab Emirates dirham United Arab Emirates
'AFN' => '971', // Afghan afghani Afghanistan
'ALL' => '008', // Albanian lek Albania
'AMD' => '051', // Armenian dram Armenia
'ANG' => '532', // Netherlands Antillean guilder Curaçao, Sint Maarten
'AOA' => '973', // Angolan kwanza Angola
'ARS' => '032', // Argentine peso Argentina
@marcguyer
marcguyer / CountryCodeFilter.php
Created May 16, 2022 11:48
Laminas Country Code Filter
<?php
declare(strict_types=1);
namespace Api\Filter;
use Laminas\Filter\FilterInterface;
use League\ISO3166\ISO3166;
use Throwable;
@marcguyer
marcguyer / Login.php
Last active November 15, 2023 01:18
Zend Framework V1 fix for TLS1.2 using Zend_Mail_Transport_Smtp
<?php
class My_Mail_Protocol_Smtp_Auth_Login extends My_Mail_Protocol_Smtp
{
/**
* LOGIN username
*
* @var string
*/
protected $_username;
@marcguyer
marcguyer / AbstractFunctionalTest.php
Last active February 9, 2020 10:56
Functional test abstract using phpunit, Expressive, Doctrine ORM, OAuth2, PSR7, PSR15
<?php
declare(strict_types=1);
namespace FunctionalTest;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
@marcguyer
marcguyer / AbstractInputFilterTest.php
Last active May 1, 2019 12:28
Zend Framework Input Validation with Dependencies
<?php
declare(strict_types=1);
namespace ApiTest\InputFilter;
use PHPUnit\Framework\TestCase;
use Zend\InputFilter\InputFilter;
@marcguyer
marcguyer / SubdomainToPathMiddleware.php
Created October 18, 2018 21:20
PSR-7 PSR-15 middleware to convert subdomain to base path
<?php
declare(strict_types=1);
namespace Api\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
@marcguyer
marcguyer / create_customer_example.php
Last active September 14, 2017 19:57
Create Customer Examples
<?php
$client->newCustomer([
'code' => 'TEST_CUSTOMER',
'firstName' => 'Example',
'lastName' => 'Customer',
'email' => 'example_customer@example.com',
'subscription' => [
'planCode' => 'PLAN_CODE'
]
]);
#!/usr/bin/env python
"""
Server Density Supervisord plugin.
Track the number of processes in each state.
For possible states see the docs at
http://supervisord.org/subprocess.html#process-states
"""