30 Jul 2009

Got suggestions on training regimes?

Yesterday I registered for the Blue Ridge Relay race in September and Charlotte’s Thunder Road marathon in December. Aside from the smaller 5k and 15k that I did earlier this year, these two will be the toughest physical challenges thus far.

The Blue Ridge Relay race is a 208-mile race that starts in Grayson State Park in Virginia and finishes in Asheville, North Carolina. It runs along the scenic (and hilly) Blue Ridge Mountains. The race starts at 7:30am on Friday, September 11 and goes until each team crosses the finish line 208 miles later. Time of day makes no difference in this race, with runners running through the night and into Saturday morning. Our team is comprised of six members and since there are 36 legs of this race, each runner gets six legs.

The Thunder Road marathon in December is a 26.2 mile race that runs through downtown Charlotte, North Carolina. Nothing super challenging about it aside from a few hills here and there and the cold weather, which I’m sure will at least add a little difficulty to the race, mainly because of gloves, tobogan, etc.

Crossing the finish line in both races are going to be extremely encouraging and satisfying, but there’s still a lot of training to do. In fact, official training begins on 11 August. Melissa, myself and her brother Kevin will be using Hal Higdon’s marathon training guide to train for the December marathon. The program is 18 weeks, but we’ll be modifying it a bit to prepare for the Blue Ridge Relay race which takes place in just under seven weeks.

It was suggested that we not only practice running at times we wouldn’t normally run, but that we combine a few runs on the weekends. During the Blue Ridge Relay race, we’ll run a leg, then take a break for five, then run another leg, and so on and so forth. So we’ll need to run 6 miles, break for an hour or so, then run another few miles, then break for an hour, then run again.

One idea I had for training regime is as follows. I’m very curious to hear feedback and suggestions from others, who thinks this is either crazy or not enough.

  • Monday, Tuesday and Wednesdsay, do the normal scheduled runs as per the guide.
  • Break on Thursday
  • On Fridays run 6 miles after work, break for 2 hours, run 4 miles with hills, break for 2 hours, then run 2 miles. I’m assuming these runs will stretch past midnight and into Saturday morning.
  • Saturday we’d run 8 miles, break for 2 hours, then run 4 miles and break for the rest of the day.
  • Finally, I think Sunday’s were set aside for cross-training, so we could resume normal training schedule but we should probably rest.

My only question is: Is this too much? Not enough? Or “just right but maybe do this instead”? Melissa and Kevin, what do you guys think?

Thanks to all who offer input in advance.

23 Jul 2009

Accessing the Joomla! framework from outside Joomla!

A while back we got a client that wanted their website redesigned in Joomla, a content management system based on components, modules, and plugins. Having never used Joomla before I was a little intimidated but ready for the challenge and eager to learn something new. Coding the templates was pretty straight-forward – write your HTML, drop in a few Joomla tags, and bam, you’re all set. Sorta anyways.

The client wanted a ton of customizations. “Can we have this? And this? Oh and this?” All the while nearing the boundaries of what Joomla is capable of. Don’t get me wrong, Joomla is a really powerful tool. The problem with Joomla is that you have to remain within the Joomla framework to access Joomla’s content and databases, limiting the number of external applications you can make that integrate with the system. That is, until today (for me at least).

I spent three months researching ways to gain access to the Joomla database from outside the Joomla framework. I read through countless forum threads for an iota of advice, only to find the thread dropping off after the tough question was posed. I decided rather than to search specifically for ways on accessing the database, I’d break it down into smaller chunks, such as, “how does joomla access database”. I broke the larger problem into smaller problems that would turn over more results.

Using these answers and my knowledge of PHP, I was able to finally figure out a way in. Since this was such a pain in the arse for me, I figured I’d share my research with anyone else who might be interested, or who might be curious as to how to do this.

In this case, our client wanted a queue for users who’ve submitted registrations for the members area. They wanted an application that would kind of hold registered users in an “in-between” place and choose when to accept or decline their memberships. In addition to this, they wanted specific emails to be sent to the registrants and to administrators with details… basically more stuff than Joomla would include. Plus, I always prefer to do things from scratch because I know exactly what each piece does and I enjoy having that detailed control. It’s cleaner and it keeps me sane. And I don’t have to go sifting through help files or tutorials trying to find out what John Doe did in his custom component.

