Android 5.0 Lolipop

Moto G – Android 5.0, Lollipop

MOTOROLA Confirmed that Android 5.0 Lollipop update will be coming to the Moto G and Moto X Devices.

Motorola said in a blog post: Now that Android 5.0 Lollipop will be going to the world with Nexus 6, a product of some of our own engineering, we are excited to confirm that this latest and greatest Android release will also come to our other devices as part of our ongoing software strategy to provide fast updates to our pure Android experience.

But motorola not yet confirmed when the update will be available on devices.

Creating Responsive Header Menu with CSS

Responsive design is become more important as Mobile Users are increasing. So, making your website responsive is good idea.

Here i would like to Start with Created Responsive Header Menu’s with CSS (Without Using any Javascript Code)

CSS for Responsive Header Menu :

<style>
body {
	width: 100%;
	font-family: Verdana, sans-serif;
}

header {
    width: 100%;
    height: 76px;
    border-bottom: 1px dotted coral;
}
#logo{
    margin-left: 20px;
    float: left;
    width: 200px;
    height: 75px;
    background: url(https://www.google.co.in/images/srpr/logo11w.png) no-repeat center;
    display: block;
}

nav {
    float: right;
    padding: 20px;
}

#menu-icon {
    display: hidden;
    width: 40px;
    height: 40px;
    background: #4C8FEC url(https://www.google.co.in/images/srpr/logo11w.png) center;
}

ul {
    list-style: none;
}

li {
    display: inline-block;
    float: left;
    padding: 10px
}

/* @media - If device width is higher than 640px use this css and if less than 640px use above */
@media only screen and (max-width : 640px) { 

    header {
        position: absolute;
    }

    #menu-icon {
        display:inline-block;
    }

    nav ul, nav:active ul {
        display: none;
        position: absolute;
        background: #fff;
        border: 1px dotted #444;
        right: 20px;
        top: 60px;
        border-radius: 4px 0 4px 4px;

    }

    nav li {
        text-align: center;
        width: 100%;
        padding: 10px 0;
        margin: 0;
		border-bottom:1px solid #AAA;
    }

    nav:hover ul {
        display: block;
    }
}
</style>

CSS has @media section, which check device width and apply styles depends on Conditiona.

HTML Part of Responsive Header Menu


<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Responsive Header Menu Example Code</title>
</head>

<body>
	<header>
	<a href="#" id="logo"></a>
		<nav>
			<a href="#" id="menu-icon"></a>
			<ul>
				<li><a href="http://sixants.com/">Six Ants</a></li>
				<li><a href="http://google.com">Google</a></li>
				<li><a href="http://yahoo.com">Yahoo</a></li>
				<li><a href="http://bing.com">Bing</a></li>
			</ul>
		</nav>
	</header>
</body>

</html>

How to use spl_autoload_register

spl_autoload_register register a function with the Standard PHP Library (SPL) provided __autoload stack. If the stack is not yet activated it will activate the stack.

If you are already used __autoload() function in your code, then the function must be explicitly registered on the __autoload stack. This is because spl_autoload_register() will effectively replace the engine cache for the __autoload() function by either spl_autoload() or spl_autoload_call().

If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast, __autoload() may only be defined once.

Example of spl_autoload_register

<?php
function my_autoload_function($class) {
    include 'my_classes/' . $class . '.class.php';
}

spl_autoload_register('my_autoload_function');
?>

using an anonymous function as of PHP 5.3.0

<?php
spl_autoload_register(function ($class) {
    include 'my_classes/' . $class . '.class.php';
});
?>

Persistent Connections with MySQLi Extension

Persistent connection support in MySQLi Extension was introduced in PHP 5.3, Persistent connection means it will reuse the connection already established instead of creating and destroying each time. Which will reduces the overhead of creating fresh connections every time.

Like mysql_pconnect in mysql extension, MySQLi does not provide a separate function for opening persistent connection.

To open a persistent connection you must prepend p: to the hostname when connecting. Below is the example of persistent Connection with MySQLi.

Object oriented Method : MySQLi Persistent Connection

<?php
$mysqli = new mysqli("p:SERVERNAME", "USERNAME", "PASSWORD", "DATABASE");
?>

Procedural Method : MySQLi Persistent Connection

<?php
$dbCon = mysqli_connect("p:SERVERNAME", "USERNAME", "PASSWORD", "DATABASE");
?>

The major drawback of persistent connections is that they can be left in unpredictable states by clients, However MySQLi extension  provides built-in cleanup handling code.

