Skip to content

Instantly share code, notes, and snippets.

@udovicic
udovicic / INSTRUCTIONS.md
Last active January 6, 2021 19:16
Instructions for setting up Magento 2 code analysis with PHPSTorm

Setting up MEQP Coding standard checks in PHPStorm

Overview

In order to submit extensions to Magento marketplace, source code needs to pass Magento Extension Quality Program Coding Standard checks.

You can either do it manually, by following this guide in official Github repository, or by fixing things as you code, by setting up check in PHP Storm.

Install and configure Code Sniffer on system

#!/bin/bash
function get_project_handle ()
{
local project_handle=${PWD##*/};
echo ${project_handle}
}
if ! grep -q "www.$(get_project_handle).loc" /etc/hosts; then
@udovicic
udovicic / setup-oci8.sh
Created December 27, 2021 09:59
OCI8 installation on ubuntu Ubuntu 18.04.5 LTS running PHP 7.4 from ondrej PPA
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Download the Oracle Instant Client and SDK from Oracle website
mkdir /opt/oracle
cd /opt/oracle/
@udovicic
udovicic / di.xml
Created September 14, 2023 11:29
Magento 2 maintenance IPs when site is behind proxy
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- ... -->
<!-- Inside di.xml, place the following -->
<!-- Restore original visitor IP from CloudFlare header -->
<type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
<arguments>
<argument name="alternativeHeaders" xsi:type="array">
<item name="http_cf_connecting_ip" xsi:type="string">HTTP_CF_CONNECTING_IP</item>
@udovicic
udovicic / ocp.php
Created February 1, 2024 07:20 — forked from ck-on/ocp.php
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@udovicic
udovicic / ray-trace.py
Created February 8, 2025 12:04
Sample ray trace using python
import numpy as np
import pygame
import time
# Define screen dimensions
WIDTH, HEIGHT = 1024, 768
# Define colors
LIGHT_COLOR = np.array([1, 1, 1])