Wednesday, September 11, 2013

Hibernate scalar types deprecated

In earlier versions of Hibernate, you might have had code that looks like this

session.createSQLQuery("select * from person").addScalar("id", Hibernate.INTEGER)


The fully qualified name of that type is org.hibernate.Hibernate.INTEGER.
That entire type class (org.hibernate.Hibernate) was replaced by org.hibernate.type.StandardBasicTypes.


Thus, your new code should look like this:

session.createSQLQuery("select * from person").addScalar("id", StandardBasicTypes.INTEGER)


Note that the documentation on the JBoss website is outdated depending on which version you are looking at.

For example, documentation for Hibernate 3.3 still says this:
sess.createSQLQuery("SELECT * FROM CATS")
 .addScalar("ID", Hibernate.LONG)

Thursday, January 31, 2013

[CODE] Setting the transaction timeout in EJB 3 using annotations

It's annoyingly hard to find this info online, so here it is:

The timeout annotation is provider specific (weblogic, jboss, etc.).  For example, for Weblogic it is @TransactionTimeoutSeconds(value=40)


http://docs.oracle.com/cd/E16764_01/web.1111/e13720/annotations.htm#i1438354

It's a class annotation, and should be put on the same class you have your javax.ejb.Stateless (or Stateful) EJB.

e.g.

@Stateless(mappedName="myClass")
@TransactionTimeoutSeconds(value=50)
public class MyClass implements ...

Wednesday, August 31, 2011

[CODE] Finding database constraints in Oracle

Quick and easy way to find a constraint by name in Oracle.

By the way, if the constraint name comes out as MYSCHEMA.ConstraintName, leave off the schema part when you search for the constraint.

Friday, July 29, 2011

[RANDOM] Giving NBA referees their due

One of my biggest peeves with sports fans are their complete disregard for the difficulty of being a ref or an umpire in professional sports. They have an extremely hard task that demands perfection and they very nearly get it all the time. Playoff refs are actually chosen based on their number of mistakes during the regular season (for NBA and the NFL, at least. I assume it's the same for other sports). There is a relentless review of their work after every game and each referee is criticized and trained throughout their careers to become better.

They could get 99% of their calls right, and yet they still get lambasted when they make one wrong call.

A great passage I read from Peter Post summed up my feeling towards the matter well. Paraphrased, it was something along the lines of, "Never blame the ref for one bad call that costs you the game. Chances are your team made at least one mistake along the way, so you should instead lament all your missed opportunities that would have won it for you."

At any rate, here's a fantastic article from ESPN where the writer spends a day hanging out with NBA referees at work and has some very interesting and insightful comments.

[RANDOM] Monty Hall Problem

The "Monty Hall" problem is a famous probability question that stumped me when I heard it. Even though I guessed it was a trick question, I couldn't mathematically prove why either solution was correct, which I would consider as getting the question false (I don't think blind guesses should count for anything).

If you've never heard it, it's a fun one to puzzle through. I'll put the problem description below and a link to the Wikipedia page with the solution afterwards.

"Suppose you're on a game show and you're given the choice of three doors [and will win what is behind the chosen door]. Behind one door is a car; behind the others, goats [unwanted booby prizes]. The car and the goats were placed randomly behind the doors before the show. The rules of the game show are as follows: After you have chosen a door, the door remains closed for the time being. The game show host, Monty Hall, who knows what is behind the doors, now has to open one of the two remaining doors, and the door he opens must have a goat behind it. If both remaining doors have goats behind them, he chooses one [uniformly] at random. After Monty Hall opens a door with a goat, he will ask you to decide whether you want to stay with your first choice or to switch to the last remaining door. Imagine that you chose Door 1 and the host opens Door 3, which has a goat. He then asks you "Do you want to switch to Door Number 2?" Is it to your advantage to change your choice?"
-Krauss and Wang 2003:10