Built-in Cleanup includes:

  • Rollback active transactions
  • Close and drop temporary tables
  • Unlock tables
  • Reset session variables
  • Close prepared statements (always happens with PHP)
  • Close handler
  • Release locks acquired with GET_LOCK()

This ensures that persistent connections are in a clean state on return from the connection pool, before the client process uses them.

The disadvantage of this could potentially be a little slower, as the code to perform the cleanup needs to run each time a connection is returned from the connection pool.

By compiling PHP with MYSQLI_NO_CHANGE_USER_ON_PCONNECT we can avoid auto Cleanup.

How to use MySQLi Connect in PHP – Object Oriented Method

mysql_connect extension is deprecated as of PHP 5.5.0, and will be removed in the future. So We have to start using MySQLi or PDO_MySQL extension. MySQLi can be used in Procedural Method and in Object oriented Method.

MySQLi Connect Object Oriented Method Example :

<?php
// Establishing Connection
$mysqli = new mysqli("SERVERNAME", "USERNAME", "PASSWORD", "DATABASE");

// If Connection through Error
if ($mysqli->connect_errno) {
    die("Error : ". $mysqli->connect_error);
}

// Preparing a Query
$query = "SELECT `name`, `email` FROM `users`";

// Executing Query 
$result = $mysqli->query($query);

// Looping through the Result
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ) {
	echo 'Name : '.$row["name"].', Email : '.$row["email"].'<br/>';
}

// Free the Result 
$result->free();

// Closing the Connection
$mysqli->close();
?>

How to use MySQLi_connect in PHP – Procedural Method

mysql_connect extension is deprecated as of PHP 5.5.0, and will be removed in the future. So We have to start using MySQLi or PDO_MySQL extension. MySQLi can be used in Procedural Method and in Object oriented Method.

MySQLi_connect is a Alias of mysqli::__construct(), when we call MySQLi_connect Internally it will call MySQLi Class construct Method and Make Connection.

mysqli_connect Procedural Method Example :

<?php

// Establishing Mysql Connection, Prints Error Message If Any
$dbCon = mysqli_connect("SERVERNAME","USERNAME","PASSWORD","DATABASE") or die("Error : " . mysqli_error($con));  

// Preparing a Query
$query = "SELECT `name`, `email` FROM `user`";

// Executing Query with Connection, return Resource on Success
$resource = mysqli_query($dbCon, $query );

// Looping through the Resource
while($row = mysqli_fetch_array($resource )) {
  echo "Name : ".$row["name"].", Email : ".$row['email'].'<br/>';
}

// Closing the Connection
mysqli_close($dbCon);
?>

COUNT_BIG : Aggregate Function – TSQL Tutorial

COUNT_BIG function returns the number of items in a group.

COUNT_BIG works like the COUNT function. The only difference between the two functions is their return values.

COUNT_BIG always returns a bigint data type value. COUNT always returns an int data type value.

COUNT_BIG Syntax

COUNT_BIG ( { [ ALL | DISTINCT ] expression } | * )
OVER ( [ partition_by_clause ] order_by_clause )

COUNT : Aggregate Function – TSQL Tutorial

COUNT function returns the number of items in a group.

COUNT works like the COUNT_BIG function. The only difference between the two functions is their return values.

COUNT always returns an int data type value. COUNT_BIG always returns a bigint data type value.

COUNT Syntax

COUNT ( { [ [ ALL | DISTINCT ] expression ] | * } )
OVER ( [ partition_by_clause ] order_by_clause )

COUNT Example

ID Salary
1 300
2 500
3 700

SELECT COUNT(e.id) AS CountEmployees FROM employee e

CountContracts
3
Sony_motionshot_ported_2

How to install Xperia Z1 MotionShot Camera in any Android 4.0+ device

Sony has released a MotionShot camera app, which actually captures a short movie and makes it as a single image. Currently this app is only available for Sony Xperia Z1. But XDA Forum Member xperiaz2 ported this app to all the android phones which run on android 4.0+. The app is reported to be stable and working without any issues.

Sony in it’s Google Play app page describes that this app is also perfect for creating animated gif images. This MotionShot camera can be used in any action scenes involving sports, animals, kids, friends, vehicles, airplanes and moving objects.

This app also includes variety of effects (fade-in/fade-out), and you can also chose set the number of animation sequences, and specify other settings to create a original expression.

How to install Xperia Z1 MotionShot Camera in any Android 4+ device :

Sony_motionshot_ported