Wednesday, February 27, 2013

Java Programming

I've been working on a few little programming projects geared towards my new hobby of triathlons.  Sometimes I get spare time in-between projects and use this time to practice and improve my programming skills.

Note, all of these projects were created using Netbeans 7.1.  This means that to run any of these programs you will need to have the newest Java Runtime Environment (JRE).  Download it from Oracle's site.  If you feel a bit frisky, you can download the JDK or Netbeans, then ask me for the project files so that you can modify any of the programs for your unique needs.

RaceEvent

Google Drive location

The first item I created was a listing of races by regions.  I use www.runningintheusa.com alot to find races I want to do.  Mostly, running events are listed here but you can also find triathlons.  The issue I had with this site is that I wanted to see all races in my area but only for certain counties (e.g. Harris and Galveston).  The site didn't allow this way of selection.  That is the reason for this project I call RaceEvent.

Currently I have preset locations under Texas, but it could be modified uniquely for each user.
Here is the application at initial start up.


By default, the Starting Date is set to today's date and the Ending Date is left empty which signifies to use the last day of this year.  If you double click on either of these date fields, it will set to today's date.

Race Type can be any of the following:



Once you have your date(s) and race type selected, you can then select or multiselect the locations you would like to see races for.  Here I'm selected races that are only in Galveston and League City cities and anything in Harris county.
 


Pressing the Search button now will command the program to data mine the web site for races with your defined criteria.

You can now click on any of the Race Name active links in the main display window to view the web page for that race.  Note, displaying of these web pages might be better done in your native browser, as my application doesn't handle all HTML very well :-).

Note, once you click on a Race Name link, if a USATF map is found in association with that race (the race name, city, state need to be as found on usatf's database), then the USATF Map button in the upper right hand corner will become enabled.  Click on this button will bring up a new window where you can view all the images of the route submitted to usatf for certification.

You can press the Races button to return to the list of races from your last search.


BikeFitter

Google Drive location
Google Drive location of library needed (only jmf.jar is actually needed)

BikeFitter was my way of figuring out how to self bike fit myself on my Cervelo S1.  One of the issues with bike fitting is that you need to measure some angles while sitting on the bike.  This is difficult to do for a couple of reasons.  1) You need to have a tool that measures angles between two point (e.g. between the knee and the ankle).  2) You need to make these measurements while trying not to modify your sitting form.

BikeFitter is a basic program that allows the user to either snap pictures from within the app or open an already saved image.  Once the image is captured and opened, then using the mouse, the user can draw two sets of lines and BikeFitter will display the angle between these two lines.

Here is an image of BikeFitter with an image opened.


Note, the Webcam menu item is disabled because the computer I'm running BikeFitter on, doesn't have a webcam attached.


Now I can draw two lines to find angles.  Note, by default, the line color is Pink and the text color is Blue and the curve color is Blue.



Since the colors are a bit dim on this image, I can change the text to Green and the curve to Orange, and darkening the shades of the curve then right click the image to bring up a menu which allows me to clear all line and redraw the same lines.  More than one set of lines can be made at a time.


The user can rotate the image once.  Here I rotate the image 90 degrees.  Note, the current drawings stay on the image until the user right clicks the image to clear them all.

TriEstimate

