Train your engineering workforce for using Cloud services

Everybody is talking about Cloud. Cloud and Cloud. Major tech giants are very busy for their Cloud PaaS (Platform as a Service) services including Google, Amazon, Azure, IBM and so on. There are lots of player are playing this game to takeover cloud market share. According to Right Scale blog post about their survey,

68 percent of enterprises run less than a fifth of their application portfolios in the cloud. 55 percent of enterprises report that a significant portion of their existing application portfolios are not in cloud, but are built with cloud-friendly architectures. It’s amazing. Everybody is preparing for Cloud

– Right Scale Blog

So why not you. As the cloud service market will grow with competition consumer will be much benefited. It’s simple calculation. Recently I monitored AWS, Google Cloud monthly update for their Cloud service. And I realized that every month most of the cloud service provider are releasing on avg. 10-15 new products and continuously improving their existing products. That’s a very good sign that they are expecting more people to go for cloud.

goldman-sachs-cloud-computing1

As much as I read about cloud I am feeling amazing as an engineering perspective. If we go few years back, as a software engineer always it was a hassle to deploy service for public, managing theme, upgrading them, automate the workflow. But now cloud made all those things so much easier even I can save my 40-50 hours after every project my team finish and I can become a more worry-less person than ever before. At Preview Technologies HQ, we officially announced that “we are going cloud and we are preparing resources for our existing customers also to become cloud friendly”. 50% of our engineering workforce are now getting training about cloud services and we are encouraging them about the necessity of going cloud.

cloud-computing-trends-public-cloud-usage-2015-1

Our business is heavily web application development service based and most of our clients are business institutions. So it’s not easy to bring all of them on board but we are trying and after our engineering team training we are planning to run massive campaign for our business clients about cloud. We never preferred any specific cloud service provider but also we start providing our clients to chose their best cloud providers and we can work with them. Currently most of our clients can choose between Google Cloud, AWS. As we go further, this list will be extended. All software and technology companies should start train their engineering workforce to practice cloud service and if they start doing that from right now, they must be benefited in near future cause clients are also becoming more smarter than before. They want cloud. Some clients are obsessed with this word CLOUD. So if you have a business or you are a leader among your engineering team, it’s time to be trained up and getting ready for cloud.

 

Why tag is an important piece of website

At the highest point of most HTML reports there are components that don’t show on website pages (generally). These components are avoided per-users however they are extremely valuable to your site pages and shouldn’t be forgotten unless you have a justifiable reason motivation to.

In fact, there is stand out tag that is required to be at the highest point of all HTML reports: the TITLE component. This required component is just legitimate inside the HEAD component, which is just valid inside the HTML component.

<html>
<head>
<title>

 

You can include a DOCTYPE tag above the html element

The TITLE element :

Always include a TITLE on web page.

1. 
Search engines utilize the TITLE as the essential method for cataloging sites. If your page doesn’t have an engaging or descriptive title the web indexes will give it a lower positioning than different pages. This is likewise what shows as the connection message in search engine results.

2. It shows at the top point of the browser window or in the tab, detailing the page in the browser.

3. It is what is composed when somebody bookmarks your site. If that individuals bookmark your site, you need them to recall that it was your site and not “untitled”.

 

HTML and HEAD elements :

Both of these components are required as a result of the TITLE component. They characterize your archive and give an area to hide data, as META labels that can enhance your site’s remaining in search engines.

 

Meta Data :

Meta data will be information contained in the HEAD of your HTML document to give extra data about your website page. You can include data like the author’s name, the program that was utilized to make the page, the date the page ought to expire, and, maybe in particular, descriptions and keywords for search engines.

But the most imperative META tag you ought to include on your web reports is the character set, or charset. This is essential for the security of your site pages. In HTML5, you would compose:

<meta charset=”UTF-8″>

The character set ought to be the primary line in your HEAD that programmers can’t hack it up.

Check return type of PHP class method in PHP

Most often we try to determine the return type of methods programmatically. And that’s for PHP’s ReflectionMethod like ReflectionClass. It’s simply awesome and useful to get the information of any methods inside your PHP class. So now let’s see how you will check which method return what types of data for your PHP class.

From the above code, we just created an example class ‘MyClass’ with one method ‘testMethod’ that returns bool type.

