Articles from the archive for 2008 (15 total)
Context Switching Layouts with the Zend Framework
Wed Jul 23, 2008 at 13.31
If you have not been hiding under a rock for the past few years, you realize that there are many different platforms and mediums to which a web site or application might wish to publish. The guys at Zend came up with a tool that can be used to facilitate multiple device view rendering in a semi-transparent way. This is known as Context Switching in the Zend Framework and is accomplished using the ContextSwitch Action Helper.
One hurdle I came across was figuring out a simple way to provide a consistent user experience through what is known as a two-stage view rendering. This is done using Zend_Layout. However, layouts written in standard XHTML won't really work well for our mobile platform, and likewise for XHTML-MP in a browser on a PC. Enter in context switching. First we are going to set up our context switching inside the index controller:
{
public function init()
{
$context = $this->_helper->getHelper('contextSwitch');
$context->addContext('mobile', array('suffix' => 'mobile'))
->setAutoDisableLayout(false)
->addActionContext('index', 'mobile')
->initContext();
}
public function indexAction()
{
//do something here, it's unimportant for this post
}
}
This will allow us to have a mobile view for urls such as http://example.com/index/index/format/mobile (NOTE: this should be prettier, but routing is outside the scope of this post). The key to take from this short code sample is the setAutoDisableLayout(false) bit.
Now, assuming we have created a view script called index.mobile.phtml we will now see the contents of the mobile view script dumped inside the default layout script. This isn't exactly what we wanted, believe it or not. Well, not really what we wanted but it's pretty close. We just need to tell the Layout manager that we want a contextual layout as well as a contextual view script. We do that using the layout helper:
{
$context = $this->_helper->getHelper('contextSwitch');
$context->addContext('mobile', array('suffix' => 'mobile'))
->setAutoDisableLayout(false)
->addActionContext('index', 'mobile')
->initContext();
$layout = $this->_helper->getHelper('layout');
$currentContext = $context->getCurrentContext();
if($currentContext)
{
$layout->setLayout($layout->getLayout() . "." . $currentContext);
}
}
After we have a new layout script called layout.mobile.phtml we should be good to go.
References
Zend Framework: ContextSwitch Action Helper
Zend Framework: Layout Configuration Options (see: getLayout())
- Tagged:
- technicalarticles
- php
- Zend Framework
jcarouth is M.I.A.
Thu Jul 10, 2008 at 20.20
I, like many bloggers in the blogosphere, have neglected my blog; if only I had a real reason for being so scarce. I suppose I could blame it on my new job, my girlfriend moving down here, and my being in a transitional phase of my life--you know, becoming an adult. Wihout further adieu, here are the happenings from the past month:
I started working at Texas A&M University in the Department of Research & Graduate Studies Systems Group. I am a programmer in a team of web application developers using PHP and Python. So far, I've been given some interesting projects and free reign to implement them using my choice of technologies/frameworks/methods. I've taken the opportunity to spend my time harnessing the power and flexibility of the Zend Framework. As of tomorrow, my first beta of a minor project will be released for testing by the department.
A friend of mine, Daniel Cousineau, introduced me to some automation tools that have revolutionized my development workflow: Phing and Xinc. Check out his blog post about how he implemented these tools in his environment. In using Xinc, I began to uncover some of its quirks and the desire to improve it took over me. I think that's the curse of being an application developer. I always think I know the best way an application should be implemented and how it should work. I could be wrong, but I'm the developer. After some banter around the Xinc Google group, I was selected to join the project. It's an honor and a privilige to work on this project.
Tonight was a meeting of the Bryan/College Station PHP Users Group. I didn't know this interest group was in existence, but thankfully I am a card-carrying member of the Agile development movement AgileBCS. Today we had a presentation on beginning steps with the Zend Framework and automating the workflow using Xinc and Phing (Daniel gave the presentation on Xinc as he is also a developer on the project). I'm happy to see the technological community growth in this area.
I'll be spending the next two weekends in Houston. Lisa has an appointment with her eye specialist on Friday, my older sister Cheryl's birthday is on Saturday, and next weekend my family from up north (Maryland) will be visiting.
Finally, I will be actually developing my new website soon. With the new experience I've had with the Zend Framework I am ready to build something fierce.
I should have some interesting technical articles soon.
- Tagged:
- college station
- hobbies
- life
With Continuous Integration, Who Needs a Manger?
Wed Jun 11, 2008 at 14.12
For anyone who is not familiar continuous integration (CI) is basically the practice designed to leverage automated testing and to continuously (usually daily, sometimes more) integrate changes from multiple developers using a build tool. To be successful and useful the code being integrated should be fairly well tested; meaning, something Martin Fowler refers to as "self testing code." However, one could undertake the practice and slowly introduce the comprehensive test suite as the days go by. (Notice I didn't leave any room for the lazy route of not having the test suite?).
The role played by the CI server is to on a set interval, in reaction to code updates, or on a combination thereof run a build process that incorporates testing to ensure the code checked in by each developer meshes with the overall project and does not violate the rules set forth in the unit tests. By doing this after each commit, the server verifies the stability of the code and basically stamps the product as "working". Does this remind you of what your manager is supposed to do? Is (s)he routinely (daily) checking on your and your colleagues progress and making sure everyone is on the same page? Does (s)he verify that your project is meeting the original goals of the project? Can he/she at any given time produce metrics to show the amount of code that is successfully passing tests, the amount of code that is untested, or the number of times checked-in code causes a problem in the build? Chances are, probably not. But with the help of this type of tool the answer will quickly become yes.
What I've found in my time working with (under) a CI server is I am constantly aware of what my development efforts produce. I know that once every two hours a daemon on my machine will run a script that checks my source control repository and compares the current working copy to the copy in version control. If the copy under version control is newer than the working copy the CI server runs a build script which runs the unit testing complete with a generated coverage report, runs a script to create documentation from code commenting, and copies the newly developed files to the development webserver where they can be viewed as if in the production environment. I know that I missed the mark and only have 83.0 percent of my code base covered by unit testing. I know that I've had 37 successful and 4 failed builds which shows me that 90% of the time the code I've checked in to the repository is well-tested. The other 10% of the time I must be in la-la land.
In various positions I've held meeting frequencies have varied from monthly to weekly, but never have I had the pleasure of a bi-hourly accountability like I do with my CI server. I say all this to tell you that not only is CI a great tool to help take care of some otherwise time-consuming and mundane tasks but it is also a wonderful driving force to create better development habits and more stable code.
- Tagged:
- technicalarticles
- php
Implement the Undo. Are you sure?
Tue Jun 10, 2008 at 06.52
In modern day application design there is _no_ excuse for implementing an archaic deletion functionality. Take notes on how deleting email in Gmail works. While Google's overall design--and here design means flashiness of the interface--may be lacking they definitely do not miss the mark in their application functionality design in terms of usability. If i were to delete 20 conversations from my Inbox I do not receive an "Are you sure you want to move these 20 conversations to the Trash?" message; the messages are moved into the trash and an unobtrusive yet visible yellow message box alerts me that "20 conversations have been moved to the Trash." and I am presented with the option of either a) learning more about the action or b) reversing the action I performed.
While I'm not saying that adding the functionality that allows a user to undo their previous action is a simple undertaking by any means, your users will praise your name by eliminating the obtrusive "Are you sure?" alerts or worse the complete accidental loss of data because neither the alert method nor the undo functionality are present. Over the course of time, unintentional delete actions will be performed. It's Murphy's law mixed in with a bit of Darwinian philosophy. People (read: users) will make mistakes. I've never made a mistake, but I hear it happens.
So take the few minutes, add the functionality, and gain a returning customer for years to come. I assure you there is nothing better than a happy customer. Or, rather, there is nothing worse than a disgruntled customer.
- Tagged:
- applicationdesign
- usability
Recognition is Sometimes the Best Reward
Tue May 06, 2008 at 10.19
The other day I was thinking about motivation. What motivates me? Probably in part because of my recent job interviewing and questions related to how I think, how I solve problems, how I plan things, etc but also just as a general thought. Why do I do the things I do?
I don't know when exactly it hit me, but I think that I am not alone. Motivation to me is recognition. One could easily attribute this to my ego, or narcissism, and I wouldn't really say you are wrong, but the truth is deep down everyone has an ego and everyone is at least partly a narcissist. Even if that isn't true, you can't prove it!
I came up with this conclusion yesterday when I received a ping (instant message) from a friend of mine. He entered a free photography contest and ended up in second place. If you have not seen his work before, Dan is a highly talented photographer. The thing that is most amazing is that he is completely self-taught. He has no formal training. Check out more of his work on his flickr photostream. Don't get me wrong, he definitely deserves the recognition and I am proud for him, but this is what made me think about myself and how I am motivated.
Since I am currently on a quest to build muscle, it's nice to see people I haven't seen for a few weeks. Generally their reaction is "Dude, you got bigger since last time I saw you!" That recognition is enough to validate the hours I spend in the gym, the sweat that pours from my body, the grunts, the strain, the pain. It makes it all worth it in that moment.
Now, I'm not alone. Think about the last time a female friend of yours got her haircut. When you told her, "Hey, I like your new haircut!" was she not glowing with elation? Ours is a world of validation, and I must say I enjoy the recognition as much as the next person.
- Tagged:
- life
Tri Phase Training: Phase 1 Week 1
Sat Apr 26, 2008 at 09.12
Tomorrow (Sunday) marks the end of my first of nine weeks in a training program created by Derek "Beast" Charlebois known as the Tri-Phase Training Program. This program is designed to promote muscle hypertrophy (i.e. bigger muscles) through three key training methods: volume, intensity, and frequency. For all of you math majors out there that computes to three weeks per phase for the total nine weeks on the program.
For the first phase the focus is on volume; meaning each week the volume of training increases. So, for example, if this week during chest day I complete 3 sets of 8 repetitions on the bench press, next week I should do 4 sets of 8 repetitions thus increasing my volume.
I won't bore you with the details of my numbers, but I will say that this program feels like it will work wonders. My main goals for the nine weeks include strengthening my weak areas (chest and shoulders), increasing the size of my arms (biceps, triceps, and forearms), and continuing my battle to decrease my percentage of body fat.
Here is a breakdown of what exercises I do on which days. One side note: because my shoulders are significantly underdeveloped when compared to the rest of my body I have changed this would-be 4 day split workout to a 4-day split plus one where the additional day is targeted exclusively at shoulder development.
Monday Back & Traps
Barbell Bent-over Rows
Lever Seated Rows
Seated Cable Rows
Lat Pulldowns
Barbell Shrugs
Dumbbell Shrugs
Tuesday Chest & Shoulders
Incline Dumbbell Press
Barbell Bench Press
Incline Dumbbell Flyes
Pec-dec Flyes
Freemotion Shoulder Press
Wednesday Shoulders
Smith Machine Military Press
Dumbbell Side Lateral Raises
Upright Rows
Dumbbell Front Raises
Dumbbell Shrugs
Smith Machine Behind-the-back Shrugs
Thrusday Legs (Upper and Lower)
Barbell Squats
Stiff Legged Deadlifts
Leg Press
Lying Hamstring Curls
Seated Calf Raises
Standing Calf Raises
Friday Arms
EZ-barbell Curls
Alternating Dumbbell Curls
Close-grip Bench Press
Lying Triceps Extensions (Skull Crushers)
Triceps Pushdown superset with Cable Curls
Barbell Forearm Curls
I also include 20-45 minutes of low-intensity cardio immediately following lifting.
For abdominal development I include two exercises at the conclusion of my regularly scheduled weight training Monday-Friday and do 3 sets per exercise up to muscle failure plus 10 repetitions. Saturday is my hardcore core day where I do an abdominal development routine including hyper extensions for the lower back (it's a major player in supporting heavy lifting you know?).
I am also slowly incorporating jogging/running into my daily life. I don't want to push myself too hard because excessive cardiovascular training will hinder my muscle progression which is not something I want to do at this time.
DJ Rob and OOB, whatever that means
Wed Feb 27, 2008 at 22.14
I saw a photo someone else had done some processing on and they termed it out of bounds (OOB). I'm not sure if this is the correct technical term, buzzword, or label for this type of processing, but I thought I'd try my hand at it using an image from my shoot with DJ Rob. I think as a basic proof of concept the end result isn't half-bad. It gives a real three-dimensional feel to the otherwise flat photo, or at least that's how I feel about it. What do you think?

DJ Rob Photo Shoot
Mon Feb 25, 2008 at 02.52
On Sunday I met with a College Station based DJ for a portrait session. The goal was to get some usable photos for his website as he is currently using a stock photo and some photos that he would like to replace. He is also looking at adding a gallery section so he needs shots. We met on campus to do a little work in Spence Park and on top of the Koldus parking structure around sunset to give us some interesting light to work with.
The first segment of the shoot was in the park on a bridge.




We then moved to the roof of the parking garage. (Side note: you cannot drive to the top of the garage without leasing a spot up there. At least they have elevators.)





All in all I am satisfied with the results. If I can remember, I'll update when the shots have been incorporated in his website.
- Tagged:
- photography
- hobbies
Wait, a Lamborghini Diablo?
Mon Feb 25, 2008 at 00.21
As soon as Carl mentioned he had a contact which could potentially produce a Lamborghini for us to shoot the organizing of our photo shoot began. After some "scheduling turmoil" we ended up having a few moments with the Lamborghini Diablo owned by a Texas A&M Aerospace Engineering professor. I conned my little sister, Becky, into volunteering to be our model for the shoot and at about 4:40pm the shooting began.
Here are the results...
- Tagged:
- photography
- hobbies
Ashley: Black Background and Cheesy Portraits
Thu Feb 14, 2008 at 14.06
Last night Michael Cummings, Ben Bailey, and I had a chance to arrange for Ashley to join us in Michael's photography studio located in historic downtown Bryan. This is the same girl that battled the cold forty degree wind on the roof of a parking garage on Texas A&M west campus. For nostalgia's sake here are two shots that I captured from our first meeting.
For more photos from that shoot check out Michael's photo set.
This time we put her in front of a black background and used a single Alien Bee 800 in a softbox as the light source. Here are the results of this segment of the shoot...
The setup for these shots more-or-less matches this shot. Michael added in the light you see on camera right fired into the umbrella.
I did learn that in choosing a background and lighting for a particular subject, it is very important to give consideration to the clothing they are wearing. For example, in this shoot Ashely is wearing black pants which disappear in several of the shots because the lack of separation from the background which, correct me if I am wrong, could have been provided with a rim light. I added that to my list of things to not forget for the next shoot.
I also learned that I should trust my instincts and use a reflector so that we don't lose her left eye in some of the poses. I do like the shadows, but I think the loss of the eye could be fixed without compromising all of the "drama" the shadows provide.
After the black background segment we headed into a different room and set up what I can only describe as cheesy senior-portrait-like photos where Ashley is laying on a white cloth. We were trying to blow out the background completely while maintaining the subject. I think I got close to the goal, but I do need a little work on the exposure. Here is what made it to the "final cut"
All said it was a productive shoot and I learned a little more about lighting in a studio and also worked on interaction with a model.
- Tagged:
- photography
- hobbies
Thank you Bots!
Tue Jan 29, 2008 at 12.54
Well bots, thanks for giving me a little something to do today.
Since I have been "working" on transitioning my own site to the Zend Framework I stopped development of the custom modules and what not of the current codebase. This led to the ability for the wonderful code that scours the internet to inject random urls to pron or viagra to post comments to my blog. Wonderful. Thanks.
At first I thought, "Eh, who cares, I'll be taking it down soon, anyway..." but considering I won't want to change my rock-solid database structure all that bad data will be a PITA come transition time. So I decided to add a simple question to the comment form to help deter the dumber bots form posting to my blog comments.
They might break it. If they do, I'll have something to do another day.
Yippee!
- Tagged:
- site updates
Twelve Weeks From Sunday
Sun Jan 13, 2008 at 10.21
Finally I have a goal; a motivation factor; a reason that I cannot make excuses. I will be running the Texas Marathon Half on April 06, 2008 in Dallas, TX. It should not be too difficult for me to complete the course tomorrow, but I want to complete the course competitively. Maybe that is the athlete in my speaking but considering this is an athletic event I think it is fine to listen to him.
Since I have twelve weeks for training, it only makes sense to follow a twelve week training schedule including two preparation races (the Armadillo Dash 2008 5K in College Station, TX and the Bayou City Classic 10K in Houston, TX) and significant amounts of time in the gym stretching and stengthening. After all, the core muscules become extremely important in distance running.
I am excited about this and welcome any supporting words of encouragement. Have a great Sunday!
My Studio: It VANISHED!
Tue Jan 08, 2008 at 00.49
My short lived portrait career is now seemingly at a close for the time being. After returning to College Station I put up a backdrop (really a maroon fleece blanket my mom made that is doubling as a slipcover for this god-awful chair in my lifing room) and began experimenting with lighting and such for portraits -- more specifically self portraits. However I have recently acquired a new roommate and she will be taking over the last room in my apartment meaning my studio will not get put together.
I do, however, have the plans to make some do-it-yourself studio equipment (background stand, light stands, and diffuser for lights) out of pvc pipe and some clamp on light fixtures which I will be diving into soon (note: posts to follow), but I'll just have to find a different place to put the stuff. I'll probably end up storing it when not in use in my rapidly retreating empty space in my closet.
Anyway, I leave you with the last photo taken in my studio before the background was taken down...
- Tagged:
- photography
- hobbies
- life
My Entrance Into the World of Photography
Sun Jan 06, 2008 at 11.31
Well, I've done it; I've gone out and bought myself a shiny new digital SLR camera. I decided on the entry level D40x from Nikon (yes Cannon fans, I said Nikon) and I currently have both the kit lens (18-55mm AF-S f/3.5-5.6G II) and a telephoto lens (55-200mm AF-S f/4-5.6G).
I received the camera via FedEX on December 24, 2007 and since then I have been shooting tons of photos learning the ins-and-outs of the menu system, as well as getting used to not using a point-and-shoot on "auto" mode. It will be a new experience for me, but it is something I really enjoy and hope to be able to shoot a few events for people in the future.
Currently, there is an extra room in my apartment that I have been using as a makeshift studio for self portraits. I'm going to be making some muslin backgrounds -- thanks to this article -- and then work on some studio technique.
The only problem I can foresee is subjects. I'll have to go find some willing "models" in college station that will help me get better at studio photography. I can probably make use of the studio in the ENDS department, but they have direct light which I don't know if I should be learning how to use at the moment.
Anyway, this post has been littered with photos that I've taken over the past few days. They are all hosted on my flickr photo stream, so check them out when you get a chance (clicking any of the images in the post will take you to that photo on my flickr account).
- Tagged:
- photography
- hobbies
- life
Bonfire: The Memorial - Two Thumbs Way UP
Sat Jan 05, 2008 at 02.03
If you ever venture into the great state of Texas and have opportunity to visit Aggieland (College Station) I highly recommend visiting the Bonfire Memorial. The design of the memorial is a bit abstract for any non-Aggie -- afterall, from the outside looking in you can't understand it, from the inside looking out you can't explain it -- but I will try to capture the essence of the memorial here.
Bonfire is a tradition dating back to 1907 but no longer burns on campus after the tradegy that took place on November 18, 1999. The stack, for the third time in it's history, collapsed killing eleven students and one former student and injuring twenty seven more. This would spell doom for a university-sanctioned bonfire.
In rememberance of the fallen Aggies a memorial has been constructed on the site where bonfire once burned. The very center of the memorial is the spot where center pole stood. The basic construction of the memorial is a ring -- a spirit ring -- to symbolize the unending spirit that unites all Aggies, past, present, and future. A "history walk" leads from the entrance of the memorial to the spirit ring and consists of 89 stones and 89 lights, each representing a year that bonfire burned on campus. The missing stone from 1909 to 1999 is for the year 1963 when President John F Kennedy was assasinated. Bonfire was built, but never burned out of respect for the late President. The spirit ring consists of 27 granite blocks connection 12 portals, representing an Aggie that was injured and a lost Aggie respectively. The blocks are left blank in rememberance of all Aggies that were injured over the 90 years that bonfire burned on campus. Inside the twelve portals, however, are carved into bronze the faces, names, and warm memories of the twelve fallen Aggies. From personal experience I can tell you that once you visit this memorial and read the twelve portals you will feel as if you knew each of the fallen and they will stay with you for the rest of your life. Standing in the portal you are said to be filling the hole in the spirit ring created by the missing Aggie. You can look from center pole through each portal and your line-of-sight will be directed at the hometown of the portal's respective person.
The designers and builders of this memorial did an excellent job. These twelve will never be forgotten.
- Tagged:
- photography
- texas a&m
- aggies
- college station

























