Archive for the ‘Blog’ Category

QR codes – no longer a fad?

Sunday, April 24th, 2011

I guess last year’s SXSW conference had made a difference – because QR codes (Quick Response) codes have grown in popularity and are now being used widely in mainstream print media. They’re in print ads, posters, flyers and now even in business cards. Google’s also been encouraging the use of QR codes. Their “Favorite Places” campaign puts QR codes in the windows of local businesses that point to their online listing page. Google’s mobile operating system Android has also helped along QR code adoption.

If you have a smartphone, chances are good that you have scanned a QR code before, and if you havent – download a QR code scanner from your application store and try it out . . . here’s the first one you can scan:

Line Break bug in Dreamweaver

Wednesday, April 13th, 2011

I’ve been using Dreamweaver for a while now since they stopped supporting Homesite. What I don’t like about it is the additional line breaks that appear in the source code after multiple commits/uploads – whether it is via SVN or Contribute.

Now if you’ve already downloaded the file and it has multiple line breaks – here’s how you remove the extra spaces:

  • While the document is open in Dreamweaver, press CTRL+F to load the Find & Replace dialog box. Do the search on the source code view.
  • Check the box “Use regular expression” and uncheck any other boxes.
  • Find: [\r\n]{2,}
  • Replace: \n
  • The hit “replace all”

That will do it! However, take note that this while this will remove any existing white space on your code. When you commit/upload/download the file again, the same thing will happen all over. We need to change the line feed type in the settings to get rid of this problem once and for all.

  • Inside Dreamweaver, click Edit on the menu.
  • Then Preferences.
  • Then Code Format.
  • Then on the “Line Break Type” select “LF (unix)”
  • Click Ok. Done!

Thanks to Jared for the article.

HTML5 – Using semantic markup

Tuesday, January 11th, 2011

Let me start off by saying “Happy new year!” Hope everybody had a terrific holiday season and has now settled back into reality and a normal routine. Am not sure if you guys are into new year’s resolutions but one of mine includes using HTML 5 semantic markup into all (or most) of my new projects.

I like HTML5’s new form input types, video controls, geolocation and offline capabilities but that is not what I will be covering here. My main concern is semantic markup. Instead of <div>s – we can now make use of the new HTML5 structure – <header>, <nav>, <section>, <article>, <footer> and a few more. Now let’s look at the steps we should take to incorporate HTML5 into our project.

  1. Specify the DOCTYPE. <!doctype html>, that’s it! done.
  2. Next is to define the character encoding. <meta charset=utf-8>.
  3. You wouldn’t need to include <html> or <head> or <body> but I prefer it, so we should probably put it in.  The minimal structure of an HTML5 document will look like this:


<!doctype html>
<html lang=en>
<head>
  <meta charset=utf-8>
  <title>HTML5 rocks</title>
</head>
<body>
  <p>This is a purely validated HTML5 document.</p>
</body>
</html>

My goal for incorporating HTML5 into my projects is for semantic markup – meaning that the elements define the meaning of the content as closely as possible.   In HTML4, the way to do this is to name the classes properly – take for example the HTML4 document below:


<div id="header">
  <h1>My BLOG</h1>
</div>
<div id="sidebar">
  <ul class="menu">
    <li><a href="previous.html">Previous Entries</a></li>
    <li><a href="about.html">About Me</a></li>
  </ul>
</div>
<div class="post">
  <h2>What a Day!</h2>
  <p>Happy New Year guys! Today is the first day of 2011 . . . Let's all have a great year together!</p>
</div>
<div id="footer">
  <p>Copyright 2011. All Rights Reserved.</p>
</div>

This is what semantic markup meant in HTML4. But now that we have HTML5 – see what we can do:


<header>
  <h1>My HTML5 BLOG</h1>
</header>
<nav>
  <ul>
    <li><a href=”previous.html”>Previous Entries</a></li>
    <li><a href=”about.html”>About Me</a></li>
  </ul>
</nav>
<article>
  <h2>What a Day!</h2>
  <p>Happy New Year!  Let's all use HTML5!</p>
</article>
<footer>
  <p>Copyright 2011. All Rights Reserved.</p>
</footer>

Now as with CSS and Javascript, we all know that it can’t be this easy . . . there is always the issue of cross browser compatibility.  And as almost always is the case, IE will not cooperate without some arm twisting – we will need to use Javascript to create these new HTML5 elements.


<script>
  document.createElement('header');
  document.createElement('nav');
  document.createElement('article');
  document.createElement('footer');
</script>

