Skip to content

Instantly share code, notes, and snippets.

View timneutkens's full-sized avatar
👋

Tim Neutkens timneutkens

👋
View GitHub Profile
@timneutkens
timneutkens / InstallData.php
Last active August 30, 2016 12:35
Magento2 add product attribute programatically. Based on https://www.atwix.com/magento/adding-attribute-programatically-magento2/
<?php namespace TimNeutkens\InstallProductAttributes\Setup;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
@timneutkens
timneutkens / block.php
Last active September 27, 2016 10:05
Load a block based on deployment mode (development, default, production) Magento 2
<?php namespace TimNeutkens\Example\Block;
use Magento\Framework\App\State;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
class ExampleBlock extends Template {
protected $developerMode;
public function __construct(Context $context, array $data = []) {
/** @var State $state */
@timneutkens
timneutkens / catalog_product_view.xml
Created August 23, 2016 09:23
Remove reviews from product page Magento 2
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.review" remove="true" />
<referenceBlock name="reviews.tab" remove="true" />
</body>
</page>
@timneutkens
timneutkens / ip.sh
Created August 15, 2016 11:47
Get your external IP adress
alias ip='dig +short myip.opendns.com @resolver1.opendns.com'
@timneutkens
timneutkens / .my.cnf
Last active August 15, 2016 07:53
~/.my.cnf mysql username and password.
[client]
user=mysqluser
password=mysqlpass
host=localhost
@timneutkens
timneutkens / validation-classes.js
Last active August 7, 2016 13:44
Magento2 get javascript validation classes like validate-number etc. can be ran on front-end and admin panel
(function() {
var exec = false;
if(typeof requirejs !== 'undefined') {
exec = requirejs;
} else if (typeof require !== 'undefined') {
exec = require;
} else {
console.log('require.js not found');
return false;
}
@timneutkens
timneutkens / .vimrc
Created July 23, 2016 12:02
Enable vim syntax highlighting for mac
filetype plugin indent on
syntax on
@timneutkens
timneutkens / swiper.css
Last active July 22, 2016 07:43
Swiper.js horizontal slider styling
.swiper-container {
position: relative;
overflow: hidden;
width: 100%;
}
.swiper-wrapper {
position: relative;
width: 10000%;
}
@timneutkens
timneutkens / jquery-ui-accordion-opened-tab-scroll.js
Created July 19, 2016 10:26
jQuery UI accordion scroll to clicked tab
function scrollTo(element) {
jQuery('html, body').animate({
scrollTop: jQuery(element).offset().top
}, 500);
}
jQuery('.accordion').on('accordionactivate', function( event, ui ) {
scrollTo(jQuery(event.target).find('.ui-accordion-header-active'))
});
@timneutkens
timneutkens / findtypekitfonts.js
Created July 15, 2016 07:31
Find typekit fonts. Run this in your console.
$('html').attr('class')
.split(' ')
.filter( function (word) {
return word.match(/wf-(.*)-active/g); }
)
.forEach( function (font) {
console.log(font.replace(/wf-|-active/g, ''))
})