Google Drive location
Google Drive location of parsed race files
Google Drive location of library needed (everything but jmf.jar is needed)
Note: directory structure needs to be as follows.
  • triestimate.jar (any location, for example your Desktop)
  • lib/jcommon-1.0.17.jar (in lib folder; lib/ is located at same level as triestimate.jar)
  • lib/jfreechart-1.0.14.jar (in same lib folder as above)
  • triestimate/Races/* (all race files in Races/ folder which is in triestimate/ folder; triestimate/ is located at same level as triestimate.jar)

TriEstimate was create to help me determine what time I should expect to complete any triathlon distance.  I was looking for a good app on the iPhone, and at the time there was none.  I decided that this is a fairly easy task to get the distances for the race, then the known pace from the user in swimming, biking and running.  Then I try to factor in the other little variables, such as choppy waves, wearing a wetsuit, pool swim over open water, etc.

As I had more and more time to spend, I added additional functionality.  One was to have the ability to not only determine the predicted finish time, but to then see where that would place me in a given race (if that race's results are available in this tool).

Since I was getting race result data for this tool, I created a python extraction tool to make data mining race results much more convenient.

On start up, here is TriEstimate.
And here are the other tabs (T1, Bike, T2, Run and Place).
Once the user enters all their information in Swim, T1, Bike, T2 and Run, they can then go to the Place tab and select a Race and an Age Group then press the Place Me button.
As you can see from the image above, I would place 309 Overall (which is in the 83.06% of all racers).  I would place 34th place in the M40_44 Age Group (which is in the top 89.47% of this age group).

Another additional feature I have added, is the ability to view the race data and to do searches within each race file (e.g. if you want to search for your times) or to search for a keyword in all the race files.  This allows the user to find all of his/her race times.  Note, the keyword entered can be a regular expression pattern.  This allows a more powerful search option.  So if I wanted to search for "O'Neal" and some races have it spelled as "ONeal" and some as "O'Neal" and others as "O Neal", then I can use regular expression to search for "O'?Neal"; without the quotes.  This says the " ' " is optional ? (0 or 1 occurrences).

Here is the search results for "O'?Neal".  Note, I only have certain race data available.  More can become available as time permits.
Or a search can be done on an individual race.  When this is done, the tool will highlight the first occurrence of the keyword and the title will show you how many matches were found (in this case only 1).

In addition, graphs of the race data can be viewed by selecting a race and pressing the Graph button.  Within the graph window, selection can be made for the Average Finish Time, Average Swim Time, Average Bike Time, Average Run Time per age group.
 

The last new functionality I added was the ability to have the user enter their own configuration values.  In this application I had to determine what it meant (with respect to time) to have rough or very rough waters, or to wear a wetsuit, or to have head winds, or positive elevation.  This was mostly a guess.  So I added a new window to allow all these values to be modified.

Redmond, WA

Note: This was written in March of 2009.  I found it sitting in the drafts folder and decided to send it out.

I arrived in Seattle,Wa yesterday after a 3 hour flight. I was lucky enough to have my company send me out to Redmond to work with my team in person. I have been working on this team for about 5 months and never seen them in person. It is nice to put a face to those voices.

Our work site is surrounded by the Microsft campus. Actually, I have been told that they will take over the remainder of the buildings in the near future.

It is Saint Patrick's day and my co-workers didn't seem to want to go out. I'm still a bit under the weather anyway; who knows..I might find a pub anyway.

Oh, did I forget to mention, this area is full of old white people. I feel like an ambassador for the southern population :-)

Wednesday, September 22, 2010

OMG, this blog is dusty


I haven't written in here in a long time. Since that time, I have moved to Houston, worked on two different projects with my company, and dated a couple of different girls (not at the same time :-) ). I also renounced my love for riding bicycles again with my Cervelo road bike.


I'm also fixing up my mountain bike and riding that more. I'm also trying to run more. My goal is to compete in a triathlon, which means that I will need to work on swimming too.

I'm signed up for a duathlon (run->bike->run) on my birthday 10-10-10. I'm excited about it; transitions! I'll try to post some images from that if I get a chance to take some.

Oh, and if you want to donate to a good cause, tax deductible, then please follow this link.

Wednesday, August 19, 2009

High school 20 year reunion trip




I received notice from my mother that my high school class reunion was about to occur. The reunion committee sent the notice to her house; I'm not even sure how they got her address.

I talked with my girlfriend about this and we decided to make a trip out of it. It was very last minute and I knew this would be a tough test on our relationship. BTW, did I mention that we were going to drive the 1100 miles (each way)?

We started off on Wednesday night (August 6th) after I got out of work. We made it to Las Cruces, NM were we stayed the night at my aunt and uncle's house. This is the first time for my girlfriend to meet any member of my family. My aunt wouldn't let us go to sleep till about 2am! We woke up that morning around 8am, had breakfast and took off for San Antonio, TX. We made it to SA around 4pm and checked into the Red Roof Express near downtown. This hotel was nice at a great price. The parking was plentiful and free and the Internet was also free (you needed to get a connection card to enter a daily access code). We were only about 1 block away from the Riverwalk mall and thus the Riverwalk itself.

On Thursday night, we walked the Riverwalk and ate at Cafe Ole. We had a huge plate of chicken and steak fajitas and my gf got a margarita. The margarita was awesome. We had to order another glass 'cause we downed it so quickly. After dinner, we were both so full that I thought I was going to pass out into the Riverwalk!

Friday we spent some time at the mall. I forgot to pack t-shirts and it is so humid and hot that I was kicking myself for not bringing any loose and light shirts. I bought two shirts that were on sale and one which is now one of my new favorite shirts. When we asked the sales man about the size, he mentioned that the med would be too small for me and I should get a large. He was an Asian, gayish man...and it was just funny how he said. My gf was trying to get me to buy the shirts too small so that I would end up giving them to her.


We decided to go visit Shamoo at Sea World. We spent most of the day at the park and had a bit of an issue. I wanted to ride a roller coaster that was kinda rough, but my gf decided to "just say no!". I didn't want to wait in line and ride this coaster on my own, so I was a little disappointed. When we got back to our hotel, we decided to get more margaritas at the Cafe Ole restaurant. It was ugly! We ended up not talking, arguing and just ignoring one another. When we decided to leave, I let her guide us back (remember, we are only about 1 block away from our hotel). We ended up in the worst part of the ghetto! I joked that we started seeing dead people, which just were the homeless people sleeping on the streets. But after a bit more walking, the "dead" people were no longer in sight (this was not good). We stop at a crossing which was a feed to the freeway. We waited for about 25 minutes before my gf realized that you had to press the cross button to get the cross signal to come up. REALLY? Finally a glimmer of hope. I can finally see the glowing sign of our Red Roof hotel, but we had to first cross the darkest part of the ghetto area that only had a single bar (Krazy's, I think was the name) lighting up part of an intersection.

We made it alive!

Saturday morning, we made up with the usually couples make-up routine and tried to leave for Houston. I did say "tried". My truck had a metal pin stuck in the rear right tire. I changed it in the parking garage and spent the next 5 hours trying to find a Discount Tire to replace it!!! After a long wait and $125, I had a cheap, no white label, tire mounted. Now we are really off to Houston...really.

About 2 of driving we made it to downtown Houston. The Double Tree hotel was very close by to our off ramp and the valet was impressive. We checked and and got our warm cookies. The room was "swanky" nice. The view was from the 14th floor and just as nice. We started off by working out at the hotel's gym, which was small but nice. After about 1.5 hours at the gym we got ready for the reunion party. The room was kinda small, everyone was talking to everyone and I felt a bit uncomfortable. We immediately met up with someone who called out my name. It was Steve, someone how used to work at Taco Bell with my older sister. I was a bit surprised that he was at my reunion, since I thought he graduated before me. We then got some finger foods and met some other of my old class mates (JJ, Brian, ??). We walked outside the room and we talked on our own for a bit. I ended up telling my gf about some of my dark secrets from my past. I'm not too sure this was the best thing for me to do. It ended up back firing on me during our drive back. More about that later.

We decided to leave the reunion party and walk around downtown. As we were leaving, I heard someone call out my name. It was Jeff from my class. He and his gf went outside with us to just talk. This was probably the most memorable moments of the entire trip. I learned so much about Jeff and his past. Even though Jeff and I didn't spend a lot of time together during our High School years, I spent the most time with him during this reunion.

After our talk, my gf and I decided to do that walk downtown. We found the "hot spot" and stepped into an Irish Pub and had a drink. Walking back to our hotel we ran into a lot of tall, beautiful women. We both enjoyed this walk back.

Sunday morning and now for the long ride back. We tried finally found a place to get breakfast and my gf took over the driving. OMG, this was a nice change. I really enjoyed watching the Seinfeld episodes and just dozing off. We had two arguments dealing with lack of trust on my gf's side. I tried to convince her that there was nothing going on but it just wasn't enough. This sucks. We got home around 10pm and I asked her to not spend the night at my place and for her to go home. Let the drama begin. Needless to say, it went over badly. She finally went home and we didn't speak for about a week.

I text'ed my ex-gf and told her we can still be friends and that she owed me 1/2 the cost of the hotels. She finally responded with an email that just flamed me to hell. She mentioned that she wasn't going to pay me the agreed upon hotel cost because she cooked for me in the past. Huh? I'm not playing these childish games. I guess I learned a $150 lesson.

We finally made up and now whenever she talks about this trip, she says "it wasn't that bad". I'm starting to wonder if we were both on the same trip.