To make it easier, you can just include the html5 shiv that will add these elements for you – since you will only need to address IE8 and below – it is better to put it under conditional comments:


<!--[if lt IE 9]>
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Include the above code before the </head> tag and your HTML5 elements would now be “style-ready”.  Aside from IE, older versions of Firefox (v.2) and Camino wouldn’t render HTML5 unless it was perfect XHTML and served as XML.  However, upgrading to the newer versions should solve these issues and users of these browsers tend to upgrade their browsers frequently anyway.

As an early adopter of HTML5, there will be bugs . . . but I think it’s worth the effort as HTML5 will be the standard for now and the future.

Using jquery to parse XML

Thursday, December 9th, 2010

I have used javascript to parse XML in the past but jquery is by far, the easiest and most flexible solution. You would not need any plug-ins except for the jquery library which can be found here.

In your html file, you would need a placeholder for where the parsed XML would appear:


<div class="xml-text"></div>

The sample xml file looks a little like this:

<?xml version="1.0" encoding="UTF-8"?>
<xmlcontent>
<article>
<content>
<para>This is the first paragraph of the first article</para>
<para>This is the second paragraph of the first article.</para>
</content>
</article>
<article>
<content>
<para>This is the first paragraph of the second article.</para>
<para>This is the second paragraph of the second article.</para>
<para>This is the third paragarph of the second article.</para>
</content>
</article>
<footer>
<content>
<para>© 2010. All Rights Reserved.</para>
<para>Contact the webmaster for any questions, comments and/or suggestions.</para>
</content>
</footer>
</xmlcontent>

At the bottom of your html, insert this piece of script:


<script type="text/javascript">
<!--
$(document).ready(function () {
$.ajax({
type: "GET",
url: "xml_file.xml",
dataType: "xml",
success: xmlParse
});
});

