Skip to content

Instantly share code, notes, and snippets.

View LucasCalazans's full-sized avatar
:octocat:
jQuery > JS

Lucas Calazans LucasCalazans

:octocat:
jQuery > JS
View GitHub Profile
@LucasCalazans
LucasCalazans / .hyper.js
Created December 4, 2023 13:10
Hyper Config File
"use strict";
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
@LucasCalazans
LucasCalazans / .wslconfig
Created July 12, 2023 14:31
WSL Confi file
[wsl2]
memory=16GB # Limits VM memory in WSL 2
localhostForwarding=true
@LucasCalazans
LucasCalazans / .hyper.js
Created July 12, 2023 14:29
Hyper Config File
"use strict";
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
@LucasCalazans
LucasCalazans / main.js
Last active March 10, 2023 02:17
Refresh bindings for a knockout component
$('#btn').on('click', () => {
$.get('https://app.magento.localhost/test/index/index').done(result => {
$('#container').replaceWith($(result).find('#container'));
$('body').trigger('contentUpdated');
ko.cleanNode($('.column.main')[0]);
$('.column.main').applyBindings();
})
});
@LucasCalazans
LucasCalazans / README.md
Created January 5, 2023 14:27
Grunt less fix

In magento 2.4.4 version, CSS source mapping could have an issue to show the correct less file on the source mapping on the browser. To fix it, go to your package.json file, find the grunt-contrib-less, and change its version to: 1.4.1

"grunt-contrib-less": "~1.4.1"
@LucasCalazans
LucasCalazans / slider.html
Created December 15, 2022 20:43
Unslick - Remove carrosel from a specific breakpoint
<script type="text/x-magento-init">
{
".product-slider": {
"slider": {
"slickOptions": {
"responsive": [{
"breakpoint": 1024,
"settings": "unslick"
}]
}

Usage

If you need to add more items to the CSP go to the line 36 and add more items inside the object.

Here I used as an example the font-src. In this case I just needed to add 1 more URL, so I added a string to the font-src key.

If you need to add more than 1 item you can use the value as an array. Also, if you need to add more keys, just add it to the object, like this:

updateContentSecurityPolicy(definitions, {
@LucasCalazans
LucasCalazans / style.css
Created November 24, 2021 18:54
Skeleton effect
.placeholder {
animation-name: fade;
animation-duration: 1s;
background-color: #e5e5e5;
animation-iteration-count: infinite;
}
@keyframes fade {
0% {
opacity: .6
@LucasCalazans
LucasCalazans / project.iml
Created September 22, 2021 02:44
Magento 2 on PHP Storm - Configure the excluded and sources folders
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/vendor/magento" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/vendor" />
<excludeFolder url="file://$MODULE_DIR$/dev" />
<excludeFolder url="file://$MODULE_DIR$/generated" />
<excludeFolder url="file://$MODULE_DIR$/pub" />
@LucasCalazans
LucasCalazans / UpdateCMSBlock.php
Last active May 11, 2023 19:26
Data Patch examples
<?php
namespace Vendor\Module\Setup\Patch\Data;
use Magento\Cms\Model\BlockFactory;
use Magento\Framework\Setup\Patch\DataPatchInterface;
/**
* Class UpdateCMSBlock
* @package Vendor\Module\Setup\Patch\Data