Skip to content

Instantly share code, notes, and snippets.

View Tomasz-Silpion's full-sized avatar
💭
I may be slow to respond.

Tomasz Gregorczyk Tomasz-Silpion

💭
I may be slow to respond.
View GitHub Profile
@Tomasz-Silpion
Tomasz-Silpion / providers.php
Last active August 10, 2016 13:48
Count customers email domain occurences from Magento orders
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
$emails = array();
$orders = Mage::getModel('sales/order')->getCollection();
foreach ($orders as $order) {
$emails[] = $order->getCustomerEmail();
@Tomasz-Silpion
Tomasz-Silpion / validation.js
Created August 20, 2016 01:44
Prototype.js Magento value trim (replace spaces) on email validation
$$('.validate-email').each(function(input){
input.observe('change', function(e){
this.value = this.value.replace(/^\s+|\s+$/g,"");
});
});
@Tomasz-Silpion
Tomasz-Silpion / cleanup.sh
Created November 19, 2016 00:00
Basic bash script to git stash every server directory
for d in */ ; do
(cd $d && git stash)
done
@Tomasz-Silpion
Tomasz-Silpion / prolong_cookie.php
Created December 12, 2016 17:27
Prolong all cookies by 1 minute (extending all cookies lifetime)
@Tomasz-Silpion
Tomasz-Silpion / backup.sh
Created January 28, 2017 02:07
Shell script for database and files site backup
# Database credentials
DB_USER=""
DB_PASS=""
DB_HOST=""
DB_NAME=""
# Database dump
mysqldump --user=$DB_USER --password=$DB_PASS --host=$DB_HOST $DB_NAME > $(date +"%d-%m-%Y").sql
# Files backup
@Tomasz-Silpion
Tomasz-Silpion / gpsmp.sh
Created February 7, 2017 00:59
Script for parsing Google PageSpeed optimized content MANIFEST
# Script for parsing Google PageSpeed optimized content MANIFEST
# Copyright (C) 2016 Tomasz Silpion Gregorczyk - All Rights Reserved
file="MANIFEST"
while IFS= read line
do
#strip file paths
IFS=':' read -r src protocol url <<EOF
$line
@Tomasz-Silpion
Tomasz-Silpion / fix_stock.php
Created March 10, 2017 17:00
Fix Woocommerce stock to match qty
<?php
define('WP_USE_THEMES', false);
require('./wp-load.php');
$args = array('post_type' => 'product', 'posts_per_page' => -1);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
@Tomasz-Silpion
Tomasz-Silpion / wcpdf.php
Created April 14, 2017 12:28
Load WooCommerce PDF Invoices & Packing Slips document anywhere
<?php
require('./wp-load.php');
$wpo_wcpdf = WPO_WCPDF();
$pdf = $wpo_wcpdf->export->get_pdf('invoice', array($order_id));
header("Content-type:application/pdf");
echo $pdf;
@Tomasz-Silpion
Tomasz-Silpion / deploy.sh
Created June 5, 2017 20:49
Magento2 shell script shorthand for redeployment with Snowdog front-end tools gulp usage
# Magento2 shell script shorthand for redeployment
php bin/magento setup:upgrade
cd tools && gulp clean && cd ..
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
cd tools && gulp styles && cd ..
chmod -R 775 var
chmod -R 775 pub/static
@Tomasz-Silpion
Tomasz-Silpion / nocache.conf
Last active June 8, 2017 21:15
Nginx config to return Magento 1 not cached images if the cached version does not exist
location ^~ /media/catalog/product/cache/ {
try_files $uri @nocache;
}
location @nocache {
rewrite ^/(media/catalog/product)/(.*/.*/.*/.*)/(.*/.*/.*) /$1/$3 redirect;
}