Friday, September 28, 2012

Running

Yesterday, I ran 1.7 miles in about 25 minutes. According to a co-worker, I should have a longer run on the weekend.  I will probably run about 3.5 or 4 miles tomorrow at around the same pace.

Thursday, September 27, 2012

So I've been starting to run to get back into shape.  My wife and I have been walking for a few weeks, and I decided I also wanted to run a little.  Looking around the internet, I came across an odd statement- "You should stretch only after running, and not before".  I was always taught to stretch before and after, but apparently studies suggest that stretching beforehand is more likely to cause an injury.

I have about another ten pounds to go until I reach my goal weight.  As for goal times, I still have a lot to do.  My first two runs were exactly 2.2 miles in 30 minutes, including 2 minutes for warming up and cooling down on the treadmill.  The only difference was that the second run included plenty of inclines.  The first run I couldn't handle the inclines, so I had to undo it when the treadmill inclined.  Also, my second run was right after a night of Mexican fajitas made by my darling wife.  Also another bad mistake to run after spicy food.

Friday, September 7, 2012

jQuery and Apache Velocity

Apache Velocity is a powerful tool which allows you to transform data into an output format via VM file.  It can be used to output HTML files, XML files, JSON objects, etc.  A common problem I run into is using the dollar sign in a VM file when we want to parse jQuery/javascript code.  There are multiple ways to alleviate this issue, but I find that replacing the dollar sign with 'jQuery' gets the job done.

In your .VM file:

     //Velocity doesn't like this dollar sign.
     $(document).ready(function() {
          //some code here
     });

Instead write one of these:

     //Skip using dollar sign completely
    jQuery(document).ready(function() {
          //some code here
     });

    //Tells Velocity to parse a dollar sign
    ${esc.d}(document).ready(function() {
          //some code here
     });

    //Tells Velocity not to even bother parsing
    //This option is for 1.7 and higher I believe
    #[[
    $(document).ready(function() {
          //some code here
     });
     ]]#

    //Altenative way of escaping the dollar sign
    //Try not to do this one


    \$(document).ready(function() {
          //some code here
     });

     
This issue is well documented, however you have to either read through all the responses to the question asked.  Instead, I simply provided a list of common solutions for this problem.  I've actually had problems with using the backslash with the dollar sign, so I would try to avoid that solution.

Good luck!