If you need to display an image created / opened using the Imagick library in the img tag, then you can use this code:

$image = new Imagick();

//output to the img tag:
echo '<img src="data:image/jpg;base64,'.base64_encode($image->getImageBlob()).'" alt="test" />';


If you're experiencing a Git "pre-receive hook declined" error, there are a few options how to fix it. 

The most common reason is that in your repository (for example GitLab) the master branch is now “protected” and the main branch have a name “main”.

Possible solutions:

  • In the project settings (Settings > Repository), go to the section of protected branches "Protected branches", find the branch "master" and click on "Unprotect".
  • As an alternative solution, you can set your user permission to make changes in this branch.

To query data from a table for the current day, you can use the following query code:

FROM table_name
WHERE DATE(date_field_name) = CURDATE()

where table_name =  the name of the table where you want to get data from.

date_field_name - name of the field where dates are stored (in date or datetime format)


An alternative is to write today's date into the query using PHP (sometimes it makes sense if you use indexing on a date column):

$mysqlQuery = "SELECT *
FROM table_name
WHERE date_field_name > '" . date('Y-m-d') . " 00:00:00' ";

To translate Daterangepicker into your language you need to add translations during script initialization.

Initial values:

locale: {
"daysOfWeek": [
"monthNames": [
"applyLabel": "Apply",
"cancelLabel": "Cancel",
"fromLabel": "From",
"toLabel": "To",
"customRangeLabel": "Custom",

Replace those values with your language. 

Let's  consider the case that you have a date “08/25/2022” and you want to use in a new Date() object. The problem is that this date format cannot be passed to new Date(), because there will either be an error or the final date value won't be correct.

First you need to convert the date to the other format.

An example:

var splittedDate = "25.08.2022".split(".");  
var formattedDate = splittedDate[1] + "/" + splittedDate[0] + "/" + splittedDate[2];
var finDate = new Date(formattedDate);

This is an example of a function that extracts files from an archive, renaming them if there are files with the same name in the destination folder:

function extractZip($zipFilePath, $folderToExtract) 
$zipArchive = new ZipArchive();
$result = $zipArchive->open($zipFilePath);
if ($result === TRUE) {
for ($i = 0; $i < $zipArchive->numFiles; $i++) {
$filename = $zipArchive->getNameIndex($i);
$filePath = $folderToExtract. '/' . $filename;
if (file_exists($filePath)) {
$fileInfo = pathinfo($filename);
$newFileName = $fileInfo['filename'] . '_(copy).' . $fileInfo['extension'];
copy("zip://" . $zipFilePath . "#" . $filename, $folderToExtract . '/' . $newFileName);
} else {
copy("zip://" . $zipFilePath. "#" . $filename, $filePath);

Function parameters:

$zipFilePath - path to zip file

$folderToExtract - path to the folder where the archive should be unpacked.


It should be noted that the function has not been tested on nested archives and nested folders.

A function that allows you to extract files from a zip archive to a specified folder:

function extractZip($filePath, $extractTo){
$zip = new ZipArchive();
$result = $zip->open($filePath);
if ($result === TRUE) {
return $result;

$file = ''; // change to your file path
$folder = 'myfolder'; // change to your folder path

extractZip($file, $folder);

Note: you need a zlib library for this code to work


If you want to delete a directory using PHP,  first you need to delete all existing files inside it.

For these purposes, you can use this function:

public function removeDirectory($dir): bool
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->removeDirectory("$dir/$file") : unlink("$dir/$file");
return rmdir($dir);

Let's consider an example of how you can get an image dimensions, knowing its URL.

We create an Image object, then assign a link to it and then after image load we can find out the width and height of the object.

An example:

const img = new Image();
img.src = ''; // change to your URL
img.onload = function() {

This example should print to the console the width and height of the image you have specified in the URL.

If you need the restriction that user cannot select a date in the Datepicker from the future, then there are 2 easy ways to do this.

You must add the maxDate parameter with a value of 0 or the current date “new Date()” at Datepicker initialization. 

An example: 

 $(function() {
$( "#mydate" ).datepicker({ maxDate: new Date() });


$(function() {
$( "#mydate" ).datepicker({ maxDate: 0 });

If you have encountered an error  "A problem occurred evaluating project ':app'. > Could not find method kapt() for arguments"  when you have tried to include room in Android Studio, then this quick solution should help you to fix it up.

In the build.gradle file find plugins section and add id 'kotlin-kapt'” to it: 

plugins {
id ''
id ''
id 'kotlin-kapt'