function xmlParse(xml) {
$(xml).find("article").each(function () {
$(this).find("para").each(function(){
$(".xml-text").append('

' + $(this).text() + '

 

');
});
});
}
//-->
</script>

The first line of code just initializes jquery to load the xml file . . . under url, you would need to type in your xml file – due to certain security restrictions this should be a local file – if it is an external xml feed, you would need to talk to your systems administrator or write a script to capture the xml and save it to a local directory – if your hosting provider supports PHP – then you should insert this code into rss.php


<?php
header('Content-type: application/xml'); //Changes the format from plain text to XML
echo file_get_contents($_GET['feed_url']); //Echos the RSS feed from the GET feed address
?>

And in your jquery, instead of the initialization code, you would put in this one-liner:


$.get('/rss.php',{feed_url:'http://sample.com/feed/'});

I have not fully tested grabbing external feeds, so if the code above doesn’t work, don’t blame me – but it does require a bit more work to get external feeds to work – it all depends on how your site and servers are configured.

The parse function is pretty straightforward . . . it goes through the xml content to find the <article> tag and then under each <article>, it would look for the <para> tag and then insert the text into the placeholder, which in this example is <div class=”xml-text”>. Magic!

960 grid framework

Tuesday, November 30th, 2010

I have been using the 960 grid system for almost 2 years now. It is really helpful especially during the initial stages of development when you are trying to get the first page out. It provides a clear structure and is especially helpful when you are working with a programmer.

The main structure looks like this:

<div class="container_12">
<div class="grid_7 prefix_1">
<div class="grid_2 alpha">
...
</div>
<div class="grid_3">
...
</div>
<div class="grid_2 omega">
...
</div>
</div>
<div class="grid_3 suffix_1">
...
</div>
</div>

The container specifies how many total columns exist, either 12 or 16 (or even 24). For the most part, you will only ever need to specify a class name of grid_XX, where XX represents the column width.

If a grid unit contains grid children, the first child in a row will need a class of alpha and the last child in a row requires the class name omega. Likewise, if you want to insert empty space before or after a grid unit, use class prefix_XX or suffix_XX.

It’s all pretty simple and straightforward – and it works! View a template here. The creator of this highly successful grid system is Nathan Smith – he’s such a good guy too!

If you wish to use a fluid or elastic layout – there are variations of this grid system available as well . . . Typogridphy allows you to create grid layouts which are versatile and great looking. Fluid 960 is for fluid layouts and includes Jquery or Mootools effects to get your prototype out really fast.

Give Thanks

Thursday, November 25th, 2010

Patience with others is love,
Patience with self is hope,
Patience with God is faith.
– Adele Bestavros

This Thanksgiving season, take a moment and focus on the things that you have – may it be as simple as the clothes you wear, the meal you just ate, the roof over your head and friends/family whom you love. Don’t make a habit of always wanting – it’s really not about having what you want but wanting what you have. I apologize for the cheesy cliches but if you really think about it . . . there is a lot more to life than what we’ve all been led to believe.

Saving Blue Like Jazz the movie . . .

Friday, November 19th, 2010

We saved Blue Like Jazz!. Just a month ago, this movie was going to be shelved because of lack of funding but somebody thought it was too good not to be made . . . so to rescue it, they started a Kickstarter campaign and it became the most successful crowdsource-funded campaign ever! Raising $8 short of $346K! And I’m so glad that I’m a part of it . . . I read the book a few months back and it really touched a part of me I didn’t know I had.

Donald Miller is sending out regular updates on his blog and I can tell that it is going to be one heck of a movie . . . can’t wait to see it!

Book Review: Drive by Daniel Pink

Tuesday, November 16th, 2010

Drive by Daniel Pink

I read this book and it now seems very clear to me why there are people who dread Mondays and people who kind of look forward to it (or at the very least, do not need to drag themselves out of bed on a Monday morning.) The main concept of the book is simple – Business. How we have run, conducted and applied it has never really changed since the word’s been in existence. We have rewarded the best employees and hired them by throwing money at them. We still believe that the best way to motivate people is by giving them more money . . . unfortunately, this has been proven to be so ineffective – it actually demotivates people.

Through various studies conducted by scientists and psychologists around the world, they have proven that by giving a reward to somebody actually enjoying a task – will actually diminish its enjoyment. Because the act of monetary reward will transform the said task into “work”. These “if then” rewards have worked for a while during the industrial age when the usual occupation is routinary and without any monetary benefit, nobody would actually be doing any of those tasks . . . however, the landscape has significantly changed and we are now more immersed in our jobs. And to stay motivated, we subconsciously crave for something “intrinsic”. One example of this is open source development – the people involved don’t get paid, yet they spend countless hours working because they work for a purpose – to be a part of something bigger than themselves. And because of them, we have benefited with some amazing products – like Mozilla Firefox, Wikipedia, the Linux OS to name a few.

The carrot (monetary reward) and stick (punishment through suspensions, demotions) method is no longer a good way of controlling employees . . . they will do the work, but when they aren’t motivated – their work lacks quality, efficiency and their productivity suffers. It’s so astounding how so many managers still believe that this is the best way to control their staff. Wake up!!

Here is an excerpt from the book: DRIVE PDF.

Book Review: Rework

Wednesday, November 3rd, 2010

Every now and then, I’m going to start reviewing books that I’ve read recently. Just a few days ago, I started reading “Rework” by Jason Fried & David Hansson – both are founders of 37signals – a profitable web applications provider (makers of Basecamp, Backpack, etc.).

There are a couple of good ideas here for small business owners, entrepreneurs, managers and any business-minded individual. The main idea is more common sense than anything . . . Don’t hire if you don’t need to. Don’t put out a half-assed product – it’s better to put out half a product that kicks ass (pardon the french). Keep everything simple – more features doesn’t translate to a better product. Don’t use jargon – be conversational in your marketing materials. Don’t pretend to be a big company – Be honest. It amazes me how a lot of these concepts we already know in the back of our minds but ignore because we think that imitating what the “other guys” are doing must be the right thing to do.

My favorite idea in the book – is the “Pick a fight” idea . . . if you are in business and you feel that some of your competitors are wrong – say so! pick a side . . . and stand your ground. While some people may not agree with you – the people who do, will stand behind you and they will do so passionately because it shows them you believe in something.

There is a short summary here.

Common CSS bug – width:100% with a background

Friday, October 15th, 2010

I found out about a very common bug recently that has been going on unnoticed – this bug has been so evasive so as to go undetected by even the most popular websites.

If you set a width of 100% on a div and that div has a background, then most likely you will have this bug on your website . . . the bug appears when you resize your window to the point when horizontal scrollbars appear and then you scroll to the right. It’s probably not common practice for somebody to do this and that is probably the foremost reason this bug has been mostly ignored by designers.

Here are some of the more popular websites I’ve found (as of today) that have this:

Facebook

Groupon

Groupon

MSNBC

MSNBC

Now that I’ve exposed this bug . . . the fix is fairly simple – all you have to do is add a min-width property . . . so if your CSS looks like this:


div { width:100%; background:#fefefe url(/images/some_image.jpg) repeat-x; }

then simply add:


div { width:100%; min-width:960px; background:#fefefe url(/images/some_image.jpg) repeat-x; }