http://en.wikipedia.org/wiki/Monty_Hall_problem#Extended_problem_description

[RANDOM] Google data online

Sorry about the six month absence of new posts onto this blog. It's been more a lack of energy than a lack of motivation or ideas that's been preventing anything from going up. I actually have a ton of content that I've been wanting to post about for a while now, and hopefully I'll make some progress on that in the next few weeks.

For starters, I never cease to be amazed at the great work Google does at putting up information online. I stumbled on this a while ago and was impressed at how easily they put data into the public arena and how accessible it is. I'm the type of person who likes to debate and talk about varied subjects, and I think that backing up your arguments with proof is important. That previous link is to GDP of countries in the world, but you can access all sorts of nifty statistics here. It's worth exploring if you're into demographic data like this and I'm sure it'll be useful in the future in more serious research as well when awareness grows.

Just to scare you, check out this chart on the rise of chlamydia in the US.

Tuesday, January 4, 2011

[FOOTBALL] Ed Hochuli and other referee-related awesomeness

Besides my obvious interest in software development (and XKCD, which is where I got my blog title from), I also love football.

While I could write a novel on all the reasons I love football, I'm sure people would love to just see some interesting random football tidbits instead.

For starters, Ed Hochuli is basically my hero. He is one of the only two refs that I know the name of. When they release the ref schedules for the games I actually get excited when I see him listed for a Pats game.

Why is he my hero? Oh, so many reasons...

  • He's really jacked.
  • The guy is in better shape than I am and he's over sixty.
  • He's one of the best active refs out there, having been selected to ref for two Super Bowl and many playoff games.
  • His day job is a lawyer.
  • He represents the refs in their union.
  • He has the best explanations of any ref I have ever heard, gaining points for clarity, completeness, and unintentional humor.
  • The players think he's hilarious.
  • Did I mention he's really, really jacked?
  • and the list goes on...
But that's enough hero worship. Just check out some of his awesomeness.

"There was no foul on the play... the defender was just overpowered." Check out Belichick's facial expression.

God, this guy is thorough with explanations.

NFL special "I want to be Ed Hochuli":
"He once needed 91 words to explain an illegal motion infraction."
Jared Allen: "Ed's arms are looking better than all of ours!"

Butt slap at 0:47-

Tony Romo wishes he was Hochuli:

Ed Hochuli gives a penalty call in Spanish while refereeing a game in Mexico:

And just so I'm not too focused on Hochuli, here's a great ref call that I won't spoil by typing it out first.

Friday, October 22, 2010

[CODE] Problems with Ext.LoadMask and Modal Windows

Anyone who has used the Ext.LoadMask object with a modal window (basically a popup that prevents you from interacting with anything outside the window) that spawns another mask will know that there is a known bug in ExtJS that doesn't mask the modal window automatically.

Example:

Say you're looking at an online menu for a restaurant, like something you would see on GrubHub. You select one of the dishes and it pops up another window that asks you what kind of rice you want with it, simultaneously graying out everything around the popup. That rice-selection popup is a "modal window".

Imagine you select your rice choice (white, of course) and press the OK button. A small loading icon appears, a mask appears over the modal window, and a second later the modal window and both masks go away, leaving you on your original menu window, with your dish and rice option selected.

That's what should happen. In ExtJS that second mask doesn't overlay the modal window, meaning you can click things while it is doing work in the background. It probably won't affect the operation, but it's tacky and unprofessional.

I've run into this at work, and an easy solution that worked for me is

Ext.WindowMgr.getActive().setDisabled( true );

That will (usually) get the topmost window, likely the modal window you are looking at, and disable it which causes it to gray out as if masked. Call this right after the user hits the OK button and you should be all set!

Monday, October 4, 2010

[GAMES] Figuring out your saved Nethack character name on Windows

