Skip to content

Instantly share code, notes, and snippets.

View MTheProgrammer's full-sized avatar

Matt Chad MTheProgrammer

View GitHub Profile
@MTheProgrammer
MTheProgrammer / asdf_install_php_ubuntu.sh
Last active February 14, 2025 08:19
Asdf PHP Magento
#!/usr/bin/bash
sudo apt -y install libsodium-dev libxslt1-dev
PHP_CONFIGURE_OPTIONS="--with-pgsql --with-openssl --with-sodium --with-xsl --with-iconv" \
asdf install php 8.3.8
@MTheProgrammer
MTheProgrammer / aws-docker.pkr.hcl
Last active August 14, 2024 19:18
Setup Docker on AWS EC2 with HashiCorp Packer
packer {
required_plugins {
amazon = {
version = ">= 1.0.0"
source = "github.com/hashicorp/amazon"
}
}
}
variable "aws_region" {
@MTheProgrammer
MTheProgrammer / schema_diff_check.php
Created December 4, 2023 06:24
Magento 2 schema upgrade differences check
<?php
// Forked from https://github.com/magento/magento2/issues/19597#issuecomment-671880440
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get(Magento\Framework\App\State::class);
$state->setAreaCode('adminhtml');
@MTheProgrammer
MTheProgrammer / elixir-best-practices.md
Last active April 10, 2023 16:05
Elixir Best Practices

Favor pattern matching over guards

Guards are powerful construct, but they increase complexity:

def pasta_recipe(eggs) when is_list(eggs), do: scramble(eggs)

With pattern matching the function definitions is shorter:

def pasta_recipe([_ | _] = eggs), do: scramble(eggs)

Introduction

Because Varnish doesn't support SSL, most people choose a setup where Nginx SSL will forward all traffic to Varnish and Varnish will forward will forward the traffic it cannot handle back to nginx. Or worse, bind Varnish on port 80 and direct all traffic into Varnish. This will already degrade performance, because Varnish will purge more because static files are also taking up room in the cache.

Default configuration

Next up, the Nginx configuration of Magento will handle static files.

Generate PHP8.1 data model class with constructor promoted properties named ${DTO_NAME} with fields extracted from this array keys:
[
"externalid" => $quoteItem->getItemId(),
"name" => $quoteItem->getName(),
"price" => $this->coreHelper->priceToCents($quoteItem->getPrice()),
"quantity" => $quoteItem->getQty(),
"sku" => $quoteItem->getSku(),
"description" => $quoteItem->getDescription(),
"imageUrl" => $imageUrl,
"productUrl" => $product->getProductUrl()
@MTheProgrammer
MTheProgrammer / Mac OS
Last active July 4, 2024 09:46
Instal php with asdf and postgres pdo
brew install libpq
PHP_CONFIGURE_OPTIONS="--with-pgsql --with-openssl --with-sodium --with-xsl --with-iconv=$(brew --prefix libiconv)" asdf install php 8.1.25
@MTheProgrammer
MTheProgrammer / symfony-6-tailwind.md
Created December 22, 2022 14:23
Chat gpt programming questions

Using Symfony 6 and Tailwind, refactor this into modern looking login form: Here place code snippet

<script>
const isActive = ref(true)
const error = ref(null)
const classObject = computed(() => ({
active: isActive.value && !error.value,
'text-danger': error.value && error.value.type === 'fatal'
}))
</script>