Skip to content

Instantly share code, notes, and snippets.

@6ui11em
6ui11em / emulateAreaCode.php
Created April 15, 2021 13:26
Magento 2: Emulate Area Code #magento2 #areacode #state #frontend #adminhtml
# File: vendor/magento/framework/App/State.php
public function emulateAreaCode($areaCode, $callback, $params = [])
{
$currentArea = $this->_areaCode;
$this->_areaCode = $areaCode;
$this->_isAreaCodeEmulated = true;
try {
$result = call_user_func_array($callback, $params);
} catch (Exception $e) {
$this->_areaCode = $currentArea;
@6ui11em
6ui11em / duplicate.sql
Last active February 15, 2022 11:05
SQL: Find duplicate values #mysql #sql #select #duplicate
SELECT
col,
COUNT(col)
FROM
table_name
GROUP BY col
HAVING COUNT(col) > 1;
---
@6ui11em
6ui11em / entity_atributes.sql
Created January 13, 2021 11:19
Magento: Query atributos entidades #magento #sql #eav #attributes
-- Category:
SET @entity_id = 1;
(SELECT e.attribute_code, 'varchar' AS type, v.store_id, v.value FROM catalog_category_entity_varchar v
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id)
UNION
(SELECT e.attribute_code, 'datetime' AS type, v.store_id, v.value FROM catalog_category_entity_datetime v
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id)
UNION
(SELECT e.attribute_code, 'decimal' AS type, v.store_id, v.value FROM catalog_category_entity_decimal v
@6ui11em
6ui11em / autoincrement_allow_0.sql
Created December 30, 2020 17:43
Mysql: Allow 0 for autoincrement when import #mysql #autoincrement #import
SET [GLOBAL|SESSION] sql_mode='NO_AUTO_VALUE_ON_ZERO'
@6ui11em
6ui11em / bold-hover-without-shift.scss
Last active October 21, 2020 08:13
CSS: Bold on Hover without layout shift #css #scss #bold #hover
/*
By Ryan Mulligan
Source: https://css-tricks.com/bold-on-hover-without-the-layout-shift/
*/
.menu-link {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
@6ui11em
6ui11em / clearurl.sh
Last active June 12, 2020 16:07
Command: Clear url from varnish #varnish #cache #purge
# Enter varnish admin
varnishadm
# clear cache for index home page only
ban req.http.host ~ windparadise.com && req.url ~ "^/$"
# clear cache for specific page
@6ui11em
6ui11em / touch-media-quieries.css
Created May 5, 2020 14:10
CSS: Tocuh screen media quieris #css #media-query #responsive
/* smartphones, touchscreens */
@media (hover: none) and (pointer: coarse) {
/* ... */
}
/* stylus-based screens */
@media (hover: none) and (pointer: fine) {
/* ... */
}
/* Nintendo Wii controller, Microsoft Kinect */
@media (hover: hover) and (pointer: coarse) {
@6ui11em
6ui11em / composer.sh
Last active October 17, 2019 09:47
Composer: useful commands #composer #commands
# run composer to avoid memory limit error
php -d memory_limit=-1 /usr/local/bin/composer …
# ignore requirements
composer ... --ignore-platform-reqs
@6ui11em
6ui11em / docker.sh
Last active October 6, 2019 22:32
Docker useful commands #docker #commands #unix
# List all containers
$ docker ps -a
# List started containers
$ docker ps
# List stopped containers
docker ps --filter "status=exited"
# Stop container
@6ui11em
6ui11em / gitinit.sh
Created August 27, 2019 06:58
Git code to repository #git
git init
git add .
git commit -m "initial commit of full repository"
git remote add origin <bitbucket_URL>
git push -u origin --all