Subheader

Lazy Programmer's Blog

Pages

Thursday, May 30, 2024

How to disable Compare Products module in Magento 2

Tested & worked for Magento 2.4.*
Algorythm for Ubuntu
1) cd [MAGENTO_ROOT]/vendor/magento/theme-frontend-luma/Magento_Catalog/layout
2) nano default.xml
3) Add the following code at the end of xml doc before tag:
<referenceBlock name="catalog.compare.link" remove="true" />
<referenceBlock name="catalog.compare.sidebar" remove="true" />
<referenceBlock name="catalogsearch.product.addto.compare" remove="true" />
<referenceBlock name="category.product.addto.compare" remove="true" />
<referenceBlock name="crosssell.product.addto.compare" remove="true" />
<referenceBlock name="related.product.addto.compare" remove="true" />
<referenceBlock name="upsell.product.addto.compare" remove="true" />
<referenceBlock name="view.addto.compare" remove="true" />
4)launch bin/magento c:c & bin/magento c:f

Thursday, July 15, 2021

How to change target framework in c# project from Visual Studio

Very often after project is created we need to change target .NET Framework. Here there is an instruction of how to do this from VS IDE interface. Step 1. Select project root in project tree on the right sidebar
Step 2. Click on properties icon

Friday, April 17, 2020

Click on Icon to Minimize Application Window in Ubuntu dock panel

Step 1. Run Terminal

Step 2. Run command
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


Enjoy!

Wednesday, April 15, 2020

ASUS Notebook functional buttons not working properly. How to fix?

Very often on Asus notebooks functional buttons by default don't properly work. Pressing F5 button in browser will give us brightness increase instead of page reload. It will work like Fn+F5 combination.

To fix this we need to install ASUS Keyboard Hot keys Driver from ASUS ATK Package. We can find it through search on asus.com or in Microsoft Store for Windows 10/8. Here is link https://www.microsoft.com/en-us/p/asus-keyboard-hotkeys/9pk20dg5fb6b?activetab=pivot:overviewtab



After that you need to launch ASUS Keyboard Hotkeys app & set radio button to F1-F12 position.



Enjoy!

Tuesday, April 14, 2020

How to install Microsoft Office Picture Manager

Since MS Office Picture Manager had been deprecated Microsoft excluded this tool from modern MS Office Versions starting from MS Office 2013. So the only way to get Picture Manager on your system is install it from MS Office 2010. But you don't need to have all MS Office 2010 installed in this case. All you need is to download MS Office Share Point 2010 package & choose only MSO Picture Manager as an install candidate. Here is an algorithm:

Step1. Download MSO Share Point Package
https://www.microsoft.com/en-us/download/confirmation.aspx?id=16573

Step2. Choose only MS Picture Manager as an install candidate


Step3. Install

Enjoy!

Saturday, April 27, 2019

How to enable Login Shell in Deepin Terminal?

There is no way to do this from Deepin Terminal GUI, but it's possible to do this via config file.

Step 1:
Go to

~/.config/deepin/deepin-terminal/
and open
config.conf

Step 2:
Find section

run_as_login_shell=false
in config file

Step 3:
Change flag run_as_login_shell into true

Step 4:
Reload Deepin Terminal

Friday, December 29, 2017

Error installing ruby 2.1.1 on ubuntu 17.04

Installing ruby binary package via RVM you can get an error message that RVM is not able to find ruby binary distributive, for example:
rvm install ruby-2.1.1

Searching for binary rubies, this might take some time. No binary rubies available for: ubuntu/17.04/x86_64/ruby-2.1.1. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for ubuntu. Installing requirements for ubuntu. Updating system.......There has been an error while updating your system using `apt-get`. .....It seems that there are some 404 Not Found errors for repositories listed in: /etc/apt/sources.list /etc/apt/sources.list.d/*.list Make sure that all repositories are available from your system and verify your setup by running manually: sudo apt-get update Make sure that it works correctly before proceeding with RVM. If you are working from the GUI instead of the terminal, you might want to verify and fix broken repositories using "Software & Updates" application. . Error running 'requirements_debian_update_system ruby-2.1.1', please read /home/home-pc/.rvm/log/1514552025_ruby-2.1.1/update_system.log Requirements installation failed with status: 100.

Solution:

Get the latest version of RVM:
rvm get head

Reload the RVM:
rvm reload

Install ruby:
rvm install ruby-2.1.1

Friday, July 22, 2016

Rails Paperclip and SVG files

Paperclip has unpleasant handling of SGV files, so it corrupts SVG XML file, and finally uploaded original file will have just header.

Temporary dirty solution is to replace original SVG file. Lets assume we need to store jpg/png/gif/svg image, which can have thumbnail.

Model
class Image < ActiveRecord::Base
  has_attached_file :file,  styles: { thumb: {processors: [:image_thumb]}}
  validates_attachment_content_type :file,
    content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif", "image/svg+xml"]

  attr_accessor :tmp_stage_file_name
    attr_accessor :tmp_stage_file_ext
    before_post_process :save_staged_file
    after_save :replace_original_file

  def save_staged_file
        if (path = file.staged_path)
            if (file.content_type == 'image/svg+xml')               
                @tmp_stage_file_name = File.join("/tmp", SecureRandom.uuid)
                @tmp_stage_file_ext = File.extname(path)
                FileUtils.cp(path, File.join("/tmp", "#{tmp_stage_file_name}#{tmp_stage_file_ext}"))
            end
        end
    end

    def replace_original_file
        if !file.blank? && !tmp_stage_file_name.blank?
            path = File.join("/tmp", "#{tmp_stage_file_name}#{tmp_stage_file_ext}")
            if File.exist? path
                FileUtils.cp path, file.path
                FileUtils.rm path, force: true
            end
        end
        @tmp_stage_file_name = nil
        @tmp_stage_file_ext = nil
    end
end
Image Processor
lib/paperclip_processors/image_thumb.rb

module Paperclip
    class ImageThumb < Processor
        HEIGHT = 320
        WIDTH = 320
        def initialize file, options = {}, attachment = nil
      super
      @file = file
      @instance = options[:instance]
      @current_format   = File.extname(@file.path)
      @whiny = options[:whiny].nil? ? true : options[:whiny]
      @basename = File.basename(file.path, File.extname(file.path))
            @geometry = options[:geometry]
    end

    def make
      geometry = Paperclip::Geometry.from_file(@file)
      filename = [@basename, @current_format || ''].join
      dst = TempfileFactory.new.generate(filename)

            begin
                cmd = file.content_type != 'image/svg+xml' ?
                    %Q(convert '#{file.path}' -resize '#{WIDTH}x#{HEIGHT}^' -gravity 'center' -crop '#{WIDTH}x#{HEIGHT}+0+0' +repage '#{dst.path}') :
                    %Q(rsvg-convert -a -w #{WIDTH} -h #{HEIGHT} -f svg '#{file.path}' -o '#{dst.path}')
                Paperclip.run(cmd)
            rescue
                raise Paperclip::Error, "There was an error processing the thumbnail for #{@basename}" if @whiny
            end
      dst
    end
    end
end

Monday, July 11, 2016

SVG support for Imagemagick in Ubuntu

Converting SVG to jpeg/png/gif via Imagemagick in command line you can get Unable to find rsvg-convert library exception. This means you have no support for SVG.

Type in your terminal
sudo apt get install rsvg-convert
in order to add support for scalable vector graphics.

In case if rsvg-convert wasn't found in your repositories you can perform
sudo apt get install librsvg2-bin

After that you will be able to perform conversion from SVG to one of the popular image formats