Skip to content

Instantly share code, notes, and snippets.

@keithgreer
keithgreer / magerun.txt
Last active April 11, 2018 13:55
n98-magerun Commands
___ ___
_ _/ _ ( _ )___ _ __ __ _ __ _ ___ _ _ _ _ _ _
| ' \_, / _ \___| ' \/ _` / _` / -_) '_| || | ' \
|_||_/_/\___/ |_|_|_\__,_\__, \___|_| \_,_|_||_|
|___/
n98-magerun version 1.101.1 by netz98 GmbH
Usage:
command [options] [arguments]
@keithgreer
keithgreer / logging-at-random-intervals-javascript.html
Last active April 11, 2018 13:55
Logging at random intervals in JavaScript
<!DOCTYPE html>
<html>
<body>
<script>
for (i = 0; i < 5; i++) {
(function() {
var j = i;
var x = Math.floor(Math.random() * 20000);
setTimeout(function () {
// Log Result of i (increment) and x (time)
@keithgreer
keithgreer / magento.txt
Created April 11, 2018 13:59
./mage Commands
Connect commands available:
===========================
channel-add Add a Channel
channel-alias Specify an alias to a channel name
channel-delete Remove a Channel From the List
channel-info Retrieve Information on a Channel
channel-login Connects and authenticates to remote channel server
channel-logout Logs out from the remote channel server
clear-cache Clear Web Services Cache
@keithgreer
keithgreer / privacy-popup.html
Created April 11, 2018 14:35
JavaScript and CSS framework independent cookie pop-up notification for legacy websites.
<!DOCTYPE html>
<html>
<body>
<!-- JavaScript and CSS framework independent cookie pop-up notification for legacy websites. -->
<div id="privacy-pop-up" style="display:none; position:fixed; z-index:9999; bottom:0; left:0; right:0; background:#dc143c; color:#fff; margin:1em; padding:0.5em; text-align:center; ">
<strong>Important information regarding cookies</strong><br>
By using this website, you consent to the use of cookies in accordance with our
<a href="/privacy-policy" style="text-decoration: underline; color:#fff">Privacy Policy</a>.<br>
<a id="exit-popup" style="background:#fff; color:#000; padding:0.25em 0.5em; margin:0.5em; cursor:pointer; font-weight:bold; font-size:90%; ">
@keithgreer
keithgreer / update-attribute-sets.php
Created April 14, 2018 22:47
Magento Code: Bulk add a new product attribute to all store attribute sets
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$attSet = Mage::getModel('eav/entity_type')->getCollection()->addFieldToFilter('entity_type_code','catalog_product')->getFirstItem();
$attSetCollection = Mage::getModel('eav/entity_type')->load($attSet->getId())->getAttributeSetCollection();
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
->setCodeFilter('**ATTRIBUTE CODE**')
->getFirstItem();
@keithgreer
keithgreer / seasonal-sales-link.php
Created April 14, 2018 22:49
Magento Code: Seasonal sales link
@keithgreer
keithgreer / .gitignore
Created April 3, 2019 10:59
Magento 1 .gitignore file
# Various IDE &#038; OS files that should never be committed
.DS_Store
*.swp
*.lock
__MACOSX
.idea
/nbproject/*
.project
.buildpath
.thumbs
@keithgreer
keithgreer / old.gitignore
Last active April 3, 2019 10:59
Old version of .gitignore for Magento
#---------------------------------------------------------------------#
# Magento Default Files #
# https://github.com/github/gitignore/blob/master/Magento.gitignore #
#---------------------------------------------------------------------#
/app/etc/local.xml
/media/*
!/media/.htaccess
@keithgreer
keithgreer / telephone-country-codes.php
Last active December 23, 2021 09:59
Mapping international dialing codes to ISO 3166-1 alpha-2 country codes - https://keithgreer.dev/global-payments-sca-3d-secure-2
/*
* Usage: $calling_codes['GB'] will return "44", the UK's dialing code.
*/
$calling_codes = [
'BD' => '880',
'BE' => '32',
'BF' => '226',
'BG' => '359',
'BA' => '387',
@keithgreer
keithgreer / numeric-country-code.php
Last active December 23, 2021 09:59
This code maps ISO 3166-1 alpha-2 country codes to their ISO 3166-1 numeric three-digit equivalents https://keithgreer.dev/global-payments-sca-3d-secure-2
/*
* Usage: $countries['GB'] will return "826", the UK's ISO 3166-1 numeric three-digit code.
*/
$countries = [
'AF' => '004',
'AX' => '248',
'AL' => '008',
'DZ' => '012',
'AS' => '016',