Showing posts with label is. Show all posts
Showing posts with label is. Show all posts

Sunday, February 15, 2015

Java program to find whether a number is armstrong or not

Java program to find whether a number is armstrong or not

class Armstrong
{
public static void main(String...s)
{
int m,n,i,j=0;
n=Integer.parseInt(s[0]);

m=n;
while(n!=0)
{
i=n%10;
j+=(i*i*i);
n/=10;
}

if(j==m)
System.out.println("
Number is armstrong");

else
System.out.println("
Number is not armstrong");

}
}
Read more »

What is PHP’s MySQLnd and How It Performs Easy Read Write Splitting

MySQL is the most sought-after database server used with PHP. In fact, PHP web applications are connected to MySQL server by default. Although, some people also use other database servers like Oracle, SQL Server etc. for data storage, but for handling the web workload, MySQL is the most commonly used database.

In the past – PHPs mysql extension, PHPs mysqli and the PDO MYSQL driver – used MySQL Client Library (also known as libmysqlclient) – for communicating with the MySQL database server. But, libmysqlclient interface wasnt  optimized for interaction with PHP applications, as the library was primarily built keeping C applications in mind. Thats why, a replacement to the libmysqlclient was developed, called as the MySQL Native Driver (also referred to as mysqlnd); mysqlnd is also a library that provides almost similar functionality as provided by  MySQL Client Library.

Also Read: PHP Frameworks and Libraries That Every Web Developer Must Know About

The MySQL Native Driver was made available in PHP 5.3. And it has been the default library that is used to connect to the MySQL Server since the release of PHP 5.4 (although, you can even compile against libmysqlclient). The MySQL Native Driver offers additional features, improved performance, and better memory usage compared to libmysqlclient.

In this post well talk about how you can perform read/write splitting easily with help of PHP’s MySQLnd. But before that it is important to learn about mysqlnd installation process. Also, well discuss about MySQL Native Driver Plugins that youll require in read/write splitting. 

Installation

For installing mysqlnd, well have to compile one out of the three MySQL extensions named “ext/pdo_mysql”, “ext/mysqli” and “ext/mysql”. Remember, not to define the path to the MySQL Client Library ( libmysqlclient) in each instance.

What is PHP’s MySQLnd and How It Performs Easy Read/Write Splitting?

Note: Installation of ext/mysql or ext/mysqli, automatically enables the third extension – ext/pdo_mysql. 

Furthermore, you can choose an extension, by selecting one or more configure flags as listed below:

    --with-mysql

    --with-mysqli

    --with-pdo-mysql

Lastly, keep in mind that in case youre using Debian, or Ubuntu operating system, you can install the php5-mysqlnd package without a fuss using the following line of code:

$ sudo apt-get install php5-mysqlnd

This will help you get rid of the libmysqlclient php5-mysql package, and instead will let you include all three MySQL extensions.

List of MySQL Native Driver Plugins

MySQL Native Driver not only provide performance benefit, but the biggest benefit it provide is its plugins. You can access the plugins through PECL, and install them using the following line of code:

$ pecl install mysqlnd_<name>

Lets discuss about some of the stable plugins:

  • mysqlnd_ms: Helps to carry out read or write splitting between the “master and slave” servers effortlessly, with help of simple load balancing.
  • mysqlnd_qc: It embeds a simple query cache to PHP
  • mysqlnd_uh: It lets you write mysqlnd plugins in PHP

Performing Read/Write Splitting

In order to split reads and writes, well be using the mysqlnd_ms plugin. 

Configuration

After installation of the mysqlnd_ms plugin using PECL, well have to configure php.ini as well as the mysqlnd_ms configuration file.

In php.ini, well add the following lines of code:

extension=mysqlnd_ms.so

mysqlnd_ms.enable=1

mysqlnd_ms.config_file=/path/to/mysqlnd_ms.json

Next, create the mysqlnd_ms.json file, which helps to determine the master and slave servers. In addition, the file also help define the “read or write splitting” and “load balancing strategies”. 

Our configuration file consists of one master and one slave:

{

"appname": {

"master": {

"master_0": {

"host": "master.mysql.host",

"port": "3306",

"user": "dbuser",

"password": "dbpassword",

"db": "dbname"

}

},

"slave": {

"slave_0": {

"host": "slave.mysql.host",

"port": "3306"

"user": "dbuser",

"password": "dbpassword",

"db": "dbname"

},

}

}

}

You only need to make changes to one setting called as host, and all others are optional. 

Routing Queries

The mysqlnd_ms plugin transparently route the queries – by default – that starts with SELECT to the slave servers. Besides this, the plugin route the queries that doesnt start with SELECT to the master.

This can prove good as well as bad for you. Well, being transparent spares you from making any changes to the code. However, you wont be able to know whether a query is read-only or not, as the plugin doesnt analyze the query. 

Apart from not only sending a query that does not start with SELECT to the master, the plugin will send a write query with “SELECT..into the slave” that can prove to be a disaster. Fortunately, the plugin boasts the ability to provide hint regarding sending the query to the right server (i.e. master or slave server). For this, it places one among the below listed three SQL hint constants within the query:

  • MYSQLND_MS_MASTER_SWITCH: It helps to run the query statement on the master
  • MYSQLND_MS_SLAVE_SWITCH: Allows to run the query statement on the slave
  • MYSQLND_MS_LAST_USED_SWITCH: This one enables to run the query statement on the server that was used in the last

In order to use any one of the SQL hints, well need to add a comment prior to the query. One of the easiest way to so requires using sprintf(). Lets consider an example, where the mysqlnd_ms plugin is sending a SELECT to the master, using the first SQL hint constant:

$sql = sprintf("/*%s*/ SELECT * FROM table_name;", MYSQLND_MS_MASTER_SWITCH);

Below mentioned query is used for not sending a SELECT to a slave, using the second SQL hint as discussed above:

$sql = sprintf("/*%s*/ CREATE TEMPORARY TABLE `temp_table_name` SELECT * FROM table_name;", MYSQLND_MS_SLAVE_SWITCH);

Now, lets consider an example where the last hint will help you ensure how the same connection is used just like the one for the query mentioned above. This will ensure that switch from the master to reading has been made, after the data is modified, but still hasnt replicated. In addition, it also ensure that the switch is made when carrying out certain transactions including both read as well as write statements. 

if ($request->isPost() && $form->isValid()) {

$user>setValues($form->getValues());

$user->save();

}

$sql = sprintf("/*%s*/ SELECT * FROM user_session WHERE user_id = :user_id", MYSQLND_LAST_USED_SWITCH);

Conclusion

You can split read or write between servers using the mysqlnd_ms plugin. Its a useful plugin, especially when you want to move large legacy PHP applications to using distributed read/write. Though the plugin might not appear to be perfect to many users, but it will definitely get you 80-90% of success – and youll be able to move most applications – without fiddling with the code.

Author Bio
Maria Mincey is a web developer by profession and a writer by hobby and works for Xicom Technologies, a PHP development company. She loves sharing information regarding PHP development tips & tricks. If you are looking forward to hire PHP developers then just get in touch with her.
Read more »

Thursday, February 5, 2015

What is Online Marketing Online Marketing Training Course Learn how to Market Online

What is online marketing? Learn the fundamentals of how to market online in this excellent online marketing training course by lynda.com. In Online Marketing Fundamentals, let Lorrie Thomas Ross take you through the process of how to create a successful online marketing campaign. This excellent training course is ideal for web marketers, web designers, business owners, and executives. Topics include: Working with web analytics software, Building a site map, Selecting a domain name and a web host, Planning for mobile, Conducting social media marketing, Developing an email marketing campaign, Reviewing online public relations, Understanding the difference between search engine marketing (SEM) and search engine optimization (SEO), and more! Visitors of Tutorials101 can access the entire course for free by signing up for a free 7-day trial. You can also learn more about the training course by watching the free videos below.


Online Marketing Fundamentals by

START LEARNING TODAY!
or

WATCH THESE 4 FREE VIDEOS FROM THE COURSE

WHO IS THIS COURSE FOR? - What is Online Marketing? - Online Marketing Training Course - Learn how to Market Online


ONLINE MARKETING DEFINED - What is Online Marketing? - Online Marketing Training Course - Learn how to Market Online


COMPONENTS OF ONLINE MARKETING - What is Online Marketing? - Online Marketing Training Course - Learn how to Market Online


DEFINING YOUR TARGET MARKET - What is Online Marketing? - Online Marketing Training Course - Learn how to Market Online

START LEARNING TODAY!
or

Course Information

Training Provider: Lynda.com
Title: Online Marketing Fundamentals
Author: Lorrie Thomas Ross
Duration: 1hr 47mins
Date of release: 07 December 2011

Chapter 1: What Is Online Marketing?
Online marketing defined
How online marketing works
Distinctions of online marketing
Components of online marketing

Chapter 2: Building a Foundation
Online marketing planning and success
Defining your target market
Online marketing measurement

Chapter 3: Planning a Web Site for Online Marketing
Site map
Site components
Wireframing
Elements of a successful site
Home page best practices
Privacy policy

Chapter 4: Building or Optimizing a Web Site for Online Marketing
DIY or hire help?
Web site platforms
Domain names
Choosing a hosting company
Web site maintenance and management
Mobile sites

Chapter 5: Content Marketing
Authority marketing
Article marketing
Social media content
Online PR
Web site and email content

Chapter 6: Search Engine Marketing
Overview of search engine marketing (SEM)
Search engine optimization (SEO)
Paid search
Local search

Chapter 7: Social Media Marketing
Social media, social networking, and social media marketing defined
Blogging and microblogging
Social networking
Video sharing
Social shopping and opinions
Social news and social bookmarking
Social events
Wikis
Social media strategy

Chapter 8: Blogging
To blog or not to blog?
Blogging success
Blog content creation ideas

Chapter 9: Online Advertising
Search ads
Display ads
Affiliate marketing
Social media advertising
Local advertising
Email advertising

Chapter 10: Email Marketing
Collecting email addresses
Using a third-party management company
Email messages
About Lynda.com

Lynda.com is an online video training provider with over 1000 courses covering a wide array of topics - 3D, video, business, the web, graphic design, programming, animation, photography, and more. They produce top quality video tutorials with the best industry experts as your instructors. With a subscription, you can log-in at any time, and learn at your own pace. New courses are added each week, and you will receive a certificate of completion for each course that you finish.

Start learning today!
If you enjoyed the sample videos above and want to access the entire Online Marketing Fundamentals course, you can sign up for a lynda.com membership. Your membership will allow you to access not only this course, but also the entire lynda.com library for as low as $25 for 1-month. Their training library has over 1000 courses with 50,000+ video tutorials. No long-term commitment required. You can cancel your membership at any time.



Not yet convinced? Try a FREE 7-day trial.
As a special promotion, visitors of this site can get a FREE 7-day trial to lynda.com. This free trial gives you access to their entire training library of over 1000 courses.

If youre ready to learn how to market online, then become a lynda.com member today, to start viewing this excellent online marketing training course! Your membership also gives you access to the entire lynda.com library of over 1000 courses.

START LEARNING TODAY!
or
Read more »

Tuesday, February 3, 2015

What is CWM ClockWorkMode in Android

CWM (ClockWorkMod) Recovery in Android OS. 

What is CWM Recovery ?

CWM Recovery


CWM (ClockWorkMod) Recovery is a Custom Recovery for Android tablets and smartphones to allow user to Backup/Install and restore ROM,gain root access,kernels & mods ,backup full device data. CWM work as  alternative to Stock Recovery . CWM was built by Koushik Dutta (Koush) a well named developer in Android world. Somehow CWM work better than Stock Recovery  as its have better and more option which we do not have in Stock Recovery.
 Different Android devices have different method to install CWM but the common and easy way to install CWM over Stock Recovery is ROM Manager . Rom Manager is an app which available on Google Playstore

Note:- Make a deep search before installing CWM on your android device. Make sure every thing work perfect. 



Rom Manager 
You may also like to read :

Android System Recovery
CWM Recovery for Rockchip tablets
What is a difference between Stock and Custom Firmware .
Read more »