Enhance Social Logins in web application

We can implement the social Login Integration to the Websites or web application in order to widen the reach of your web applications.

To start with, to integrate Facebook with your web application, we need to register our web application or website with Facebook, and get an application ID(appId), along with a secret key . you can create and retrieve the appId on the App Dashboard ( https://www.facebook.com/developers/)

Here we try to  implement login in a web application using the JavaScript SDK.

This code will load and initialize the JavaScript SDK in your HTML page. Use your appId where indicated.

<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
  // This is called with the results from from FB.getLoginStatus().
  function statusChangeCallback(response)...

Bash Scripting

Bash is a popular command-line interpreter for Linux computers including Mac OS X. Bash can execute a vast majority of Bourne shell scripts, mainly benefitting the administration and programming tasks. Many of the features were copied from sh, csh and ksh. Bash is also like a programming language so you can write programs using bash usually to automate tasks. You can start writing scripts right away, wrap up multiline operations in one file, implement flow control and interact with users to get input.

Here I would like to explain how bash scripting helps in mailing an attached file using smtp.

a) Mailing particular file in a directory

#!/bin/bash
emailsend=fromemail@gmail.com
emailrec=toemail@gmail.com
password=password
name=toemail@gmail.com
/usr/local/bin/sendEmail -v -f “$emailsend” -s smtp.gmail.com -xu “$name” -xp “$password”...

Type Annotations: An added feature to annotations in JAVA 8

Earlier we could only use annotations in Java on declarations. With Java 8, annotations can be written on any use of a type in declarations, generics, and casts. Type annotations are not one of the highlighted features of Java 8. Annotations add more behavior to the piece of code we have written. So type annotation is just an add-on to that, in the sense, it boosts the productivity and ensures higher-quality for our code.

For example, if you want to ensure that a particular variable is never assigned to null. You would then modify your code to annotate that particular variable, indicating that it is never assigned to null. The declaration can be like this:

@NonNull String str;

When you compile the code the compiler prints a warning if it detects a defect, which allows you to modify the code if an error is found. After you correct the code to remove all warnings, this particular error will not occur when the program runs.

When we look for tools that make our...

Java 8: What’s new in it ?

Oracle launched a new version of java Jdk1.8 with a lot of features. Some of the important features are provided below.

1) Lambda

 JDK 1.8 allows you to create Lambda functions. Lambda functions will become a powerful concept once integrated with JAVA. Lambda refers to anonymous function in a programming language. Lambda function, generally known as Lambda expression, is a function but without a name. It is very much used in languages like Python and Ruby (which is borrowed from LISP) etc.  An anonymous function (lambda function) does not carry name, access specifier, access modifier, parameters etc. It is just to simplify the code. Lambda function is very convenient to use in the same place where we write a function. If you would like to use the function only once, lambda function is the more convenient way. It reduces typing a lot of code, because the function code is written directly where we use the function and the...

Object list sorting using BeanComparator

We can sort List<Objects> using BeanComparater instead of writing comparator. The beanutils.jar has to be imported. Default sort order is in ascending order.

For eg.
Collections.sort(postings, new BeanComparator(“resumeCount”));
OR
BeanComparator bc = new BeanComparator(“resumeCount”);
Collections.sort(postings, bc);
Collections.reverse(postings);

Pros:- Concise, Minimal code

Cons:- Low performace, Uses reflection(Now if a field is renamed, the compiler won’t even report a problem)

Always override hashcode() if overriding equals()

In Java, equals() is implemented in Object class by default. This method is used to compare two objects. The default implementation just simply compares the memory addresses of the objects. You can override the default implementation of the equals() method defined in java.lang.Object. If you override the equals(), you MUST also override hashCode(). Otherwise, a violation of the general contract for Object.hashCode() will occur, which results unexpected behavior when your class is in conjunction with all hash-based collections.

This is a general contract in java programming that “whenever you override equals(), override hashcode() also”.

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information...

Wowza Adaptive Streaming Engine

Wowza is an adaptive stream engine which is used for streaming high-quality video and audio to any device. It provides live and on-demand streaming of media player technologies. It can deliver content to many popular media players such as Flash Player, Apple iPhone, iPad, iPod touch, JWPlayer etc. Wowza Streaming Engine includes support for many streaming protocols including Adobe HTTP Dynamic Streaming (Adobe HDS), Apple HTTP Live Streaming (Apple HLS) MPEG-DASH streaming, MPEG-2 Transport Streams (MPEG-TS), Real Time Messaging Protocol (RTMP), Real Time Streaming Protocol (RTSP) and Real-time Transport Protocol (RTP).

1. Server installation

Wowza Media Server is a Java 6 (aka 1.6) and Java 7 (aka 1.7) application and requires the installation of a Java Runtime Environment (JRE) that supports deploying Java in server environments. The JRE has everything needed to run Wowza Media Server on your system.

The following Java packages...

The Usability Factor – WordPress vs. Drupal

