Skip to content

Instantly share code, notes, and snippets.

# put it into magento install dir
app/code/core/
app/code/community/Phoenix/Moneybookers
app/design/adminhtml/default/default/
app/design/frontend/base/default/
app/design/frontend/default/default/
app/design/frontend/default/blank/
app/design/frontend/default/iphone/
@Stasevi4
Stasevi4 / jpegoptim
Last active July 8, 2016 12:45
Optimize images in folder ( Magento optimize image) jpegoptim and optipng
sudo apt-get install jpegoptim
sudo apt-get install optipng
find /path/to/magento/ -iname '*.jpg' -exec jpegoptim --strip-all -p {} \; -exec chmod 755 {} \; -exec chown www-data:www-data {} \;
find . -iname '*.png' -exec optipng -o7 -preserve {} \; -exec chown www-data:www-data {} \;
// 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
@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
@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: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: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: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 / 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 / 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