Customize an android shortcut icon

You can use Shortcut Maker “to change individual app icons on your phone for first-party and third-party apps just the same. It’s a popular alternative method that lets you tweak the app icons on your home screen.”

pdf editor (linux)

The best pdf editor in linux is, IMO, Master PDF. That is not, however, an open source application: to get its full function you must buy a (quite expensive) license.
You can bypass this problem using a previous pdf master release, that have less features, but all free. Remember to lock (pin) this relaese, otherwise your software manager will update it to the new ones.

There are others pdf editor, but not so good

  • LibreDraw i.g. can edit a pdf, but the result a very untidy (detroying original formattation) and huge-sized (4 or 5 bigger than the original one) page.
  • Scribus can edit a pdf, but not the outlines, and in a very poor mode. Moreover big pdf files are a problem for Scribus.

to install an appimage

Make an appimage executable is absolutely easy. But less easy is to associate that application with its mime-type files. Especially if that type of file doesn’t exist already on your system.

A very easy way, then, is to go to the appimage folder and, in a terminal, do

(sudo) ./appimage-name install

With this command all will be ready, correctly set, as if that application wouldn’t be an appimage, but a “regular” one.

automatize your website

Recently I managed to make some new improvements about website automation

After the automation of gallery, in a previous post, I did this other automation (with php):

list php pages with a given name

With the following code, you can list (and link) all webages php files containing in its filename the variable you can set:

<?php
echo "<h3>testi on-line di $autore</h3>";
echo "<ul class=\"flexmenu\">\n";

// Escape special characters in $autore to use safely in glob pattern
$phpfiles = glob("$path/*" . preg_quote($autore_di, '/') . "*.php"); // Get all PHP files with $autore in the name

foreach ($phpfiles as $phpfile) {
    $contents = file_get_contents($phpfile);

    preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatch);
    preg_match('/\$subtitle\s*=\s*"(.*?)";/', $contents, $subtitleMatch);
    preg_match('/\$description\s*=\s*"(.*?)";/', $contents, $descriptionMatch);
    preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatch);

    $title = $titleMatch[1] ?? 'No title';
    $subtitle = $subtitleMatch[1] ?? 'No subtitle';
    $order = $orderMatch[1] ?? '';
    $description = $descriptionMatch[1] ?? 'No description';

    // Correctly extract the filename
    $filename = $phpfile; // Use basename on $phpfile directly

    echo " <li role='menuitem' style=\"order:$order\"><a href=\"{$filename}\">{$title}</a>, <i>{$subtitle}</i>: {$description}</li>\n";
}

echo "</ul>";


echo "<h3>testi on-line su $autore</h3>";
echo "<ul class=\"flexmenu\">\n";

// Escape special characters in $autore to use safely in glob pattern
$phpfiles = glob("$path/*" . preg_quote($autore_su, '/') . "*.php"); // Get all PHP files with $autore in the name

foreach ($phpfiles as $phpfile) {
    $contents = file_get_contents($phpfile);

    preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatch);
    preg_match('/\$subtitle\s*=\s*"(.*?)";/', $contents, $subtitleMatch);
    preg_match('/\$description\s*=\s*"(.*?)";/', $contents, $descriptionMatch);
    preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatch);

    $title = $titleMatch[1] ?? 'No title';
    $subtitle = $subtitleMatch[1] ?? 'No subtitle';
    $order = $orderMatch[1] ?? '';
    $description = $descriptionMatch[1] ?? 'No description';

    // Correctly extract the filename
    $filename = $phpfile; // Use basename on $phpfile directly

    echo " <li role='menuitem' style=\"order:$order\"><a href=\"{$filename}\">{$title}</a>, <i>{$subtitle}</i>: {$description}</li>\n";
}

echo "</ul>";
?>

You can call that code in a webpage, with something like this:

<?php
/*files beginning with i must be uppercase */
$path="../testi";// your path
$autore="Aristotele";
$autore_di="Aristotele[di]";//texts of $autore
$autore_su="Aristotele[su]";//texts about $autore
include "$root/lista-files-testi-[autore]-online-con-metatags.inc";
?>

automatically list files in a website menu

You can create an automatic menu list of your files in a given folder, and in a folder with the same name of one file (without extension, of course). With a code like the following:

<?php
$phpfiles = glob("{$root}/$menupath/[^index]*.php");

