LibreWriter styles strange behavior

It could happen that apply a (custom) style doesn’t work as expected, i.g. even you have in that style a margin-left this margin is not applied, or it is only temporarily.

To solve you can try removing unused custom styles. Or making that style non hierarchically depending from other styles.

Regex for first lowercase letter

If you have en ebook that split badly a paragraph, you can try (to merge the bad splitted paragraph), as find

</p>\n\n\s\s<p>([a-z])

so that a paragraph beginning with a lowercase word be merged with the previous one.

But in Calibre editor you must check “case sensitive”, otherwise [a-z] will be read as [A-Z], and all first letters (lower and upper case) will be selected.

And as replace you could try

 \1

In this way you keep whatever letter is found with ([a-z]) in the result.

Regex for “space”

It can happen that you want replace a double space before <p>: use the \s. I.g. to replace

,</p>

<p>

You should use this find: ,</p>\n\n\s\s</p>

leaving xampp

For many years I used xampp (for Linux: Lampp), because of its simplicity, unlike the “native” Linux apache/php/mysql apps, wich seemed to me very difficult to configure.

The pro of xampp is its simplicity (with few mouse clicks you can do all to install and configure your local php/mysql sever). But the con is that your xampp apps don’t are updated regularly, and there can raise conflicts with Linux “native” mysql.

Therefore I decided to learn how to configure “native” (system-rooted, so to say) apache/php/mysql apps. I chose to install mariadb and not mysql.

And in these last weeks I managed to configure the server, with the following steps:

  • sudo apt install -y apache2
  • sudo apt install -y php
  • sudo apt install mariadb*
  • sudo mysql_secure_installation
  • sudo mysql -u root -p (and within >mysql shell
    • use mysql
    • GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION;
    • SHOW GRANTS FOR 'root'@localhost; //to check if it is all right
    • FLUSH PRIVILEGES;
    • exit;
  • sudo systemctl enable mariadb.service

off-line comparation of two documents

You can use LibreOFfice (OpenOffice), following these steps (see here):

«In order to compare documents you need to have the original document and the one that is edited. To compare them:

  1. Open the edited document that you want to compare with the original document.
  2. Select Edit > Compare Document.
  3. An open document dialog appears»

mysql add some string to several rows

If a column has several rows, i.g.:

'red'  
'NULL'  
'red, yellow'  
'green'  
'NULL'  
'yellow, green'

And you want to add a new string (‘blue’) to every row, so that the result be:

'red, blue'  
'blue'  
'red, yellow, blue'  
'green, blue'  
'blue'  
'yellow, green, blue'

you can use this code

UPDATE my_table 
SET mycolumn = CONCAT('same new string ',mycolumn); 

But the above code works only for rows with some content, not for the empty (NULL) ones. Therefore you can complete your task with the following:

UPDATE my_table 
SET mycolumn = 'same new string' 
WHERE mycolumn IS NULL; 

mysql/php output in utf8

To avoid output problems in non-latin characters you should add this line in a msyqli query (i.e. after $db = mysqli_connect($db_host, $db_user, $db_password, $db_name);):

mysqli_set_charset($db, 'utf8');

import an external table to a mysql table

  • You can use a graphical interface to prepare the rows to insert in mysql table: be careful that a) the number of columns be matching with the mysql table rows number and b) the order of columns be the same.
  • Save your date as csv: in this way you will be able to make further modifications to your data: i.g. you could add new ,NULL,columns (because in librecalc if a column is empty at the end of a file that column is not added).
  • Be very careful with comma (,) within the columns, if you import the table in mysql with comma as column separator. You should avoid commas within a column, if you use commas as separator.
  • In phpmyadmin import your csv file as a new table. As and of line you can set \n if yout line ends with something like “NULL”. Otherwise, if you rows ends with “NULL”, you will get an undesired column at the end of teh impoorted table.
  • Don’t worry if the columns type doesn’t match with the destination mysql table: this is negligible.
  • In sql do this command:

INSERT IGNORE
INTO your_destination_table
SELECT *
FROM the_new_data_table-from-csv;

  • Using insert IGNORE you can avoid to delete the ID beginning column, if it is simply an autoincrement one.
  • Your new rows should have been added to your destination table: done!