Skip to content

Instantly share code, notes, and snippets.

@mpchadwick
mpchadwick / Non Sucky YouTube Embed
Created November 27, 2013 03:00
This directive lets you easily embed YouTube videos in your ng-app with out the performance suckiness of YouTube's iFrame embed code (which forces users to download 400K of data before even pressing play). This directive first finds and displays the video's thumbnail based on the id attribute, and only swaps in the iframe when the thumbnail is c…
directive('nonSuckyYoutubeEmbed', function factory() {
var directiveDefinitionObject = {
restrict: 'E',
template: '<div style="position: relative;">' +
'<img src="img/play-btn.png" style="position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin-left: -24px; margin-top: -24px; cursor: pointer;" alt="Play" />' +
'<img src="http://i.ytimg.com/vi/{{id}}/0.jpg" style="width: 100%; height: auto; display: inline; cursor: pointer" alt="" />' +
'</div>',
scope: {
id: '@id'
},
@mpchadwick
mpchadwick / gist:9076670
Created February 18, 2014 18:22
Feedmagnet API
<!-- simple CSS styling for sidebar and updates -->
<style>
.fm-update { margin-bottom: 20px; border-bottom: 1px #ddd; }
.avatar { float: left; margin-right: 10px; height: 48px; width: 48px; }
.author { font-size: 1.2em; padding-top: 5px; }
.timestamp { font-size: .8em; color: #777; }
.text { margin-top: 20px 0; }
.social-feed {
width: 33%;
float: left;
@mpchadwick
mpchadwick / Massive Dropdown Attribute
Last active August 29, 2015 14:17
Massive Dropdown Attribute
########################################
# Set Up A Masssive Dropdown Attribute
########################################
# User defined vars
SET @num_options = 3500;
SET @attribute_code = 'massive_attribute';
SET @attribute_label = 'Massive Attribute';
SET @store_id = 0;
@mpchadwick
mpchadwick / Mpchadwick_Missing_Acl_Checker.php
Created July 11, 2015 03:42
Mpchadwick_Missing_Acl_Checker.php
<?php
require_once 'abstract.php';
/**
* Generate a CSV of modules with admin routes that haven't implemented _isAllowed()
*/
class Mpchadwick_Missing_Acl_Checker extends Mage_Shell_Abstract
{
const MODULES_PATH = 'modules';
@mpchadwick
mpchadwick / configurable_best_sellers.sql
Created August 16, 2015 16:52
Magento Best Sellers - Configurable Products
SELECT
cpf.entity_id,
cpf.name,
cpf.type_id,
(
SELECT SUM(sbam.qty_ordered)
FROM sales_bestsellers_aggregated_monthly sbam
LEFT JOIN catalog_product_super_link cpsl
ON cpsl.product_id = sbam.product_id
WHERE sbam.product_id = cpf.entity_id
@mpchadwick
mpchadwick / query.sql
Last active August 29, 2015 14:27
Mageto Improved Autocomplete Query
#################################################################
# ORIGINAL
# Then the term matching the search is plucked to the top in PHP
# This eliminates the ability to put a "limit" on the result set
#################################################################
SELECT
DISTINCT IFNULL(synonym_for, query_text) AS `query`,
`main_table`.`num_results`,
`main_table`.*
FROM `catalogsearch_query` AS `main_table`
@mpchadwick
mpchadwick / SUPEE6788Checklist.md
Last active November 10, 2015 16:44
SUPEE-6788 Checklist

SUPEE-6788 CHECKLIST

  • Base patch installed
  • Template changes integrated to custom theme
    • customer/form/register.phtml
    • customer/form/resetforgottenpassword.phtml
    • persistent/customer/form/register.phtml
    • page/js/cookie.phtml
  • Layout change (customer.xml) integrated to custom theme
  • SDUPEE-8766 applied (curl -sS https://raw.githubusercontent.com/sdinteractive/SDUPEE-8766/master/SDUPEE-8766.diff | git apply)
  • APPSEC-1063 incompatibilities fixed
@mpchadwick
mpchadwick / OrdersWithoutStatusHistory.sql
Last active November 5, 2015 16:09
Orders Without Status History
# Get the number or orders without any status history
# Can be useful for debugging (e.g. it is expected that there is a status history such as "Authorize Amount"
SELECT
date(result.created_at),
count(result.entity_id) as Orders,
SUM(CASE WHEN result.comments IS NULL THEN 1 ELSE 0 END) as OrdersWithoutStatuses,
CONCAT(FLOOR(100 * SUM(CASE WHEN result.comments IS NULL THEN 1 ELSE 0 END) / count(result.entity_id)), '%') PercentageWithoutStatuses
FROM (
SELECT
@mpchadwick
mpchadwick / cw-text-fix.js
Created November 6, 2015 19:50
ConnectWise Text Fix
var cells = document.querySelectorAll('.day-info-cell[style^="background: rgb(0, 0, 255);"] div');
function setBackgroundWhite(element) {element.style.color = "white"}; Array.prototype.forEach.call(cells, setBackgroundWhite);
@mpchadwick
mpchadwick / magento-deadlock-simulation.sql
Last active December 15, 2015 15:17
Simulate a Deadlock in Magento
# Run the following queries
set transaction isolation level serializable;
# In the admin
start transaction;
select * from core_config_data;
# load the system configuration
# On the frontend
start transaction;