Skip to content

Instantly share code, notes, and snippets.

View cgdangelo's full-sized avatar

Charles D'Angelo cgdangelo

View GitHub Profile
@cgdangelo
cgdangelo / gist:8834735
Created February 5, 2014 22:36
faking Magento requests
<?php
$_SERVER['HTTP_HOST'] = 'magento.local';
require 'app/Mage.php';
umask(0);
$request = new Mage_Core_Controller_Request_Http('http://magento.local/guitars-basses');
Mage::run('', 'store', array('request' => $request));
@cgdangelo
cgdangelo / mage-scan.sh
Created March 8, 2012 21:19
Find insecure Magento websites
#!/bin/bash
if [ -e "$1" ]; then
dataset=$(cat $1)
elif [ ! -z $1 ]; then
dataset=$@
else
exit 1
fi
@cgdangelo
cgdangelo / git-iclean.sh
Created April 4, 2012 18:27
Interactive git-clean
#!/bin/sh
GC_OPTS=$@
for item in `git clean $@ | grep -v git-iclean | grep "Would remove" | cut -d' ' -f 3`; do
rm -ir $item
done
@cgdangelo
cgdangelo / gist:2956737
Created June 19, 2012 21:49
Compare customized layout to default
#!/bin/sh
# Run from /docroot/app/design/[adminhtml|frontend|install]/[package]/[theme]
vimdiff ../../base/default/${1} ${1}
<?php
require 'app/Mage.php';
umask(0);
Mage::app();
$attribute = Mage::getModel('catalog/entity_attribute')->loadByCode(
Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(),
'tiger_cost'
);
@cgdangelo
cgdangelo / gist:3219998
Created July 31, 2012 20:02
Interactively delete untracked files
for i in `git ls-files --other --exclude-standard`; do rm -ir $i; done
@cgdangelo
cgdangelo / output
Created August 22, 2012 15:43
wat?
<?php
class X_TigerEDI_Model_Observer_850 extends X_TigerEDI_Model_Observer
{
protected $_ediID = 850;
private $_ediFiles = array();
/**
@cgdangelo
cgdangelo / gist:3495542
Created August 28, 2012 06:35
Magento Rakefile with some basic, common tasks
current_path = File.dirname(__FILE__)
parent_path = File.dirname(current_path)
project = File.basename(current_path)
namespace :mage do
desc 'Clear the Magento cache.'
task :cc do
sh %{cd #{current_path} && rm -rf var/cache/*}
end
@cgdangelo
cgdangelo / gist:3498364
Created August 28, 2012 14:12
lol, magento
<?php
/* @var $tree Mage_Catalog_Model_Resource_Category_Tree */
$tree = Mage::getResourceModel('catalog/category_tree');
/* 594 = 616, 597 = 856 */
$storeCategories = $this->getStoreCategories();
$storeCategories->delete($storeCategories->searchById(594));
$storeCategories->delete($storeCategories->searchById(597));
$node = $tree->loadNode(616);
@cgdangelo
cgdangelo / .gitignore
Created October 5, 2012 17:06
Magento .gitiginore
var/*
media/*
pkginfo/*
config/*
app/etc/local.xml
includes/*
Capfile
.idea/*
.DS_Store
*.*~