Skip to content

Instantly share code, notes, and snippets.

@mfdj
mfdj / gist:59b378a72a26cc45aff3b4eabe0a3734
Created July 12, 2017 21:25
that's a fun stacktrace
Product Price index has been rebuilt successfully in 00:00:07 SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '1066-188-1-524' for key 'PRIMARY', query was: INSERT INTO `catalog_product_index_eav_idx`
(`entity_id`,`attribute_id`,`store_id`,`value`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?,
?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?,
?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?,
?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?,
?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?,
?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?,
?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?,
@mfdj
mfdj / what-forms.js
Last active April 12, 2017 18:46
console snippet to find all the forms on page
toArray = function(itterable) {
return Array.prototype.slice.call(itterable)
}
toArray(document.querySelectorAll('form')).map(function(form) {
let name = form.id
? `#${form.id}`
: (form.classList.length > 0
? '.' + toArray(form.classList).join('.')
: 'form');
<?php
$tenItems = array_map(function ($n) {
return substr(md5("$n"), rand(0, 15), rand(5, 20));
}, range(0, 10));
$listTypes = [
'disc',
'circle',
'square',
@mfdj
mfdj / magento2-devbox-bashrc.sh
Last active February 6, 2017 06:25
shell helpers for inside and outside VMs using Copious Magento 2 Starter
# NOTE: Copious convention is to move typical Magento 2 project-root into a ./magento subdirectory
# default to vagrant folder when starting shell sessions in VM
cd /vagrant
# allow aliases to be used
shopt -s expand_aliases
# add magento and composer bins
export PATH+=:magento/bin
@mfdj
mfdj / shush.bash
Created November 29, 2016 21:18
Live dangerously: fuzzy match active processes by their name and tell them to go nigh'nigh
# shellcheck disable=SC2148
shush() {
local procName matches match binary pid
for procName in "$@"; do
matches=$(ps aux | grep -i "$procName" | grep -v grep | sed -E 's/[[:space:]]+/ /g')
if [[ $matches ]]; then
echo "shushing processes that match '$procName'"
@mfdj
mfdj / javascript-undefined.html
Last active June 20, 2021 22:12
In ES5 undefined is protected at the global level but it's not quite bulletproof
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"></head>
<!-- Normal script -->
<script>
// starting in ES5 window.undefined is read-only
undefined = 'NOT UNDEFINED'
console.log(undefined === window.undefined) // prove that we are scoped to window object (global object in node)
console.log(undefined !== 'NOT UNDEFINED')
/*
When measuring type in comps using a cross-hair tool you may not
always have a descender to check the font-size in pixels, meaning in most cases
(especially for all-caps titles) you only have the ability to measure from
baseline to cap-height.
This algorithm will help you convert that cap-height measurement into the correct
font-size within about pixel (often it's less than half a pixel off).
Adjust for optics and browser-rendering on case-by-case basis.
@mfdj
mfdj / plus.svg
Last active October 31, 2021 17:33
turn svg files into data-uri'd sass-mixins with color-variations
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfdj
mfdj / n-shim.js
Last active May 26, 2016 20:31
Extends n (https://github.com/tj/n) to pick node version from .node-version or package.json
n() {
# forward straght to n
[[ $# > 0 ]] && {
command n "$@"
return
}
# look for a version
@mfdj
mfdj / bash_profile.sh
Last active December 15, 2016 22:37
~/.bash_profile for magento1 vagrant environment
cd /vagrant
alias mage='n98-magerun.phar'
alias cf='mage cache:flush'
alias dis='mage cache:disable'
alias en='mage cache:enable'
alias compare='mage sys:set:compare-v'
alias run='mage sys:setup:run'
alias xdebugon="sudo sed -i 's~;zend_extension~zend_extension~' /etc/php.d/15-xdebug.ini; sudo service php-fpm restart"
alias xdebugoff="sudo sed -i 's~^zend_extension~;zend_extension~' /etc/php.d/15-xdebug.ini; sudo service php-fpm restart"