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 / 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');
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()
@JeroenBoersma
JeroenBoersma / NGINX - Magento 2 Static files optimization.md
Last active July 2, 2025 22:04
NGINX - Magento 2 Static files optimization

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.

@rishitells
rishitells / Jest_GitLab_CI.md
Last active October 8, 2025 15:13
Setting up Jest tests and coverage in GitLab CI

Configuring Jest Tests in GitLab CI

1. Add GitLab CI configuration file in the root

In the root of your project, add .gitlab-ci.yml with the configuration below.

image: node:latest

stages:
@moroz
moroz / application.ex
Created April 3, 2021 05:30
Automatically migrate Ecto database in release
defmodule MyApp.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@migrator if Mix.env() in [:prod, :staging], do: [MyApp.Migrator], else: []
def start(_type, _args) do
children =
@dianabotean
dianabotean / env.php
Created February 11, 2021 17:38
move open source queues to rabbit
[
(...)
'queue' => [
'amqp' => [
'host' => '<rabbitmq_host>',
'port' => '<rabbitmq_port>',
'user' => '<rabbitmq_user>',
'password' => '<rabbitmq_pass>',
'virtualhost' => '/',
'ssl' => false
@mAlishera
mAlishera / ecto_migration.exs
Created January 23, 2017 22:15
Composite primary key in Ecto
defmodule Messaging.Repo.Migrations.CreateGroupChatVersions do
use Ecto.Migration
def change do
create table(:group_chat_versions, primary_key: false) do
add :group_chat_id, :uuid, primary_key: true
add :version, :integer, primary_key: true
timestamps
end
@cupracer
cupracer / varnishlog-examples.sh
Last active September 13, 2024 15:57
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
@magnetikonline
magnetikonline / README.md
Last active August 27, 2025 06:08
Setting Nginx FastCGI response buffer sizes.