Skip to content


Streamlined Web Development: In-Depth

Note: This is a work in progress. I will finish the rest after the presentation. I just wanted to publish the post to link to. If you have any questions, please post them below I will try to answer them as fast as I can. I probably won’t have time to finish this until Sunday, due to several critical projects that are due ASAP.

This in the “In-Depth” part of my presentation on “Streamling Web Development with SVN & Trac.” I can’t possibly cover all the aspects of this topic. I like to post a “in-depth” article right after my presentation with links, tutorials, and all my resources used for the presentation. This allows for me to spend more time on questions & answers. I’d appreciate any feedback on the presentation, and if you have any questions feel free to ask. This article is an extension to the presentation, so I suggest listening to the presentation first if it seems like there are any pieces missing.

Presentation

Here is the Scribd version of my Presentation. Since it didn’t like some of the things I used in the presentation, I uploaded a pdf version as well.

UPHPU - Streamlined Web Development

Overview

As a web developer, I like to spend the most time possible on adding improvements, making changes, and ensuring quality. What I don’t like spending time on is repetitive tasks trying to manage the project. Over the last few years, I’ve been trying to focus on “automating” the processes of web development, letting programs, scripts, and othe technologies keep me focused on real development. I’ve pooled together all the information I’ve found on the subject, and hopefully I can help anyone searching for more information. Continued…

Posted in General, Programming, Technology, Web Design.

Speaking: Utah PHP Usergroup - Streamlined Web Development

Next Thursday, November 20th, at 7 PM Mountain Time (9PM EST, 6PM PST) I will be speaking at the Utah PHP Usergroup meeting on “Streamlined Web Development.” I will be speaking with Kevin Carter from Code Greene. Here is the annoucement on the UPHPU website:

I’m very pleased to announce the topic for November’s UPHPU Meeting : Streamlined Web Development using a VCS (Version Control System) and Trac.

Starting the meeting off will be Code Greene’s Kevin Carter. Kevin, who has used Git in a production environment for several months now, will be presenting a primer on how to get started with Git. Additionally, he’ll cover the advantages of distributed source code control and possibly some topics on using git in an svn eniroment. His blog can be found at http://dexterthedragon.com.

Following Kevin will be are main speaker, Justin Carmony. His presentation will focus on the unique challenges with developing, deploying, & managing Website development. Justin Carmony has put together his trips, tricks, and suggestions for streamlining the development cycle. With a focus on automation, using SVN and Trac allows developers to focus on development rather than redundant tasks. Whether a small project with a single developer, or a large project with a big team, SVN and Trac in a LAMP environment can help any developer. Time permitting he will show some of his own live examples of using SVN & Trac. If you have a specific topics or questions you would like addressed in his presentation, please feel free to let him know on his blog.

Justin Carmony has worked in web development professionally for the last four years. With emphasis on PHP, .NET, and Web Services, he has worked on projects ranging from simple websites to complex communications between thousands of remote systems. He currently is working as an independent contractor & private consultant. If you have any questions, comments, or curiosities you can contact him (justin AT justincarmony DOT com) or read about his latest endeavors at his blog (www.justincarmony.com/blog).

We will have streaming as usual and slides will be posted early.

If you’re in the Salt Lake City area, and would like to attend, it will be at the following address: 12393 Gateway Park Place Suite 600, Draper, Utah.

If you’re not able to make it, but would still like to listen in & participate via IRC, check out the UPHPU’s live meeting page. If you have any specifics on what you would like to hear, or have any questions that you would like me to answer in my presentation, leave a comment below.

Posted in Programming, Web Design. Tagged with , , , , , .

Digital Conversion Video

This made my day, and I thought I would share it.

Posted in General. Tagged with .

MySQL - Does Table Exist w/o Throwing Errors

There are times where you would like to know if a table exists before executing an query. Most solutions require having MySQL throw an error saying "table does not exist," but I prefer a cleaner way. I found on this forum post a clean way to do it:

SQL:
  1. /* example with table name: table_name */
  2. SHOW TABLES LIKE 'table_name';

This solution will return 1 row if it exists, and 0 rows if it doesn't. Here is a PHP example using this:

PHP:
  1. function DoesTableExist($name)
  2. {
  3.    $sql = "SHOW TABLES LIKE '$name'";
  4.    $result = mysql_query($sql);
  5.    if(mysql_num_rows($result)> 0)
  6.    {
  7.       return true;
  8.    }
  9.    else
  10.    {
  11.       return false;
  12.    }
  13. }
  14.  
  15. if(DoesTableExist('users'))
  16. {
  17.    echo "Users table found!";
  18. }
  19. else
  20. {
  21.    echo "Users NOT FOUND!!!";
  22. }

Posted in Programming. Tagged with , , , .