And we created a simple function which will take the method’s information as string and our required tag (@return) as parameter and it will tell us what types of return type testMethod() method will return. Now time to play the magic here. We simply implemented ReflectionMethod to get the information of the given method (testMethod) and passed that information in checkDocBlock() function that we created to make task simpler.

Now when you will execute this file you will see ‘bool’ that means our testMethod() is returning boolean data type. Happy PHP’ing.

Using custom domain to Google App Engine with custom routing

Adding custom domain to Google App Engine is pretty straight-forward and easy to implement.

But there are some complexities around it when you want to point your custom domain or sub-domain to any specific service or module in Google App Engine. In your Google Cloud project you can have multiple App Engine service. By default your first app engine app will be considered as “default” service. Rest of the apps must need to be on another service or module. So the main use case scenario is, suppose you have a sub-domain “office-api.yourdomain.com” and you want to point that in your App Engine’s “office-api” service.

Then you can’t do that because if you point your “yourdomain.com” to Google App Engine then you can’t use that domain for your other purposes. Google will use that domain to point all services, default, custom, etc..

But if you want to use your primary business domain inside App Engine like your corporatebusiness.com domain then what you will do. You have hosted your website in this domain in another server, you have another services hosted on that domain. But for better personalized sub-domain you want to use that same doamain’s sub-domain in Google App Engine.

Here is the steps about how you can configure your sub-domain directly pointed to any specific service.

First,
You need to add your custom domain to Google App Engine from App Engine -> Settings -> Custom Domain.

app-engine-domains-previewtechs-gc-us-central-1a

Now you need to add your custom domain and need to verify your domain name. Google has a very easy way with instruction to do that. Now from your domain registrar, you need to just change your CNAME pointed to ghs.googlehosted.com domain. Only CNAME, cause you are using this domain for your other services. Only this specific sub-domain will be used in Google App Engine.

After doing that you are done! Now google has it’s own routing policy to route your application based on service-id.yourcustomsub-domain.com but you want to customized that in your way. And you can do that by appcfg.py command line python tools. You can learn that directly from https://cloud.google.com/appengine/docs/python/how-requests-are-routed#routing_via_url . Now in your dispatch file write the following configuration.

dispatch:
  - url: "office-api.businessdomain.com/*"
    module: office-api

And upload this dispatch file with the appcfg.py command line utilities. Documentations are available https://cloud.google.com/appengine/docs/python/config/dispatchref. Now you have your official homepage hosted on www.businessdomain.com and office-api.businessdomain.com is pointed to Google App Engine custom services. Now browse your office-api.businessdomain.com url and you will see your application. Thanks.

Simple pagination in PHP

This is a simple PHP pagination script. First create a database and create a table name users  then connect your database by hostname, username, password, dbname to run this script. you can change table name and add more column.

<?php

$conn = new mysqli('hostname', 'user', 'password', 'dbname');
$start = 0;
$limit = 10;

if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $start = ($id - 1) * $limit;
} else {
    $id = 1;
}
$sql = "SELECT * FROM users LIMIT $start, $limit";
$query = $conn->query($sql);
?>

<html>
<head></head>
<body>
    <table>
        <tr>
            <th>Name</th>
            <th>department</th>
        </tr>
        <?php
        while ($result = mysqli_fetch_array($query)) { ?>
        <tr>
            <td><?= $result['name'] ?></td>
            <td><?= $result['department'] ?></td>
        </tr>
        <?php } ?>

    </table>
    <?php
    $rows = mysqli_num_rows(mysqli_query($dbconfig, "select * from user"));
    $total = ceil($rows / $limit);
    if ($id > 1) {
        echo "<a href='?id=" . ($id - 1) . "' class='button'>PREVIOUS</a>". "      ";
    }
    if ($id != $total) {
        echo "<a href='?id=" . ($id + 1) . "' class='button'>NEXT</a>";
    }
    ?>
    <ul class='page'>
        <?php
        for ($i = 1; $i <= $total; $i++) {
            if ($i == $id) {
                echo "<li class='current'>" . $i . "</li>";
            } else {
                echo "<li><a href='?id=" . $i . "'>" . $i . "</a></li>";
            }
        }
        ?>
    </ul>
</body>
</html>