Skip to content

Instantly share code, notes, and snippets.

@kesonno
kesonno / logging.php
Created September 25, 2018 08:10
Magento 2 logging q&d
$logger = \Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
$logger->debug('$randomString = "' . $randomString . '"');
@kesonno
kesonno / get-latest-terraform.sh
Created September 29, 2017 07:31 — forked from josh-padnick/get-latest-terraform.sh
Auto-update to latest version of Terraform
#!/bin/bash
LATEST_RELEASE=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-)
if [[ ! -e ${LATEST_RELEASE} ]]; then
echo "Installing Terraform ${LATEST_RELEASE}..."
rm terraform-*
rm terraform
wget https://releases.hashicorp.com/terraform/${LATEST_RELEASE}/terraform_${LATEST_RELEASE}_linux_amd64.zip
unzip terraform_${LATEST_RELEASE}_linux_amd64.zip
rm terraform_${LATEST_RELEASE}_linux_amd64.zip
@kesonno
kesonno / quick-slugify.sh
Created July 2, 2017 20:12 — forked from oneohthree/quick-slugify.sh
Quick bash slugify
echo "$STRING" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z
@kesonno
kesonno / Vagrantfile.rb
Created February 26, 2016 09:50
Ask for user input in Vagrantfile during provisioning phase
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/#{VM_NAME}/*").empty? || ARGV[1] == '--provision'
print "Please insert your credentials\n"
print "Username: "
username = STDIN.gets.chomp
print "Password: "
password = STDIN.noecho(&:gets).chomp
print "\n"
config.vm.provision :shell, :path => "provision-vagrant.sh", :args => [username, password]
end
@kesonno
kesonno / gist:5d61391842c65a8fccc4
Created April 13, 2015 17:27
Finding largest tables on MySQL instance
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
@kesonno
kesonno / gist:be8ecda2633349f1dfa9
Created January 27, 2015 17:06
Get actually used options list for a given attribute in a given website
SELECT DISTINCT o.option_id, v.value
FROM `eav_attribute` a
INNER JOIN `eav_attribute_option` o ON a.`attribute_id` = o.`attribute_id`
INNER JOIN `eav_attribute_option_value` v ON v.`option_id` = o.`option_id`
INNER JOIN `eav_entity_type` t ON t.`entity_type_id` = a.`entity_type_id`
INNER JOIN `catalog_product_entity_int` pi ON o.`option_id` = pi.`value` AND o.`attribute_id` = pi.`attribute_id`
INNER JOIN `catalog_product_website` pw ON pw.product_id = pi.entity_id
WHERE pi.`entity_id` IS NOT NULL
AND a.attribute_code = '<attribute code>'
AND t.`entity_type_code` = "catalog_product"
@kesonno
kesonno / gist:164d2c4cdf539586ea32
Created January 27, 2015 14:47
Include Magento blocks outside Magento
/*
* Initialize magento.
*/
require_once 'app/Mage.php';
Mage::init();
/*
* Add specific layout handles to our layout and then load them.
*/
$layout = Mage::app()->getLayout();
@kesonno
kesonno / fastcgi.conf
Created January 27, 2015 13:53
Disable suEXEC as FastCGI wrapper
Insider /etc/httpd/conf.d/fastcgi.conf:
FastCgiWrapper Off
@kesonno
kesonno / gist:4719794a9b0ec6433956
Last active August 29, 2015 14:05
Example rows for import configurable products w/ Magento csv importer
_super_products_sku,_super_attribute_code,_super_attribute_option,_super_attribute_price_corr
tshirt-S-red,shirt_size,S,5.0000
tshirt-S-red,color,red,5.0000
tshirt-S-black,shirt_size,S,5.0000
tshirt-S-black,color,black,5.0000
tshirt-L-green,shirt_size,L,5.0000
tshirt-L-green,color,green,5.0000
@kesonno
kesonno / gist:dca2ccf8fd526bb1589e
Created August 7, 2014 12:57
iptables config for allow only ssh, http and https access
# Generated by iptables-save v1.4.7 on Fri May 30 11:43:24 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4464:613754]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT