Skip to content

Instantly share code, notes, and snippets.

View dfelton's full-sized avatar

Darren Felton dfelton

View GitHub Profile
@dfelton
dfelton / haversine.php
Last active September 21, 2018 13:38
Add Haversine formula to a Magento resource collection. Expects the collection to have 'lat' and 'lng' attributes in the main FROM table.
<?php
// Just add the following methods inside your existing resource collection class.
class ModuleNamespace_ModuleName_Model_Resource_EntityName_Collection
extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
/**
* Filters the collection to only include records within X miles of a specified
* latitude and longitude coordinates.
*
* Example (radius unit: mailes):
@dfelton
dfelton / 000 - Magento Installer Script Quick Reference Guide.md
Last active September 16, 2019 19:51
Magento - Quick Reference Guide for creating new attributes via an installer script for EAV and flat table entity types.
@dfelton
dfelton / 000 - Magento Layout XML Snippets
Created June 24, 2016 16:17
Quick Reference guide for common (or not so common) layout XML instructions.
Each file below refers to the layout handle it may typically apply to.
@dfelton
dfelton / 000 - robots.txt
Last active July 19, 2016 21:04
Magento Robots Boilerplate.
# Google Image Crawler Setup
User-agent: Googlebot-Image
Disallow:
# Crawlers Setup
User-agent: *
# Directories
Disallow: /app/
Disallow: /dev/
@dfelton
dfelton / 000 - Magento .gitignore
Last active May 10, 2021 22:42
.gitignore for Magento 1.9 projects
##
# Magento stuff.
##
downloader/.cache/*
downloader/cache.cfg
downloader/connect.cfg
maintenance.flag
media/*
media/**
var/*
@dfelton
dfelton / 000 - abstract.php
Last active June 29, 2016 18:37
Abstract shell class
<?php
/**
* Abstract shell class for non-magento sites.
*
* @category FirstScribe
* @package FirstScribe_Shell
* @author Darren Felton
*/
abstract class FirstScribe_Shell_Abstract
{
@dfelton
dfelton / 000 - TinyPNG Shell Script.md
Last active March 1, 2017 09:16
Shell script for compressing JPG and PNG images.
@dfelton
dfelton / magento_nginx.conf
Created July 13, 2016 18:02
nginx configurations for Magento store.
############################################
## Disallow PHP scripts in /media/ and /js/
location ^~ /media/ {
location ~ \.php$ {
return 403;
}
try_files $uri $uri/ =404;
expires 30d;
}
location ^~ /js/ {
@dfelton
dfelton / 000 - Installers.md
Last active July 4, 2019 22:18
Magento 1.9.X Installer scripts
@dfelton
dfelton / Magento 2 - tar exclusion parameters.MD
Last active March 27, 2024 10:45
Magento 2 - Directories to exclude when tarballing a site

Exclusion List

List of exclusion paramters for tar command. Focus put on image cache directories, tmp files, log files, and generated source files.

  • --exclude="./pub/media/*/*/cache"
  • --exclude="./pub/media/js"
  • --exclude="./pub/media/tmp"
  • --exclude="./pub/media/wysiwyg/.thumbs"