C,C++/JAVA/BASH/ASM ARENA

वह प्रदीप जो दीख रहा है झिलमिल दूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है चिन्गारी बन गयी लहू की बून्द गिरी जो पग से चमक रहे पीछे मुड देखो चरण-चिनह जगमग से बाकी होश तभी तक, जब तक जलता तूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है अपनी हड्डी की मशाल से हृदय चीरते तम का, सारी रात चले तुम दुख झेलते कुलिश का। एक खेय है शेष, किसी विध पार उसे कर जाओ; वह देखो, उस पार चमकता है मन्दिर प्रियतम का। आकर इतना पास फिरे, वह सच्चा शूर नहीं है; थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है। दिशा दीप्त हो उठी प्राप्त कर पुण्य-प्रकाश तुम्हारा, लिखा जा चुका अनल-अक्षरों में इतिहास तुम्हारा। जिस मिट्टी ने लहू पिया, वह फूल खिलाएगी ही, अम्बर पर घन बन छाएगा ही उच्छ्वास तुम्हारा। और अधिक ले जाँच, देवता इतन क्रूर नहीं है। थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है।

Project Euler Problem 57 – Square root convergents March 22, 2013

Filed under: Project Euler — whoami @ 11:33
Tags: , , , ,

It is possible to show that the square root of two can be expressed as an infinite continued fraction.

√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + … ))) = 1.414213…

By expanding this for the first four iterations, we get:

1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666…
1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379…

The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.

In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?

Euler57

 

Installing Solr and Nutch and Solr-Nutch Integration September 14, 2012

Hello,

As i have worked on using Apache Solr and Apache Nutch for one of my college projects, so thought to rewrite about the procedure so that it can help me or anyone in future.

I will discuss following things:-

1. Installing Apache Solr

2. Installing Apache Nutch

3. Integrating Solr and Nutch

1. Installing Apache Solr– Apache Solr has some important feature to develop a good search engine. One of the important role that Solr serves is Indexing.The other important feature of Solr is Serverization, i.e. it provides a good server feature for searching. This solr has been developed upon Lucene

Installing Apache Solr requires that you have a latest Java(JDK) installed in your system and appropriate JAVA_HOME path is set. Though the current installation process means for Linux system. We can install Solr in windows with similar procedure. Download the latest Apache Solr package from the solr or Apache site. The package by default contains jettty server. Now unzip/untar the compressed solr package. If you have correct JAVA_HOME set, then you can start the Apahce Solr as

$cd <location_of_solr> e.g. $cd apache-solr-1.3

$cd example

$java -jar start.jar

this will display on the command prompt string like………………….

  Sep 11, 2012 11:38:35 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
  INFO: JNDI not configured for solr (NoInitialContextEx)
  Sep 11, 2012 11:38:35 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
  INFO: solr home defaulted to ‘solr/’ (could not find system property or JNDI)
  Sep 11, 2012 11:38:35 PM org.apache.solr.servlet.SolrUpdateServlet init
  INFO: SolrUpdateServlet.init() done
  2012-09-11 23:38:35.683:INFO::Started SocketConnector@0.0.0.0:8983
  check for any error on the screen ….
  open the browser -> http://localhost:8983      ———> click the link and u can find the admin page of solr.
   This is    normal working of solr. For more customization you need to study in depth.
  Note: Solr configuration and index directory can find in     —– example/solr directory which contains
   i) bin  ii)conf  iii)data(initially it does not exist)  iv)README.txt  v)solr.xml
    2. Installing Apache Nutch –  Nutch is a good crawler which has also got developed from Apache Lucene.
     Proper installation and working of Nutch requires JAVA to be installed and its proper path set as
     discussed   above. To install the Apache Nutch, download latest Nutch from the Apache Site.
      extract the Nutch tar ball in home folder.

      $cd <location_of_nutch> e.g. $cd nutch-1.2

Nutch now available -> just check whether $bin/nutch is there.

Change the permission of nutch binary to executable file.

—————————–using Nutch for crawling ———————————-

Crawling several websites and fetching the data from each website can be performed as a   single  command or   step wise commands. The details can be found here. http://wiki.apache.org/nutch/NutchTutorial

3. Integrating Solr and Nutch 

Tutorial 

Will update more……………………..

Good night 🙂

 

Installing Tomcat7 on Fedora15/Linux through Command Line September 8, 2012

Filed under: Uncategorized — whoami @ 10:45
Tags: , , ,

Hello Friends,

Generally it happens we installing any  software , configure it and then make it running after much hard work. But we forget it when the next time, when we need to go through the installation on crashed machine or new computer. And there is no point in remembering each and every step of installation. We just need to know the overview to install it again. But yeah we need to get the document for step wise installation , otherwise we are again going to waste time by experimenting with new installation.

 

I am posting this because i was once having fedora , then tomcat was installed and configured well either using “Yum” or “command line installation” . At that time, i was beginner in installing Tomcat, so it took me time to keep things running. Now i know how things work in tomcat. This time i need to install tomcat fresh on the fedora, but i do not remember the steps, so i went through some articles and installed it. Also i converted the contents to pdf for further reference

will update the post on any new stuffs related to Tomcat installation and its uses.

 

Exception in thread “main” java.lang.NoClassDefFoundError: Main September 4, 2010

Filed under: Uncategorized — whoami @ 18:14
Tags: ,

Sometimes , inspite of setting proper classpath for JAVA_HOME, getting this Error on running

$java filename(without exten)  – Producing error means something strange. I too got irritated and finally found that its bcz its not considering the present working directory.

So by doing this

$java -classpath  .  filename

problem was solved

Here is the Great Hepful Link

 

Execute .jar file on Double Click -Linux March 2, 2010

Filed under: JAVA,LINUX,Top Coder — whoami @ 09:08
Tags: , ,

Read this link.

Actually u have to change 2 things- in properties of .jar file-
1. set the permission to run it as a program
2.then open with – use custom command , there find the location of jexec and press open.
Now ur file directly open with this jexec command after pressing double click…..
I am using it run The Editors for TopCoder
Thanks

 

Java Errors October 26, 2009

Filed under: C,Coding,JAVA — whoami @ 08:17
Tags:

If following error u r getting , then :
Main.java:12: cannot find symbol
symbol : constructor BufferedReader(java.io.InputStream)
location: class java.io.BufferedReader
BufferedReader in = new BufferedReader(System.in);
^
1 error
—————————————-
Sol:
[Do this]
InputStreamReader br = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(br);

 

Palindrome August 30, 2009

Filed under: JAVA — whoami @ 15:39
Tags:

import java.io.*;
class palim
{
 public static void main(String args[]) throws IOException
 {
 System.out.println("Enter The Number");
 DataInputStream in=new DataInputStream(System.in);
 int num=Integer.parseInt(in.readLine());
 int n=0,rem=0,old=num;
 while(num>0){
 rem=num%10;
 num=num/10;
 n=n*10+rem;
 }

 if(n==old)
 System.out.println("The Given number is Palindrme");
 else
 System.out.println("Given number is not palindrome");

 }//end of main

}