Skip to content

Instantly share code, notes, and snippets.

View petemcw's full-sized avatar

Pete McWilliams petemcw

View GitHub Profile
@petemcw
petemcw / .gitignore
Created December 16, 2010 18:24
What to ignore from Magento in Git
# 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 / my.cnf
Created February 25, 2011 20:11
Ubuntu MySQL 5.1 Configuration - 4GB RAM, Heavy InnoDB
# The MySQL database server configuration file.
#
# DESC: InnoDB mainly, heavy queries, fewer connections, 4GB RAM
#
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
@petemcw
petemcw / key_generator.rb
Created April 27, 2011 15:16
Random Key Generator
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 / default.vcl
Created May 22, 2011 02:20
Lullabot's Custom Varnish VCL File
#
# Customized VCL file for serving up a Drupal site with multiple back-ends.
#
# For more information on this VCL, visit the Lullabot article:
# http://www.lullabot.com/articles/varnish-multiple-web-servers-drupal
#
# Define the internal network subnet.
# These are used below to allow internal access to certain files while not
# allowing access from the public internet.
@petemcw
petemcw / magento_sql_snippets.md
Created July 21, 2011 19:41
Magento SQL Snippets

Magento SQL Snippets

Clear Temporary Data Tables

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
@petemcw
petemcw / gist:1165317
Created August 23, 2011 14:48
Command-line Magic

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 / gist:1169053
Created August 24, 2011 20:06 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@petemcw
petemcw / vhost.conf
Created August 31, 2011 14:33
Sample Apache vhost Configuration File
<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 September 7, 2011 22:04
MySQL user creation
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 September 23, 2011 15:56
Script to build an "authors" template file for migrating Subversion repo to Git
#!/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