Skip to content

Instantly share code, notes, and snippets.

View eniuz's full-sized avatar

Mariusz Szot eniuz

View GitHub Profile
@eniuz
eniuz / docker-cleanup
Created January 3, 2016 20:21 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@eniuz
eniuz / install.sh
Created January 3, 2016 20:21 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
@eniuz
eniuz / disable-local-modules.txt
Created December 31, 2015 12:06
Disable local magento modules
<disable_local_modules>true</disable_local_modules>
@eniuz
eniuz / createTaxRules.php
Created December 29, 2015 16:50 — forked from peterjaap/createTaxRules.php
Generate tax rules for Magento
<?php
chdir(dirname(__FILE__));
require_once '../app/Mage.php';
Mage::app();
umask(0);
require_once 'countries.php'; // import lists with all countries
// UK Island shipping rates; http://www.crearegroup-ecommerce.co.uk/blog/magento-advice/shipping-rates-to-the-uk-islands.php
@eniuz
eniuz / gist:e30de10bf688a702272f
Created December 7, 2015 09:03 — forked from molotovbliss/gist:4f71f6242a16fa894a92
Debugging Layout XML issues
Source: https://magento.stackexchange.com/questions/95/debugging-layout-xml-loading
You can log the compiled layout XML directives which are used to generate blocks. Create an observer on controller_action_layout_generate_blocks_before, and in the observer method log the update XML from the transported layout object:
public function logCompiledLayout($o)
{
$req = Mage::app()->getRequest();
$info = sprintf(
"\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
$req->getRouteName(),
@eniuz
eniuz / gist:6a4c549c865c7030caf9
Created December 7, 2015 09:03 — forked from molotovbliss/gist:2562551
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'dev/log/active', '1') on duplicate key update `value`='1';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/session_cookie_lifetime', '360000') on duplicate key update `value`='360000';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'web/cookie/cookie_lifetime', '360000') on duplicate key update `value`='360000';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/password_is_forced', '0') on duplicate key update `value`='0';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/password_is_forced', '0') on duplicate key update `value`='0';
update core_config_data set value = 'http://project.192.168.50.100.xip.io/' where path like '%base_url';
update core_config_data set value = ''
@eniuz
eniuz / curl-paypal-nvp.sh
Created November 19, 2015 10:55
curl paypal nvp
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d
"USER={YourUserID}
&PWD={YourPassword}
&SIGNATURE={YourSignature}
&METHOD=SetExpressCheckout
&VERSION=98
&PAYMENTREQUEST_0_AMT=10
&PAYMENTREQUEST_0_CURRENCYCODE=USD
&PAYMENTREQUEST_0_PAYMENTACTION=SALE
&cancelUrl=http://www.example.com/cancel.html
@eniuz
eniuz / 1.factory-methods.md
Created November 11, 2015 10:00 — forked from Vinai/1.factory-methods.md
Model & Resource Model Class Resolution Steps

Debugging (Resource) Model Instantiation

Follow each step manually and any bugs during (resource) model instantiation will become obvious.

Since many people find model and resource model instantiation to be one of the more challenging things in Magento 1, these are all the steps Magento does to resolve the factory name to the real PHP class name.

To debug, simply follow each step manually until you find a non-match. This works really well in my experience.
Less guessing, more and faster results.

In the examples I use a factory name of "example/thing".

@eniuz
eniuz / get-php-extension-dir.sh
Created November 2, 2015 15:57
Get php extension dir
php -i | grep extension_dir