I’m Boycotting Electronic Arts (EA) Games

ealogo.pngAs of today, I'm not going to buy another Electronic Arts (aka EA) video game. I'm tired of their "quantity over quality" point of view, and their poor decisions. I've blogged about my problems with EA Games before, but today I read that they are implementing a new system for their forum moderation. Basically, if you get banned on their forums, or any other part of their website, all relating account & games will be banned as well. So for the dozens of EA games that I own that I play online, some volunteer moderator at the EA forums can think my post is out of line, and ban me from all my purchases with EA? Some games aren't played online, but almost all games now have some form of online participation.

If EA wants to punish its consumers so heavily for posting on their forums what might be inappropriate or out of line, that's fine, just ban their forum account. But if you ban their entire online gaming connections, that is going too far. This is my last straw with EA, and until I see significant changes in their attitude towards consumers, they will not receive a single penny from me. My money as a consumer is an award for good companies, and I don't believe in awarding bad companies.

Update: it appears EA has retracted it's statement to clarify that bans are handled individually, not globally. However, until I see better quality from EA, I'm not buying their games, period.

Posted in Video Gaming. Tagged with , , , , .

Father Sued Over Freedom of Speech

I thought I would step in and write about the total non-sense that has been going on with the Linspire/Freespire debacle. Today I just found out my father, Kevin Carmony and ex-CEO of Linspire, is being sued by Michael Robertson over "... cybersquatting, trademark infringement, and unfair competition..." for "$100,000 and other damages." You can read the entire post on Kevin's blog. He summarizes the real intent behind this lawsuit well:

The lawsuit even states, "Although the FREESPIRE mark was recently assigned as part of an asset purchase, [Robertson] expressly reserved all rights in and to all claims against Carmony arising from the freespire.com domain name and website." Now, why would Robertson want to carve out that one thing to hang on to? He's no longer involved with Freespire, so why does he care? Is he desperate for money? With Robertson's companies struggling and laying employees off, does anyone really believe this is the most important thing Robertson should be concerning himself with? His motives are pretty transparent--to suppress freedom of expression that is critical of Robertson.

This is a nuisance lawsuit, intended to silence my freedom of speech. I will defend my right to free speech by continuing to point freespire.com to my blog and keep reporting on Robertson's disturbing actions.

Enough is enough Michael. You once stated that the "The Record Labels Want My Minivan" playing the victim of a personal lawsuit. Seems rather hypocritical now that you're suing my father. What about my stocks in Linspire? I was hoping to use them to help pay for school or a down payment on my house. But of course my house, car, or personal money doesn't matter to you Michael, since you drove Linspire into the ground and sold it's assets off in a single year. I'm glad to see you valued the shareholders to much. Seems its only a crime when its "your minivan" at risk.

If you want to read up more on Michael Robertson & the Linspire/Freespire issue, you can checkout my father's blog.

Posted in General. Tagged with , .

PHP Design - Biggest Database Oversights

Over the last three years I've had the opportunity to work on several PHP projects, some of them having grown rapidly and required to scale quickly. Three in particular have been a fantastic learning experience for me. Now I don't consider myself a total expert, but I thought I would share my experiences. Many PHP developers are self-taught, like I was, and are learning PHP to be able to create dynamic websites. Many haven't had studied or learned best practices for Object-Oriented Programming (OOP). They are web designers first, and programming in PHP is just a way to do things simple HTML can't do.

Because most PHP applications rely heavily on the ability to read and store information in a database, many times designing how you interact with that database is critical. The reason being is if you design something, but don't foresee a requirement or necessity, it can be extremely time consuming to go back and change. These "oversights" can be costly in time, money, and resources.

I've thought of some of the biggest oversights I've had when working with PHP and MySQL and put them in a list. This is my personal list, and I'm sure some people can think of some other oversights that belong on the list as well. This list is just for PHP & MySQL, not PHP and any database. I know many people like using software like Doctrine to allow switching between different database types. That is beyond the scope of this article.

Many of the examples in this article are very simple and are designed for showing techniques of better programming, not for actual use. Straight copy and paste most likely will not create sound, robust solutions. Search the web for a solid MySQL PHP Class to handle these issues for you, or you can make your own.

Now that I've thrown out my disclaimers and thoughts, lets venture on to by list:

  • Oversight #1 - No Data Access Layer
  • Oversight #2 - Design for Only One Database Connection
  • Oversight #3 - No Developer Logging
  • Oversight #4 - Queries Written In Procedural Processes
  • Oversight #5 - No Separation of Reads & Writes

Oversight #1 - No Data Access Layer

I first heard the term Data Access Layer was when I was reading about ASP .NET. Basically a Data Access Layer (DAL) is a layer of code that you access data through. Sounds simple right? Many new php developers don't have any type of DAL. Here is an example of not having a Data Access Layer:

PHP:
  1. <?php
  2.  
  3. // Create MySQL Connection
  4. $connection = mysql_connect('localhost', 'mysql_user', 'mysql_password');
  5.  
  6. // Query User List
  7. $result = mysql_query("SELECT * FROM users", $connection);
  8.  
  9. // Get User List in an Array
  10. $user_list = array();
  11. while($user = mysql_fetch_assoc($result))
  12. {
  13.      $user_list[] = $user;
  14. }
  15.  
  16. // Take the populated user list and display a table...
  17. // ..
  18.  
  19. ?>

Now, that wasn't so bad, was it? Lots of developers just use the mysql commands. I have several projects I worked on my early days with PHP that fall victim to this oversight. One in particular now has grown out of hand so bad that we've decided to start from scratch for a whole new version. Why? Lets say you have 3000+ php files, and your boss says "Hrm, we're seeing some problems with performance. Can you display at the bottom of each page the # of queries you use on that page?" If you coded your entire project like the example above, you would be totally screwed. You would have to find each and every mysql_query() and add some counter at the end. It would be a managing Nightmare. So how cold you solve this problem?

PHP:
  1. <?php
  2.  
  3. // Declare MySqlDAL class
  4. class MySqlDAL
  5. {
  6.      public $connection = null; // hold the connection link resource
  7.      public $query_count = 0; // total number of queries executed
  8.  
  9.      // Connect when creating an instance of this class
  10.      public function __construct($host, $user, $pass)
  11.      {
  12.           $this->connection = mysql_connect($host, $user, $pass);
  13.           return true;
  14.      }
  15.  
  16.      // Run a query against the database. The key here is to make sure
  17.      // every query command goes through this function
  18.      public function Query($sql)
  19.      {
  20.           // Execute Query & Get Result Resource
  21.           $result = mysql_query($sql);
  22.          
  23.           // Increment Query Counter
  24.           $this->query_count++;
  25.          
  26.           // Return the result
  27.           return $result;
  28.      }
  29.  
  30.      // Function to take an SQL query, execute it, and return all
  31.      // the rows in an assoc. array.
  32.      public function FetchArray($sql)
  33.      {
  34.           // Execute the Query and get the Result
  35.           $result = $this->query($sql);
  36.  
  37.           // Create Empty Array to Store all the rows
  38.           $array = array();
  39.  
  40.           // Loop through each row
  41.           while($row = mysql_fetch_assoc($result))
  42.           {
  43.                // Add the row to the array
  44.                $array[] = $row;
  45.           }
  46.  
  47.           // Return the array containing all the rows
  48.           return $array;
  49.      }
  50. }
  51.  
  52. $dal = new MySqlDAL('localhost','mysql_user','mysql_pass');
  53. $user_list = $dal->FetchArray("SELECT * FROM users");
  54.  
  55. // Display Table of Users...
  56. // ..
  57.  
  58. ?>

First of all, you've satisfied the boss's wish of keeping a counter for the total # of queries. The trick is to have all queries go through the function "Query($sql)." This will ensure the counter stays current. You can also add code to catch errors, display error messages, log queries, etc. Having a class to wrap around your database connection, queries, etc. can make your life easier, and more simple.

Continued...

Posted in Programming. Tagged with , , , , , .

Empowering JavaScript Through jQuery

Once I discovered jQuery, my life as a web developer changed. There are few libraries, tools, etc. that I can honestly say have completely changed the way I code. In all honesty, jQuery makes the difficult aspects of JavaScript and turns them into a strength. I recommend it over any other JavaScript library I know. It is smaller, leaner, straight forwards, and more powerful than anything out there. Large companies like Google, Microsoft, and Dell use it. Microsoft is now including jQuery in Visual Studio, their powerful IDE for making websites. If anything, I have yet to meet a person who has used jQuery and has gone to anything else.

Learning anything new can be challenging, so I thought I would share my resources on learning jQuery. First off you need to check out jQuery's tutorial section. I recommend just about every tutorial on there, and each will help you understand jQuery a little better. Once you've gone through the tutorials on how jQuery, sit down and make something meaningful with it. Don't just follow the tutorials, but actually try to use it in your next project. Soon you'll see how amazing jQuery can be. Last but not least, my absolute favorite quick reference is Visual jQuery by Remy Sharp & Yehuda Katz. When ever I need to look up quickly how to do something, I use can find it within seconds on Visual jQuery.

I'm going to try to post at least one tip or trick with jQuery every week, not only to help me keep a history of my tricks, but to help others solve common problems. If anyone has any questions, please feel free to leave a comment and I'd be more than happy to answer any questions.