In jest, here’s what I’ve done: Users arrive at the website and wish to access materials behind the members section. Without login credentials all they can do is register for an account. Said user fills out a fairly detailed form (including more information than Joomla would ask), and submits the form. Rather than storing the details for the user account in Joomlas database (and thereby creating a logged in user) it goes into a queue database and an email is sent to both the administrators and the registrant. The administrators can access a secure page, custom for this application, and see a tabled list of all those registrants in the queue. There, they can approve or decline the registration. Once approved, the application writes the information to Joomlas database tables and establishes a new user account. An email is sent to the new user and all is well.

First, you need to know PHP (obviously). Joomla is tightly knit together with many, many individual files that come together to form what’s called the framework. Take out one file and the whole thing ceases to function properly. Since I didn’t know Joomla that well, I opted not to write a custom component, module, or plugin, rather utilize the skills I do know and write a program from scratch. Regardless of whether you’d prefer to write a component for Joomla or a custom application, this should benefit you.

Secondly, you’ll need to know how Joomla access and stores data in its database. In our case, we’re creating users and, instead of using a single database table to store user information, it uses three. Why, I have no idea. Those three tables are:

jos_users
jos_core_acl_aro
jos_core_acl_groups_aro_map

Furthermore, if you don’t insert the information correctly, it won’t work. I discovered that you have to not only write to the tables in that order, but you must use elements from each to create entries on the next. I made a chart today to prevent a big headache.

Untitled-1
Chart illustrating the three Joomla user tables and how they’re connected.

As you can see, the ID from the new row on `jos_users` becomes the value on `jos_core_acl_aro`. You get the idea for the others. Keep in mind these fields are “auto-increment” so they’ll be generated automatically. Just make sure they match up.

Next up, the password. Joomla does some serious encryption and I’m not talking about standard md5 encryption, this system ensures your password is safe and secure. Check this out…

The function:

$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword("blabla", $salt);
$password = $crypt . ':' . $salt;

What does this mean? Well, in short…
1. User chooses a password of “blabla” (as an example).
2. Joomla generates a random string of 32 characters (asdf84rahsljdhf34jahdfhas97dfjah… or something similiar)…
3. Then proceeds to md5 hash the above string…
4. It then encrypts the user’s password (blabla) with md5 hash…
5. Then combines the two with a color colon in between.

What you get looks something like this:

758asefouahseo57asohefoas76e59aysp9r:984awozisjdfoiasjfdas8fdjw84jq38

How’s that for a password, eh?

Okay, back on topic. Once you get all of the user information collected and the password generated, you’re ready for your insert queries. Lucky you, I’ve written them all, so it’s just a matter of adapting what I’ve got to your code. Those of you familiar with PHP will know that words preceded by a $ are variables collected from the form you wrote which brings in the responses from the user. The PHP function “last_insert_id()” will return the last auto-incremented id from the previous insert. This is very important.


insert into `jos_users` (`id`,`name`,`username`,`email`,`password`,`usertype`,`block`,`sendEmail`,`gid`,`registerDate`,`lastvisitDate`) values (NULL,'$name','$username','$email','$insPassword','Registered','0','0','18','0000-00-00 00:00:00','0000-00-00 00:00:00')"


insert into `jos_core_acl_aro` values (NULL, 'users', last_insert_id(), 0, 'Registered', 0)


insert into `jos_core_acl_groups_aro_map` values (18, '', last_insert_id())

You’ll want to do some research as to what the specific variables are. In this case, I’m inserting normal lowest-level users. They are assigned “Registered” which corresponds with ‘18′ in the user groups table. “$isnPassword” is the salted password we generated above. Once you do all this correctly, you should have your new user appear in the Joomla User Manager tool.

22 Jul 2009

Run, run, run!

When my decision to run in the Blue Ridge Relay race this year became final, I knew there would be a lot of training involved, especially if I don’t want to let the team down. For those of you who think I run too much now, you just wait. But first, let’s go back in time to only two years ago when I first decided to take up this hobby. I was living in Columbia, SC and my boss at the time, Dean, was a big time runner. And I guess you could say that in addition to my need to quit gaming, he inspired me. So I bought my first pair of running shoes, Aisics Evolution IIs.

I was only running a mile or two at best at a time and I thought I was hot shit, haha. No, it’s okay to be proud, especially when I was at least making an effort to get outside and be active. Two miles miles nearly killed me (not literally, of course), but I also had encouragement coming from my – at the time – new friend Melissa, who’d “run with me” sometimes and provide that extra fuel. So I’d run twice a week, a mile or two each time. It was nice to earn the approval of my boss too, and it gave us other things to talk about besides LOST, Apple products, or intuitive and usable web design.

