Skip to content

Instantly share code, notes, and snippets.

View petemcw's full-sized avatar

Pete McWilliams petemcw

View GitHub Profile
@petemcw
petemcw / brew-instructions.sh
Last active March 27, 2024 15:59
Setup dnsmasq on Mac OS X
# Install `dnsmasq` and configure for *.test domains
$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf
# Reload configuration and clear cache
$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ dscacheutil -flushcache
@petemcw
petemcw / 01-README.md
Last active February 2, 2024 11:50
Mac OS X LEMP Configuration

Mac OS X LEMP Configuration

This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.

Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.

Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup

Setup

@petemcw
petemcw / 01-SolrSetup.md
Last active January 18, 2020 03:45
Basic configuration steps for setting up Solr 3.x on CentOS/RHEL 6.4 -- specifically for use with Magento Enterprise

Installing Solr on CentOS/RHEL 6

From the Apache Software Foundation, "Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON, Ruby, and Python APIs, hit highlighting, faceted search, caching, replication, and a web administration interface." Magento has had built-in support for Solr since Enterprise verion 1.8.

The following instructions show how to complete a basic installation and configuration of Apache Solr for use with Magento Enterprise on CentOS/RHEL 6. These instructions the Java JDK with Tomcat rather than jetty.

Note: Solr should be on a dedicated server if possible, especially for large installations, as it can be resource intensive

Install Java JDK

@petemcw
petemcw / gist:2719758
Created May 17, 2012 15:53
Commands to clean a Ubuntu install for smaller Vagrant packages
# 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 December 3, 2011 16:41
Re-order Magento Categories Alphabetically
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`,
@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
@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 / 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: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 / 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