Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
yuya-takeyama / fizzbuzz.php
Created January 23, 2011 18:07
FizzBuzz code golf.
<?for(;$i++<100;)echo $i%15?$i%5?$i%3?$i:Fizz:Buzz:FizzBuzz,"
";
@edulan
edulan / transpose.php
Created August 10, 2011 12:08
PHP matrix transpose using a functional approach
<?php
$matrix = array(
array('a', 1, 2),
array('b', 3, 4),
array('c', 5, 6),
array('d', 7, 8)
);
$transpose = array_reduce(
$matrix,
@jayelkaake
jayelkaake / Version.php
Created December 30, 2011 22:33
Magento version/edition helper for determining the Magento BASE version (regardless of edition) and adds functions to check if Enterprise, Professional or Community are being run.
<?php
/**
* Magento version/edition helper for determining the Magento BASE version (regardless of edition) and adds functions to check if Enterprise, Professional or Community are being run.
* Adds isMageCommunity(), isMageProfessional() and isMageEnterprise()
*
* @category TBT
* @package TBT_Rewards
* @author WDCA Sweet Tooth Team <contact@sweettoothhq.com>
*/
class TBT_Rewards_Helper_Version extends Mage_Core_Helper_Abstract {
@colinmollenhour
colinmollenhour / cleanCache.php
Created May 17, 2012 00:50
Simplified cache cleaning script for production updates.
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');
@ashsmith
ashsmith / actionsxml.xml
Created May 30, 2012 12:43
Magento 1.7.0.0 Dataflow Profile for Importing Product Images
<action type="dataflow/convert_parser_csv" method="parse">
<var name="delimiter"><![CDATA[,]]></var>
<var name="enclose"><![CDATA[]]></var>
<var name="fieldnames"></var>
<var name="map">
<map name="sku"><![CDATA[sku]]></map>
<map name="image"><![CDATA[image]]></map>
<map name="image_label"><![CDATA[image_label]]></map>
<map name="small_image"><![CDATA[small_image]]></map>
<map name="small_image_label"><![CDATA[small_image_label]]></map>
var ALPHA = 'abcdefghijklmnopqrstuvwxyz',
ALPHA_UPPER = ALPHA.toUpperCase(),
NUMERIC = '0123456789',
PUNCTUATION = '-!@£$%^&*()[]{}\'"/?.>,<;:\\|~`€#',
UNDERSCORE = '_',
WHITESPACE = '\x20\t\n\r\f\v\xa0\u2028\u2029\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff'; // thanks Mathias!
var SHORTHAND_CC = {
'\\S': ALPHA + ALPHA_UPPER + NUMERIC + PUNCTUATION + UNDERSCORE,
'\\s': WHITESPACE,
@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@SlexAxton
SlexAxton / updatechromium.sh
Last active December 15, 2015 02:49
add this function to your .zshrc or .bashrc file to update chromium to the latest nightly with a command.
updatechromium () {
Platform='unknown'
platform='unknown'
unamestr=`uname`
case "$unamestr" in
('Darwin') Platform="Mac"
platform="mac" ;;
('Linux') Platform="Linux"
platform="linux" ;;
(*) if [[ $# = 2 ]]
@Vinai
Vinai / fix-url-keys.php
Last active September 2, 2022 16:24
This fixes the duplicate url_key issue in a Magento 1.8 / 1.13 installation.
<?php
/**
* Drop this into the shell directory in the Magento root and run with -h to see all options.
*/
require_once 'abstract.php';
/**
* Fix duplicate url keys for categories and products to work with the 1.8 alpha1 CE url key constraints.
@Vinai
Vinai / 1.factory-methods.md
Last active July 6, 2021 05:25
Model & Resource Model Class Resolution Steps

Debugging (Resource) Model Instantiation

Follow each step manually and any bugs during (resource) model instantiation will become obvious.

Since many people find model and resource model instantiation to be one of the more challenging things in Magento 1, these are all the steps Magento does to resolve the factory name to the real PHP class name.

To debug, simply follow each step manually until you find a non-match. This works really well in my experience.
Less guessing, more and faster results.

In the examples I use a factory name of "example/thing".