Find disk usage at command line

To find out disk usage by directories, use:

  • ncdu
Advertisements

Add PDF pseudo-printer on Ubuntu

Sure, there already exists an option to print to a file, but sometimes you wish that there was a dedicated virtual printer for producing PDF output.

Try this:

  • apt-get install cups-pdf

Prestashop front page error – too many redirects

A very frustrating feature of Prestashop online store package is it being prone to unexplainable endless redirect loop at the shop front right after successfully completing installation. The admin access is working just fine, but as soon as you want to see the store, you get an error.

The actual error message will vary depending upon your browser:

  • Firefox:
    The page isn’t redirecting properly
  • Chrome/Vivaldi:
    This page isn’t working
    <site> redirected you too many times.
    ERR_TOO_MANY_REDIRECTS
  • Brave:
    Attempting to load an URL resulted in too many redirects.

It is also extremely irritating, that the shop you initially set up in your test environment works perfectly, but after setting up the same thing on your production server it enters endless redirect loop right after the setup was supposedly successfully completed.

I am calling it a “feature” and not a “bug”, because I can see that it has been around for many years, but nothing was done to fix it, so it is tempting to assume that it is there by design and is supposed to remain there forever. Also it is extremely hard, nearly impossible to find the solution to this unfortunate phenomenon. There is a lot of various cryptic advices online, but next to nothing that would actually work.

Well. Anyway… The problem obviously is the SSL.

It is very likely that your test environment did not use SSL, while the production server does. In order to break out of the redirect loop, you must enable SSL in Prestashop settings, where it is off by default.

In Prestashop 1.6:

  • Go to Preferences -> General -> Enable SSL, switch it from No to Yes.
  • Click the save icon bottom right to save the setting.
  • Go to Preferences -> General -> Enable SSL on all pages, switch it from No to Yes.
  • Click the save icon bottom right to save the setting.

In Prestashop 1.7:

  • Go to CONFIGURE -> Shop Parameters -> General -> Enable SSL, switch it from No to Yes.
  • Click the save icon bottom right to save the setting.
  • Go to CONFIGURE -> Shop Parameters -> General -> Enable SSL on all pages, switch it from No to Yes.
  • Click the save icon bottom right to save the setting.

That is all.

Thanks to Daria Gavrilova at plesk.


Web fonts do not show if www missing

You may experience a situation when the locally served Web fonts used in your website do not show if the address is entered in the browser without the leading “www” part, for example, instead of “www.example.com” you type it in simply as “example.com”.

The simplest solution is to just redirect all request that are missing the “www” part to the correct address with an .htaccess file like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]


Generate strong password with apg

The passwords created at default settings by the apg utility are probably quite all right for everyday purposes, but sometimes you want a stronger security, so you may run it with few extra parameters to generate stronger passwords:

  • apg -m 20 -x 1 -M SNCL -a 1

Generating nice and ordered random names

You may want to generate random names, ordered by alphabet, which sound nice, instead of using total random gibberish or, on the opposite, using standard “alpha”,”bravo” etc. naming convention.

This may be useful for naming product versions or any other purpose where you need a sequential indexing of items.

One solution is to use wordoid.com, enter the first letter in accordance to your current version, and pick one name to your liking from the generated results.


Photoshop PSD thumbnailer for Gnome file manager

This script generates a system script and associated meta-information for displaying Adobe Photoshop .PSD image thumbnails in Gnome file manager. It is intended to work with Nautilus, but also works with Nemo in Linux Mint 18.2 Sonya Cinnamon, even though “Add GConf Hooks” section of the script fails.

Run the script with sudo and reboot afterwards.

The script was acquired from askubuntu.com here, and it is actually preferable that you get it from there, because here it may be automatically reformatted and fail at execution. It is posted here only for archival purposes.


#!/bin/bash

# ———————————————————–
# — Write psdthumbnailer
# ———————————————————–
OUTFILE=/usr/lib/psdthumbnailer
(
sudo cat <<‘EOF’ # bin/bash # Arguments / Parameters %i %o %s f_in=$1 f_out=$2 f_size=$3 # Execute Convert PSD to PNG through ImageMagick exec convert “psd:$f_in[0]” -scale “$f_sizex$f_size” “png:$f_out” EOF ) > $OUTFILE
# ———————————————————–
# — Write photoshop.thumbnailer
# ———————————————————–
OUTFILE=/usr/share/thumbnailers/photoshop.thumbnailer
(
sudo cat <<‘EOF’ # bin/bash [Thumbnailer Entry] TryExec=/usr/lib/psdthumbnailer Exec=/usr/lib/psdthumbnailer %i %o %s MimeType=image/vnd.adobe.photoshop; image/x-photoshop; image/x-psd; EOF ) > $OUTFILE
# ———————————————————–
# — Set File Permissions
# ———————————————————–
sudo chmod 0755 /usr/lib/psdthumbnailer
sudo chmod 0644 /usr/share/thumbnailers/photoshop.thumbnailer

# ———————————————————–
# — Add GConf Hooks to parse thumbnails
# ———————————————————–
sudo gconftool-2 –set /desktop/gnome/thumbnailers/image@vnd.adobe.photoshop/enable –type bool true

sudo gconftool-2 –set /desktop/gnome/thumbnailers/image@vnd.adobe.photoshop/command –type string “/usr/lib/psdthumbnailer %i %o %s %i %o %s”

# ———————————————————–
# — Install Dependencies
# ———————————————————–

sudo apt-get install imagemagick