PHP Closure and Lazy Loading

What is the Closures?

Let’s define firstly what is the anonymous function? If you are a front-end developer and have worked with JavaScript, you should be already familiar with anonymous functions. These pretty useful to write short inline functions, define callback etc.

An anonymous function is a function that was declared without any named identifier to refer to it. Here is the PHP implementation of anonymous function:

<?php
$anonymousfunctionReference = function(){
    echo "Anonymous function called"
};

echo $anonymousfunctionReference();

Continue reading “PHP Closure and Lazy Loading”

Advertisements

HTTP Cache Headers

HTTP caching can speed up web applications. It’s standardized and well implemented in all modern browsers and results in a lower latency app and improved responsiveness.

HTTP caching occurs when an item is fully cached for faster retrieval the next time the resource is required. The browser may choose to not contact the server at all and simply use its own local copies of web resources. There are many cache headers such as “Cache-Control”, “Expires”, “Last-Modified” and “ETag”.

Continue reading “HTTP Cache Headers”

How To Add Jobs To cron Under Linux or UNIX

What is the Cron job?

Cron job are used to schedule commands to be executed periodically. You can setup commands or scripts, which will repeatedly run at a set time. Cron is one of the most useful tool in Linux or UNIX like operating systems. The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, and /etc/cron.*/ directories. It also checks the /var/spool/cron/ directory.

What is the Crontab?

Each user can have their own crontab file, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. You need to use crontab command for editing or setting up your own cron jobs.

To see your crontab file, type the following command at the UNIX / Linux shell prompt:
$ crontab -l

In order to edit your crontab file, type the following command at the UNIX / Linux shell prompt:
$ crontab -e

Continue reading “How To Add Jobs To cron Under Linux or UNIX”

Know which types to choose

Types of fat to choose

Let’s talk about Health. When choosing fats, pick unsaturated fat over saturated or trans fat. You don’t need to completely eliminate all fat from your diet. In fact, some fats actually help promote good health. But it’s wise to choose the healthier types of dietary fat and then enjoy them.

Here’s how to know the difference:

Continue reading “Know which types to choose”

Regular Expressions

What is a Regular expressions?

Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec and test methods of RegExp, and with the match, replace, search, and split methods of String.

How to Write a Regular Expression Pattern

A regular expression pattern is composed of simple characters, such as /abc/, or a combination of simple and special characters, such as /ab*c/ or /Chapter (\d+)\.\d*/. The last example includes parentheses which are used as a memory device. The match made with this part of the pattern is remembered for later use, as described in Using Parenthesized Substring Matches.

Continue reading “Regular Expressions”

Gradle build tool

Sharing my own experience with you on Gradle

Gradle is nice tool to build applications like Maven and ant since it brings best of Maven and ANT… One thing that I don’t like with Gradle is too slow! It is slowest one when compared with ANT and Maven but it is simplest one either 😉

Gradle may be future of building JAVA apps. One day, it might be more popular and will be replaced with Maven by many companies.

Gradle uses the “Groovy” programming language! Don’t panic! You don’t need to know Groovy in order to write build script in Gradle! You just need to understand the Groovy and that is it! However, if you wanna learn about Groovy then here is link for you: Gradle

Continue reading “Gradle build tool”