Calendar Date Select in Ruby on Rails 2.3.5

Calendar Date Select is an excellent date picker for Ruby on Rails.  I didn’t create or figure out any of the following.  This is merely a combination/re-blogging of various other posts, including instructions from the calendar date select home page

  1. Get the gem of calendar date select: ‘gem install calendar_date_select’
  2. Update your project’s environment.rb to include the calendar_date_select gem: ‘config.gem “calendar_date_select” ‘
  3. Unpack the gems to your project.  This is not required but it makes life easier: ‘rake gems:unpack’
  4. Start your server and navigate to your home page to make sure everything is working.
  5. The version in the gem has a line that needs to be updated for Rails 2.3.5.  If you get the error calendar_date_select undefined method `calendar_date_select_includes’ when you start the server and navigate the site you need to update the calendar_date_select file.
    1. Go to project_root\vendor\gems\calendar_date_select-1.16.1\lib and update line 5 of calendar_date_select.rb.
    2. Before Change: if Object.const_defined?(:Rails) && + “/public”)
    3. After Change: if Object.const_defined?(:Rails) &&
    4. Thanks for this suggestion goes to this guy
  6. In your layout or page add references to the default javascript files and the calendar date select files
    1. Put this one first: <%= javascript_include_tag :defaults %>
    2. <%= calendar_date_select_includes “silver” %>
  7. Check out the calendar_date_select demo page for examples and code snippets.
  8. Another excellent blog post reference from the calendar date select home page

Installing Ruby on Rails and Heroku for Windows XP


The following is intended to be a complete guide for getting up and running on Ruby on Rails, Heroku, git and the other supporting players on Windows XP.  I wrote this guide because I was excited about Heroku but I could not get it to work.  I started in a virtual machine running ubuntu but couldn’t get the gems to work.  Then I tried cygwin and that didn’t work.  Finally I found a couple of key posts that solved the windows install.  The following is not of my own technical expertise.  It is merely a compilation of what was found via some Google searches and the results of my trials and errors.

Click here to open the overview

Wild hair up my….

Two posts in one day, oh you lucky readers.  This one is really more of a rant on Java Enterprise.  I think I’ve said this before but here it is again: JAVA ENTERPISE/J2EE IS NOT FOR BEGINNERS.  It isn’t even for beginning programmers.  The complexity of the Java Enterprise software suite is absolutely mind-boggling.

I’ve just started as a brand-spanking new developer at my employer and I was blown away by how complex our application was.  I thought I understood MVC frameworks and how Java Enterprise interacted with them but I didn’t.  As a quick sample here are three design patterns that we use:

  1. Struts where form actions from the .jsp pages are tied to the java Command classes using an XML page.  The data from the .jsp page populates a Value Object (VO).
  2. Then the Command class calls a Delegate which calls a Session Bean which calls a Business Object (BO).  The business logic is mostly located in the BO but some of it is sprinkled into the Session Bean.  Once the BO gets through with validating the data from the VO.
  3. The BO then calls the DAO to persist the data to our database

I’m seriously not trying to make this sound complex, that is as easy as I can write it.  This is my favorite: Command -> Delegate -> Session Bean -> BO -> DAO.  5 classes!

Please understand; I’m not bashing our setup.  I’ve been in the work force long enough to know that when you encounter, what appears to be, overly complicated processes/designs there were very good reasons and a bunch of really smart people behind the design and implementation. And just like the old mainframe world, due to the cost of changing, many of us new programmers are going to have to learn the existing code so we can remain gainfully employed

The amazing thing is how early in the evolution of software we really are. It’s encouraging to see guys like Adam Bien writing really great posts about how to use EJB 3.0 and Java5/6 to greatly simplify your code.  Java Enterprise is not that far removed from Cobol, which is not that far removed from punch card stacks.  It feels like quantum leaps because each one is so much better than it’s predecessor.

We are still mostly at the mercy of the computer’s native tongue when it comes to writing software.  The next twenty years will be very exciting as new languages and hardware are created so that we can get the computer to start understanding our language for a change.

public class StoreFormData {

Take first name, last name, and address;

Store them in a place where I can retrieve them later;

Please make sure the zip code, city, and state are valid with each other;

And one more thing, please make sure it is a valid phone number;

And if anybody else needs this data while I’m using it, don’t let them have it until I’m done;



That’s what user friendly software looks like 🙂

Entrepreneur thoughts – Albom Column

It’s been a long time since my last post.  It’s funny, right about the time I want to start posting every day, I end up not posting for over two months.  I started my third Java class and transferred over to a new position at work as a developer so needless to say, it has been a busy Fall.

Mitch Albom inspired me to write today.  His column today about fame was excellent and it pertains to business and entrepreneurship as well.  The best part of the column is when he states “Didn’t you once have to DO something to become famous? Now being famous IS doing something. The most important currency in this country is not measured on green paper. It’s measured by how many people point at you and say, “Aren’t you …?””

To me this is almost the same thing as Twitter and Facebook and their ilk being considered businesses.  The comment could easily be re-written to say: “Didn’t you once have to make money to be considered a business?  Now having “customers” is being in business.  The most important currency in this country is not measured on gree paper.  It’s measured by how many people point at your website and say, “I’m with them…””

The whole premise of their business is to attract more customers.  Just like Albom’s column where the whole premise of Fame is to be seen by people, not necessarily to have any talent, skill, or other exceptional quality.  They don’t make money (enough to justify their valuations), nor do they have any concrete plans to make money.  Yet the fact that they have tons of users makes them “Famous”, which in this sense means that they are great businesses which attract millions of dollars in investments.

At the core of these businesses is a single person that was in possession of one key element: TIME.  Evan Williams sold Pyra Labs (Blogger) to Google for enough money to buy him all the time in the world.  With that time he created Twitter.  Mark Zuckerberg was a student at Harvard when he created Facebook, with enough free time on his hands to create a cool app for his friends to stay in touch with one another.  In both of these cases, and many others, the founder was wealthy with either time, or enough money to buy time.  Take a look at the stories in Inc. magazine once.  Most of the founder stories are about people that were successful before they were successful.

Back to the Albom point: With time, and in most cases money, the business doesn’t need to make money.  The founder is just fine with banging away on it until something better comes along or until enough people find his cool time-killer.  This is a sobering fact for a lot of us wanna-be entrepreneurs with day jobs and families.  Time is something we don’t have.

It’s not too late

The Inc 500 arrived in the mail a couple of weeks ago and here is the most interesting fact: 72% of the CEOs are over 35 years old.  In the world of Zuckerberg (Facebook), Williams (Twitter), Rose (Digg), and every other famous Harvard drop out it’s easy to get the feeling that you need to start a business in college or shortly thereafter in order to be successful.

In reality most successful entrepreneurs don’t get that way until after the age of 35.  Granted there are usually early signs, perhaps a few failed ventures prior to that age.  But the key is that you don’t need to be a wunderkind to start a successful business.

It’s not an  earth-shattering revelation, but it’s re-assuring to those of us that are already beyond 30 and feared that our entrepreneurial chance had already passed us by.  Another intriguing stat: 80% of the CEOs are married.  Also good news to those of us with competing priorities in our lives.

Macro De-Duplication of data

I thought I would use some buzz words in the title to get everybody excited. I’m not referring to removing duplicate records in databases and tables. I’m referring to an overall strategy where application developers should be looking to reduce the amount of data that is stored in their databases in context of the entire Web. Through the use of web services and a some other cool new technologies we should be looking to connect to external sources to retrieve data as it is needed. Web-wide data warehouses are sparsely available right now but they are coming online.  For example do you really need to store a person’s address if you can go to the address source to get their latest address every time?

Yes, there are hurdles (speed and reliability) but with every passing year these these hurdles get lower and lower. But there are also huge benefits such as access to the most up to date information. Corporations are already leveraging Web Services to communicate between their vast number of internal applications. Many coporations are going to SOA (Service Orientated Architecture) platforms across their business. Independent developers/web designers need to start thinking the same way. The maturation of the Internet relives us from having to store non-proprietary/non-mission critical data in a “local” database.

JavaEE and why Sun is too smart for normal people

I’m starting to feel more comfortable with the definition of JavaEE (formerly J2EE).  Other overviews of JavaEE have been severly lacking for beginners. I consider myself somewhat astute, but when looking at pages such as this one and this one, my eyes start to glaze over by about the 3rd paragraph.  I cannot follow it at all.  If you are used to the Internet and downloading files, you are accustomed to seeing xxxxxx.exe files or files.  But with Java you get things like ‘download spec’.  What the hell is a spec?  How am I going to create programs using a spec?

I don’t mean to rail on Sun but their stuff seems to be written by developers, for developers.  Have you ever tried one of their tutorials? If you don’t have previous experience with JavaEE, I dare you to try one and make it work. Go ahead… I’ll wait… The same goes for programming books. I have a rant all saved up programming books that I’ll post some time. I don’t like programming books.  Give me a nice shiny textbook any day of the week.

With that said Sun’s documentation and information starts to make a heck of a lot more sense once you’ve had exposure through some other means. But that doesn’t change the fact that it sucks for beginners.  For instance a sentence like this from Sun: “(Java EE) is a set of coordinated technologies” is fairly simple… once you understand the Alphabet soup that comprises those coordinated technologies.  JSP, EJB, JDBC, POJO (only in the new version), and JAX-WS are completely cryptic when read in a sentence together. Throw it together with JSF, Hibernate, Maven, Ant, Swing, and all of their competitors and you quickly discover that JavaEE is not for beginners.

Here is what I think I know now that I’m getting into this:

Ant: Command line build tool.  It offers a way for you to specify your src files, target build path, classpaths, test utilities (such as jUnit), logging utilities (such as log4j) among myriad other things I’m sure.  Using the file and build.xml file you can specify all of these things such that you can run a simple ‘ant package’, or ‘ant test’ command from the command line to create thousands of files that comprise your final application AND run test scrips at the same time.  Great stuff once you get familiar with it. Key files: and build.xml both of which reside in your project base directory

Maven: To me this seems like Ant. I don’t understand Maven very well yet, although I’m using it within Eclipse.  I know that if you use Maven, you may not need Ant and vice versa.  Key files: pom.xml which is stored in your base project directory, but can be stored at lower levels in your program if necessary.  And settings.xml which is stored in .m2 directory in your Home directory (C:\Documents and Settings\Michael Hoitomt\.m2 for me on Windows).

JDBC: Used to connect to your database.  It is easier to use if you set up some properties for it either in your Build.xml file (Ant) or pom.xml file (Maven). The build tool (Ant/Maven) does a lot of the heavy lifting.  Database scripts (ddl files, data definition language, files that contain SQL scripts) are mapped in the configuration file (build.xml or pom.xml). Additionally database properties such as location, username, and password are mapped in the configuration file. Upon building your application Java/Ant or Java/Maven will use the configuration file to execute the database scripts and allow your program to pull and push data in and out of the database without having to specify all of the settings in each of your classes.

That’s where I’m at so far.  In one of the upcoming posts I will start talking about end to end application flow and how JavaEE makes it easier.

What is a classpath and why do I care?

When starting out in Java one of the things that confused me the most, and coincidentally is one of the primary strengths of Java, is the concept of a classpath and libraries (.jar files). I want to take some time to go over both of them and hopefully simplify it.

When starting out in Java you will end up doing a lot of work from the command line, in Windows it is your C:\ prompt.  I know, you thought you’d never use it again once Microsoft put a nice GUI on MS-DOS. From the command line you will run commands like ‘javac’ and ‘java’ over and over again to compile and run your programs.  Unfortunately Windows does not natively recognize these commands.  Therefore you have to tell Windows how to recognize them.

That’s where our Path comes in, the close cousin of the classpath.  In Windows you can view your Path by going to Start/My Computer/(right-click) on My Computer/properties/Advanced tab/Environment Variables.  You’ll see an entry in the System variables called ‘PATH’  When installing Java, you need to put the path to your jdk_xx_xx_xx.xxxx/bin directory into your PATH so that Windows knows where to look for your java commands (java, javac, etc…).  My Windows PATH looks like this where JAVA_HOME has been defined as C:\Program Files\Java\jdk1.6.0_11.

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;%MAVEN_HOME%\bin;%ANT_HOME%\bin

After installation you will mostly modify your application classpath you work in Java. Think of your CLASSPATH as a toolbox.  If you are going to build a shelf you need a saw, measuring tape, nails, and a hammer.  These are the tools required for the job.  When you sit down to build the shelf you can’t just sit down anywhere and start building.  You need to make sure your toolbox is with you and that it includes your saw, measuring tape, nails, and hammer.

This is the same thing as your CLASSPATH. Java includes some basic tools, such as the java.util class, class, and a few others.  Think of these classes as your basic tools: hammer, screwdriver, and saw.  It is difficult to do any projects without a saw, hammer, or screwdriver and the same goes for Java. Therefore Java includes some of necessary tools in your toolbox and it makes sure you always have your toolbox.  You still need import statements but you don’t need to modify your CLASSPATH.

However, if you are going to finish your new shelf you will need some sandpaper, stain, varnish, and some rags.  Therefore you need to go to Home Depot and buy some materials and put them into your toolbox. Think of the Internet as Home Depot.  And think of sandpaper, stain, varnish, and rags as .jar files.  .jar is not a jelly jar, not a honey jar, and definitely not Jar Jar Binks.  .jar stands for Java Archive and is a collection of classes that perform a specific function.

Let’s say you want to use jUnit to perform some testing when your java program compiles, like Part A of the Johns Hopkins example. You need to work with the jUnit API (Application Programming Interface).  To do this with Java you add import statements at the beginning of your class so that Java knows to look for some additional tools. Once you import the classes from the API, then you can use the objects and methods described by them.

However, when you compile your program, the Java compiler has no idea where to find the classes described by the import statements.  This leads to an error something like: package junit.framework does not exist.  (Which leads you to say something like: “&#!&&, I just downloaded it and put it in the directory, what do you mean it doesn’t exist!”).  You have to tell the compiler where to look by specifying your CLASSPATH when compiling.  There are two ways to do this:

  1. You do this by adding the -classpath parameter along with the path to the necessary .jar file to your javac command (something like:  javac -classpath c:/jhu/repository/junit/junit/3.8.1/junit-3.8.1.jar
  2. You can add the path to the .jar file to your Windows CLASSPATH variable (found in the same place as the Path variable).  This is not a good idea as you start doing Web programming.  You will most likely not have access to your application server’s classpath so it is a good idea to get used to option 1

You will run into this over and over again in Java.  The reason Java has so much power and flexibility is directly related to the ability to import various .jar files (APIs) to add power and functionality to your application.  Programs like Maven and Ant help out considerably with compiling and running programs. They automate option 1 above so that you don’t have to specify a lengthy classpath every time you run your application. Even more helpful still are IDE’s like Eclipse and Netbeans.  They will help facilitate the building of your classpath so that it is almost invisible to you. Even if you are starting with an IDE it is a good idea to understand what is happening “under the hood” of these programs.

Environment Setup – Progress and Comments

I’m working through the First Sample Application from the Johns Hopkins Enterprise Java class that I referenced earlier. I got the development environment setup by following the excellent guide put together by the professor of the course, Jim Stafford. Everything worked great with very few issues. Once again if you’ve fumbled around the web looking for a decent overview of a Java Enterprise environment this site is a utopia.

One of the things I like about University course work is that it builds on itself.  Class 3 builds on Classes 1 and 2.  That is exactly the way this guide is written.  If you have a foundation in Java where you have a basic understanding of inheritance and packages, you’ll be able to follow along and troubleshoot your issues. A couple of comments from the setup guide.

  • If you are on Windows, you don’t need to install cygwin, just as Stafford notes.  However, be aware that you need to set your file paths correctly.  Unix uses ‘/’ as the directory separator.  Windows uses ‘\’.
  • Another gotcha between Windows and Unix: Windows uses %PATH_VAR% whereas Unix uses $PATH_VAR.  I think the environment setup covers this pretty well, I don’t recall any problems there.  But keep it in mind for Exercise One
  • The revisions of the software in the guide are older than the current revs of the software.  However I recommend sticking with the Revisions that he specifies.  I had some trouble when I tried to use the latest version of JBoss.

I’m not all the way through Exercise 1 but here is what I’ve found so far

  • Part A went pretty smoothly. Part B I had to adjust the path in to reflect Windows.  (“M2_REPO=C:\\jhu\\repository” and the subsequent paths)  You need to “escape” slashes ‘\’, that’s why you use the double \
  • In Part C the ‘ant test’ command wasn’t finding my ‘log4j.xml’ file so I had to move it out of my ex1\src\test\resources directory into ex1.  For some reason the resources directory was not being picked up by my classpath designation.  After moving the file the logging worked. Cool stuff by the way

Hopefully I’ll get through the rest of Exercise 1 this weekend and can get started connecting to my database using JDBC.

If the links above don’t work, check out the archive site for the Fall 2008 course

The Intersection

Mark Cuban wrote a couple of really good blog posts about media and the internet here and here.  His argument boils down to this: If the sole purpose of your website is to bring in ad revenue, you’re not going to last.  In other words: giving away content for free, drawing visitors, and making money solely off of  ads on your site is not a long-term business model.  Specifically he is referring to large media conglomerates such as Newscorp (Fox) and the NY Times with huge brands that offer different types of media

This brings up a good point about web-based businesses all together.  You aren’t going to make money just because you know the Internet and how to create websites.  We are exiting a 15 year period since the early 1990’s where Internet knowledge (knowing how to build websites) was all you needed to start a little company and do it professionally. You could be mostly dumb to the business for whom you built the website.

Internet knowledge is becoming a commodity. Now the Internet is more of a tool, than an end result, to be used by those who know business. It is like a hammer.  Just because you can hammer a nail doesn’t mean you can build a house.  Just because you can build websites, doesn’t mean you can run a business.  However, The inverse is also true: it is difficult to build a house unless you know how to use a hammer.  Just like it is difficult to build a business unless you know how to use the internet

More and more people are learning how the use the tools (the Internet). Just like more and more programmers are learning the business. You need to have these skills to keep up.  Even if you think you are in a position/career track where you will never cross paths with the Internet.  I can almost guarantee you that you will cross paths with somebody who knows the Internet.  And that person will beat you in a competition based on their knowledge.  Knowing the tool is a competitive advantage.

That is why I’m learning this stuff (programming) and putting the information out there to help you learn it too. We need the tools so we can fully apply our business knowledge. I guarantee you there are better programmers than Bill Gates.  But there are few if any better businessmen/technicians.  Now and in the future, those who master the intersection of business and technology will be the ones that are calling the shots