Posts

How to install Android N ( Version 7) on Nexus 5

You can install Android N (AOSP) build on your Nexus 5 and use the functionality such as multi windows support, quick notification reply on your Nexus 5 as well. 

Before going ahead, I would remind you that by following this method will void your device warranty/guaranty. There are chances that your device may get bricked (unusable). So make sure you follow the steps correctly and do not stop the process in between.

Requirements:

Working android SDK platform tools ( fastboot and dab)Updated USB driver for your device installed on computer.USB debugging enabled on device. Check this for how to enable USB debugging on mobile.Download recovery from TWRPDownload latest Android N (AOSP) image from xda-dev forum, you can choose any other image shared on forum.
Unlocking Bootloader

Once you have enabled USB debugging on device and connected device to computer execute below command on command prompt or terminaladb reboot bootloaderOnce your device restarted, check if the device is in fastboot by e…

How to enable USB debugging on Android devices

USB debugging has a number of uses on Android devices. To enable USB debugging you should first enable Developer options. Developer options have some setting relevant ro advanced users and developers.

Developer options is hidden by default, and can be activated with the following steps:

From Settings, select About phone (or About tablet).Tap the Build number entry seven times. On the seventh tap, you will be notified that "You are now a developer."Return to Settings. Developer options should now be visible just above the About phone ( or About tablet).Now to enable USB debugging click on the Developer options -> USB debugging (Android debugging). Some devices might require Developer options to be on before clicking on USB debugging.

Design an Parking lot system

Let's consider below are the requirements for parking lot. Based on these requirements we will have to design a parking lot.
Requirements The parking lot has multiple slots.The parking lot can park motorcycles, cars, and buses.The parking lot has small slots, compact slots, and large slots.A motorcycle can park in any slot.A car can park in either a single compact slot or a single large slot.A bus can park only in a single large slot.
We can devise below use cases from above requirement.
Use cases Any vehicle enters and asks for free parking slot ID.If any appropriate parking slot is available, vehicle will get assigned parking slot and that parking slot will be blocked for parking till vehicle leaves the slot.Any vehicle when leaves the parking slot, the same slot will be free for parking other vehicles.If appropriate parking slot (to fit the vehicle) is not available, parking lot will return parking full message.
Lets brea…

Elevator system design

Let's first start with the use cases or requirements of the elevator. There are multiple modules/ systems involved in complete elevator system. We will break down the uses cases as per the individual system.

High Level Requirements:

User should able to request the elevator from the floor.Once elevator reaches the requested floor, User should get in and should able to choose destination floor.Once destination is chosen by user, elevator should move to destination floor. Once elevator reaches destination floor, user leaves elevator.

User
Presses the button on particular floor to request the elevator. Inside elevator cabin (referred as Cabin here after) user presses the required floor button.Leaves the cabin once elevator reaches particular floor.Floor Floor has ID which indicates which floor it is.Floor has buttons to request the elevator.Floor has a display which indicates current location of the lift.Buttons Button get illuminated when pressed indicating the action is performed.Button s…

Installing MariaDB 10.1 on CentOS 6

Inorder to install MariaDB 10.1 you nned to have your MariaDB.repo entry. So create a file "/etc/yum.repos.d/MariaDB.repo" under "/etc/yum.repos.d/" directory.
Update the MariaDB.repo file with below text for 64bit OS

[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Update the MariaDB.repo file with below text for 32bit OS
`
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Now run below command just to check if the repo is set correctly.

#sudo yum search Mariadb 

Now install MariaDB using below command

# yum install MariaDB-server MariaDB*engine MariaDB-client

Error : class_name is not mapped, Hibernate

You may get this error while using Hibernate with Java. There could be multiple reasons why this can happen

You haven't really mapped the class name in config.The class name ( Entity) is case sensitive, meaning you should specify the entity name as is in the query. Your entity name may differ than table  name in DB, but still you will have to refer to exact case of entity name. 

Exception handling with RestTemplate

Spring framework offers RestTemplate for consuming RESTful services. Recently I used RestTemplate for consuming one of the third party RESTful service.

RestTemplate offers 'ResponseErrorHandler'; which you can extend to decide which are errors for you and how to handle those error. You can override hasError and handleError methods of ResponseErrorHandler.
In handleError you can throw customException if you want, as outlined in below code.

import org.springframework.http.HttpStatus; import org.springframework.http.client.ClientHttpResponse; import org.springframework.web.client.ResponseErrorHandler; import java.io.IOException; public class RestTemplateErrorHandler implements ResponseErrorHandler { @Override public void handleError(ClientHttpResponse response) throws IOException { throw new MyCustomException(response.getStatusText(), response.getStatusCode()); } @Override public boolean hasError(ClientHttpResponse response) throws IOException …