Friday, March 14, 2014

movie_HER_red carpet_scarlett johansson_11102013

Fanny Neguesha at a football match

Mario Balotelli's girlfriend Fanny Neguesha looks on during the FIFA Confederations Cup Brazil 2013 Group A match between Mexico and Italy at the Maracana Stadium on June 16, 2013 in Rio de Janeiro, Brazil.

Java regular expressions sample code

This is sample code of how to do regular expression's pattern matching in Java. I used it to get the thumbnails, image files and captions from this webpage - Click Here. It uses Apache Commons IO to read the file and the rest you can figure out. It was pretty easy when I finally figured out how to use the Matcher class.

The output of this program is the html source for this blog post Pictures of North American Inuit peoples life style

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;

/**
 * @author ranjit sandhu
 * @date Fri, Mar 14, 2014  4:02:04 PM
 */
public class htmlParser {

 public static void main(String[] args) throws IOException {
  File ff = new File("c:\\ranjit\\code\\java_read_file.txt");
  String input = FileUtils.readFileToString(ff); 
  
  Pattern pat = Pattern.compile("http://s.imwx.com/dru/2014/02/.+_980x551.jpg");
  Matcher mat = pat.matcher(input);  
  printMat(mat);
  ArrayList bigImages = retMatches(mat);
  
  pat = Pattern.compile("http://s.imwx.com/dru/2014/02/.+_85x64.jpg");
  mat = pat.matcher(input);
  printMat(mat);
  ArrayList smallImages = retMatches(mat);
  
  pat = Pattern.compile("caption\":\".+\\(");
  mat = pat.matcher(input);
  printMat(mat);
  ArrayList captions = retMatches(mat);
  
  StringBuilder sb = new StringBuilder();
  for (int i=0; i < smallImages.size(); i++) {
   sb.append("<img src=\"").append(smallImages.get(i)).append("\" class=\"smallImage\" onClick=\"jump(")
   .append(i).append(");\">  ");
  }
  sb.append("<br><br>");
  String caption = new String();
  for (int i=0; i < captions.size(); i++) {
   caption = (String)captions.get(i);
   caption = caption.substring(10,caption.length()-2);
   sb.append("<div class=\"caption\" id=\"").append(i).append("\">").append(caption).append("</div>");
   sb.append("<img src=\"").append(bigImages.get(i)).append("\" class=\"bigImage\"").
   append(">  <a href='#top'>Back to Top</a><br><br>");
  }
  System.out.println(sb);
 } // end main
 
 public static void printMat(Matcher mat) {
  int index = 0;
  int matchNumber = 0;
  while (mat.find(index)) {
   matchNumber++;
   System.out.println("match number: " + matchNumber);
   System.out.println("match start/end: " + mat.start() + "," + mat.end());
   System.out.println("match value: " + mat.group());
   index = mat.end();
  }
 } // end printMat
 
 public static ArrayList retMatches(Matcher mat) {
  ArrayList ar = new ArrayList();
  int index = 0;
  while (mat.find(index)) {
   ar.add(mat.group());
   index = mat.end();
  }
  return ar;
 } // end retMatches
} // end class

Pictures of North American Inuit peoples life style

Pictures of North American Inuit peoples life style

                                                                                                  

Two Inuit hunters in Canada strip the meat from a pair of reindeer carcasses in March 1924.
  Back to Top

An Inuit hunter with a rifle is camouflaged behind a white board in June 1920.
  Back to Top

An Inuit woman carries a papoose on her back in Arctic Alaska in 1912.
  Back to Top

A group of Inuits of America's Arctic coastline came to visit the camp of the Canadian explorer Vilhjalmur Stefanson, near Point Barrow. Stefanson is known for his books on Inuit culture.
  Back to Top

An Inuit is frostbitten after drifting on an ice floe for 9 days while hunting walrus in 1935.
  Back to Top

An Inuit mother and child are captured in a photograph.
  Back to Top

An Inuit man with his catch of fish, Greenland, 1930.
  Back to Top

A group of Inuit villagers drag home a walrus, Alaska,1930.
  Back to Top

An Inuit woman fishes for crabs through a hole in the ice in Canada, March 1924.
  Back to Top

An Inuit woman from Alaska dresses skins in January 1936.
  Back to Top

