How to create a folder in PHP if it doesn’t exist

This article will show you how to create a folder automatically in PHP if it does not exist.  We will see several different approaches to solve this problem in a right way.

Continue reading

Posted in PHP | 1 Comment

Solution for ‘Lombok plugin incompatible with 2018.1 Intellij Idea’ warning

Migrating from older to the newest version of IntelliJ Idea can cause a warning message for Lombok module.
Continue reading

Posted in JetBrains suite | Tagged , , , | Leave a comment

How to loop over HashMap in Java

HashMap is one of the most used data collection. There are several ways how to loop over it and get what you need. We will show five different ways how to loop over HashMap. So what is the best way to iterate over the items in a HashMap? Continue reading

Posted in Java | Leave a comment

How to sync up new Git repository on GitHub or GitLab

From time to time you necessary to set up new Git repository. This article is about a list of commands which are helpful for creating a new repository and syncing it with GitHub or GitLab.

Continue reading

Posted in Solutions | Tagged , , | Leave a comment

Python String split() Method

From time to time, you will find yourself trying to get a list of things from a string. For this purpose, you can use the split() function.

Continue reading

Posted in Python | Leave a comment

How to concatenate or append strings in Python

If you are looking for answer how to append strings in Python, you are on the right page.
Continue reading

Posted in Python | Leave a comment

How to write CRON jobs

CRON jobs or CRON tasks are very useful for automatizing repetitive work. With cron job help you can for example once a week wipe out cache files in your app directory or send email about number of newly registered users. You can imagine any kind of task which require repetitiveness.

Continue reading

Posted in Tips & tricks | 1 Comment

How to compute distance between 2 GPS points?

In one of my projects I was looking for simple way how to compute direct distance between 2 arbitrary airports in the world. Simply, I was looking for a way to measure distance between 2 GPS points. Naturally there exist several ways how to compute such thing. After research I found that many people use algorithms derived from Great circle distance method [wiki].

Here is a PHP code:

    /**
     * Great Circle distance algorithm
     *
     * Notes:
     * - South and West locations are negative, North and East are positive.
     * - Automatically transfer degrees to radians
     * - https://en.wikipedia.org/wiki/Great-circle_distance
     *
     * @param lat1 - latitude of first point on sphere
     * @param lon1 - longitude of first point on sphere
     * @param lat2 - latitude of second point on sphere
     * @param lon2 - longitude of second point on sphere
     * @param unit - units for output (miles, kilometers, nautical miles)
     * @return - distance in desired distance units
     *
     */
    function GCdistance($lat1, $lon1, $lat2, $lon2, $unit) {
        $theta = $lon1 - $lon2;
        $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
        $dist = acos($dist);
        $dist = rad2deg($dist);
        $miles = $dist * 60 * 1.1515;
        $unit = strtoupper($unit);

        switch ($unit) {
            case 'MI':
                return $miles;
                break;
            case 'KM':
                return ($miles * 1.609344);
                break;
            case 'NM':
                return ($miles * 0.8684);
                break;
        }
    }

There are 2 simple corrections how to simplifie this algorithm more. First by padding all the sub-results into one big equation. And second, by ensuring the the input units will be always the same (using numbers instead of Strings) strtoupper() function can be removed.

 

Posted in Solutions | Tagged , | Leave a comment

How To Start With Codeception PHP Framework And Selenium

Recently I have been working on one job interview with test case requiring to write portion of automatized tests in Codeception PHP framework. Since I didn’t have any experience with Codeception PHP framework I needed to learn quickly as much as I could.

Continue reading

Posted in Tutorials | Tagged , , , , , , | Leave a comment

How to solve plugin or theme installation error on XAMPP local WordPress installation

Shifting from Windows to OS X makes lots of simple tasks ridiculously hard. Since I was thought by Windows that installing things on WordPress localhost installation shall be easy, it took me a lot of temper and power to bite into my lips and start searching for solution.

Continue reading

Posted in Wordrpress | Tagged , | Leave a comment