Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
if (isset($_SERVER['REMOTE_ADDR'])) {
if ($_SERVER['REMOTE_ADDR'] == '1.1.1.1') { // Your IP-addrese
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 300'); //300 seconds
exit;
}
}
@magefast
magefast / magento
Created October 11, 2020 13:06 — forked from miped/magento
nginx + php-fpm magento setup
# /etc/nginx/sites-enabled/magento
server {
listen 80;
server_name ec2-184-72-68-219.compute-1.amazonaws.com;
root /var/www/magento/;
access_log /var/log/nginx/magento-access_log;
error_log /var/log/nginx/magento-error_log;
location / {
@magefast
magefast / ampify_img.php
Created September 3, 2020 20:46 — forked from elalemanyo/ampify_img.php
Make img AMP-ready
<?php
/**
* Replace img tag with amp-img
*
* <amp-img src="[src]"
* width="[width]"
* height="[height]"
* layout="responsive"
* alt="[alt]">
* </amp-img>
rffr
<?php if(!Mage::getSingleton('customer/session')->isLoggedIn()):
$groupPrice = $_product->getData('group_price');
if($groupPrice && is_array($groupPrice) && isset($groupPrice[1]) && isset($groupPrice[1]['price'])):
if($_product->getData('final_price') > floatval($groupPrice[1]['price'])): ?>
<div class="price-block-for-nonclient">
<span class="client-price">
@magefast
magefast / Install Composer using MAMP's PHP.md
Created July 3, 2020 13:13 — forked from irazasyed/Install Composer using MAMP's PHP.md
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@magefast
magefast / varnish-install.sh
Created June 18, 2020 10:21 — forked from atouchard/varnish-install.sh
Install Varnish on MacOSX via Homebrew
#!/bin/sh
#
# Install Varnish via Homebrew
#
# You need to add /usr/local/sbin in your PATH
# vcl files are in /usr/local/etc/varnish
#
# Usage :
@magefast
magefast / Csv.php
Created June 10, 2020 23:33 — forked from Nil79/Csv.php
Add mass action in Order Grid in Magento 2.2
<?php
namespace Vendor\ModuleName\Controller\Adminhtml\Export;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
@magefast
magefast / php-mamp-cli-with-alias.md
Created December 1, 2019 17:16 — forked from Irvyne/php-mamp-cli-with-alias.md
Use mamp php in cli (using an alias)

Use mamp php in cli (using an alias)

Open a terminal and type php -v to see the current version of php.

Determine the path for the wanted php version of mamp (YOUR VERSION ON YOUR COMPUTER!)

  • example : /Applications/MAMP/bin/php/php5.x.x/bin/php

Type in the terminal cd ~ to change the current directory (in your home)

@magefast
magefast / gist:6a78f9dd0bba4e1820a5a41aaf522636
Created November 27, 2019 09:45
Get Brands for Prom.ua form XML
<pre>
<?php
$ids = '900035163, 900024565, 900033949, 900030745, 900027462, 900048395, 900023229, 900027885';
$ids = explode(',',$ids);
$idsArray = array();
foreach ($ids as $id) {
$idsArray[trim($id)] = trim($id);
}
@magefast
magefast / Magento2 - get categories data
Created October 10, 2019 12:07
Magento2 - get categories data
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body>
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . './../app/bootstrap.php';
$params = $_SERVER;