Skip to content

Instantly share code, notes, and snippets.

View eniuz's full-sized avatar

Mariusz Szot eniuz

View GitHub Profile
@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 / 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 / create_website_scope.php
Created January 14, 2016 11:55 — forked from yireo/create_website_scope.php
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
@eniuz
eniuz / nginx.conf
Created January 29, 2016 12:08 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@eniuz
eniuz / install-magerun.sh
Created January 29, 2016 15:59
Install Magerun
# install as superuser
wget http://files.magerun.net/n98-magerun-latest.phar -O magerun && chmod +x magerun && mv magerun /usr/local/bin/
@eniuz
eniuz / magerun-cannot-redeclare-class.sh
Created February 5, 2016 14:07
Cannot redeclare class n98\magento\command\config\dumpcommand
php -d apc.enable_cli=0 magerun
@eniuz
eniuz / fix-indexer.sql
Created March 1, 2016 15:24
duplicated product breaks indexer
delete FROM `catalog_product_entity_datetime` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_decimal` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_group_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_int` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_media_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_text` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_tier_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_varchar` where entity_id not in (select entity_id fro
@eniuz
eniuz / gist:526d355e190a9aa52a3e
Created March 7, 2016 17:25
find last line in csv found on stack
function getLastLine($file, $bufferSize){
$fp = fopen($file, 'r');
$size = filesize($file);
$buffer = '';
for ($pos = $size - $bufferSize; ; $pos -= $bufferSize) {
$pos = max(0, $pos);
fseek($fp, $pos);
$b = rtrim(fread($fp, $bufferSize));
$nlPos = strrpos($b, "\n");
@eniuz
eniuz / create-product-attribute.php
Created March 8, 2016 13:58
Create Product Attribute
<?php
// http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/
<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
* Adding Different Attributes
*/
@eniuz
eniuz / remove-open-short-tags.sh
Created March 10, 2016 10:42
Remove open short tags
for file in *.php
do
sed -i 's/<?$/<?php/' $file
sed -i 's/<? /<?php /' $file
done