Wednesday, November 12, 2014

WashingtonPost.com - null trailer null

WashingtonPost.com website is written in Java. Back a couple of years they were an atrocious website, mainly because they had hired a bunch of java idiots who had over architected the whole thing, throwing all the latest java technology like JSF, Spring, Hibernate, etc...into the mix, making a very fine mess of everything. Every couple of days they would advertise for a new software developer, as some poor soul, ran away screaming. They seem to have gotten their crap together now. But, every so often we get stuff like below.

The title of below webpage is "Null trailer Null"...where can i watch this movie :)

wtf

i found this at this url: http://www.codingforums.com/showthread.php?t=267682
what could be the problem :)
With thanks to all codingforum members and volunteers...
I'm facing weird issues for a few days while im working with if condition.
Whenever i use something like

<? if ($x='1') { ...

this always returns $x to be 1, even though my database records say its not.

Hulu software developer job application

Hulu software developer job application

i was looking at Java jobs in LA on indeed.com and ran across Hulu's software developer position. So, I did ok on qualifications, CS degree, TDD, web services, etc. Also, ok on experience, Java, no objective-C, Python, no streaming video or Flash, but you know I could dream. So far. But then, I ran into this:

Since we're clearly into lists, here's a Top 5 for how you know you need to work at Hulu in no particular order (* they probably meant - how you need to think ! (nice, if a little Orwellian)):

You fall asleep thinking of ways to search through 100 billion sheep (sadly my last thoughts before going to sleep all involve ludicrous fantasies, involving women, mad money, absolute power, world domination...)

You recently had a nightmare that involved an unbalanced red-black binary tree (i kinda know what an unbalanced binary tree is, but a red-black one...)

You can compress better than H.264 (it's a video compression format, good for making torrents of Hollywood movies (jk, i'm into arthouse)...)

Your most recent open-source app was the 'Most Active' entry on SourceForge (SF and now there's github - sadly my projects always run into my arch enemies - beer, women, junk tv (storage wars !))

You rule at ping-pong, eating contests or Project Euler (exercise is a must, i love eating (PHO) and Euler was a mathematician)

If you're the kind of developer who obsesses over indentation (spaces or tabs), monitoring services, and jumps at the opportunity to take on new math challenges then Hulu may be the place for you. (i do like well formatted code, Euler was a mathematician....)

Dear Hulu,

Why do you have to be such dicks. Did you really have to give us this list? To utterly crush our hopes, just when we were getting ready to fire off our resume. To deny us the small satisfaction of saying, "hey i tried, i applied". A justification to spend the rest of the afternoon watching tv...contemplating your dwindling bank balance...the resultant panic of impending homelessness...causing you to call your Mom, after forgetting her birthday and ignoring countless calls...Did you REALLY have to drive us to this ???

I give up. Job postings like this make me realize, that I am just a mediocore developer. I do like writing code and am pretty good at it, but it's not my life. It's not the end all. Hire a bunch of us mediocore guys, pay your CEO a little less.

Ranjit

http://hire.jobvite.com/CompanyJobs/Careers.aspx?c=qxc9Vfwx&jvprefix=http%3a%2f%2fwww.hulu.com&jvresize=%2fjobs%2fresize_jobvite_frame&page=Job%20Description&j=oAaCWfw2

Java Code - This returns the first key in a HashMap given a value

Java Code - This returns the first key in a HashMap given a supplied value

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * general purpose utility methods
 * @author ranjit sandhu
 */
public class Utils {

    // gets first hashmap key from supplied value    
    public static String getKeyByValue(LinkedHashMap lhm, String value) {
        String tt = "";
        Iterator fat = lhm.entrySet().iterator();
        while (fat.hasNext()) {
            Map.Entry pairs = (Map.Entry)fat.next();
            String key = pairs.getKey().toString();
            String val = pairs.getValue().toString();
            if (val.equals(value)) {
                tt = key;
            }
        }
        return tt;
    } // end getKeyByValue
    
} // end Utils

google maps fractal

in google maps, street view you can zoom the camera upwards and achieve fractal views like below.



Monday, August 4, 2014

Oracle Jobs - DBMS JOBS - broken fix re-run

i was working on a pl/sql application and apparently it had some jobs which were being run on some schedule. I should have just used SQL Developer's Scheduler folder tab to see what jobs were running...but i didn't think of it and ended up googling for some SQL which was:
 -- sys level
 select * from dba_jobs
 -- sys level
 select * from dba_scheduler_jobs
 -- schema user level
 select * from user_scheduler_jobs
 -- schema user level
 select * from user_scheduler_job_run_details
 -- schema user level WORKED 
 select * from user_jobs order by broken, job asc
if a job fails to successfully execute it will go into a broken state after 16 attempts, so all my jobs were broken and the scheduler was NO longer trying to re-run them. i wanted to reset that flag and execute them straight away. i wrote a loop in a stored procedure to do this.
 FOR i IN (SELECT * FROM user_jobs WHERE broken = 'Y') loop
  num := i.job;
  -- i didn't want to restart some of my broken jobs
  if (num <> 232 and num <> 233 and num <> 241 and num <> 270) then
   -- true does the opposite
   dbms_job.broken(i.job, false);
   -- run the job one time, if it's broken throws an error
   dbms_job.run(i.job);
  end if;
 END LOOP;

Friday, July 18, 2014

javascript object hashmap associative array

i use javascript quite a bit and i program for work in Java, so I wanted to mash them both together and as a result was reading about Rhino, which allows javascript to call Java classes and methods. And I was looking through some sample code and the following blew my mind:
var f = new File(arguments[0]);
var o = {}
var line;
while ((line = f.readLine()) != null) {
 // Use JavaScript objects' inherent nature as an associative array to provide uniqueness
 o[line] = true;
}
for (i in o) {
 print(i);
}
i didn't understand the code!  after some investigation, i found that the base javascript object acts like a HashMap, a TreeSet and an associative array. check out the code below:
<script>
 var tt = {hair:"black,cat,dog",eyes:"brown"};
 console.log(tt);
 tt["eyes"] = true;
 tt[""] = true;
 tt[null] = true;
 console.log(tt);
 console.log(tt[0]);  // should print hair
 console.log(tt[0][1]);  // should print cat
</script>
it's output is:
Object { hair="black,cat,dog", eyes="brown"}
Object { hair="black,cat,dog", eyes=true, =true, null=true}
undefined
TypeError: tt[0] is undefined
the only drawback is that the last two don't work, you can't access it like an array, even though internally it's an array of arrays. anyways that explains how they were able to get unique lines, they were checking the values against the javascript objects keys (which have to be unique).

tomcat oracle spring BLOB OracleLobCreator exception error

I recently switched from an older version of Tomcat 5.5 to 7.0. This created an error because the newer version of tomcat creates database connection pools differently. The error pops up in my application when I try to upload a file, because it creates a BLOB type, which this new pool object doesn't support.

ERROR message: document update Blob error exception:org.springframework.dao.InvalidDataAccessApiUsageException: OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [org.apache.tomcat.dbcp.dbcp.PoolableConnection]: specify a corresponding NativeJdbcExtractor; nested exception is java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolableConnection cannot be cast to oracle.jdbc.OracleConnection

my original Spring beans XML file:
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor" lazy-init="true"/>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
 <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
</bean>
As you can see, I was using WebSphereNativeJdbcExtractor as the LOB handler, but tomcat passes it's own implementation of the Oracle database connection to the Spring class. I changed it to:
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor" lazy-init="true"/>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
 <property name="nativeJdbcExtractor" ref="commonsDbcpNativeJdbcExtractor"/>
</bean>
<bean id="commonsDbcpNativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"/></b>
This works!

Monday, July 14, 2014

sqlplus connect to database without using the SID

sqlplus connect to database without using the SID
sqlplus connect to database using description string
sqlplus change expired password

here's the command:
sqlplus user_name/password@"description_string"

Example description string (keep all brackets): (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=name_or_IP)(PORT=1521))(CONNECT_DATA=(SID=sid_name)))

