Sunday, December 2, 2012

Android Installation problem [Can not complete the Install ] Solved


Problem
Cannot complete the install because one or more required items could not be found.
  Software being installed: Android Hierarchy Viewer 18.0.0.v201203301601-306762 (com.android.ide.eclipse.hierarchyviewer.feature.group 18.0.0.v201203301601-306762)
  Missing requirement: Android Hierarchy Viewer 18.0.0.v201203301601-306762 (com.android.ide.eclipse.hierarchyviewer.feature.group 18.0.0.v201203301601-306762) requires 'org.eclipse.core.runtime 3.6.0' but it could not be found

Please note same message for  "Android DDMS","Android Development Tools" and  "Android Traceview"

Or Duplicate Repository problem where as creating the new Android Project option doesnt appear 


Head over to Help -> Install New Software. Click on Available software sites. Delete the Android repo. Uncheck Indigo & Eclipse updates & recheck them. Now head back to Help -> Check for updates. Once done, add the Android repo again. Accept the license & you should be good to go.
(Had to do the same yesterday after getting Indigo)
Source: StackOverFlow: Pasting here as this Solution worked for me after trying a lot of solutions posted over net 

Sunday, August 26, 2012

TCS fiasco and How to keep your account safe while changing mobile no


  24th August and the morning news came out as Techie steals Rs 49L from 3 bank accounts in Chennai. This news was definately worth the attention as while working with multiple service /Product companies techies like me  do get exposed to sensitive information. Here is what heppned in short and how the fraud was done



TCS Fraud protype

















                         

 Now the account and details related to it are in total unsafe hands and is     exposed to the variety of fraud which can be done . Now though the likelihood of having access to Bank DB is very less but even a person in million having access  to bank DB with malicious intention can give any bank a very hard time. The only way for the bank to trace back in these situation is to trace  the user            Machine IP where query was executed and me myself being a techie can say it for sure , its a cake walk to  mask my IP and give the Bank guys even a harder time trying to trace the origin of fraud.
  The point worth mentioning in this TCS fiasco is ,the techie was caught only becasue he/She  gone greedy and started withdrawing large amounts. However if they had kept a little control on their greed, it was close to impossible to figure out . And we will never know if the employee had done small such malicious activity in past and the amount was not big enough to draw attention of bank officials.

  Looking at the pattern however , it exposes the seriousness with which customer's private data is maintained, and the low level of security practises banks follow in order to save their customers hard earned money.this also brings the necessity  of a strong and capable Real Time online fraud monitoring system where multiple such incidents are coded as  a part of online transaction as well as card swipe process and is capable to stop transaction in any of the possible fraud scenario and is part of core banking system . 

  it will be interesting to see in indian market where changing the mobile number  is such a common process , if one gets access to telecom DB and does a intersection and imaginary scenario something like this 

The received out put list is the list of customer whoose transaction should be immideatly blocked until the new number is updated other wise in a matter of second and effort of two software engineers (One working for Bank and one working for Telecom ) is capable of adding multiple zeroes in the 49Lakh amount fraud..
  For customers , they should immediately give standing instruction to bank/Credit card company to stop doing any sort of transaction unless  they have a working number again.The process might look a little cumbersome to follow but as we all know it for a fact that its always  “better to be safe than sorry“.











Sunday, June 24, 2012

Count The No of Inversion in merge Sort

Algo:

 i have followed to do the same


  1. Merge sort array A and create a copy (array B)
  2. Take A[1] and find its position in sorted array B via a binary search. The number of inversions for this element will be one less than the index number of its position in B since every lower number that appears after the first element of A will be an inversion.
    2a. accumulate the number of inversions to counter variable num_inversions.
    2b. remove A[1] from array A and also from its corresponding position in array B
  3. rerun from step 2 until there are no more elements in A.