Dean would run every day at lunch in constant training for marathons. He was doing like one a month, something like that, but he’d run for miles and miles like a machine. Part of me felt a little discouraged because, here I was struggling to run a mile when he was cranking out mile after mile and always with a smile. But I knew that if I stayed with it, I too would be running mile after mile.

And looking back two years ago it’s nice to see how far I’ve come. Granted, I’m no marathoner (yet…) but I’m averaging 6 or 7 miles now, and more than twice a week too. I run 4 to 5 days a week with a longer run usually on the weekend. And, don’t get me wrong I still struggle, but looking back it’s such a sense of accomplishment seeing where I was before, and seeing where I am now. And I’ve got a long way to go, but when I start to get frustrated with myself for “only doing six miles,” it’s encouraging to know that six is better than one.

21 Jul 2009

Only 234.2 miles to go…

I’ve decided to run in the Blue Ridge Relay race this year and I’ve joined a team called Team 4tunate. The team is half veteran runners and half newbie runners, I being one of the newbies along with Kevin. They have been welcoming thus far and organized, which helps keep my mind calm especially when thoughts of this challenge loom only a few short months away.

The Blue Ridge Relay race is a 208-mile relay race from Grayson State Park in Virginia to Asheville, North Carolina following a moutainous course through the Blue Ridge mountains. The race spans two full days (September 11 and 12) and is sure to be breathtaking, no pun intended.

As said, there are six of us, each runner getting six legs. I get legs 6, 12, 18, 24, 30 and 36 with 36 being the big finish (pretty excited about that, actually) totalling 32.5 miles. Some legs are hard and some are easy. Luckily I think my overal mileage has a decrease in altitude, meaning despite the steep hills and gradual uphill slops, it’s mostly downhill. I only hope my knees don’t buckle as I try to maintain a requested 9-10 minute per mile pace.

I’m pretty excited. Nervous of course, especially since this will be one of the hardest physical challenges I’ve put myself through, but I’m excited. I’ve always said that with great challenges come great rewards and I can’t even imagine the happiness and sense of accomplishment I’ll feel when I cross that finish line 32.5 miles and 48 hours later.

A plus side to this race being in September is that it’s in the middle of marathon training. I’m running the Thunder Road marathon in Charlotte this December with Melissa. Following all this running and physical cruelty will be a nice trip to Hawaii for a week to visit my parents.

So let the training begin! Next item on my list: a new pair of shoes.

20 Jul 2009

Google vs. bing or Familiarity vs. Competition

A good friend of mine recently calmed my abhoration for Microsoft and/or bing, the new search engine from Microsoft that is a direct competitor to Google which we all know and love. What was a blatant and probably over-the-top hatred for bing, including but not limited to commercials, advertisements, and other assorted sightings, turned into an opinionated distaste based on personal preferences rather than emotional ones.

(Thank you)

I’m a fan of simplicity – less is more. If it’s not needed, it’s wasteful, so get rid of it. Maybe I’ve learned a tad too much from Jakob Nielsen and have taken a liking to stark, graphic-less layouts that allow nothing to compete with usability? Or maybe I just like to hate “the man”? Ever since I learned about Google I fell in love with the simplicity of it all, which is effectively and efficiently tailored simple, quick searches. After all, the act of searching is to accomplish one thing and one thing only: to search. Why then, must I have to look at all this other mumbo jumbo that does nothing but distracts me from my goal? This is what I thought when I saw bing for the first time.

Sure, the site looks pretty, but am I really going to be spending more than five seconds on the bing homepage? Not likely. If it’s not needed, get rid of it. My initial reaction was, “Search engines make a killing off of advertisements and paid listings… Microsoft just wants more money!” But I guess what matters more than the initial appearance of the search engine is how it lists its search results. I’d say, depending on what you search for, bing and Google are comparable, with bing having better presentation at times and Google having better presentation at other times.

The fact that bing was even created was beyond me. Why try to fix what’s not broken? The same thing goes with the next generation Zunes – Microsoft had an obvious fail with it when Apple controls the MP3 player market, yet they’re trying again. I’d sit and stress over things like the Zune and bing, but for what? I prefer Google and Apple, why do I care what they do?

Then we discussed competition and how it’s good that Microsoft came out with bing because it will keep Google on their toes and if Google is on their toes, it means better functionality, results presentations, and a better overall product for us users. So very true! And for those who wish to use bing, you can be sure Microsoft is trying hard to produce a product that’s better than Google. It’s really a win-win situation for everyone, but I didn’t realize that until this weekend.

But simply out of curiosity, for those of you who’ve used both, which do you prefer and why? And if results are equal, do you prefer the added visuals and graphics of bing, or the simplicity and “to-the-point” of Google?