An Inuit mother and papoose who visited the Stefanson Arctic Expedition Camp on March 18, 1914.
  Back to Top

Inuits at Point Barrow, Alaska, cut up a walrus for winter meat in 1930.
  Back to Top

An Inuit hunter in Canada stands next to the carcass of a freshly-killed walrus, March 1924.
  Back to Top

An Inuit hunter in Canada drags the carcass of a seal behind him, March 1924.
  Back to Top

An Inuit stands next to the carcass of a polar bear on Wrangle Island, 120 miles off the coast of Siberia, November 1923.
  Back to Top

A scene at an Inuit blubber market in Canada is littered with dead walruses in March, 1924.
  Back to Top

An Inuit family and their igloo in Labrador, Seattle during the during the Alaska-Yukon-Pacific Exposition in 1909.
  Back to Top

An Inuit man listens to a gramophone among hanging furs in 1922.
  Back to Top

An Inuit girl wears clothing made from animal hides on Feb. 20, 1936.
  Back to Top

An Inuit seamstress softens up a hide by crimping it with her teeth in 1950.
  Back to Top

An Inuit women in Canada holds a salmon, which has been split and smoked in 1950.
  Back to Top

Two Inuit children at Point Barrow, Alaska, hold the tusks of a large walrus, probably killed for food in 1930.
  Back to Top

A group of Inuits from Wrangel Island, extreme north eastern Russia in the Arctic Ocean, pose for a photo on Feb. 28, 1925.
  Back to Top

An Inuit man prepares his Kyak canoe, made from seal skin, on Nunivak Island, Alaska, in 1950.
  Back to Top

An Inuit man kayaks to shore.
  Back to Top

An Inuit carpenter uses a traditional bow drill which he holds with his mouth and turns with a string in 1910.
  Back to Top

An Inuit couple is photographed during the Stefanson Arctic Expedition in 1914.
  Back to Top

1955: An Alaskan Inuit is at work carving ivory with a bow-drill in 1955.
  Back to Top

A portrait of an Inuit woman believed to be Esther Enutsteak, mother of Nancy Columbia, who was declared Queen of the Carnival during the Alaska-Yukon-Pacific Exposition in 1909.
  Back to Top

Inuit Nancy Columbia and her dog pose for a photo during the Louisiana Purchase Exposition in Missouri, 1904.
  Back to Top

An Inuit man, Mec-oo-sha, and his wife, Ah-ma, were helpers during Frederick Cook's expedition to the North Pole.
  Back to Top

Three Inuit men pose at a table inside the winter quarters during Robert Stein's expedition to Ellesmere Island from 1899 to 1900.
  Back to Top

Seals and furs hang above a hut as an Inuit family sits outside.
  Back to Top

An Inuit family in Labrodor, Seattle, during the Alaska-Yukon-Pacific Exposition in 1909.
  Back to Top

An Inuit man is dressed in fur in a portrait from 1901 or 1902.
  Back to Top

Two Inuits dressed in animal skins from head to toe pose for a photo.
  Back to Top

The Kaviagamutes dress for their traditional "wolf dance" in 1914.
  Back to Top

An Inuit woman from Alaska shows off her extremely long hair in 1950.
  Back to Top

Inuits perform a tribal dance in 1914.
  Back to Top

A group of Inuit pose for a photo in 1904.
  Back to Top

Inuit kill salmon with spears in Canada.
  Back to Top

An Inuit woman poses for a photo in 1903.
  Back to Top

An Inuit mother and child are dressed in fur in 1903.
  Back to Top

An Inuit man does laundry in a tub alongside a tent in 1906.
  Back to Top

A young Inuit girl wears traditional winter clothing in 1955.
  Back to Top

An elderly Inuit woman wearing a fluffy fur -trimmed hood looks into the camera in 1955.
  Back to Top

Inuit sisters from Unalakleet, Alaska, aged seven and ten, pose for a picture in 1955.
  Back to Top

A young Inuit boy leaning on a stick looks towards the camera in 1950.
  Back to Top

A young Point Barrow Inuit carrys a can of fuel from the water front where it was transferred from an American ship which brings merchandise to Alaska in the summer of 1950.
  Back to Top

BUILD SUCCESSFUL (total time: 0 seconds)