Here’s an example run of this algorithm. Original array A = ( 14, 8, 12, 3, 2)
1: Merge sort and copy to array B
B = (2,3,8,12,14)
2: Take A[1] and binary search to find it in array B
A[1] = 14
B = (2,3,8,12,14)
14 is in the 5th position of array B, thus there are 4 inversions. We know this because 14 was in the first position in array A, thus any lower value element that subsequently appears in array A would have an index of j > i (since i in this case is 1).
2.b: Remove A[1] from array A and also from its corresponding position in array B (bold elements are removed).
A = ( 14, 8, 12, 3, 2) = (8, 12, 3, 2)
B = (2,3,8,12,14) = ((2,3,8,12)
3: Rerun from step 2 on the new A and B arrays.
A[1] = 8
B = ((2,3,8,12)
8 is now in the 3rd position of array B, thus there are 2 inversions. We know this because 8 was in the first position in array A, thus any lower value element that subsequently appears would have an index of j > i (since i in this case is again 1). Remove A[1] from array A and also from its corresponding position in array B (bold elements are removed)
A = (8, 12, 3, 2) = 12,3,2
B = (2,3,8,12) = 2,3,12
Continuing in this vein will give us the total number of inversions for array A once the loop is complete

Try to code as per Algo , it gives a complete result
i am not sharing code as its against the fair code Stanford rule and will share only once the date for submitting assignment is expired
however am okay if u need any help in completing this exercise and Java is teh language i prefer to code in 


Friday, May 11, 2012

Basic IP Check with Ping using Java



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;


public class testIp {

public static boolean checkIp (String sip)
  {
      String [] parts = sip.split ("\\.");
      System.out.println("Parts length is "+parts.length);
      if ( parts.length != 4 )
      {
          return false;
      }
      for (String s : parts)
      {
          int i = Integer.parseInt (s);
          if (i < 0 || i > 255)
          {
              return false;
          }
      }
      if (pingIp(sip))
      return true;
      else
      return false;
  }

private static boolean pingIp(String sip) {
// TODO Auto-generated method stub
try {
InetAddress adr = InetAddress.getByName(sip);
boolean stat= adr.isReachable(2000);
return stat;
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return false;
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter the IP to be chacked");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {

String line = br.readLine();
boolean status=testIp.checkIp(line);
System.out.println("Status is "+status);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}




Thursday, May 10, 2012

EMMA Report Comparison Shell Based Utility


Here i am pasting the Symbolic code for comparing two EMMA Reports where Assumptions are
1.before.txt ---> the actual report
2.after.txt----> report after modification

This Script will get in to those twpo reports and show block by Block Comparison
The idea behind sharing this is that using this Logic a Extensive User Utility script can be developed which can be used to compare EMMA Reports



function retLineNobefore()
{
Str=$1
while read Line
do
val=$(grep -n "$Str" | sed -n 's/^\([0-9]*\)[:].*/\1/p')   # this is to Extract just the Line no
break
done < before.txt
}

function retLineNoAfter()
{
Str=$1
while read Line
do
val=$(grep -n "$Str" | sed -n 's/^\([0-9]*\)[:].*/\1/p')
break
done < after.txt
}

rm -fr report.txt

retLineNobefore "OVERALL COVERAGE SUMMARY:"
no1=$val


retLineNobefore "OVERALL STATS SUMMARY:"
no2=$val
echo "----------------Before-------------------------- " > report.txt

awk "{if((NR>"$no1")&&(NR<$no2)) print}" before.txt  >> report.txt



retLineNoAfter "OVERALL COVERAGE SUMMARY:"
no1=$val
echo $no1


retLineNoAfter "OVERALL STATS SUMMARY:"
no2=$val
echo $no2
echo "----------------After-------------------------- " >> report.txt
awk "{if((NR>"$no1")&&(NR<$no2)) print}" after.txt  >> report.txt


Wednesday, March 7, 2012

Customized page using JIRA which can autorefresh


hello All
recently have been working on a small configuaration change in JIRA which can allow a user to write a gadget whcih can autorefresh it at a given interval .. just so that this post conversation can be helpful for others i am pasting the link as it is .
in case any problem revert back


want to create a customized page using JIRA functionality which can autorefresh it in say 15 sec interval  any direction is appreciated
 By Manish Ranjan (1 karma) on Mar 02 at 5:22 a.m.
jira
jira-plugins
answer my own question | add comment
edit|poke atlassian answer my own question | add comment 0

 4 Answers:
oldest answers
newest answers
popular answers ↑
oldest answers
newest answers
popular answers ↑

I think you have to explain this a little bit more. I have no idea what you want to do... Sorry
 By Thomas-S (616 karma) on Mar 02 at 5:57 a.m.
add comment
permanent link add comment

actually i want to write a plugin which will ahev a customized landing page and the page needed to be be refresh at an interval of 15 sec .
(Mar 02 at 06:16 AM)
Manish Ranjan

actually i want to write a plugin which will ahev a customized landing page and the page needed to be be refresh at an interval of 15 sec .
(Mar 02 at 06:16 AM)
Manish Ranjan 0


Is this a jira dashboard you are trying to get to refresh every 15s?

The old skool approach would be to have an HTML page with frames & a piece of javascript that reloaded your target page every 15s but that would be nasty!
 By Matthew Cobby (1.4k karma) on Mar 02 at 11:38 a.m.
add comment
permanent link add comment

may be i will have my own gadget doint it for me .. but as of now i am facing another problem where i am able to see my gadget in plugins but not able to add it to the newly created dashboard.

can you also please help me in how can i add my own custom page to JIRA dashboard .. That would be in form a gadget right ?

also say i want to modify the "Assign to me" gadget providded by JIRA for a time less than a min rather than the options provided by JIRA which is atleast 15 mins.. how can i do that ?


(Mar 03 at 08:13 AM)
Manish Ranjan

may be i will have my own gadget doint it for me .. but as of now i am facing another problem where i am able to see my gadget in plugins but not able to add it to the newly created dashboard.

can you also please help me in how can i add my own custom page to JIRA dashboard .. That would be in form a gadget right ?

also say i want to modify the "Assign to me" gadget providded by JIRA for a time less than a min rather than the options provided by JIRA which is atleast 15 mins.. how can i do that ?


(Mar 03 at 08:13 AM)
Manish Ranjan 0

 Why not just a meta tag, please see http://en.wikipedia.org/wiki/Meta_refresh
 By Dieter (3.1k karma) on Mar 03 at 9:05 a.m.
add comment
permanent link add comment

but to embed the meta tag i need to figure out the source of "assigned to me" jsp right ? i tried but couldnt do the same. i have been doing research on this since wednesday so if i asking something silly am sorry,just to add i have not been able to add my own Custom page to JIRA as mentioned above so i am kinda stuck ..
(Mar 03 at 09:22 AM)
Manish Ranjan

but to embed the meta tag i need to figure out the source of "assigned to me" jsp right ? i tried but couldnt do the same. i have been doing research on this since wednesday so if i asking something silly am sorry,just to add i have not been able to add my own Custom page to JIRA as mentioned above so i am kinda stuck ..
(Mar 03 at 09:22 AM)
Manish Ranjan
Oh sorry, i hadn't seen your comment that you want to override the refresh period of the gadget. My answer was meant for a classical webwork action page, so probably this anwer is not useful.
(Mar 03 at 11:59 AM)
Dieter
Oh sorry, i hadn't seen your comment that you want to override the refresh period of the gadget. My answer was meant for a classical webwork action page, so probably this anwer is not useful.
(Mar 03 at 11:59 AM)
Dieter
1
you should search through all gadget.xml files in the Atlassian source tree to find the html and js code that makes up the assigned to me gadget.
(Mar 03 at 12:04 PM)
Dieter
1
you should search through all gadget.xml files in the Atlassian source tree to find the html and js code that makes up the assigned to me gadget.
(Mar 03 at 12:04 PM)
Dieter

when you say altassian source tree you mean in Jira installtion which is at /opt/atlassian/jira right ??i have been trying to backtrace the xml file but no success yet .. will try harder .. thanks for your help .. any pointer to search the same will be really helpfull. Manish
(2 days ago)
Manish Ranjan

when you say altassian source tree you mean in Jira installtion which is at /opt/atlassian/jira right ??i have been trying to backtrace the xml file but no success yet .. will try harder .. thanks for your help .. any pointer to search the same will be really helpfull. Manish
(2 days ago)
Manish Ranjan
1

no i mean the source code that you can get when you buy a commerical license. You will not find anything in the installed distribution since the gadget.xmls live in JAR files.
(yesterday)
Dieter
1

no i mean the source code that you can get when you buy a commerical license. You will not find anything in the installed distribution since the gadget.xmls live in JAR files.
(yesterday)
Dieter

okay cool .. i do have a commercial license , will look in to that . Thanks for your help
(yesterday)
Manish Ranjan

okay cool .. i do have a commercial license , will look in to that . Thanks for your help
(yesterday)
Manish Ranjan 0


If it's the assigned to me gadget that you want to change the refresh rate, then there is a really simple answer if you also have Confluence. Edit a page, bring up the macro browser & insert the gadget you want.  At the bottom should be an option to refresh, set it anything, it doesn't matter.  Save.



Then look at the macro that has been created in your page.  It should have a refresh parameter. Change this to be your new rate e.g. refresh=1 for every minute.  If you put something like refresh=true then it will refresh as fast as it can & will massively increase the load on your jira server.
{gadget:url=http://jira.xxxxxx.com:8080/rest/gadgets/1.0/g/com.atlassian.jira.gadgets:filter-results-gadget/gadgets/filter-results-gadget.xml}filterId=filter-11027&num=10&columnNames=--Default--&isConfigured=true&refresh=1{gadget}


JIRA-abbreviation, not an acronym


 JIRA as known to world as  bug, issue and project management for a fair while now – it’s almost industry standard and has an excellent developer community for plugins. I’m forever asked ‘What does JIRA stand for?’

Back in the days when those days when Bugzilla ruled the world and the guys at Atlassian dreamed of building a monster capable of beating it, they realised there was only one option – Godzilla. But calling their wonderful new bug and issue tracking system Godzilla was a bit obvious, so they abbreviated the original Japanese name for Godilla – Gojira. So, Gojira became JIRA: King of the issue management systems.

So when you get asked what does JIRA stands for, just tell them is an abbreviation, not an acronym.

Friday, January 20, 2012

Traffic Solution

okay


  This is a sample image of how a Chauraha looks like and hence i have devided it in four quadrants however as per the requirement it can be subdivided/coagulated .
in center what you see is square a area what we do not want to consider  and other than that 1/2/3/4 has sensors which are density measuring sensors
Defn of density is
Density=Weight/SQinch

now what these sensors do is they feed data from the circled area to computers and they let teh network learn about the traffic pattern , on that basis we divide the whole traffc 12 hrs say 8-8 in 12 diff zone with diff color codes and ofcourse diff weight as it will translate in to code

now say at any given time section A has 5 bus section B has 11 Cars C has 2 Bus 3 cars and D has only Bikes   
then as per density  feeded by the sensors to the Computer the program will be able to decide that its the section one which needs immediate clearance and it will be synchronized with the  next stop. with +-2 min this is also a way to let people know that they need to get on to public transport system .

Now this arrangement ill fail if the peopel do not follow traffic rules , yes but that probblem can not be solved unless we hire peopel but hell no , thats not the solution, what we need to do is give the power back to Citizen , if i find a Vehicle offending traffic rule at junction what all i need to do is take a pic of vehicle and send it
the Image sending location in 90% of teh cases will be also the source of problem /Plate no May be .

Then the snapshot of vehicle can be taken by CCTV cameras at those chaurahas and Charge can be directly sent through email/Phone message..

Monday, January 16, 2012

CodeChef/FACTORIAL


The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need some attention and technicians need to check their function periodically.
The technicians faced a very interesting problem recently. Given a set of BTSes to visit, they needed to find the shortest path to visit all of the given points and return back to the central company building. Programmers have spent several months studying this problem but with no results. They were unable to find the solution fast enough. After a long time, one of the programmers found this problem in a conference article. Unfortunately, he found that the problem is so called "Traveling Salesman Problem" and it is very hard to solve. If we have N BTSes to be visited, we can visit them in any order, giving us N! possibilities to examine. The function expressing that number is called factorial and can be computed as a product 1.2.3.4....N. The number is very high even for a relatively small N.
The programmers understood they had no chance to solve the problem. But because they have already received the research grant from the government, they needed to continue with their studies and produce at least some results. So they started to study behavior of the factorial function.
For example, they defined the function Z. For any positive integer NZ(N) is the number of zeros at the end of the decimal form of number N!. They noticed that this function never decreases. If we have two numbersN1<N2, then Z(N1) <= Z(N2). It is because we can never "lose" any trailing zero by multiplying by any positive number. We can only get new and new zeros. The function Z is very interesting, so we need a computer program that can determine its value efficiently.

Input

There is a single positive integer T on the first line of input (equal to about 100000). It stands for the number of numbers to follow. Then there are T lines, each containing exactly one positive integer numberN, 1 <= N <= 1000000000.

Output

For every number N, output a single line containing the single non-negative integer Z(N).

Example

Sample Input:
6
3
60
100
1024
23456
8735373
Sample Output:
0
14
24
253
5861
2183837




package com.factorial;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  try {
   String temp=br.readLine();
   int noofInp=Integer.parseInt(temp);
   int inputArray[]=new int[noofInp];
   for (int i = 0; i < noofInp; i++) {
    temp=br.readLine();
    inputArray[i]=Integer.parseInt(temp);
   }
   for (int i = 0; i < noofInp; i++) {
//    /System.out.println(inputArray[i]);
    int result=calctrailingZeros(inputArray[i]);
    System.out.println(result);
   }
   
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  

 }

 private static int calctrailingZeros(int val) {
  // TODO Auto-generated method stub
  int i=1;
  int result=1;
  int ret=0;
  while(result>=1)
  {
   result=(int) (val/Math.pow(5,i));
   i++;
   ret+=result;
  }
  
  return ret;
  
 }

}

CodeSprint/Coin Toss


/* Enter your code here. Read input from STDIN. Print output to STDOUT */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Solution {


public static void main (String args[]) throws IOException
{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
double solutionArray[];
int anArray[] = new int [2] ;
String Delims=" ";
String temp= br.readLine();
int counter= Integer.parseInt(temp);
String[] tempArray= new String[counter];
solutionArray= new double[counter];
for (int i = 0; i < counter; i++) {
tempArray[i]=br.readLine();
}

DecimalFormat df = new DecimalFormat("##.00");
for (int lubaluba=0;lubaluba<counter;lubaluba++)
{
String andrtemp[]=tempArray[lubaluba].split(Delims);
anArray[0]=Integer.parseInt(andrtemp[0]);
anArray[1]=Integer.parseInt(andrtemp[1]);
// System.out.print("Parsed values are"+anArray[0]+"and"+anArray[1]);
if (anArray[0]==(anArray[1])&&(counter==1))
{
String chumma="0.00";
System.out.println(chumma);
System.exit(1);
}
if(anArray[0]>anArray[1])
{
double val1= Math.pow(2, anArray[0]+1);
double val2= Math.pow(2, anArray[1]+1);
double sol=val1-val2;
solutionArray[lubaluba]=sol;
}
else if (anArray[0]==(anArray[1]))
{
double chumma=0;
solutionArray[lubaluba]=chumma;
}

}

for (int i = 0; i < solutionArray.length; i++)
{
if (solutionArray[i]==0)
{
System.out.println("0.00");
}
else
{
System.out.println(df.format(solutionArray[i]));
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
br.close();
}
}

Interview Street/String Similarity


/* Enter your code here. Read input from STDIN. Print output to STDOUT */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Solution {

/**
* @author manish
*/

public static void main(String[] args)
{
int no=0;
String[] baseArray;
int[] total;
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
no = Integer.parseInt(br.readLine());
baseArray= new String[no];
total =new int[no];
for (int cnt=0;cnt<baseArray.length;cnt++)
{
baseArray[cnt]= br.readLine();
total[cnt] = baseArray[cnt].length();
}
for(int count = 0;count <baseArray.length;count++)
{
for (int i = 1; i < baseArray[count].length(); i++)
{
String test=baseArray[count].substring(i);  
int retVal=maxMatch(test,baseArray[count]);
total[count]= total[count]+retVal;
}
System.out.print(total[count]+"\n");
}
}
catch(Exception e)
{
//System.out.println("Problem");
}
}

private static int maxMatch(String s,String str)
{
// TODO Auto-generated method stub
int counter=0;
char[] main_String = str.toCharArray();      
char[] substring = s.toCharArray();
for (int i = 0; i < substring.length; i++) {
if(substring[i]==main_String[i])
{
counter++;
}
else
return counter;
}
return counter;
}
}