Tuesday, December 19, 2006

Question about ranking of poker hands

I can't figure out why a flush is ranked higher than a straight
in poker.

From personal experience, it's alot easier to get a flush
than it is a straight.

Using Texas Hold'em to illustrate. Assume your two hole
cards are suited and the flop comes with two more of the same
suit. The odds of a 3rd card of the same suit hitting to make
your flush is 1/4. Right?

Now let's say you have connected hole cards (e.g. 7-8) and
the flop comes 10-9-3. You have an open ended straight draw
and the possibility of getting that Jack or 6 to complete the
straight is 2/13. That's less probable than the 1/4 chance of
making a straight and this is for an open ended straight draw.
If you are looking for an inside straight draw (e.g. you hold 7-8
and the flop comes J-9-3, you need a 10) than it's an even
worse 1/13 chance.

Seriously, from experience it's alot easier to make a flush
than it is a straight. Hell, I'd guess that poker players make
flushes more frequently than a 3 of a kind yet that is also ranked
lower as a poker hand.

Any statisticians or poker experts care to enlighten me?

I'll trade you a nuke

Today North Korea proclaimed itself a nuclear power and
made demands that U.N. sanctions against it be lifted and
also that they be provided with a light water nuclear power
reactor.

If you're the U.N. or Washington, how can you give in to these
demands? You give them the reactor and they dismantle
their warheads. Next year, they'll restart the nuclear program
again and demand HBO and all the stray dogs in our pounds.

The thing that puzzles me is, is it that much more difficult to
build a "nuclear power reactor" than it is to build a nuclear
weapon?

Thursday, December 14, 2006

Drip...drip...drip

Am I the only person who can't stand the fact that the cup/covers
used by Tim Horton's are horribly designed and have this drip
feature built in for the sole purpose of driving me insane?

Go buy a cup of Tim Horton's coffee. While carrying your cup
of coffee, if you've moved ever so slightly, the coffee will start
to drip somewhere beneath the lid. I wipe it off hoping it's just
an aberration but a few seconds later, there it is again.

Tim Horton's sells the most coffee in Canada. They are making
a fortune. Is it too much to ask that they get rid of those shitty
lids and use ones that don't drip all over my car's console or
all over my desk??

My guess is the problem is a combination of a poor lid design
and the curled lip of the cup itself. If you have sloshed the
coffee around in the cup, the coffee hits the lid and hangs there,
eventually finding it's way to the edge (it it hasn't dripped back
into the cup). Somehow the curled edge of the cup doesn't form
a very good seal with the lid and the coffee finds it way between
the lip and cup's edge, and you have your drip.

If you've experienced the drip, please add a comment and
hopefully we'll initiate some change.

Thursday, November 09, 2006

Need Macbook advice

My 1.25Ghz w/ 1Gb ram, G4 Powerbook is getting a bit long in the tooth.

More infuriating is how often the spinning beachball
halts my work. Quie often, I have nothing other than
Safari open with like 7 tabs and I'll get the beachball.

So I'm looking at upgrading to either a Macbook or Macbook Pro.

I have a few questions that maybe some of you developers can
help with.

1. What's the battery life comparison between these two? My
PB rarely gave me more than 2hrs. I recall the G4 iBooks were
alot better. Is the battery life better in either the MB or MBP?
Yes I know the specs say up to 6hrs for MB and up to 5hrs for
MBP, but in your real life experience, please let me know what
to expect.

2. For watching movies, DVD's and doing development work; I
probably don't need the 256Mb video card option do I? No
I won't play games on this and Photoshop work is minimal.

3. Is it true the current Core 2 Duo cpu's are crippled
somewhat because the chipset on the logic board only runs at
667Mhz. I hear the next chipset, Santa Rosa, should run at
800Mhz and be out early next year. How much performance
improvement can one expect from this.


