Thursday, June 27, 2013

Free Zone powered by Google

Presenting Free Zone powered by Google, an innovative service that allows you to access Google mobile services on the go at absolutely no data costs! Now with your
internet-enabled mobile on the airtel network you can:
  • Search on Google and browse the internet for FREE
  • Send and read emails on Gmail for FREE
  • Stay connected with your friends on Google+ for FREE

  Free Zone

  • Search
  • Gmail

how can I get started?

  • Just visit airtel.in/freezone from your phone’s internet browser.
  • Then start searching or sign in with your Google account to access Gmail or Google+
  • If you don’t have a Google account, create one at no cost by clicking on sign up or click here.
Note: The free data usage on Free Zone is available up to a limit of 1GB per month.

IRCTC Revised Refund Rules / Cancellation Rules / Cancellation Charges



Indian Railways has recently revised the refund rules and new rules will come into effect from 01-July-2013. The existing refund rules has not been updated for pas 15 years where the ticketing system has changed substantially. Computerized Passenger Reservation has also been changed enormously for past 15 years through which more than 40% of total tickets are being booked.
Highlights of the Current Refund Rules:
  1. Unreserved tickets has to be presented for cancelled within 3 hrs of the issue of the ticket. Not after 3hrs of the actual departure of the train.
  2. If the unreserved ticket is issued in advance, the ticket is presented up to 2400 hours of the day preceding the day of journey. 
  3. If the Reserved ticket is presented for cancellation for more than 48 hrs instead or existing 24 hrs, the cancellation charges per passenger will be flat rate of 120/- for AC 1st class/ Executive Class , Rs. 100 for AC 2-tire/First Class,Rs.90/- for AC 3-Tire/ 3 Tire economy/air-conditioned chair car and Rs.60 for Sleeper Class and Rs. 30 for 2nd Class.
  4. If the Reserved ticket is presented for cancellation between 48 hrs and upto 6 hrs instead of existing 24 hours and upto 4 hours before the departure of the train, cancellation charges will be 25% of the fare subject to the minimum of cancellation charges.
  5. If the ticket is presented for cancellation within 6hrs of the actual departure of the train instead for existing 4hrs and after 2 hrs of the actual departure of the train irrespective of the distance, cancellation charges will be 50% of the fare subject to a minimum of the cancellation charge.
  6. No refunds will be given after 2hrs of the actual departure of the train.
  7. In case, on a party ticket or a family ticket issued for travel of more than one person, some persons have confirmed reservation and others are on waiting list, full refund of fare, less clerkage, shall be admissible for confirmed passengers also provided that the entire ticket is surrendered for cancellation within six hours instead of existing 4 hours before the scheduled departure of the train and upto two hours instead of existing 3 hours after actual departure of the train”
  8. For unused RAC or Waitlisted tickets , passenger has to present the ticket for cancellation within 3 hrs after the actual departure of the train irrespective of the distance. In case no current counters are available at journey originating station for night trains leaving between 21.00 hours and 06.00 hours(actual departure , refund shall be admissible at the station within first two hours after the opening of reservation office.
  9. No refund will be given after 3 hrs of the actual departure of the train for unused RAC or Waitlisted tickets.
  10. In case of confirmed/ RAC e-ticket ,if the reservation charts have been   prepared, Passenger has to file TDR for cancellation within 2 hrs of the actual departure of the train. No refund will be given after 2 hrs of the departure of the train.
  11. No refund of fare shall be admissible on RAC e-tickets in case the request for refund is filed online after three hours of the actual departure of the train.
  12. Incase of Lost, misplaced, torn or mutilated tickets, issue of new ticket will be charged Rs. 50 per passenger for Sleeper and 2nd class and Rs. 100 per passenger for all other classes instead of existing clerikage charges.
  13. For refund of fare under circumstances other than those specified in these rules or under circumstances like ‘bandh’ or agitations or floods,  etc., the passengers could not reach the reservation counter or station or current counters for cancellation of tickets, in those cases, a TDR  shall be issued to the passenger and the passenger may apply for refund of fare within ten days instead existing 90 daysfrom the day of commencement of journey to the Chief Commercial Manager (Refunds) of the railway administration under whose jurisdiction the TDR issuing station comes, enclosing the original TDR. The TDR shall be issued only upto three days instead of existing 30 days after the scheduled departure of the train.
IRCTC Revised Refund Rules / IRCTC Cancellation Rules / Railway Refund Rules

NBFC (non-banking finance companies)



NBFC (non-banking finance companies)


Check before depositing money with NBFCs: RBI (Cautions investors to carefully evaluate investment decisions)


With a spate of financial scams, the Reserve Bank of India today cautioned investors to carefully evaluate investment decisions, including making deposits with non-banking finance companies (NBFCs). It regulates these and has authorised only a few NBFCs to accept deposits. The list of those authorised are on its website and people should check this, it cautioned.



Currently, the maximum interest an NBFC can pay to a depositor should not exceed 12.5 per cent. The RBI keeps changing these rates, depending on the macroeconomic environment. 



The public can register complaints with the local police or their Economic Offences Wing if some financial entity is found conducting business unauthorisedly or does not repay deposits. RBI is also categorical in saying it does not regulate chit fund activities or those of ‘collective investment schemes’.

Wednesday, June 26, 2013

E-filing



It must for those Taxpayers with annual income of over 5 lakh will now have to file their returns in electronic form. The threshold limit for e-filing of returns was 10 lakh last year. The e-filing allows for faster processing of income tax returns and settlement of errors and omissions. Even the wealth tax returns will now have to be filed electronically.

RuPay Global Card



RuPay Global Card


National Payments Corporation of India (NPCI)'s RuPay debit card will go 'global' in a strategic tie-up with an American card issuer, Discover Financial Services (DFS) which will offer international acceptance of the card. With this, RuPay will emerge as an alternative of international payment gateways like VISA or Mastercard and wants to make substantial difference in payment landscape.

RTGS, NEFT and Internet Banking



Electronic fund transfers are safe & also a faster and cheaper way to transfer money. Both RTGS 

and NEFT, the money is transferred directly from the bank account of the person sending or remitting the money to the bank account of the receiver.


RTGS



This is the fastest way of transferring funds. The transactions are settled on an instruction by instruction basis. Just that the minimum that can be so transferred is Rs 2 lakh.

NEFT

The transfer happens on a deferred net settlement basis. The transactions are settled in batches against the continuous individual settlement in RTGS. It operates in hourly batches from 9 am to 7 pm on weekdays, and 9 am to 1 pm on Saturdays. For instance, transactions put through between 9 am and 5 pm on weekdays are settled on the same day. For transactions settled after 6 pm on weekdays and after 1 pm on Saturday, the amount will be settled on the next working day. But it can be used for smaller amounts with no minimum threshold. Apart from the receiver’s name, the details required include the receiver’s bank, account number, and IFSC (Indian Financial System Code) of the destination bank branch for both RTGS and NEFT.

Internet banking


To access an online banking facility, you must register for the service. To access online banking, you will have to go through the bank’s website, and enter the online banking facility using your user name and password. One can carry out transactions such as fund transfers, utility bill payments, shopping and so on through internet banking. As of now, banks do not charge any fees for this service.

Tuesday, June 25, 2013

How many ways to create Thread


How many ways to create Thread



There is exactly one way to create a new thread in Java and that is to instantiate java.lang.Thread (to actually run that thread you also need to call start()).


Everything else that creates threads in Java code falls back to this one way behind the cover (e.g. aThreadFactory implementation will instantiate Thread objects at some point, ...).

There are three different ways to specify which code to run in that Thread:

1. Implement the interface java.lang.Runnable and pass an instance of the class implementing it to the Thread constructor.
2. Extend Thread itself and override its run() method.
3. Divide and Conquer by Java Threads

The first approach (implementing Runnable) is usually considered the more correct approach because you don't usually create a new "kind" of Thread, but simply want to run some code (i.e. a Runnable) in a dedicated thread.


1. Implementing the Runnable Interface

The Runnable Interface Signature
public interface Runnable {
void run();
}

One way to create a thread in java is to implement the Runnable Interface and then instantiate an object of the class. We need to override the run() method into our class which is the only method that needs to be implemented. The run() method contains the logic of the thread.


The procedure for creating threads based on the Runnable interface is as follows:

1. A class implements the Runnable interface, providing the run() method that will be executed by the thread. An object of this class is a Runnable object.

2. An object of Thread class is created by passing a Runnable object as argument to the Thread constructor. The Thread object now has a Runnable object that implements the run() method.

3. The start() method is invoked on the Thread object created in the previous step. The start() method returns immediately after a thread has been spawned.

4. The thread ends when the run() method ends, either by normal completion or by throwing an uncaught exception.


Below is a program that illustrates instantiation and running of threads using the runnable interface instead of extending the Thread class. To start the thread you need to invoke the start() method on your object.


2.Extending Thread Class


The procedure for creating threads based on extending the Thread is as follows:
1. A class extending the Thread class overrides the run() method from the Thread class to define the codeexecuted by the thread.
2. This subclass may call a Thread constructor explicitly in its constructors to initialize the thread, using the super() call.

3. The start() method inherited from the Thread class is invoked on the object of the class to make the thread eligible for running.
Below is a program that illustrates instantiation and running of threads by extending the Thread class instead of implementing the Runnable interface. To start the thread you need to invoke the start() method on your object.


3. Divide and Conquer


There is a interesting property of threads which comes to our rescue.Thread maintains the private copy of object on which it operates called asworking copy in which it keeps the local modification which are made to the object. While main memory contains the master copy of every object. After all threads stop executing all the working copies are merged into the master copy. This becomes the curse in case of multiple objects modify the same field in the object because merging back creates the confusion and results in a unpredictable behavior. However if each thread works on the different field of the object merging won't cause a conflict and hence state remains consistent and predictable. This improves the performance many folds and hence application gain scalability which was missing in the single threaded application.


Snippet:

import java.util.ArrayList;
import java.util.List;

public class Test {

public static void main(String[] args) {
final List list = new ArrayList();
Person person = null;
for (int i = 0; i < 100; i++) {
person = new Person();
Runnable runnable = createFirstRunnable(person);
Runnable run = createSecondRunnable(person);
Thread thread = new Thread(runnable);
Thread tt = new Thread(run);
thread.start();
tt.start();
list.add(person);
}

for (Person p : list) {
System.out.println("This is " + p.getFirstName() +

" " + p.getLastName() + "'s Blog.");
}
}

private static Runnable createSecondRunnable(final Person person) {
Runnable run = new Runnable() {

@Override
public void run() {
person.setLastName("Gupta");

}
};
return run;
}

private static Runnable createFirstRunnable(final Person person) {
Runnable runnable = new Runnable() {
@Override
public void run() {
person.setFirstName("Subodh");
}
};
return runnable;
}

private static class Person {
private String firstName = null;
private String lastName = null;

public Person() {
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
}
}

Ref: Subodh's Blog, javabeginner

Wednesday, June 19, 2013

Enum to map code with label



import java.util.HashMap;
import java.util.Map;


public enum MapNameWithId {


CANCELBOOKING("2006", "CancelBooking",
"CancelBooking");

 

private String code;
  private String label;
  private String description;
  private static Map<String, MapNameWithId> codeToClassMapping;

private MapNameWithId(String code, String label, String description) {
this.code = code;
this.label = label;
this.description = description;
}

/*
* This method for getting name of class based on ID
*/
  public static String getCode(String i) {
String returnValue=null;
if (codeToClassMapping == null) {
initMapping();
}
MapNameWithId result = null;
result = codeToClassMapping.get(i);
if(result==null){
returnValue="We do not have matching code for given class name";
}else{
returnValue=result.getCode();
}
return returnValue;
}
  private static void initMapping() {
codeToClassMapping = new HashMap<String, MapNameWithId>();
for (MapNameWithId s : values()) {
codeToClassMapping.put(s.label, s);
}
}


public String getCode() {
return code;
}

public String getLabel() {
return label;
}

public String getDescription() {
return description;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Status");
sb.append("{code=").append(code);
sb.append(", label='").append(label).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append('}');
return sb.toString();
}

}

Load property file on changes



import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;


public class ReadConfig {

private static PropertiesConfiguration config =  new PropertiesConfiguration();
public static synchronized String getProperty(final String key) {

                        config.setPath("<path of property file>");
config.setReloadingStrategy(new FileChangedReloadingStrategy());
config.load();
return (String) config.getProperty(key);
}


}

Friday, June 14, 2013

PHP DB Check


<?php
$dsn = 'mysql:host=localhost;dbname=cake';
$username = 'root';
$password = '';
$options = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
); 

$dbh = new PDO($dsn, $username, $password, $options);
?>

Load property file on changes



import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;


public class ReadConfig {

private static PropertiesConfiguration config =  new PropertiesConfiguration();
public static synchronized String getProperty(final String key) {

                        config.setPath("<path of property file>");
config.setReloadingStrategy(new FileChangedReloadingStrategy());
config.load();
return (String) config.getProperty(key);
}


}

Basic Log4j Configuration using xml:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j=
              "http://jakarta.apache.org/log4j/"
               debug="false">
   <appender name="consoleAppender"
      class="org.apache.log4j.ConsoleAppender">
      <param name="Threshold" value="ALL" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d
             %-5p  [%c{1}] %m %n" />
      </layout>
   </appender>
   <appender name="fileAppender"
           class="org.apache.log4j.RollingFileAppender">
      <param name="Threshold" value="ALL" />
      <param name="File" value="D:/logs/jmsLogger.log"/>
      <param name="maxBackupIndex" value="20"/>
      <param name="maxFileSize" value="52428800"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d
                %-5p  [%c{1}] %m %n" />
      </layout>
   </appender>
   <logger name="com.comfort" additivity="false" >
      <level value="ALL" />
      <appender-ref ref="consoleAppender"/>
      <appender-ref ref="fileAppender"/>
   </logger>
</log4j:configuration>

What is iterator



Iterator in Java is nothing but a traversing object, made specifically for Collection objects like List and Set. we have already aware about different kind of traversing methods like for-loop ,while loop,do-while,for each lop etc,they all are  index based traversing but as we know Java is purely object oriented language there is always possible ways of doing things using objects so Iterator is a way to traverse as well as access the data from the collection. Even with traversing with object we have Enumeration, Iterator and ListIterator in Java which we will in this Java Iterator tutorial.