One of my coworkers is a dual major in computer science and game design, and recently we've been talking about some of the games that set the groundwork for the games we know today. He started talking about the game Rogue and the games that built off of it, called "roguelikes". Basically, they're text-based dungeon crawling games with randomized dungeons and permanent death. Diablo was actually heavily influenced (according to the developers) by the most popular roguelike, NetHack.

Of course, I had to try it out, and now I'm pretty much addicted.

But this post isn't about my propensity for gaming addiction, it's to actually provide some useful information. I got the furthest I'd ever been last night and saved and went to bed.

The problem is that I couldn't remember my character name. I'd started and died so many times I was just hitting random keys for name creation. However, you can look at the save file and figure out your character name.

On Windows XP at least, it will be saved into the same directory as the NetHack executable. The file format is

WINDOWS_USERNAME-charname.sav

For example,

Administrator-AwesomeValkyrie.sav

Just type in "AwesomeValkyrie" in the load screen and you're all set!

I hope that helps someone out there who looked up the solution to this problem and only ran into *nix answers :-)

Wednesday, September 29, 2010

[TOOLS] Transparent development progress

One of the biggest movements in software development is that of transparency: telling all observers, especially stakeholders, exactly what the team is building right now.

For example, the Scrum development methodology suggests the use of a "burndown chart", a publicly visible graph that shows how much work is left to do in a sprint.

I found another cool example of this when following the Natural Selection 2 video game's blog. They released an alpha version of their game to people who have pre-ordered the game, and want to keep people updated on their progress towards completion and which features they're working on.

Through the use of Pivotal Tracker (I've never used the tool, so I can't say good or bad things about it) and a simple web page (actually the web page might be built through the tool) the company has created a great transparent window into their development process and increased the connection with their customers.


This is a huge step forward in communication with the customer. Anyone who has ever pre-ordered something still in development (a phone, some software, even startup capital in a new company) knows how frustrating it is to sink money into a black hole and not know what happens to it.

With a simple but effective interface like the one shown above, people can have faith that their money is actually being spent on real features and get a handle on the direction of the product. It also encourages new investment by displaying the progress of the team.

Tuesday, September 28, 2010

[TOOLS] Spring 3.0 - making life difficult

Just kidding. Kind of.

In Spring 3.0 they decided to break up the main spring.jar into a bunch of smaller jars. While I'm sure they had great reasons for doing so, it means that old examples are now broken since you have to figure out which jars they use.

Or, alternatively, you can just reference all of the jars. In Eclipse, create a new "User Library" called spring jars and just add all those spring jars into it. In whatever package needs spring, add your new user library to the build path.

Thursday, September 2, 2010

[TOOLS] Off-label use: ExtJS 2.3 with Managed IFrames

FYI:

The ExtJS extension "Managed IFrame" only lists support for ExtJS 1.1+, 2.0.X and 3.1.1+ only.

However, I can tell you from personal experience that the miframe_1_2_7 version (found here) definitely works with ExtJS 2.3.0. We use it at work in our widget system, and we found it to work perfectly.

Sunday, August 29, 2010

[RANDOM] Best of Wikipedia edit wars

For a bit of amusement, check this out and see what the lamest edit wars on Wikipedia are.

My personal take:
-Why bother mentioning House's lack of Asian diversity?
-Totally appropriate to put spiders on the arachnophobia page :-)
-Aluminum
-Cat: Owner
-Sulfur

Wednesday, August 18, 2010

[TOOLS] Amazing desktop wallpaper

It's sleek, simple and useful. What's there not to love?


Here's an example one...

(you need to click on the image to see the whole wallpaper)

It took me a while to find a blank version, but you can finally get it here.

I'm loading it up right now on my computer, maybe I'll post it when I'm done :-)

By the way, you might need to change your icon grid settings to get it to work:

Wednesday, August 11, 2010

[SCRUM] Keeping your team informed of technical details

In the past few months my scrum team has doubled in developer size. We started out with four developers, a Scrum Master and a Product Owner and have since added four more developers (two full-timers and two co-ops, who are full time until the end of December).

