Sunday, December 31, 2006

Dogs of the Dow for 2007

This is my first public mention of the stock market, so please bear with me ...

Every year, I find myself worrying about where to place my money for the upcoming year. Last year around this time, I really liked metals and mining stocks. The year before that, it was oil and gas royalty trusts (I am a Canadian investor).

This year, I find myself intrigued with the 'Dogs of the Dow' theory, which according to wikipedia, is where 'an investor should annually select for investment the ten Dow Jones Industrial Average stocks whose dividend is the highest fraction of their price.'

According to the SINLetter, the Dogs faired quite well in 2006 in comparison to the rest of the Dow (and other American markets).

Dogs Of The Dow Performance Vs Major Indices
2006 Dogs of the Dow 24.8%
Dow Jones Industrial Average16.29%
S&P 50013.62%
Nasdaq9.52%
Russell 200017%

The 2007 picks for the dogs of the Dow are as follows (Name/Yield):

Pfizer4.45%
Verizon Communications4.34%
Altria4.13%
AT&T4.00%
Citigroup3.87%
Merck3.49%
General Motors3.27%
General Electric3.07%
Dupont3.02%
Coca-Cola2.80%

I have read about some modifications, for instance, picking the top yielding dogs with the smallest market capitalization with the hopes of higher growth which would translate into higher returns. Some opponents of the Dog strategy mention that some stocks (usually the high tech ones) pay smaller dividends which result from there consistent exclusion from the list.

The 'Pigs of the Dow' is another modification of the Dog strategy that doesn't exclude any members of the Dow. This strategy entails picking the 10 worst performing Dow stocks of the previous year. Of course, you might want to make sure that they didn't underperform for some obvious reason (maybe there was mention of bankruptcy, or have some form of potentially crippling pending litigation).

Anyways, I wish you luck with all your investments in the new year! Please feel free to comment on these strategies and to mention others that people might like.

Disclaimer:
  • I am not be liable for any investment decision made or action taken based upon the information on this page.
  • I suggest you check with a broker or financial adviser before making any stock investing decisions.
  • I am not offering financial advise, but rather commenting on widely available investment strategies.
  • Finally, Caveat emptor!

Tuesday, December 19, 2006

Intel ProSet Wireless ... Part 2

Previously (see here), I had noted some problems that occurred upon performing an upgrade of the drivers for my Dell Intel 2915 ABG Wireless Network Card.

Specifically, I had to downgrade my router from acting as a wireless G router, to acting as a B/G router. This resulted in slower performance (from the router).

I am glad to say that this morning, I upgraded my network cards' drivers (see here) and it seems like Dell finally corrected this problem. I can safely say that the problems that I have encountered in the past have fully been resolved.

The update is for the Intel wireless adapter model number 2915 and 2200. Before upgrading, make sure to backup your 'profiles' that you connect to just in case.

Just thought that I would let you know!

Wednesday, December 06, 2006

Where is my context.xml coming from!?!

I recently modified some JSPs that were being served by Tomcat. Specifically, I added some 'Environment Entries' so that I could set some 'global' variables for my webapp.


I added things like the following to my context.xml file in the META-INF directory of my webapp:
<Environment name="maxExemptions" value="10" type="java.lang.Integer"/>

So that during execution I could do load the variable and use it like so:



Context c = new InitialContext();
String maxExemptions =
((Integer)c.lookup("java:comp/env/maxExemptions")).intValue();


After I deployed my new code, I tested it and found out quickly that the javax.naming.NamingException were being throw. The error basically stated that the variable was not bound in this context.

At first I thought that I did the whole looking up stored properties incorrectly. What really happened though, was that in my

/${catalina.home}/conf/Catalina/localhost/

directory was a cached copy of my context.xml file under the name of 'my_webapps_name'.xml.

Once I deleted that and restarted Tomcat, everything worked as expected.

If you came here trying to debug javax.naming.NamingExceptions, I recommend that you first try removing that file first!

Good Luck!

Wednesday, November 22, 2006

Funny EA Sports NHL 2007 Bug

I came across a bug that I reported to EA but wanted to share since I haven't come across anyone else that has encountered it before.

The basic gist of the bug is that there is an extra goalie on one of the teams. Moreover, the team that has the extra goalie seems to steal this man from the other team because they are one man shy. So not only does one team have an extra goalie, the extra man was taken from the other team!

