Skip to content

Instantly share code, notes, and snippets.

View denvit's full-sized avatar
🎯
Focusing

Denis Veg denvit

🎯
Focusing
  • Gornja Radgona, Slovenia
  • 13:10 (UTC +02:00)
View GitHub Profile
@denvit
denvit / algoliaexport.rb
Last active June 30, 2023 18:20
Ruby script to get a list of records in Algolia index
# 1. Install ruby using brew
# 3. Run in terminal: gem install algoliasearch
# 4. Run this script in terminal: ruby script.rb
require 'json'
require 'algoliasearch'
Algolia.init(application_id: '<insert id here>', api_key: '<insert admin key here>')
index = Algolia::Index.new('< name of your index >')
@denvit
denvit / gist:5c4688ddbaeeb77bcb785702349b03f9
Created July 21, 2021 13:15
Script for generating SSL certificate on MacOSX
#!/bin/bash
echo Enter domain:
read domain
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
@denvit
denvit / sphp.sh
Created November 27, 2020 14:20 — forked from w00fz/sphp.sh
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@denvit
denvit / catalog_product_view.xml
Last active May 27, 2020 06:28
Add custom block on product details page
<?xml version="1.0"?>
<page 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.social">
<block class="Magento\Catalog\Block\Product\View" name="product.info.brand" as="brand" template="Magento_Catalog::product/view/brand.phtml"></block>
</referenceBlock>
...
</body>
</page>
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// For performance use one level down: 'name/{,*/}*.js'
// If you want to recursively match all subfolders, use: 'name/**/*.js'
module.exports = function (grunt) {
'use strict';
@denvit
denvit / FileSaver.js example
Created December 15, 2019 18:20
Save content to file using javascript
<script src="http://cdn.jsdelivr.net/g/filesaver.js"></script>
<script>
function SaveAsFile(t,f,m) {
try {
var b = new Blob([t],{type:m});
saveAs(b, f);
} catch (e) {
window.open("data:"+m+"," + encodeURIComponent(t), '_blank','');
}
}
@denvit
denvit / Firebear\ConfigurableProducts\Plugin\Pricing\Price\FinalPrice.php
Created November 8, 2019 11:49
Solution for Firebear Configurable products NoSuchEntityException on categories
public function afterGetValue(\Magento\ConfigurableProduct\Pricing\Price\FinalPrice $subject, $result)
{
/**
* @todo Add check on whether preselect is enabled
**/
$defaultProductId = $this->defaults->getDefaultProductId($subject->getProduct());
if (!$defaultProductId) {
$defaultProductId = (int) $this->_request->getParam('id');
}
if ($defaultProductId) {
@denvit
denvit / xampp_php7_xdebug.md
Created May 4, 2019 15:37 — forked from odan/xampp_php7_xdebug.md
Installing Xdebug for XAMPP

Installing Xdebug for XAMPP with PHP 7.x

Requirements

Setup

@denvit
denvit / Drupal 7 Commerce stock - custom stock message
Last active November 12, 2018 13:17
Drupal 7 - Hook alters stock display message. Formatter for Stock must be set as "Unformatted" on Product > Manage display.
/**
* Implements hook_commerce_product_reference_default_delta_alter().
*/
function test_module_commerce_product_reference_default_delta_alter(&$delta, $products) {
$test = 123;
foreach ($products as $product) {
if ($product->commerce_stock['und'][0]['value'] > 0){
$products[1]->commerce_stock['und'][0]['value'] = "On stock";
}else {
@denvit
denvit / jwtRS256.sh
Created June 6, 2018 09:02 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub