Skip to content

Instantly share code, notes, and snippets.

7c8650400a5a09e278999cbe6624042f2b074000
@Stasevi4
Stasevi4 / ProductimgFix.patch
Last active June 22, 2018 05:58
Magento Fix Undefined index - app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 145
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
index 13e8659..f7000df 100755
--- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
@@ -141,12 +141,12 @@ class Mage_ConfigurableSwatches_Helper_Productimg extends Mage_Core_Helper_Abstr
$swatchLabel = $label . self::SWATCH_LABEL_SUFFIX;
$imageKeys[$label] = array_search($label, $imageHaystack);
- if ($imageKeys[$label] === false) {
+ if ($imageKeys[$label] === false && array_keys($mapping, $label)) {
@Stasevi4
Stasevi4 / C php Serializer.cs
Created November 7, 2016 22:55 — forked from xiangwan/C php Serializer.cs
C# php Serializer
/// <summary>
/// Serializer Class.
/// </summary>
public class Serializer
{
//types:
// N = null
// s = string
// i = int
// d = double
@Stasevi4
Stasevi4 / serachdom.sh
Created July 27, 2015 21:20
Search for UTF-8 files with BOM?
find -type f |
while read file
do
if [ "`head -c 3 -- "$file"`" == $'\xef\xbb\xbf' ]
then
echo "found BOM in: $file"
fi
done
@Stasevi4
Stasevi4 / gist:250ff8aa8e975b7dc477
Created November 11, 2014 23:57
Resize all selected block to same size
(function ($) {
$.fn.blockresize = function () {
var height = 0;
this.each(function () {
c_height = parseInt($(this).height());
if (c_height > height) {
height = c_height;
}
});
this.css('height', height);
@Stasevi4
Stasevi4 / gist:957b8fbcbca4c7b283f0
Created November 9, 2014 06:07
Vertical Align of element jQuery
(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
return this.each(function(i){
var ah = $(this).height();
var ph = $(this).parent().height();
var mh = Math.ceil((ph-ah) / 2);
$(this).css('margin-top', mh);
});
};
@Stasevi4
Stasevi4 / gist:bbe258e36f479638d38f
Created October 8, 2014 22:53
Magento Update product set first image as default image , small_image, thumbnail
UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_id IN (70, 71, 72) <------------- Change attribute id (Image, small_image, thumbnail)
AND mgv.position = 1;
@Stasevi4
Stasevi4 / gist:84911b914b6e189778c7
Created October 8, 2014 22:26
Rename Files and folder to lowercase Linux
This is a good one liner command, specially when dealing with lots of files that you want to change its names from upper-case to lower-case.
for f in * ; do mv -v $f `echo $f | tr '[A-Z]' '[a-z]'`; done
That will work on all files in the current folder, if you want more specific files use this form
for f in `find . -name '*.rar'` ; do mv -v $f `echo $f | tr '[A-Z]' '[a-z]'`; done
This last case, will look for files with .rar extension, you can use find with all its options to improve your search.
@Stasevi4
Stasevi4 / gist:1d33d0160f8e5642aadf
Created September 25, 2014 17:54
Fix for CVE-2014-6271 bash vulnerability,
mkdir src
cd src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#download all patches
for i in $(seq -f "%03g" 0 25); do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done
tar zxvf bash-4.3.tar.gz
cd bash-4.3
#apply all patches
for i in $(seq -f "%03g" 0 25);do patch -p0 < ../bash43-$i; done
#build and install
// jpegtran
$DIR=/path/to/folder
for file in $(find $DIR -type f \( -name "*.jpg" -or -name "*.jpeg" -or -name "*.JPG" \)); do
echo found $file for optimizing...
jpegtran -copy comments -optimize -progressive -outfile $file $file
done