Oddly, enough, I really like this bug. It's really fun trying to deke out both goalies. Right when you think that you have beat one of them, the other dives across and saves the day. Who knows, maybe EA should add a mini-game in the next installment that allows you to play against a team with an extra on ice goalie.

So how does one re-create this bug?
  • First of all, I have an Xbox 360, so that is the only platform that I have tried this game on. So all other consoles are out of luck.

  • Second, the bug has happened to me many times, and only when playing against a friend using the 'play now' mode. The team that always seems to be on the ice when this happens are the Buffalo Sabres. For the screenshots below, they were playing against Colorado.

  • Thirdly, you have to edit your lines once you have chosen your teams and before loading the game. When changing your lines, try to have as many players listed as 'undefined, undefined, undefined'. If you don't know what I mean, try double shifting players repeatedly until this glitch occurs.

  • Finally, go on and play the game. During a face off, you will notice that all of a sudden both teams are 4 on 4. After the face off, a player will come off the bench and his team will have an extra goalie.
So below are some screen shots that I took when I encountered the bug. Sorry if they are out of focus, but I am sure that you get the point!






Thursday, November 09, 2006

Intel ProSet Wireless Issues and Solutions

I decided today that I would update the drivers for my Intel Pro/Wireless 2915ABG Network Card. This is the network card that came with my Dell Inspiron 6000.

Downloading the file from Dell's website was no problem at all. The only thing that bothers me is that the file is 100MB. A bit large for something that just handles wireless connections don't you think?

Anyways, in the past all attempts of upgrading my drivers have led to failure. For one reason or another, the upgrade doesn't work and I revert to old drivers. I always wonder what it is that I am missing ...

Back to the story ... I downloaded the drivers and installed them. I wasn't surprised when I was unable to connect to my network. Another upgrade, and another failure... Wait, not this time. I was determined to see it through.

To save you from my ramblings, this is what I found:
  1. My Intel wireless card does not like my wireless router.
  2. To get my router and the wireless card talking, I had to downgrade router. Actually, I went from a purely G router, to a mixed mode B/G setting.
  3. My wireless card likes to beep when it connects to a network
Okay, so point 2 solved my incompatiblity issue. That's great, except I wish that I didn't have to run in mixed mode. To make sure that my wireless card isn't running in B mode, I made sure that the adapters 'Wireless Mode' was set to '802.11g only'. You can modify this setting from the 'Advanced' tab of the wireless card's properties panel (Control + A from within the Intel ProSet/Wireless application window).



As for point 3 above, the beeping, I think that I managed to fix that by modifying a setting in the Intel PROSet/Wireless Application Settings (issue a Control + P from within the application) window. The setting that I changed was to uncheck the 'Show Information Notifications' box. This seemed to work for me.



All in all, I am glad that I finally was able to upgrade my drivers. Hope that you can too.

Monday, October 30, 2006

Scheduling an Ongoing Task in a Servlet

Recently, I had the need to create a task that had to run hourly, with the stats to be available to clients. I wanted the task to be distributed without having to worry about configuring a database store, etc.


The solution I came up with was to create a JAVA servlet and use a Timer object to schedule a timer task that runs every hour. The task then runs hourly and saves the results in memory.


Usually, creating threads (which is what a TimerTask object is) in a servlet container is frowned upon because the container cannot manage the resources used by the user spawned thread. In addition, whenever your web application is deployed, reloaded, or undeployed you have to ensure that you clean up after your thread.


The first thing that you will do is implement the ServletContextListener interface. This interface consist of 2 methods that you will have to implement, namely,


public void contextInitialized (ServletContextEvent servletContextEvent);

&

public void contextDestroyed (ServletContextEvent servletContextEvent);


The contextInitialized(...) method is invoked by the servlet container everytime the servlet is 'started up'. So upon initial deployment, this method is called. Everytime you reload your web application, this method is invoked.

The contextDestroyed(...) method is invoked everytime the web application is shut down, for example, when you reload or un-deploy the web application.

Ideally, anything that you need to do when the web application first starts up should be done in the contextInitialized(...) method, while anything to undo the initialization should be done in the contextDestroyed(...) method.


In the contextInitialized(...) method, the idea is to create a TimerTask object and using the Timer object, schedule it at the desired time interval. Once the scheduling is done, we save the Timer object as an attribute in the ServletContext.

