Monthly Archives: February 2012

Sample HtmlUnit Automation for Finding ASIN on Amazon.com

import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.util.ArrayList; import java.util.List; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import com.gargoylesoftware.htmlunit.*;  import com.gargoylesoftware.htmlunit.html.*; public class AsinFinder {  /**   * @param args   */  static final WebClient browser;     static { … Continue reading

Posted in Information Technology | Leave a comment

Accessing secure wiki pages in Java

import java.io.BufferedReader; import java.io.InputStreamReader; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.params.AuthPolicy; import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; … Continue reading

Posted in Information Technology | Leave a comment

Card Shuffle

Chef is organizing an online card game tournament and for this purpose he has to provide a card shuffling software. This software has to simulate the following shuffling process. A stack of N cards is placed face down on the … Continue reading

Posted in Information Technology | Leave a comment

Extracting absolute URL from a website using Jsoup

import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class LinkChecker {  /**   * @param args   */  public static void main(String[] args) {   // TODO Auto-generated method stub         try {             Document document = Jsoup.connect(“http://www.amazon.com”).get();          Elements … Continue reading

Posted in Information Technology | 1 Comment

Guess Your Number

http://www.quizyourprofile.com/guessyournumber.swf              The trick how it works: All the numbers in the grid belong to either of five color buckets and there are five different numbers of each color. Based on the color selected, the corresponding five numbers are split (rather … Continue reading

Posted in Entertainment | Leave a comment