Posted in General. Tagged with , , , , , , .

Is Apple Blinded by Style?

I have to add my voice to Jason D. O'Grady from ZDNet's "The Apple Core" about the new MacBook & MacBook Pro. Jason complains:

The thing that bums me out the most about yesterday’s MacBook announcements is Apple’s move to all-glossy displays. I’ll make no bones about it – I loathe glossy displays – especially on a notebook computer.

Apple will spin it that blacks look darker and colors are more saturated, blah, blah, blah. It’s a load of garbage. How are we expected to read the screen when the glare is practically blinding? (Don’t even get me started on fingerprints).

I remember when I was talking with my boss about the order for my new MacBook Pro. When he asked about my screen, I repeated several times "not-glossy, never, ever glossy." We triple checked the order at the end that I had the matted screen. I'm glad that I got my MacBook Pro when I did, because I cannot stand a glossy finish. The only purpose for a glossy finish is shine.

Why shine? Because it looks cool from the outside-in. The demos looks really nice. I love the new approach they're taking. My only beef is the lack of option. Offer glossy and matte. I'm all about choice. But this decision to only offer glossy is a blatant example of "Apple knows best" and their priority is style, not functionality. Those laptops look "sexy", but blinding.

I haven't had a chance to handle one myself, but when I get my hands on one I'll let you know. If you want to see a video about the new MacBook Pro, check out this video.

Posted in Technology. Tagged with , , , .

EA - Lack of Quality & Out of Touch

An article posted on Slashdot just set me off today. Custom PC reports a quote from EA's CEO, John Riccitiello, about DRM & their recent games:

‘We implemented a form of DRM and it's something that 99.8 per cent of users wouldn't notice,’ claimed Riccitiello, ‘but for the other 0.2 percent, it became an issue and a number of them launched a cabal online to protest against it.’ The use of SecuROM in EA’s recent PC games, including Spore, Mass Effect and Crysis Warhead, has caused a lot of controversy on the Internet, resulting in hundreds of one-star reviews on Amazon.

99.8%? That is magical statistics at its best. I bought Spore, and I had an insanse time trying to get it to read the disc and install on my machine. SecuROM is extremely evasive, and when I re-format my machine, I have to go through the entire hassel again. To think that normal "gamers" don't know mind these DRM tatics is total ignorance. I can't backup my Spore DVD incase I lose it or it gets damanged. I've already written about my thoughts on DRM, but I can't help re-emphasis my point:

DRM doesn't stop illegal downloads. It harms legal users try to use their purchase legally. DRM will never, ever, be succcessfully until it makes the users life easier.

The one example of DRM I love is Steam. I buy a game once and it handles everything else for me. If I move computers, it works. If my computer blows up, it works. I can delete and re-download my game as many times as I want. It handles all updates for me. I can buy a game and play it within minutes, not needing to drive to the store. Even if I go to a friends and show him a game on HIS PC it works. Only one person can use it at a time, which for legal Steam owners is great. Steam has make my life easier so I accept it. I bought the game Crysis Warhead, and while the game's quality was okay, I bought it on Steam and I had no problems with it.

Now, my other problem with EA is their quality of games. EA has turned into a video game assembly line. They pump out more games than any other company. But I will say their quality has also gone down the shaft. My personal latest example is with their game Tiger Woods 09. I managed to completely render my game on XBox 360 completely unplayable, all due to a clitch with the game, and took me several days to solve.

Somehow I managed to equip two gloves, right hand and left hand, on my character. I'm not sure how I did it, and I was playing when I realized "hey.... I have two gloves on?" I didn't think much of it at the moment, saved and turned off my game, and waited several days before playing again. I went to turn on my game and it froze. I tried it several times, same behavior. After several hours of trial and error, I discovered the solution:

I had to first delete my game settings on my profile on the XBoX 360 hard drive. Then, I had to load the game and go the golfer manager. I then loaded my character, went to the "Pro Shop", had to do an "item" search with several different combonations (which figuring it out crashed my xbox 7 or 8 times alone), and unquip the item. Finally I could save, restart my XBox, and play the game like normal.

Searching the internet for hours didn't yeild any results. I tried to figure out how to contact EA for support, but gave up in the end after trying to create support acounts and jump through their hoops. Had it not been for me noticing my playered glitched, and understanding programming logic, I most likely would have never got my game to work again. What happened to Quality Assurance over at EA? I'm sure some poor gamer out there can't play his game because he on accidently equiped a right-handed glove instead of a left.

I dunno, but I'm started to think I might just boycott EA all together.  Here are imagines of my dual wielding glove golfer, for proof that I really did go through all this mess:

Note: I took these on my iPhone quickly, so I know the quality isn't that great.

Posted in Video Gaming. Tagged with , , , , .