Recently we discussed how we no longer knew exactly what each other was doing. We might know generally what part of the product they were working on (through standups), but now had very little idea of how they implemented technical details. With standup time being the same (15 minutes) and the number of people who had to speak doubling, there was no way we could fit in extra discussion. We threw around having occasional code reviews, but anything that isn't regularly scheduled tends to fall by the wayside pretty quickly.

Our final solution was for the whole team to show up to our biweekly demo an hour early and go over what we changed on the projector. It's a perfect time to show completed code, do knowledge transfer AND prepare for the demo.

Wednesday, July 7, 2010

[RANDOM] More Chess!

I've been in a chess mood lately and been reading up on a lot of chess-related wikipedia articles.

For example, did you know that the "first-move advantage" in chess that goes to White has been debated for a long time whether it even exists? While the current prevalent idea is that against an equal opponent you should expect to win as White and draw as Black, this is far from universal and has been debated for a long time. If White does have an advantage, it only comes out to about 2 to 6% more won games.

Here's another link on cheating in chess, most of which is either getting help from outside sources (meeting them in the bathroom, sneaking looks at a handheld computer, etc.) or touching a piece and not moving it.

Another link on world records in chess. The "worst performance in simultaneous games" is pretty amusing, with Robert Wade losing 20 out of 30 games, including one to a seven-year-old.

Underpromotion (promoting a pawn to anything other than a queen) is very rare, but does occur in certain very specialized circumstances. It usually happens when promoting the pawn to a queen would result in a stalemate.

Antichess is a cool chess variant where both sides try to lose all their pieces first, and kings have no special powers (no "checking" occurs). Players must capture a piece if it is possible.

Some other clever chess variants exist. Chess boxing is alternating rounds of chess and real boxing, with victory possible via knockout or checkmate. Chess960 was created by Bobby Fischer that randomizes the back rank of pieces. There are other really cool variations that seem real fun to play too- for example, using different numbers of starting pieces or capturing rules.


Monday, June 28, 2010

[RANDOM]Kasparov vs. the World

Nifty chess game between one of the best players of all time against, well, the world. Garry Kasparov played against the entire internet. Anyone was able to suggest moves, and the move with a plurality was selected. Both sides had 24 hours to make their move.

The World team also had help from four great young chess players who suggested moves, and discussions occurred on a Microsoft sponsored online bulletin board.

Monday, May 3, 2010

[CODE] How to alias commands in unix shells

One of those annoying things that takes more time to look up than it really should.

Example:

alias s='cd ..'

is one of my favorites.

If you need to know more details, man alias.

Checkdisk, and why it's a pain

Checkdisk, also known as chkdsk, is a Windows tool that scans your hard drive and checks for, and attempts to fix, problems with it. Generally speaking it can only be run after you restart, since it requires exclusive access to the drive in question.

The main way people use tend to use chkdsk is to right click on the drive in Windows Explorer, go to Tools and then click the button for Error checking. This will schedule a chkdsk for the next time your computer starts.

The problem with this is what happens when something goes wrong. For example, my computer was suffering from freezes that I suspected were related to my accidentally pulling out the power cord when plugging my external hard drive (ironically to back up my stuff).

Upon restart, it performs a chkdsk. When that finishes after several hours, it blue screens. When it restarts, it does a chkdsk again.

See the problem? If a chkdsk isn't completed successfully the drive stays "dirty", indicating that a chkdsk should be run on the next startup. This continues only a chkdsk succesfully completes, which is likely to be never unless you do something about it.

This is why you should do chkdsk from a safe mode command prompt so that if something goes wrong, you don't get into an infinite loop of chkdsk.

I can't boot into safe mode with command prompt, but that's another problem...

You also can't cancel a chkdsk that's already in progress short of restarting. Ctrl-c doesn't work.