Thursday, 23 August 2018

Recover your MYSQL database if nothing works in Ubuntu/Linux.

Recently I stuck in a situation where after spending many days I couldn't resolve the my MYSQL database connectivity in my Ubuntu system. Although I tried many solutions available on the Internet, but I was unable to resolve it.

Rather than solving my problem I thought that I have made the situation more worst then earlier because of my many hit and try on the server. However, I read at many location to keep a backup of my databases. So I was saved /var/lib/mysql directory it somewhere else.

After no success, I tried to restore databases from my mysql backed up the directory in Ubuntu after a fresh installation of MYSQL database server.

So I was copied /val/lib/mysql folder before a new installation of MYSQL. After successful installation of MYSQL server I tried to restore all my databases in  new MYSQL server like this -

Open a terminal and copy/restore your saved database to MYSQL server using the command-
(I have saved my database to Desktop and database name is itcentre)

sudo cp -r Desktop/mysql/itcentre /var/lib/mysql

enter your sudo password

after coping your database file also copy these files of your /var/lib/mysql folder to the server



sudo cp  Desktop/mysql/ibdata1 /var/lib/mysql
sudo cp  Desktop/mysql/ib_logfile0 /var/lib/mysql
sudo cp  Desktop/mysql/ib_logfile1 /var/lib/mysql
sudo cp  Desktop/mysql/debian-5.7.flag /var/lib/mysql

sudo chown -R mysql:mysql /var/lib/mysql


if there is no error your database is successfully restored to MYSQL server.


Good luck !!!

Saturday, 18 August 2018

Emulator: emulator: ERROR: x86 emulation currently require hardware acceleration!

In the continuation of previous posts, this post is also a solution of one of the Android Studio error face by newbie on this platform.


This kind of error found when Intel x86 Emulator Accelerator (HAXM Installer) is not installed in your system or if there is any problem in it.

So, to install this go to -

Tools ----> Android ----> SDK Manager  the click on SDK Tools ,  You will see that  Intel x86 Emulator Accelerator (HAXM Installer)  is not installed, just tick the box and then click on Apply.





If again problem exist, please check that virtualization is enabled or not in your system BIOS.







Saturday, 4 August 2018

Removing password complexity in Windows server 2016.

Sometimes we don't to impose password complexity when want to create a new user in Windows Server. So how can remove it for using simple password, however it is recommended that you should keep password that should meet the password complexity for security purpose on servers.

So in Windows server like 2016 it gives error when it does not meet the password complexity like this-

or like this -


So how can we remove this restriction from server?

Press Window key  + r or open run window and type gpedit.msc then press Ok.


A group policy editor window will be opened.

Go to under Computer Configuration ------>Windows settings ----------> Security settings (double click on Security settings).

In the right pane you will see Account Policies, open it.

When you open Account Policies you will see Password Policy, open it or just double click.
You will see that "Password must meet complexity requirements" policy property is Enabled.
Double click on this property and disable it.



Now you are free to use any kind or any length of your password in Windows server 2016.









Wednesday, 25 July 2018

Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ.

After a long time when I created a new project in my Android Studio 3.0.1,  it gave the error:-

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

When I searched this error on Internet I got the solution that just remove these two lines of dependencies your project's  build.gradle(Module:app). To locate  build.gradle(Module:app) go to your project directory structure and then Gradle Scripts head , you will found build.gradle(Module:app)


In build.gradle(Module:app), under dependencies section remove last two lines.


androidTestImplementation 'com.android.support.test:runner:1.0.2'androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



Then click on Sync now


After syncing you will see that your problem has been resolved now.


You can see some more solution on web. This is the only solution that I have been tried to resolve this problem.


Monday, 18 June 2018

Run your JSP page as Servlet.

Developing JSP page is easier than Servlet. But Servlet has some benefit over JSP. So if we want to run Servlet by developing our page in JSP then we can do it very easily. Although we know that all JSP page is first converted into Servlet and then run. But it makes JSP slower than Servlet. Since Servlet is written in Java while JSP is written in HTML, so it becomes difficult to design in Servlet. Another headache with Servlet that it requires compilation after every changes in code.

Servlets are best suited for large data processing and manipulation. It can also be best suited where you don't want reveal your file name without using any platform.

So if we want develop our page in JSP because of easiness in design, custom tags for calling Beans and use of JavaScript and run it as Servlet because of speed and processing then we can do it in following way:-

I assume that you have good idea of running Servlet on Apache Tomcat Server.

Create your JSP page/project on any of your favourite IDE with your desired design and save it to your project root directory. Now run this page on your server. If it is OK then do the following-

1. Go to Tomcat home folder ------> Work --------> Catalina ----------> localhost

Here you will see your project folder. Inside this folder you will find org folder.
In org folder, there is another folder apache and then jsp folder. In this jsp folder you will see the all Servlet  with the name of your JSP page you have created in your project. These Servlets are created when you run your JSP page on browser (as you know that all JSP are first converted into Servlet before run on browser).

2. Copy this folder (org) to your project/WEB-INF/classes location.

