Skip to content

Instantly share code, notes, and snippets.

Avatar

Pete McWilliams petemcw

View GitHub Profile
@petemcw
petemcw / brew-instructions.sh
Last active May 29, 2021
Setup dnsmasq on Mac OS X
View brew-instructions.sh
# Install `dnsmasq` and configure for *.dev 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 May 15, 2021
Mac OS X LEMP Configuration
View 01-README.md

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 Jan 18, 2020
Basic configuration steps for setting up Solr 3.x on CentOS/RHEL 6.4 -- specifically for use with Magento Enterprise
View 01-SolrSetup.md

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
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`,
@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: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 / 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:1169053
Created Aug 24, 2011 — forked from davidalexander/gist:1086455
Magento Snippets
View gist:1169053

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 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