foreach ($phpfiles as $phpfile) {
  $contents = file_get_contents($phpfile);

  // Match $order
  preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatches);

  // Match $title
  preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatches);

  // Assign the values
  $order = $orderMatches[1] ?? null;
  $title1 = $titleMatches[1] ?? null;

  $filename1 = basename($phpfile); // Get only the file name
  $filename = pathinfo($phpfile, PATHINFO_FILENAME);
  $filename = str_replace('-', ' ', $filename); // Replace hyphens with spaces in the filename
  $filename = ucfirst($filename); // Optional: Capitalize the first letter for better readability
  $link = "$root/$menupath/{$filename1}"; // Create the relative link

  // Start the list item for the menu
  echo "<li role='menuitem' style=\"order:$order\"><a href=\"{$link}\">{$title1}</a>";

  // Check if a sub-menu is required (look for a folder matching the filename)
  $folder = "{$root}/$menupath/{$filename}";
  if (is_dir($folder)) {
    // If the subfolder exists, generate the sublist automatically
    $subfiles = glob("{$folder}/[^index]*.php");
    if (count($subfiles) > 0) {
      echo "<ul class='flexmenu'>"; // Start sublist
      foreach ($subfiles as $subfile) {
        $subfileName = basename($subfile);
        $subfileTitle = pathinfo($subfile, PATHINFO_FILENAME);

        // Match $order for subfiles
        $subfileContents = file_get_contents($subfile);
        preg_match('/\$order\s*=\s*"(.*?)";/', $subfileContents, $subfileOrderMatches);
        $subfileOrder = $subfileOrderMatches[1] ?? null;

        // Remove hyphens and add colon after the main part of the title
        $subfileTitle = str_replace('-', ' ', $subfileTitle);

        // Separate the main part (before the colon) and the rest of the title
        $parts = explode(' ', $subfileTitle, 2); // Split into two parts: main and description
        $mainPart = $parts[0]; // This is the first word (e.g., "Aristotele")
        $description = isset($parts[1]) ? $parts[1] : ''; // Everything after the first space (e.g., "l etica")

        // Combine the main part with colon and the description
        $formattedTitle = ucfirst($mainPart) . ": " . $description;

        $subfileLink = "$root/$menupath/{$filename}/{$subfileName}";
        echo "<li style=\"order:$subfileOrder\"><a href=\"{$subfileLink}\">{$formattedTitle}</a></li>";
      }
      echo "</ul>"; // End sublist
    }
  }
  // End the list item for the menu
  echo "</li>\n";
}
?>

That you can call in a place of the whole menu with a code like this:

 $menupath="your/relative-path";
 include "menu-automatic.inc"; 

Where menu-automatic.inc is the name of the file containing the above code.

Automatic images gallery

With flickity and php you can realize an automatic images gallery, with automatic titles and (if they are present) metatags:

<div id="gallery" style="width: 50%; margin-left: auto; margin-right: auto; margin-bottom: 4%;">
<div class="carousel" title="cliccare su una immagine per ingrandirla" data-flickity='{ "cellAlign": "center", "contain": true, "fullscreen": true, "wrapAround": true, "lazyLoad": 1 }'>

<?php

$images = glob("your-images-path/*.jpg");
$flag=1;

foreach($images as $image)
{
  // Ricava il titolo dell'immagine (metatag o nome del file)
  $imagedescription = '';
  if (function_exists('exif_read_data')) {
    $exifData = exif_read_data($image);

    // Controlla se esiste un campo di commento o descrizione
    if (isset($exifData['ImageDescription'])) {
      $imagedescription = $exifData['ImageDescription']; // Titolo o descrizione nell'EXIF
    }
  }

  $imageTitle = '';

  // Verifica se la funzione IPTC è disponibile
  if (function_exists('iptcparse')) {
    // Ottieni i metadati IPTC dall'immagine
    $iptcData = iptcparse(@iptcembed('', $image)); // iptcembed recupera i metadati IPTC da un'immagine

    // Controlla se il campo "headline" (titolo) è presente nei metadati IPTC
    if (isset($iptcData[2])) {
      $imageTitle = $iptcData[2][0]; // Il campo 2 è "headline" nell'IPTC
      // Troncamento del titolo se troppo lungo
      $maxLength = 50; // Lunghezza massima del titolo
      if (strlen($imageTitle) > $maxLength) {
        $imageTitle = substr($imageTitle, 0, $maxLength) . '...';
      }
    }
  }

  // Se non c'è un titolo IPTC, usa il nome del file senza trattini
  if (empty($imageTitle)) {
    $imageTitle = pathinfo($image, PATHINFO_FILENAME); // Ottieni il nome del file senza estensione

    // Rimuovi trattini dal nome del file, se presenti
    $imageTitle = str_replace('-', ' ', $imageTitle);
  }


  echo '<div class="carousel-cell' .($flag?' active':''). '">';
  echo '<img title="'. $imagedescription .'" data-flickity-lazyload="'. $image .'" onclick="onClick(this)" />';
  echo "<span class='carusel-image-title'>$imageTitle</span>";
  echo '</div>';
  $flag=0;
}
?>

</div>
</div>

convert pdf to svg

A good website is Convertio: it can convert, for free, your pdf to an svg absolutely identical, from a graphical point of view, with your original pdf, and the text remain text.

But on the other hand the resulting svg file is much bigger than the original pdf, because it is not optimized at all.