Now in your web.xml, do the Servlet configuration like this.

<servlet>
<servlet-name>sm</servlet-name>
      <servlet-class>org.apache.jsp.home1_jsp</servlet-class>
</servlet>

<servlet-mapping>
        <servlet-name>sm</servlet-name>
        <url-pattern>/sm.arv</url-pattern>
 </servlet-mapping>

If your server is capable of running Servlet, it will also run.

Like this you can convert your all pages/project in Servlet.

Advantages:-

This kind of work can also hide your business logic of your coding from others when you have to distribute your project or share with others.

Also you can design your page in JSP and run as Servlet and you don't need to compile it everytime (for compilation just run JSP page automatically it will be compiled).

You can also hide your file extension (.htm, .html, .jsp).


Tuesday, 8 May 2018

What should be the design of your WebApp?

Jakob Nielson states: "there are essentially two basic approaches to design: the artistic ideal of expressing yourself and the engineering ideal of solving a problem for a customer." The first approach was very common in the early era of website development, but it is useful only when content is small. When your web app is complex and consists of hundreds or thousands of contents and functions then Nielson's second approach- "the engineering ideal of solving a problem for a customer" becomes more crucial.

Both generic and engineering approach is important when we think about web app design.

Every person has different test when they navigate any page. Some like only text, some low graphics, some heavy graphics and some people may have some other issues. So what kind of tools or things should be used in any website, so that it can be suitable for all type of people.

Jeff Offut mention that the success of any web application depends on 'Reliability, Usability, Security, Availability, Maintainability, Scalability, Performance and Time-to-market'. But this is not the complete list of web app quality.

Jean Kaiser also mention that web site should be -Simple, Consistent, Robust, Navigable, Compatible and should have visual appeal.

Heavy text on web page slow down the reading capacity of user than reading any hardcopy. Avoid under construction pages and make text available in available window, prefer not to use scrollable text. Menus should be consistent.

There is famous line that "beauty exists in the eye of the beholder". So that design should be aesthetic. Emphasis should be on content. 80 percent of website should be consist of content and 20 percent should be on other thing like design, menu and navigation.

Graphic deign is also play a important role in design of any website. Graphic design covers the every aspect of look & feel. In graphic design we should consider the layout of page font type, colour and size.

James Ross - president of Codcow says that web design is not only writing code and design layout, it is also about to satisfying the client and make them understand that you are a web developer. He gives a list of things that what web developer should do, when interact with client.

1. Web design is not only about technical skills, it is also about creativity and inspiration.
Web design requires talent, skills, knowledge and experience and it is not a easy task. Make this clear to the client.

2. Listen to them, but also make them listen to you too.

Web developer should use data and statistics to prove your point with clients. You are the expert of this field an client pay for this and makes rules. 

3. Understand the difference between feedback and impositions.

If any impositions is not good for the site then stop the client to do so. But feedback is always welcome.

4. Fighting with the stereotypes.

Print design and web design are very different from each other.

5. There is no such thing as a minor change.

There is no minor change in web design and it may takes hour of work. Deadline may change because of minor change.

6. Communication is the king.
Communication can solve that what client exactly want.

Another aspect of web design is some more technical. If server goes down, so how long until you realise it. For that you should make necessary arrangement and use tools.

Icons and graphical link should be clickable by bevelling the edge to give the image three dimensional look. For text based link, colour should be used to identify navigation link and visited navigation link should also be indicated. Such kind of rules make navigation user friendly.

Apart from above web developer should also consider about content design, architecture design and component design.

Steve Jobs also stats that "Design is not just what its look like and feel like. Design is how it works"



A picture can speak a thousand words, and choosing the right images for your website can help with brand positioning and connecting with your target audience. But make sure that use of images should not slow down your website  for loading.

Saturday, 5 May 2018

Read XML file data with regular expression using PHP.

Reading XML file with regular expression is useful when there is some minor mistake in your XML file.( like code which write the data on XML in my previous post).

<?php $xml = "";
 $f = fopen( 'data.xml', 'r' );
 while( $data = fread( $f, 4096 ) ) { $xml .= $data; } fclose( $f );
 preg_match_all( "/\<book\>(.*?)\<\/book\>/s", $xml, $bookblocks );
?>
 <table>
 <?php 
foreach( $bookblocks[1] as $block ) { 
?>
 <tr><td>
 <?php
 preg_match_all( "/\<textbox\>(.*?)\<\/textbox\>/", $block, $author );
 preg_match_all( "/\<name\>(.*?)\<\/name\>/", $block, $title );
 preg_match_all( "/\<file\>(.*?)\<\/file\>/", $block, $publisher );
 echo( $title[1][0]." - ".$author[1][0]." - ". $publisher[1][0]."\n" ); 
echo "\n";
 ?> 
</td></tr>
</table>
 <?php
 } 
?>

Above code read the file in one string. And using regex function this code reads all book element.
Drawback of regular expression is it does not check the XML is well formed or not. Such kind of code can not be accepted when XML directly come from user.


Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...