Skip to content

Instantly share code, notes, and snippets.

Create a file called abstract.php and place it in your root Magento folder:

abstract.php
<?php
use \Magento\Framework\AppInterface as AppInterface;
use \Magento\Framework\App\Http as Http;

use Magento\Framework\ObjectManager\ConfigLoaderInterface;
use Magento\Framework\App\Request\Http as RequestHttp;

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.

@peterjaap
peterjaap / varnish6.vcl
Last active September 19, 2025 13:18
Updated Magento 2 Varnish 6 VCL, in cooperation with Varnish Software, see Xkey soft purge version here; https://gist.github.com/peterjaap/7f7bf11aa7d089792e8fcc2fb34760fa
# A number of these changes come form the following PR's; , combines changes in https://github.com/magento/magento2/pull/29360, https://github.com/magento/magento2/pull/28944 and https://github.com/magento/magento2/pull/28894, https://github.com/magento/magento2/pull/35228, https://github.com/magento/magento2/pull/36524, https://github.com/magento/magento2/pull/34323
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
# See the Xkey version here: https://gist.github.com/peterjaap/7f7bf11aa7d089792e8fcc2fb34760fa
vcl 4.1;
import std;
# The minimal Varnish version is 6.0
# For SSL offloading, pass the following header in your proxy server or load balancer: '/* {{ ssl_offloaded_header }} */: https'
@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.

@coresh
coresh / parse_csv_file.php
Created January 5, 2022 19:39 — forked from m-manu/parse_csv_file.php
Useful CSV Parser for PHP 5.2
<?php
/*
Copyright (c) 2013, Manu Manjunath
All rights reserved.
Redistribution and use of this program in source/binary forms, with or without modification are permitted.
Link to this gist is preferred, but not a condition for redistribution/use.
*/
function parse_csv_file($csvfile) {
@tegansnyder
tegansnyder / Magento 2 Programmatically Ship an Order with Tracking Details outside of Magento.md
Created March 29, 2021 04:39
Magento 2 Programmatically Ship an Order with Tracking Details outside of Magento

Create a file called abstract.php and place it in your root Magento folder:

abstract.php
<?php
use \Magento\Framework\AppInterface as AppInterface;
use \Magento\Framework\App\Http as Http;

use Magento\Framework\ObjectManager\ConfigLoaderInterface;
use Magento\Framework\App\Request\Http as RequestHttp;
@Behinder
Behinder / gist:166bf67259268caa98675c849ecf0395
Created April 18, 2020 15:27
Increment and decrement float in PHP
function incrementFLoat($float){
echo $float."\n";
$decimal = strlen(strrchr($float, '.')) -1;
$factor = pow(10,$decimal);
$incremented = (($factor * $float) + 1) / $factor;
return $incremented;
}
function decrementFLoat($float){
// get amount of decimals
@greenmoss
greenmoss / certbot-dns-mailcow
Last active April 13, 2025 10:34
This script renews letsecnrypt SSL certificates using Cloudflare dns-1 renewal. It assumes you are using Mailcow.
#!/usr/bin/env bash
# This script renews letsecnrypt SSL certificates using Cloudflare dns-1 renewal
# It assumes you are using Mailcow
set -euo pipefail
# REQUIRED set these:
your_email=letsencrypt@your.domain
your_domain=mail.your.domain # only tested with single domain
cloudflare_ini_path=/root/.cloudflare # add your Cloudflare file here, called cloudflare.ini
@sahil-patel6
sahil-patel6 / passwordGenerator.c
Last active June 8, 2025 16:57
Password Generator Using C Language
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
char passwordType[1];
int generateRandomNumbers();
char password[512];
@aprivette
aprivette / binance-calc
Created December 10, 2017 23:04
A bash script to help you set limit orders on Binance (cryptocurrency exchange). Takes a coin ID and a target price in USD as input.
#!/bin/bash
# Binance Calculator
# Created by Adam Privette (https://github.com/aprivette)
#
# Intended to help set limit buy/sell orders on Binance by providing metrics on a target price.
# Retrieves current USD value of the coin, projected BTC value of the coin based on target price, and offset percentage of the target price
# Example usage: binance-calc IOTA 4.53
# Check for arguments
if [ -z "$2" ]; then