For example, assuming that MyTimerTask extends TimerTask,

  
ServletContext servletContext = servletContextEvent.getServletContext();
try{
// create the timer and timer task objects
Timer timer = new Timer();
MyTimerTask task = new MyTimerTask();

// get a calendar to initialize the start time
Calendar calendar = Calendar.getInstance();
Date startTime = calendar.getTime();

// schedule the task to run hourly
timer.scheduleAtFixedRate(task, startTime, 1000 * 60 * 60);

// save our timer for later use
servletContext.setAttribute ("timer", timer);
} catch (Exception e) {
servletContext.log ("Problem initializing the task that was to run hourly: " + e.getMessage ());
}

In the contextDestroyed(...) method, the idea is to clean up after yourself. In our case, this means cancelling any tasks and removing the timer object.


ServletContext servletContext = servletContextEvent.getServletContext();

// get our timer from the Context
Timer timer = (Timer)servletContext.getAttribute ("timer");

// cancel all pending tasks in the timers queue
if (timer != null)
timer.cancel();

// remove the timer from the servlet context
servletContext.removeAttribute ("timer");

The final thing that we have to do now is make sure that our ServletContextListener is added to our web.xml file.

As a child element of the <web-app> element, add the following lines of code:


<listener>
<listener-class>your.package.declaration.MyServletContextListener</listener-class>
</listener>

Where, your.package.declaration is the package containing the class MyServletContextListener that implements ServletContextListener!

Now everytime the web application starts up and shuts down, our listener will be invoked. Not only did we create an on-going task, but we scheduled the task and made sure that we cleaned up after ourselves too!

Wednesday, October 25, 2006

Creating Your Own Cat 5 Cable

The other day I wanted to create an Ethernet outlet in one of my rooms. I bought a network switch, some 'high' quality cat 5 cable, an outlet, some rj45 plug ends and a crimper.

Wiring the outlet was extremely easy, but the cable was another story... For the life of me, I couldn't find what the proper ordering of the cables was supposed to be! Most places that I had found on the internet contradicted each other.

Now that I know how this works, I wanted to post here for my future use and for others to benefit from.

There are 4 pairs of colors, with each pair consisting of a solid and a striped wire. The order of these wires is obviously important for its function and once ordered correctly, they are placed in a RJ45 plug end (shown below).


Using the image above, going from left to right, the order of the wires for a straight through cable (non-crossover, for connecting a computer to a network) is:
    1. orange striped
    2. solid orange
    3. green striped
    4. solid blue
    5. blue striped
    6. solid green
    7. brown striped
    8. solid brown
If you are interested in creating the crossover cable (for connecting a router to a switch, or connecting 2 computers directly through their network adapters), one end of your cable would be wired as stated above and the other end would be:
    1. green striped
    2. solid green
    3. orange striped
    4. solid blue
    5. blue striped
    6. solid orange
    7. brown striped
    8. solid brown
Once you line up the wires and push them into your RJ45 plug end, use your crimper to finish the job off.

Creating the wire is very easy and extremely cost effective. Good luck!

Wednesday, October 11, 2006

Configuring Tomcat to serve static files

For a long time now, I have been trying to figure out how to specify a default servlet in Tomcat 5 and still allows for static files to be served.

From all of my readings, I have noticed that in order to have a default servlet and serve static files, I would have to serve the files via my servlet. I didn't like this solution. Finally, I have discovered a work around...

To outline the problem, imagine that your web.xml file contains the following:

<servlet-mapping>
<servlet-name>My Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Now all requests to your webapp are going to go through 'My Servlet'. So if you ask for a file like http://localhost:8080/your_app/myStyleSheet.css, Tomcat will look at the request and forward it to 'My Servlet'.

Now unless that particular servlet contains code to handle the case for myStyleSheet.css, nothing will happen (depends on your 'My Servlet' code of course; 404 might be returned, etc).

So one work around that I have found is to enter the following in your tomcat/webapps/your_app/WEB-INF/web.xml:

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>

With that code all requests for a file ending in the prefix css will not be sent to 'My Servlet'. Instead Tomcat will look for the file in your web apps home directory and if found, serve it, otherwise a 404 is returned.

Now that I have found this one solution, it seems to me like it was obvious (maybe that's why I couldn't find it in all my web searching with google) ...