Skip to content

Instantly share code, notes, and snippets.

View astorm's full-sized avatar

Alana Storm astorm

View GitHub Profile
@astorm
astorm / gist:992233
Created May 25, 2011 23:29
Fix console.log in Chrome and Magento
<!-- Add to the package layout (via local.xml or however you prefer) -->
<!-- Also, best to remove before deployment, as some users report -->
<!-- it makes IE 7 crash -->
<default>
<reference name="content">
<block type="core/text" name="fix.console" as="fix.console">
<action method="setText">
<text><![CDATA[<script type="text/javascript">
iframe = document.createElement('iframe');
iframe.style.display = 'none';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<style type="text/css">
body {background-color: #fff; color: #222; font-family: sans-serif;}
pre {margin: 0; font-family: monospace;}
a:link {color: #009; text-decoration: none; background-color: #fff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse; border: 0; width: 934px; box-shadow: 1px 2px 3px #ccc;}
.center {text-align: center;}
.center table {margin: 1em auto; text-align: left;}
$ npx lerna clean -y
$ git clean -fdx
$ npm install
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
> husky@3.1.0 install /private/tmp/working/opentelemetry-js/node_modules/husky
> node husky install
$ npm install
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
> husky@3.1.0 install /path/to/opentelemetry-js/node_modules/husky
> node husky install
husky > Setting up git hooks
ENOENT: no such file or directory, mkdir 'node_modules/husky/.git/hooks'
<?php
define('nil', NULL);
function foo() {
return ["This is not go", nil];
}
list($value, $err) = foo();
var_dump($value, $err);
@astorm
astorm / gist:6919733
Created October 10, 2013 14:54
Description of how Magento normalized cache tag case using `strtoupper`

The getCache method

#File: app/code/core/Mage/Core/Model/App.php
public function getCacheInstance()
{
    if (!$this->_cache) {
        $this->_initCache();
    }
    return $this->_cache;

}

@astorm
astorm / gist:1188644
Created September 2, 2011 13:54
Moving a Magento Block Object
<layout>
<catalog_category_default>
<!-- block gets added -->
<reference name="content">
<block type="core/text" name="are_you_sure"></block>
</reference>
</catalog_category_default>
<catalog_category_default>
<!-- later, a different handle gets a reference and sets block state -->
@astorm
astorm / gist:2974947
Created June 22, 2012 20:17
Magento's Performance Profile
There's multiple reasons Magento's performance profile is different
than most "mid-2000s" LAMP stack frameworks and CMS systems.
1. SQL Bottleneck: Magento's functionality is implemented in such a
way that there's a large number of SQL queries on each page request.
Between the special EAV structure of product/category models, and a
general "model first" approach to development, you end up seeing a lot
of SQL queries.
2. "Classical" (Java/C#) style OOP. Magento uses a class heavy
@astorm
astorm / gist:2572772
Created May 2, 2012 01:03
Magento's Tax Calculation Based On setting

Info here is based on a Magento CE 1.6.1 install. Your version may vary. Also, there's lots of conjecture on my part near the end, so DANGER WILL ROBINSON.

Configuration setting is located at

System -> Configuration -> Tax -> Calculation Settings

Label is "Tax Calculation Method Based On"

Possible Settings are

//app/code/[YourNamespace]/Commercebug/view/base/web/js/commercebug.js
//replace this
//$('#commercebug-tab-content .pulsestorm-data-table').DataTable();
//with this
$('#commercebug-tab-content .pulsestorm-data-table').DataTable({
"aaSorting": []
});