WordPress and Drupal are popular platforms used by individuals and businesses to create websites. Majority of the bloggers and webmasters will choose WordPress as it is simple and easy to use. WordPress has thousands of great features which is easily customized and user friendly. Drupal provides plenty of features but one needs to create the custom features which is confusing.

WordPress encompasses a rich library of Plugins nearly 15000, whereas Drupal provides just over 8000 which is definitely a grade separator. WordPress plugins facilitates easy modification, customization and enhancement to a WordPress website. WordPress is constantly releasing new plugins (like Google Publisher, Skype Mobile Switcher, and Gallery Overview) thus adding on to the huge repository of plugins. Considering the advantages WordPress offers, InApp is currently developing a Business Consulting website for a Middle East client using WordPress. Main reason being a Classifieds plugin was readily available...

Java Native Interface (JNI)

JNI is a programming framework that enables the java code running in a java virtual machine to call native applications specific to operating system and hardware.  JNI enables one to write native methods to handle situations when an application cannot be written entirely in the Java programming language.

Here I am describing how to do programming with JNI with an example. JNI is difficult, as it involves two languages and runtimes. I shall assume that you are familiar with:

  1. Java
  2. C/C++ and the GCC Compiler
  3. (For Windows) Gygwin or MinGW.
  4. (For IDE) Eclipse C/C++ Development Tool (CDT)

Here, I am giving an example with C programming language.

Step 1: Write a Java class that uses native methods

public class HelloJNI {
   static {
      System.loadLibrary("hello"); /* hello.dll (Windows) or libhello.so (Unixes)*/
   }
   /* A native method that receives nothing...

Exposure in Image and Video Processing

Video and image processing enables us to acquire, process, and analyze images and video data for  data visualization and manipulation.

We have explored the following open source API’s for video and image manipulation:

  • OpenCV   : OpenCV (Open Source Computer Vision Library) is mainly focused on real-time image processing applications. It supports  Windows, Linux, Mac OS, iOS and Android and  has been written in optimized C/C++ .

  • FFMPEG : ffmpeg is a command line tool to convert multimedia files between formats. This is mainly used to decode, encode, transcode,  stream, filter and play the media file. It runs on the following platforms: Windows, Linux, Mac OS, iOS and Android .

  • Xuggler   : Xuggler is a Java library that allows decoding and encoding a variety...

Again Java is the world’s No.1 Programming Language

Java has reclaimed the No.1 spot of the TIOBE Index, ending C’s four month stay at the top of the programming rankings.

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

Apache Airavata

airavata-logo

Airavata is a mythological white elephant who carries the Hindu god Indra. It is also called ‘abhra-Matanga’, meaning “Elephant of the Clouds”  [http://en.wikipedia.org/wiki/Airavata].

Apache Airavata is a software framework for executing and managing computational jobs and workflows on distributed computing resources including local clusters, supercomputers, national grids, academic and commercial clouds.

Airavata has the capability of composing, managing, executing and monitoring variety of distributed applications and work-flows that runs on computational resources. Concepts of service oriented computing, distributed messaging, work-flow...

jQuery – use the “on()” method instead of “live()”

As of jQuery 1.7,the .live() method is deprecated.Use .on() to attach event handlers.

Description: Attach an event handler function for one or more events to the selected elements.
The .on() method attaches event handlers to the currently selected set of elements in the jQuery object.

Syntax:-
.on(events[,selector][,data],handler(eventObj))
.on(eventType, selector, function)

Examples:-
$(“body”).on(“click”, “#element”, function(){
$(“#my”).html(result);
});

$(“body”).on(“click” , “p” ,function(){
alert($(this).text());
});

Migration from .live() to .on()
before:
$(‘#mainmenu a’).live(‘click’, function)
after, you move the child element (a) to the .on() selector:
$(‘#mainmenu’).on(‘click’,...

Real time logging using JMS, log4j and websocket

In our daily life, we may sometime want to take the server log into the browser.  We have a lot of solutions to get this working. I am going to explain some interesting solution for real-time logging using log4j, JMS and websocket.

We all are familiar with log4j, so we don’t need much more explanation.  Normally, we use fileAppender to write logs into file.  Apache log4j has a feature to send the log messages to a JMS borker, which is called JMSAppender.

Here, in this example, I am using ActiveMQ as message broker. It is an open source message broker written in java together with a full Java Message Service client. We can use activeMQ by embedding into tomcat or by installing and running as a different server. Normally activeMQ start listening to a default TCP port 61616.

To use ActiveMQ as a destination of our messages, we need to configure JMS appender properly. The code sample...

Always use length() instead of equals() to check empty string in java

If we need to check, If the string is Empty, Then do not use this way :  string1.equals(“”)

Best way to check if string is empty or not is to use length() method. This method simply return the count of characters inside char array which constitutes the string. If the count or length is 0; you can safely conclude that string is empty.

public boolean isEmpty(String str)
{
return str.equals(“”); //NEVER do this
}

public boolean isEmpty(String str)
{
return str.length()==0; //Correct way to check empty
}
PS : From JAVA 6 onwards, isEmpty() function is available in String class itself. Please use this function directly.