I think I'm pretty much decided on getting the MBP if I do
decide to buy one now. Simply for the higher resolution. This
is one thing I've always hated on the Apple laptops, very
limited resolutions compared to PC laptops.

Thanks

Wednesday, November 08, 2006

Java code snippets

So I started a new contract recently and as I spent the first week reading documentation and going over the existing application's code, I saw something that wasn't wrong but it did catch my attention.

Do you see the difference between these two conditions?

String country = form.getCountry();
if (country.equals(Constants.USA)) {...}

and...

String country = form.getCountry();
if (Constants.USA.equals(country)) {...}


The first sample is safer as you do not run the risk of getting a NullPointerException.

It's always nice to have the time to simply read other people's code and pick up on these kind of small things. One reason why code reviews are so valuable when done correctly (unfortunately it's hard to justify the cost to the organization and most places don't provision for it).

Is the Software Piracy situation really that bad?

We read about it all the time in the media. We read about software piracy rings getting busted and then the claims from the BSA or software companies of how many hundreds of millions of dollars were lost.

I'm not going to get into the whole "well they would never have purchased it anyway" argument.

I simply want to ask a question that begs to be asked. We hear the companies scream and cry murder when it comes to the losses they experience from file-sharing, software piracy, etc but does anyone ever pause for one second to a good look at those companies and sympathize with them?

What I'm trying to say is, I don't see many of these companies going bankrupt. What I do see are ever increasing budgets (ever see how much it costs to develop a blockbuster videogame). You'd be hard pressed to convince me of their pity when it's obvious their revenues and profits are still excellent, all in light of the hundreds of millions (if not billions) of dollars lost to pirated software/music/movies.

It's like listening to the guy driving a Ferrari cry about the amount of taxes he pays. Pass me my violin and lend me a handkerchief please.

I don't advocate software piracy but it does bother me the way the media portrays the problem to the public. Even worse is the way the courts treat these offenders, sentencing them to prison terms that would make a murder/rapist/drug dealer thank their lucky stars.

I don't advocate it, but I sure as hell don't sympathize with their pleas.

Thursday, April 27, 2006

Thank god for Beverly Hills:90210

Ever come across a website that think's the United States of America is the only country in the world? You know the ones where they present a form with a zipcode field. I don't mind it the label "Zip Code", but it's the validation that bugs me. Some sites are kind enough to not validate the field and allow me to input my Canadian postal code, but then there those dweebs who write validation logic that applies to USA zip codes only.

Well thank the lord that I used to watch Brenda, Brandon, Kelly, Donna and Dylan on 90120. Without it, I'd never have a valid US zip code forged in my mind that I can use to fool those myopic websites.

Saturday, April 22, 2006

WSOP Qualifer



Out of boredom I decided to use some frequent player points on Pokerstars to play a WSOP qualifier tourney last night. This is the first time I've played in a tournament (usually just play single table games) and I can see what all the excitement is, wow!

I did quite well, actually very well. I came in 1st place and gained entry (top 14 out of 149 won entries into the 2nd round) into the second round of the qualifier which is about to start now. For this upcoming round, top 2 finishers get a trip to the WSOP in Vegas, $10k entry fee is paid for as well as hotel accomodations.

The end of last night's tourney was exciting as 15 players were left and everyone started playing tight, hoping for someone else to drop out, thus ensuring the rest of us an entry into today's tourney. Of course, leave it to me, sitting in top spot to push out the 15th player as I held pocket pairs and after the flop had an open ended straight which I got on the turn card.

Round 2 starts now...

Wednesday, March 29, 2006

Java based open source CMS portals

Spent a bit of time tonight looking at Java based CMS portals for an upcoming project. The ones I looked at briefly were

Jetnuke
Atleap
OpenCMS

We're basically looking for a CMS that we can customize and enhance through development. Our initial evaluations don't include any PHP based ones because PHP isn't our forte (yes you don't have to tell me that the CMS/Portal market is dominated by PHP products). In short our requirements include forums, news, blogs.