In the case of expired password, it will prompt you to enter a new password.

Thursday, July 3, 2014

ship slams into italian port of genoa killing seven

The bridge of the ship that crashed into Genoa harbour, the 'Jolly Nero', is clearly seen behind the wreckage of the control tower in this picture taken shortly after the collision, late on Tuesday, May 7, 2013.
The ship that crashed was the Jolly Nero. It was manoeuvring out of the port at around 23:00 local time with the help of tugboats in calm weather.

Rescuers stand on the rubble of a former harbour control tower, all that remains standing of which is a tilted metal staircase.
The control tower in the Italian port of Genoa was reduced to rubble and a single, leaning staircase after a cargo ship slammed into it late on Tuesday night, killing at least seven people.

The damaged stern of container ship Jolly Nero in the port of Genoa on May 8, 2013, the morning after the crash.
Some damage is visible on the stern of the container ship. The ship's owner, who arrived at the port soon after the incident, told journalists he was "utterly shocked".

The container ship Jolly Nero after the fatal crash. The vessel is almost 240 metres long, painted red, with a gross tonnage of nearly 40.600.
The Jolly Nero is almost 240 metres (787 ft) long. Its captain is being investigated by prosecutors with a view to possible manslaughter charges.

The control tower, looking like one at an airport, pictured in 2011, intact.
The control tower was was more than 50m (164ft) tall. About 13 people were inside at the time of the crash, which happened during a shift change.

Collapsed control tower of Genoa's port (8 May 2013)
The tower crashed backwards into the water, pulling down buildings around it.

Rescue workers in the rubble of the collapsed control tower in the port of Genoa (8 May 2013)
Rescue workers have been sifting through rubble on the dock and in the water. At least two people are still missing and four others were injured, two of them critically.

An operation takes place to remove the wreckage of the control tower from the dock at Genoa's port (8 May 2013)
The BBC's Alan Johnston in Rome says the crash has revived memories of the accident involving the Costa Concordia cruise ship off the Italian island of Giglio in January 2012, which left 32 people dead.

cygwin wget setup proxy authentication

I am behind a corporate proxy server and needed to use wget to get some pages. This is from within cygwin. You can use command line options for wget to set the server and username/password. Or, you can set it up in the wgetrc configuration file. This file is located in the cygwin_install_dir/etc directory. I tried modifying the wgetrc under etc/defaults/etc but that did not work. These are the entries you need:

use_proxy = on
http_proxy=http://blah.company.com:80/
proxy_user=username
proxy_password=password

Sunday, May 11, 2014

my old assed ubuntu install

i've been using ubuntu for ever...until the evil gnome 3 install, which was so god awful that i stopped updating my distro...i'm still on ubuntu 9 or 10...chrome is at 18 ,etc...almost everything is outdated, but it still works good enough for me...i have had another newer laptop for almost 2 years now, which i never finished fixing, it was running windows and then i installed a bunch of OS's on it and then gave up on it...the wireless card required a custom fix and the trackpad cannot be disabled easily. anyway, i wanted to post my ubuntu desktop screenshots before it all dies. enjoy !!!



An even older picture of Ubuntu 9 desktop on my toshiba laptop...check out how i have the taskbar completely transparent :)

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)