Skip to content

Instantly share code, notes, and snippets.

Avatar

Pete McWilliams petemcw

View GitHub Profile
View .my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#
# Include all files from the config directory
#
@petemcw
petemcw / local.xml
Last active Aug 29, 2015
Basic Magento Redis Configuration
View local.xml
<?xml version="1.0"?>
<!--
/**
* Magento Enterprise Edition
*
* NOTICE OF LICENSE
*
* This source file is subject to the Magento Enterprise Edition End User License Agreement
* that is bundled with this package in the file LICENSE_EE.txt.
* It is also available through the world-wide-web at this URL:
@petemcw
petemcw / .gitignore
Created Dec 16, 2010
What to ignore from Magento in Git
View .gitignore
# Magento Connect 2 cache directories and files
downloader/pearlib/cache/
downloader/*.cfg
# Magento runtime media files
media/catalog/product/cache/
media/tmp/
media/js/
media/css/
media/.thumbs/
@petemcw
petemcw / key_generator.rb
Created Apr 27, 2011
Random Key Generator
View key_generator.rb
class KeyGenerator
require "digest/sha1"
def self.generate(length = 12)
Digest::SHA1.hexdigest(Time.now.to_s + rand(567891234).to_s)[1..length]
end
end
@petemcw
petemcw / gist:1165317
Created Aug 23, 2011
Command-line Magic
View gist:1165317

Regular Expressions

Not only useful in programming, regular expressions can make complex tasks easy in many different scenarios. Here is a great site for testing your regex:

http://rubular.com

General Shell

Run the previous command again

@petemcw
petemcw / vhost.conf
Created Aug 31, 2011
Sample Apache vhost Configuration File
View vhost.conf
<VirtualHost *:80>
DocumentRoot "/path/to/web/files/"
ServerAdmin webmaster@localhost
ServerName localhost
#SetEnv MAGE_IS_DEVELOPER_MODE true
#SetEnv MAGE_RUN_CODE storecode
#SetEnv MAGE_RUN_TYPE website
<Directory "/path/to/web/files/">
@petemcw
petemcw / gist:1201928
Created Sep 7, 2011
MySQL user creation
View gist:1201928
GRANT USAGE ON *.* TO `user`@`localhost` IDENTIFIED BY 'password';
GRANT CREATE ROUTINE, CREATE VIEW, ALTER, SHOW VIEW, CREATE, ALTER ROUTINE, INSERT, SELECT, DELETE, UPDATE, DROP, LOCK TABLES, CREATE TEMPORARY TABLES, INDEX ON `database`.* TO `user`@`localhost` IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
@petemcw
petemcw / svn2git.sh
Created Sep 23, 2011
Script to build an "authors" template file for migrating Subversion repo to Git
View svn2git.sh
#!/usr/bin/env bash
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
for author in ${authors}; do
echo "${author} = NAME <USER@DOMAIN>";
done
@petemcw
petemcw / gist:2719758
Created May 17, 2012
Commands to clean a Ubuntu install for smaller Vagrant packages
View gist:2719758
# Remove items used for building, since they aren't needed anymore
apt-get clean
apt-get -y remove linux-headers-$(uname -r) build-essential
apt-get -y autoremove
# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
# Removing leftover leases and persistent rules
@petemcw
petemcw / gist:1427528
Created Dec 3, 2011
Re-order Magento Categories Alphabetically
View gist:1427528
SET @position = 0;
SET @last_parent = 0;
SET @last_level = 0;
DROP TABLE IF EXISTS `cce_new_position`;
CREATE TEMPORARY TABLE `cce_new_position`
SELECT
`new`.`entity_id` AS `entity_id`,
`new`.`parent_id` AS `parent_id`,
@last_parent := CAST(`new`.`parent_id` AS UNSIGNED) AS `new_parent_id`,
`new`.`name` AS `name`,