Jetnuke:
This is a port of PHP-Nuke done using Velocity. Jetnuke seems to have alot of of modules which is a big plus. Maybe I'm biased but I'm not really keen on taking on a Velocity project, Velocity seems to have lost it's steam and barely gets mention nowadays. Couldn't find any evidence that jetnuke supports skins/themes (hopefully using CSS) which is a requirement for us. Jetnuke does include a blog module.


Atleap:
This CMS intrigued me the most as it was developed using AppFuse and the technology stack is chock full of goodies: Struts, Spring, Hibernate, Acegi, Tiles, etc. I'm not excited about the Struts+Tiles usage but beggars can't be choosers right? There was a screenshot which I looked at and assuming my assumptions are correct, it does support themes/layouts in some sense. The site itself isn't very polished IMO but that can be worked on. Don't see any blog module though.


OpenCMS:
This project had no screenshots that I could find on their site so I had no choice but to download and install it for a quick look-see. The installation was easy enough, simply drop a war in Tomcat and follow a setup wizard. Not so fast. I chose a full installation and as it proceeded to deploy the CMS, I noticed it was unzipping alot of files. A quick look at the opencms.war file shows they embed ALOT of zip files for each module/subsytem of the CMS. No problem I say, so I let the installation run it's course. 10mins...15mins...20mins...now I start bitching. Yes it's on my laptop which is a 1.25Ghz G4 Powerbook w/ 1Gb ram (not exactly a sexy MacBook Pro) but taking this long to install anything is rediculous. I was patient and let it continue. the setup wizard was nice enough to inform me at completion that it took 1:01hr to install. ONE HOUR AND ONE MINUTE!!! Are you nuts? Now obviously that's only installation and simply starting the servlet container and deploying an already installed CMS site isn't going to take that long but if we're going to do multiple installations, that's unacceptable. A whole god damn hour for christ's sake, if I was one of those raving Ruby on Rails fanboys...I'd be raving at how I could have written a CMS in RoR in that hour ;)

OpenCMS doesn't seem to have any real usable modules, every module looks the same, simply a content pane in the middle displaying information. The "job module" shows jobs. The "news module" shows news items. Does anyone from OpenCMS want to explain to me how those modules are different? Where are the forums, blogs, galleries, etc?

The only positive thing I have to say about OpenCMS so far is that the installation, although long, was flawless. It's really rare in the open source world when you can install a product and run it and not see errors, warnings, problems. So while the 6.2 is beta, it does look somewhat stable.


So far no runaway winner. I'll keep looking and make notes here. If time were an issue and I had to pick, I'd probably pick Atleap simply based on what it's been implemented on. Hard to get excited about a new project when you don't like the current implementation (talking about jetnuke+velocity).

Wednesday, March 15, 2006

Tips for new Jetty users

Redeploying my application on Tomcat 5.5.15 on my 1.25Ghz G4 Powerbook 1GB ram was getting painstakingly slow so I decided to take a look at Jetty to see if it would help the cause.

Here are two things I came across in getting started and which I couldn't find much help on Mortbay's site/wiki/docs

1. If you use Log4J in your application and get this error:

Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d1c778 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d1c778 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))

You simply need to grab the logj4 jar file your application uses and drop it in the jetty.home/ext directory. I don't know why this necessary when the jar file itself is deployed within the webapp's WEB-INF/lib directory but it works.


2. Debugging
I got used to Tomcat's startup scripts so obviously I looked for the Jetty equivalent of 'catalina.sh jpda start' but I couldn't find anything and nary a mention of it on Google or Jetty's docs.

Well it turns out that Jetty is a java application so you can simply start it's JVM with the following standard debug options and then connect your IDE to the JVM for debugging:

java -Djava.home=$JAVA_HOME -Xdebug -Xrunjdwp:transport=dt_socket, server=y, suspend=n, address=5005 -jar start.jar



