I am often surprised by how much bad HTML is out there. Especially HTML that does not use Cascading Style Sheets yet. CSS has been around for over 10 years now! It was added to HTML in 1997 and well-supported (at least reasonably) in web browsers by 2000. I think the reason many people never upgraded is that they either learned HTML before 2000, they learned it from sources (friends, coworkers, internet, legacy code) from before CSS, or they learned just enough to get a site online and never bothered learning the “right way”.
Legacy sites are not always worth the trouble to update—I know I have plenty of old code still floating around out there—so their flaws are understandable. But some folks are carrying around their bad HTML habits still. If you ask them to code a page they probably know that frames should not be used, so they use a table to layout the page instead. They might use <center> when they want text to center. I see bad code and misused tags all the time. You can “view-source” on many major websites and see bad code by people who should know better.
If that sounds like you or someone you know, keep reading, I will try to help you break your bad habits and start good ones.
I am proud to announce that PHP with MySQL Beyond the Basics has been released on the lynda.com Online Training Library. It is the sequel to my previous video title, PHP with MySQL Essential Training. It’s almost 11 hours of video training; with the previous title, that makes a total of 21 hours of PHP training!
While the first training was an introduction to PHP and MySQL, in this title I focus on “intermediate PHP” and PHP’s object-oriented features. Objects make it easier to organize and maintain your code, make code modular and reusable, and (most importantly) add clarity by reducing complex interactions to simple behaviors. Once you understand the fundamentals of PHP, you’ll want to learn to harness the power Object-Oriented Programming provides.
PHP with MySQL Beyond the Basics is available online as streaming video to subscribers of the lynda.com Online Training Library ($25/month, $250/year, $375/year with exercise files included). It is will also be available as a CD-ROM soon both through lynda.com and Amazon.com.
Here’s the official description:
In PHP with MySQL Beyond the Basics, expert instructor Kevin Skoglund introduces powerful PHP programming techniques using object-oriented programming (OOP). Both novice and experienced PHP developers will benefit from the efficient, well-organized, reusable, and easy-to-understand code that OOP offers. Kevin shows how OOP techniques can streamline database queries, help manage sessions, and simplify user logins. While building a real-world web application, Kevin also includes practical advice on topics ranging from structuring code to logging user actions. Exercise files accompany the course.
If you are already using PHP but not objects or if you use objects but don’t understand them as well as you’d like, give this training a try and let me know what you think!
The results of the Rails Hosting Survey for 2009 are out. Thanks to Planet Argon for putting it together!
With about 1250 respondents, it has some pretty interesting results.
Here are the things that stood out to me:
- 63% use Git vs. 36% use Subversion. I knew Git was growing fast, but I didn’t expect 2:1 over SVN.
- 75% use Capistrano. About 25 percentage points higher than I would have guessed.
- 97% use either MySQL or PostgreSQL. I’m not surprised how popular they are, I’m surprised that all other database make up only 3%.
- 68% Mac, 25% Linux, 7% Windows. I know “everyone” uses Mac, but I’m surprised Windows is that low.
- 37% use Hoptoad to manage application exceptions. I had never heard of it and will have to check it out.
- 68% don’t use uptime monitoring tools. 60% don’t use any process monitoring tools. Is that a reflection of improved reliability and ISP/Hosts providing the monitoring? Or is it just hope-for-the-best developers who will wait to hear from users that the site is down? (Of which I am frequently guilty.)
- 25% use Nginx for their webserver. That’s a lot considering only 2% of all websites uses Nginx. It’s an interesting trend to keep an eye on.
- And finally, WOW some people are paying a lot for their hosting. More than $50K/month?!?! I’m dying to know who that person is.
I only wish the results had included more information about the survey sample. How did they get their sample? Independent or corporate developers? What size companies? What country and/or U.S. state are they from? If 20 developers taking the survey are all from the same company then it will skew the results in favor of that companies preferences. If they are all from San Francisco, then it says more about SF than about Rails preferences worldwide.
But it is an interesting and informative snapshot nonetheless.
I promised myself that I would pick up blogging again. I miss it and I think (hope) that my workload will allow me the time again. To kick things off, here are two articles that are definitely worth reading.
- The first is for advanced users who need to think about database design issues.
How FriendFeed Uses MySQL (spoiler: not as a relational database)
- The second is about the basic principals for social engagement in web applications.
A List Apart: The Elements of Social Architecture
I have been very delinquent in posting to this blog. Fatherhood plus several big projects have forced me to put it on the back burner. I’m hoping to resume regular blogging in January.
But until then, I do want let everyone know that Rails 2.2.2 is out. Here’s the announcement. There are lots of new features that make the upgrade worthwhile.
A few notes about upgrading though. You need RubyGems 1.3.1 first. Here’s how I upgraded RubyGems, including the error I got while trying.
>sudo gem update --system
ERROR: While executing gem ... (NameError)
undefined local variable or method 'remote_gemspecs' for
(if you get the same error, try this instead)
RubyGems installed the following executables:
(and then either...)
>sudo gem update
(which updates ALL gems not just Rails, or)
>gem install rails
(which updates just Rails)
>gem list --local
(shows you a list of all currently installed gems and all versions installed)
>sudo gem cleanup
(once you are 100% sure you want to erase old versions of ALL gems, not just Rails)
Next, edit the /config/environment.rb file in each of your Rails applications so that RAILS_GEM_VERSION is 2.2.2. Now you application will demand the new Rails version. (Even if you didn’t do a “gem cleanup” and still kept the old version installed. As long as you have both versions of the Rails gem, you can have some applications loading up 2.2 while others use still use the old Rails version.)
Whenever I learn a new set of skills—such as photography or cooking—I want to learn as much as I can about the tools that the pros use.
Sure, to learn photography you need to understand exposure and depth of field, but that’s only part of what it takes to be a real photographer, to be a good photographer. What camera and lenses should you buy? What brand of film? I even pay attention to borderline ridiculous details like what kind of camera bag the pros use. Learning first-rate cooking skills won’t do you much good if you don’t have a good set of pans. Any chef will tell you that having quality, sharp knives make a world of difference in the experience of cooking, even though it may not change the flavor. And, as I love to watch Gordon Ramsay scold, keeping a clean kitchen is an essential (and too often overlooked) step in producing quality food.
The point is that there is more to learn than just the fundamentals. It makes sense to learn from the trial-and-error experience of people who are already working with these tools everyday. I may decide I disagree with their preferences, but knowledgeably making a different choice is much better than stumbling around on my own. Plus in the process, I know I will discover some of the intricacies and pitfalls that come with working in the field.
In that spirit, here are the tools that help me as a web developer.
I installed the latest version of attachment_fu for a project I’m working on. I ran into a problem that I wanted to document here in case anyone else runs into the same thing.
The before_thumbnail_saved callback in attachment_fu is useful for tasks like giving thumbnail versions the same attributes that parent images have. So if an image belongs to an artist, the callback can give the thumbnail the same artist_id as the parent. The callback originally yielded two values to a block—record and thumbnail—like this:
before_thumbnail_saved do |record, thumbnail|
thumbnail.artist_id = record.artist_id
thumbnail.visible = record.visible
But now it yields only one value: thumbnail. To get the same functionality as before, you will need to add a line of code to first find the parent record.
before_thumbnail_saved do |thumbnail|
record = thumbnail.parent
thumbnail.artist_id = record.artist_id
thumbnail.visible = record.visible
If you haven’t tried attachment_fu yet, here are some links you may find helpful: