Skip to content

Instantly share code, notes, and snippets.

@kalenjordan
kalenjordan / gist:3901671
Created October 16, 2012 20:11
Find and mass replace, Find and delete
# Delete backup files
find . -name "*.bak" -exec rm {} \;
# Find and mass replace. It creates .bak files, but without the .bak this doesn't work in OSX
find . -exec sed -i.bak s/Find/Replace/g {} \;
# find and replace
ack -l 'Find' | xargs perl -pi -E 's/Find/Replace/g'
# Create the directory
cd ~ && mkdir bin
cd ~/bin
# Install composer
curl -s https://getcomposer.org/installer | php
# Clone the repo
git clone [email protected]:kjordan/magerun.git magerun
@kalenjordan
kalenjordan / Batched Iterator for Magento collections
Last active May 9, 2022 12:25
Batched iterator for Magento collections
// This is how you would use it. Pass in your collection
// along with an individual callback as well as a batch callback
Mage::getSingleton('stcore/resource_iterator_batched')->walk(
$collection,
array($this, 'batchIndividual'),
array($this, 'batchAfter'),
self::BATCH_SIZE
);
public function batchIndividual($model)
@kalenjordan
kalenjordan / gist:6731541
Last active December 24, 2015 02:38
Unique 404's
grep "HTTP\/...\" 404" nginx-access.log | awk '{ print $16}' | sort | uniq
@kalenjordan
kalenjordan / mass-copyright-replace.sh
Last active December 24, 2015 07:49
Change copyright from 2013 to 2012
@kalenjordan
kalenjordan / autoloader-benchmark.php
Last active December 25, 2015 00:49
Autoloading benchmark - loads ~1k classes in order to benchmark the autoloader. I've used this to compare with and without the AOE ClassPathCache autoloader.
<?php
require_once(dirname(__FILE__) . '/../app/Mage.php');
Mage::app('admin');
$classesRaw = file_get_contents(dirname(__FILE__) . '/data/classes.txt');
$classes = explode("\n", $classesRaw);
echo "Loading " . count($classes) . " classes\r\n";
<?xml version="1.0"?>
<config>
<sections>
<system>
<groups>
<backup>
<fields>
<maintenance>
<comment>supercalifrag</comment>
</maintenance>
@kalenjordan
kalenjordan / gist:7827914
Created December 6, 2013 16:39
Addon product

I'm trying to figure out what the best way is to implement what I'm calling an "addon product".

The way it works is that when a customer adds the Essentials Shakes to their cart, we want to prompt them to add a Shaker Bottle (it's like a bottle that makes it easy to make shakes) to their order as well for $5.

I would have used a grouped product for this, but you can't combine configurable and grouped products, plus there are issues with subscription orders as well.

So what I'm leaning towards now is maybe a modal that pops up after they add the Essentials to their cart which prompts them to add this other product to their cart.

Somebody has to have run into this use case before.

@kalenjordan
kalenjordan / gist:7936461
Created December 12, 2013 22:09
Gmail images
Gmail: Hey, we're caching images now, it's more secure b/c suckas can't inject nastiness on you.
JS: Liars! You're totally making it sound like you're improving privacy by no longer allowing email marketers to track opens using images.
Gmail: But....all we said was we're improving security
JS: Now that's just splitting hairs!