Skip to content

Instantly share code, notes, and snippets.

View robjstanley's full-sized avatar

Rob Stanley robjstanley

  • Liverpool, United Kingdom
  • 10:38 (UTC)
View GitHub Profile
@robjstanley
robjstanley / m2-array-to-option.js
Last active July 27, 2020 07:00
Magento 2 Admin - JS to turn an array into dropdown attribute options
var values = ["Red","Green","Blue"];
var unique = values.filter(filterunique);
jQuery.each(unique, function(index,value) {
if(!jQuery('input[value="'+value+'"]').length) {
jQuery('#add_new_option_button').click();
jQuery('#manage-options-panel table tbody tr:last-child .required-option').val(value);
}
});
@robjstanley
robjstanley / css-move-placeholder.html
Created July 4, 2018 08:28
CSS Only Placeholder Move
<style>
label {
margin:20px 0;
position:relative;
display:inline-block;
span {
padding:10px;
pointer-events: none;
position:absolute;
@robjstanley
robjstanley / truncate-products.sql
Last active August 29, 2015 14:08
Truncate all of Magento's product data
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_category_anc_products_index_idx`;
TRUNCATE TABLE `catalog_category_anc_products_index_tmp`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_cat_cl`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product_index_cl`;
TRUNCATE TABLE `catalog_category_product_index_enbl_idx`;
TRUNCATE TABLE `catalog_category_product_index_enbl_tmp`;
TRUNCATE TABLE `catalog_category_product_index_idx`;
@robjstanley
robjstanley / new_gist_file_0
Created May 12, 2014 08:51
Problem: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Solution: symlink MAMP MySQL to iOS MySQL.
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
@robjstanley
robjstanley / new_gist_file_0
Created February 24, 2014 11:15
Set LI width depending on the amount of LIs in the UL
ul {
/* one item */
li:first-child:nth-last-child(1) {
width: 100%;
}
/* two items */
li:first-child:nth-last-child(2), li:first-child:nth-last-child(2) ~ li {
width: 50%;
@robjstanley
robjstanley / 0_reuse_code.js
Created January 31, 2014 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@robjstanley
robjstanley / 0_reuse_code.js
Created January 28, 2014 08:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console