Category: Software
-
Generate a Random String of Same Pattern as Given String
Here is a PHP snippet showing how to generate a random string of same pattern as input string.
-
Replace Collation on a MySQL Dump File
Sometimes we may find difficulty with importing a database from dump file which is created from a different machine. It may issue an error message like this: Which means the dump file uses a collation which the mysql server on the target machine not understanding. One solution is to replace the collation with one that…
-
Install and Run Multiple PHP Versions in Ubuntu 22.04
I wanted to run both Drupal 7 and 9, as part of my work, in my machine now running on Ubuntu 22.04. Drupal 7 best run with PHP 5.6 while Drupal 9 requires either PHP 7.4 or 8.1 I could make it work after some research and try. Here is how I made it work.…
-
Quick Twig Template Rendering Without Much Set Up
Sometimes, I want to prepare more readable output from my PHP scripts. It is good to create a template and render with values from script out put. Here is a quick way to render a twig template. First lets assume the HTML twig template (test-report.html.twig) is: Then we have this script, test-script.php: Keeping above two…
-
Install MySQL 5.7 on Ubuntu 20.04
First follow installation instructions given at https://docs.docker.com/engine/install/ubuntu/ . Then make sure docker is running properly: Ensure it created the image by: Now, install docker MySQL 5.7 image and create a volume for storing data. Make a MySQL installation with command: Replace the password with your one. To show running instances: Login to docker instance terminal:…
-
Building Wheel for a Python Package Failed
Today I was trying to install frappe-bench package within a newly created python 3 virtual environment in my Ubuntu 20.04. It gave this error in terminal. However, the package appeared to be installed even with above error. Then I got this SO thread in my search https://stackoverflow.com/questions/53204916/what-is-the-meaning-of-failed-building-wheel-for-x-in-pip-install. It has this answer from a pip maintainer…
-
Use Python Markdown Extension in Jupyter Notebooks
I regularly use Python Markdown when working with Jupyter notebooks. It is actually straightforward to set up in Jupyter, but I always forget the exact steps to be followed whenever I set up Jupyter notebook especially after installing a new OS. So, there are those steps, I note here to help myself in future. First…
-
Get MP4 from MKV and Extract Subtitle(s)
This command helped me to get MP4 file from MKV file: This command will help to extract subtitle from MKV file. The above command will extract first subtitle. MKV file contains more than one subtitle track and if you want to extract one of them. Then you can replace “0:s:0” with “0:s:1” to extract second…
-
Create PDF from Image Files and Resize PDF to Standard Page Size
First convert image files to PDF with command: Then resize PDF to standard size with command: Read more about pdfjam at here.