Skip to content

Instantly share code, notes, and snippets.

View convenient's full-sized avatar

Luke Rodgers convenient

View GitHub Profile
@convenient
convenient / gist:b8e99c221caf9e599ac8
Last active November 6, 2015 16:25
Git PR Task List
javascript:(function() {var clickEvt = new MouseEvent("click", {bubbles: true, clientX: 20}); var editButtons = document.getElementsByClassName('js-comment-edit-button'); editButtons[0].dispatchEvent(clickEvt); var commentForms = document.getElementsByClassName('comment-form-textarea'); commentForms[0].value+="\n\n* [ ] Task 1\n* [ ] Task 2\n* [ ] Task 3\n* [ ] Task 4\n* [ ] Tasl 5\n"; var updateButtons = document.getElementsByClassName('btn-primary'); updateButtons[0].click();})()
@convenient
convenient / Mage_Core_Model_App.php
Created November 22, 2015 16:29
100 router match iterations
protected function _initModules()
{
if (!$this->_config->loadModulesCache()) {
// Hacks start here!
$this->_config->setUseCache(false);
// Hacks end here!
$this->_config->loadModules();
if ($this->_config->isLocalConfigLoaded() && !$this->_shouldSkipProcessModulesUpdates()) {
Varien_Profiler::start('mage::app::init::apply_db_schema_updates');
Mage_Core_Model_Resource_Setup::applyAllUpdates();
@convenient
convenient / Price
Created December 11, 2015 13:10
Magento indexer changelog backlog
select count(*) from catalog_product_index_price_cl where version_id > (select version_id from enterprise_mview_metadata where changelog_name='catalog_product_index_price_cl');
select IF(count(schedule_id) = 0, 'stuck', 'okay') as crons from cron_schedule where finished_at is not null and finished_at >= DATE_SUB(NOW(), INTERVAL 2 HOUR);
@convenient
convenient / readme.md
Last active August 22, 2016 10:44
Safe Update Cms Block Content - Setup Script

We've been having some issues with setup scripts causing an issue when updating CMS blocks, throws an exception and fails the deployment. The issue was related to using the Mage::getModel('cms/block')->load() function which actually does an is_active filter in the background. Meaning if you try and update a cms block that the client has actually marked as in_active, you're code assumes it is creating a new one instead of updating.

To get around this you HAVE to use collections.

The script below was an example for a particular project, in which each store had its own CMS block with the same identifier. The key ingredient is how the CMS block is updated within the second loop.

@convenient
convenient / gist:5113999404d320e15424
Last active September 27, 2016 19:56
MD5 A directory
cd ~/path/to/folder/ && find . -name '*.php' | sort -d | xargs md5sum
#files with spaces
cd . && find . -name '*.mp3' | xargs -d '\n' md5sum | sort -k 3
@convenient
convenient / file-test.php
Last active October 22, 2016 18:19
php-fpm libxml_disable_entity_loader
<?php
error_reporting( error_reporting() & ~E_NOTICE & ~E_WARNING);
/**
* @param SimpleXMLElement|bool $element
* @return string
*/
function loadedOkay($element)
{
if ($element === true) {
@convenient
convenient / mage2
Last active February 3, 2017 08:39
PHPBREW Install php for Magento 1.x
phpbrew install 5.3.26 +default +dbs +apxs2
phpbrew ext install iconv
phpbrew ext install gd
phpbrew ext install xdebug 2.2.3
#nano /home/luker/.phpbrew/php/php-5.3.26/var/db/xdebug.ini
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
@convenient
convenient / gist:459cbf6649bb73dd7343340cf6e145f8
Created May 3, 2016 10:12
apache access log group by iP
cat /var/log/httpd/access.SSL.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20
@convenient
convenient / gist:9846247e14e3c0950994ed8bd0fcc1c7
Last active June 20, 2017 14:05
Group magento system log by frequency
cut -f 5- -d ':' /var/www/vhosts/project.com/var/log/system.log | sort -n | uniq -c | sort -nr | head -20
Get all 404 requests from log
`lecli query --loggroup bes_web --leql 'where(status=404 AND request!=/(.*?)favicon.ico/)' -r 'last 1 hour'`
`grep -Eo ".{0,255}query" 404.log | sed -e 's/\", "query//' | cut -d ":" -f9 | sed 's/^.//'`
cat reqs.log | sed -e 's/.*userAgent...//' -e 's/.referer.*..//'