Even with a 1Gb ram, the speed of my laptop is becoming unbearable. After only 2yrs, I'm having a hard time convincing myself that I should shell out the bucks and get a MacBookPro, especially considering I built myself a AMD64 workstation within those 2yrs. I guess I'll console myself and force myself to wait for the next revision of the MBP's.

*editted to include the debug settings

Friday, March 10, 2006

Do good with your idle computer

While I've always known about SETI, it simply never really caught my interest.

But this blog entry by Onno brought to my attention some other projects that might interest you.

By downloading and installing a small program on our computers, we can make use of our computer's idle processing power. Those of us who leave our computers turned on day and night are wasting alot of computer power that could be put to good use, for the benefit of science and mankind.

Visit Berkeley's site to see a list of projects that you can participate in.

For the technically challenged; by installing this program, as long as you're connected to the internet and the computer is idle (not doing anything demanding), the program will run scientific calculations using your computer and then send the results of those calculations back to Berkeley for collation. You can help further scientific research by donating those spare cpu cycles!!

Or maybe you just want to help find aliens by joining the SETI project ;)

Admit it, leaving your computer on 24/7 to download torrents isn't really that demanding on your cpu, why not help out a good cause?

Tuesday, February 21, 2006

Equinox to the rescue

I've been trying to restart work on an application that I've shelved for a year. Doing so inevitably meant updating the stack to the latest/greatest versions of each framework; in this case it was Tapestry/Hibernate/Spring. Lucky me as all 3 have come out with major version releases since :(

It never ceases to amaze me that framework developers simply refuse to ease the learning curve of their products for newbies. Don't take that as me being ungrateful for the amount of time they spend on these projects, that's further from the truth. However, trivial stuff such as blank applications (i.e. struts-blank.war) are rarely bundled with a framework, meaning the new user is expected to RTFM and understand the entire framework simply to get to that starting point where they can learn/develop in a more logical manner.

Yes, each framework comes with it's sample applications. The value of a 'blank' application is vastly greater IMO as it's something each user needs for the start of any project. For new users, it's great to start with a blank canvas where all the underlying pieces have been put together for you and you concentrate on learning the framework by adding piece by piece.

I can't imagine the framework authors don't have such a template application lying around where they simply copy and rename it to a new directory in order to start a new project. I simply ask that you bundle that with the dist. Oh that piece of crap you say? No it's not crap, it's really useful, trust me!!!

Late last night, as I pounded my desk in frustation, after experiencing endless hours of modifying XML files, googling, scouring mailing lists...I was about to give up. My situation was so dire that my mind wandered and in a moment of weakness, I wondered aloud "maybe I should take a look at Ruby on Rails". I was so desperate to *just* start developing my application and not have to deal with these startup pains. Before I could even google for 'ror' to take a look at what the excitement is about, I looked up from my desk and glanced at the door to hear someone approaching *grandoise theme music playing here* A glowing aura basks the room as I hear the gallop of what sounds like a horse. I rubbed my weary eyes in disbelief as in strode a white knight on a brilliant white stallion, across the knight's chest was emblazoned a logo...I squint to read it as the light had completely enveloped the room. The logo says "Equinox". "Equinox?" I repeat to myself.


Equinox, http://equinox.dev.java.net is an application that creates a skeleton of an application (views, model, dao's, service layer) for a multitude of frameworks including (goto site to see full list): Struts, WebWork, Tapestry, Spring, Hibernate, iBatis. This application goes way beyond my wish for a 'blank' application as Equinox integrates each framework for you. Amazing tool for anyone starting a new project.

For you *nix people, the order of steps is important.
1. cd $equinox_home
2. ant fixcrlf
3 (optional if you want to use a different MVC framework) cd extras/tapestry
3b ant install
4 cd ../..
5 ant new (Maven will download it's dependecies and then you will be prompted for a project name).