Skip to content

Instantly share code, notes, and snippets.

# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@michaellehmkuhl
michaellehmkuhl / root-relative-urls-wp.php
Last active August 29, 2015 14:01
Root relative asset URLs for WP
function use_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
create_function(
'$matches',
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
'} elseif (isset($matches[0]) && strpos($matches[0], site_url()) !== false) { return $matches[2];' .
// if domain is not equal to site_url, do not make external link relative

##Given Apache 2 and MySQL are already installed.

#Update MacPorts sudo port selfupdate;sudo port -u upgrade outdated

#Install PHP 5.4.* sudo port install php54 php54-apache2handler ##Activate Apache Module cd /opt/local/apache2/modules

@michaellehmkuhl
michaellehmkuhl / tzAbbr.js
Created October 19, 2012 06:34 — forked from redoPop/tzAbbr.js
JavaScript: friendly timezone abbreviations in the client ("EDT", "CST", "GMT", etc.)
/* Friendly timezone abbreviations in client-side JavaScript
`tzAbbr()` or `tzAbbr(new Date(79,5,24))`
=> "EDT", "CST", "GMT", etc.!
There's no 100% reliable way to get friendly timezone names in all
browsers using JS alone, but this tiny function scours a
stringified date as best it can and returns `null` in the few cases
where no friendly timezone name is found (so far, just Opera).
@michaellehmkuhl
michaellehmkuhl / gist:2345870
Created April 9, 2012 19:26
PHP timezone conversion functions
/**
* Get the offset of the given timezone (in seconds)
*/
function getTimeZoneOffset($timezone='') {
$tz_tmp = new DateTimeZone($timezone);
$dt_tmp = new DateTime('now', $tz_tmp);
$offset = $dt_tmp->getOffset();
return $offset;
}
@michaellehmkuhl
michaellehmkuhl / gist:1821181
Created February 13, 2012 22:44
Punch a hole in HTTP auth to allow Flash to access without authenticating
SetEnvIf User-Agent ^Adobe\sFlash let_me_in
<Directory /var/www/vhosts/dev.domain.com>
Satisfy Any
Order allow,deny
Allow from env=let_me_in
Deny from none
</Directory>
@michaellehmkuhl
michaellehmkuhl / gist:1821012
Created February 13, 2012 22:30
Allow bypass of HTTP authentication for certain URLs
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
Order allow,deny
Allow from all
Deny from none
</FilesMatch>