Tuesday, October 27, 2009
Friday, September 25, 2009
On doing it right the first time
Everyone who writes any sort of code has been asked to do a one-off - "just do it quick, it'll never be anything but a prototype". Even serious projects have this (see http://code.google.com/p/virtualagc/source/browse/trunk/Luminary099/LUNAR_LANDING_GUIDANCE_EQUATIONS.s?r=258, the comments for lines 179 and 180). The problem with this is that it's never just a one off. Every line of code we write gets used again and again because it's becomes easier to copy and paste something than to write it from scratch. If we don't do it right the first time, there's never time to go back. So how do we get the time to do it right? Simple. Don't give in on time estimates. When they say it's just a quick example, can't it be done in an hour or two, say no. Explain why you won't cheat the process. The only way we achieve the standards we want is to refuse to accept anything that doesn't meet those standards. Set a minimum bar and don't go below it. In the long run, it makes our work better, and makes us better teammates to those who depend on us. It may not be obvious at first, but the extra time we spend up front comes back to help out down the road.
Posted by Scott Plumlee at 4:40 PM 0 comments
Wednesday, September 9, 2009
JavaScript Plugin of the Month - jQuery Datepicker
Alright, so this one is a little older, but still is very useful. The datepicker plugin works in all browsers supported by jQuery (ie6+, FF2+ etc...). This plugin is fully customizable and flexible, size, color, etc. The website has many examples of its usage, and it is very simple to use.
http://keith-wood.name/datepick.html to download this gem.http://keith-wood.name/datepickRef.html for the documentation.
Posted by Patrick at 10:45 AM 2 comments
Labels: javascript, jQuery
Tuesday, August 25, 2009
Browser Font Size Madness!
Alright so I recently had some discussions and researched a bit about font sizes in browsers. There are some really important findings here, but I will summarize as best as I can.
How does the Browser Decide on a Font Size?
Firstly, the default browser font size across all modern day browsers is 16 pixels. This is good to know when you are trying to calculate your relative font size.
Secondly, another calculation is made in regards to your font sizes, and if and if you are like me, you are using EMs. Take your base font, and multiply by your EM value, so 1.1 em * 16 pixels = 17.6 pixels. All browsers (except IE) will correctly round up to 18 pixels, so your result would be 18 pixels. IE (seemingly) truncates the decimal value, and interprets 17.6 as 17 pixels, thus giving a one pixel difference!
Make sure when you specify a relative font size, calculate it, and make sure its going to be the same in IE.
The Scaling Issue (Thanks Stephan)
http://www.kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/
Due to an issue with scaling, it's best to at least start your font size (base font size) with a percentage (%).
The code below will set the base font to 12 pixels.
body{font-size:75%;}
Using a percentage first is important because of scaling, and IE's browser font settings. After you set the % based font size, typically on the body, the EMs will work very nicely.
Also most other web developers I have talked to suggest starting off with a simple base font, that makes the em calculations simple:
font-size: 62.5%
Everything after that in EMs
(1 em ~= 10 px)
(1.1 em ~= 11 px)
(1.2 em ~= 12 px)
and so on...
Extra JavaScript Plugin of the Month - jQuery Password Strength
This is an extra plugin for the month. I thought it was useful in a project I just got into. Check it out! This helps you let your users know if their passwords are strong or not. It does a fairly good job too, and there is some configuration to play with as well. http://www.unwrongest.com/projects/password-strength/
Posted by Patrick at 4:03 PM 0 comments
Labels: javascript, jQuery
Wednesday, August 12, 2009
JavaScript Plugin of the Month - jQuery tagbox
I just thought this was a really cool plugin, if anyone has an interest in this sort of thing. It seemingly works in all browsers just fine. Had a little problem in IE6 with some of the rounded corners, but overall it was nice.
http://saynotofastfood.info/tagbox/examples/
Posted by Patrick at 12:59 PM 0 comments
Labels: javascript, jQuery
Friday, July 10, 2009
JavaScript Plugin of the Month - jQuery Visualize
Last month (June) we did not have a plugin of the month, yes I know...But since this is a new blog, these types of things are not yet defined. Previously in May, TM demonstrated a jQuery plugin, called DataTables. Which I thought was a really great plugin. There are tons of jQuery plugins out there, so many in fact, perhaps many people might miss out on some good ones. Each month I will make it a goal to highlight a plugin. I will test each plugin to insure I am able to use the plugin and help others to use it. It might not be limited to jQuery though, it could be a new library or some other hidden treasure. I hope everyone likes this idea, if you have a plugin you would like to share, let me know, and I might just post it.
This month I am highlighting the plugin called "Visualize" for jQuery.
Visualize creates fantastic bar, line, area, pie charts from HTML tables. The only caveat is that this plugin uses the HTML 5 tag "Canvas" which is not yet supported in any version of Internet Explorer. However, there is extra JavaScript which can be used, and especially for this demo, that will allow IE to render the charts just as any other HTML 5 browser would, without the canvas tag. Using this extra JavaScript is acceptable, and I can notice no difference between HTML 5 capable browsers, and IE*. Using IE, you must allow "ActiveX" controls to be run on the page, which can be quite annoying to some IE users, or mistaken as a security risk!
All the information on this plugin can be found below: http://www.filamentgroup.com
Or you can directly download this plug, and follow the example included: http://www.filamentgroup.com/examples/charting_v2/visualize.filamentgroup.zip
For further information on HTML 5 canvas tag: http://en.wikipedia.org/wiki/Canvas_(HTML_element)
Posted by Patrick at 9:52 AM 2 comments
Labels: HTML 5, javascript, jQuery, web development
Monday, June 29, 2009
Save yourself time with Subversion
If you use FTP in your day to day workflow, a switch to subversion can put time back on your calendar. Anytime you save yourself a few minutes by removing manual steps from a task, you've freed up time to do the interesting and fun parts of your job. Here's my workflow with subversion: when I've got changes I want to send to the server, I commit my changes with a single line at my command prompt, or a single right-click in Windows Explorer. Then I switch to another window and update the server with the same single command/right click. Done. My changes have arrived and are live. If I don't need the server to update immediately, I can do a scheduled task or cron job that updates itself once a minute/day/hour. Since I test locally, I only commit when I'm ready for it to go live, so the automated update works well for me. Ever worked with someone on the same file? You change it, FTP it up, then they FTP their own changed copy, and then you do another change, etc etc.? Now who's got what copy where? With FTP, the only solution is to manually overwrite the files once you've sorted out what version you need. With subversion, the logs show you who did what, and when they did it. A quick check of the logs (again, with a single right click or command) and you can see what happened. Need to get back to how things were before? Again, a single command can take you to any point in history to see how it worked, and another command gets you the latest version again. So you can fix the problem and have free time to take care of other tasks*. Web 1.0 was built on FTP. Web 2.0 rocks with subversion**. What web are you working with? * Like administering a beating to the co-worker who overwrote your files. ** To be honest, there are lots of great version control systems (VCS). Subversion, git, mercurial, etc etc. I use subversion b/c it works for me. But any VCS is better than FTP.
Posted by Scott Plumlee at 9:07 AM 4 comments
Labels: SVN
Wednesday, June 24, 2009
IE Whitespace Issue
So I ran into an old IE bug, or I would so much as call it a rendering issue. Whitespace, which should be collapsed by the rendering agent, to form inter-word spaces (except for <PRE>), all other whitespace should be ignored. This issue has been known for quite some time, but I ran into this yet again -- IE8 even. What whitespace? In HTML, spaces, tabs, and return characters are considered to be “whitespace”. One solution is, simply remove all whitespace around your links, and images:
<ul> <li> <a href="#" > <img src="img.gif" alt="Blah" /> </a> </li> </ul>As:
<ul><li><a href="#" ><img src="img.gif" alt="Blah" /></a></li></ul>This method is not very pretty, and makes it difficult to use many auto formatting tools. Another method is to apply inline styles to the parent: li { display: inline; } Also a solution is to apply float left (or right) to the parent container: li { float: left|right; } There are more solutions to this issue, but just keep in mind, IE renders whitespace as whitespace between list elements. I have also seen it rendered when an image or link is simply on its own line. In such cases sometimes applying {display:block;} to your anchor tags might do the trick, but might not be applicable. In such cases the foremost method would be suitable. Good luck. Sources: http://archivist.incutio.com/viewlist/css-discuss/34926 http://www.w3.org/TR/html401/struct/text.html#h-9.1
Posted by Patrick at 4:03 PM 2 comments
Let's make the web faster
Google has released an effort to "Make the web faster". Several tutorials and guides can be found under the "Learn" link. It also has a community driven effort, allowing developers to submit ideas, suggestions and questions via a discussion forum.
Google has maintained for years that the performance of Web sites and applications is extremely important to the company, which developed Chrome in large part because it wasn't satisfied with existing browser technology in this area.You check it out here: http://code.google.com/speed/ Usability latency: http://code.google.com/speed/articles/usability-latency.html For some extra nice articles on JavaScript optimization: http://code.google.com/speed/articles/optimizing-javascript.html Also some goodies about CSS: http://code.google.com/speed/articles/include-scripts-properly.html Sources: http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=9134736
Posted by Patrick at 3:52 PM 0 comments
Labels: google, performance, web development
Wednesday, June 3, 2009
Why is IE6 still around?
Most web developers that I know have horror stories about the countless hours spent trying to get their web application to work and behave with Internet Explorer (IE) version 6. Fortunately for us developers, those days seem to be few in number, or so we hope. With the recent release of IE8, one would think that IE6 is either dead or seriously near total annihilation; however this sadly and most unfortunately, is just not true. As of May 2009, stats by usage show that IE6 is neck and neck at 20%, with Firefox 3.
Posted by Patrick at 2:18 PM 4 comments
Labels: Firefox, IE, web development
Friday, May 29, 2009
Does php have a built-in string function that converts underscores into spaces?
Does php have a built-in string function that converts underscores into spaces?
- First is what you want to search for, and be replaced. It is called the "needle".
- Secondly is the replacement, which is used to replace the needle when it is found.
- Lastly you supply the "haystack", or the string in which you wish to find the needle(s).
Posted by Patrick at 3:33 PM 0 comments
Labels: php, web development
Monday, May 18, 2009
jQuery - Web Developers Best Friend
jQuery has been out now for three years. It was released in January 2006, by a fellow named John Resig. He is one year older than me! Anyways... jQuery has recently changed the way I write JavaScript. It has simplified some fairly complicated JavaScript tasks, and even simplified simple tasks. All in all, it is totally work a little investment in downloading, installing, and playing with it a bit. If anyone wants to give it a shot, please let me know, I will be here for you when you get stuck in the mud. Ask me a question about jQuery!
Posted by Patrick at 2:18 PM 0 comments
Labels: javascript, jQuery, web development
Thursday, May 14, 2009
DataTables: a jQuery solution
Recently I've been using a jQuery plugin from this site: http://datatables.net/index. It's fantastic! Easy to setup and use with *tons* of options. Here's a screenshot of it in action:
The data values were hard-coded for simplicity. The column sorting and pagination is all created on-the-fly by the plugin. I also wrote some callbacks to handle deleting and editing the table contents. Sweet!
Posted by TM Harover at 3:41 PM 1 comments
Labels: data tables, javascript, jQuery
Wednesday, May 13, 2009
Sample Question: How do you create a simple mouse rollover?
Question: How would you create a mouse rollover, such that I could quickly copy and paste the code into my code?
Answer:
This can be done several ways. The quickest way is to do create an inline script; however a more acceptable solution is to create functions which you could reuse elsewhere.
Since we want the quickest, or simplest solution, it may not exactly be the most ideal solution, but that is the price we pay for simplicy, and speed.
First you will need to secure an image that will act as your base image, and an image that will act as your rollover image. The base image will be what is displayed when the mouse is not hovering over the image. The rollover image would be your image to replace the base image, while the mouse is hovering over the image.
You will need to have your images in a directory that is accessible by your script.
For example:
/root/index.html
/root/images/base.gif
/root/images/rollover.gif
For speed you would simply then use the basic image tag:
<img src="images/base.gif" alt="base" title="base" />
You then add the JavaScript code for the two events. One for the mouse over the image, and mouse out (when the mouse is no longer over the image).
onmouseover="this.src='images/rollover.gif';"
onmouseout="this.src='images/base.gif';"
add them together:
<img src="images/base.gif" alt="base" title="base" onmouseover="this.src='images/rollover.gif';" onmouseout="this.src='images/base.gif';" />
This is a widely accepted solution. There may be many other ways of answering this question, however to me this is the quickest.
Posted by UCD Web Developers at 1:27 PM 2 comments
Labels: javascript, QA, rollovers, web development
Welcome to the Web Developers Blog!
Welcome to the UCD Web Developers Question and Answers Blog, Dear visitor, Thank you for visiting the UCD Web Developers attempt at sharing our cache of knowledge, with you. We are taking time to answer questions related to web development in any way, shape, or form. No question is too much or too little. Some questions may require demonstrations, some might require research, but we are willing to answer your questions quickly, and accurately. Regards, Patrick Simpson To give you an idea on some of your questions could be related to, but not limited to the following: CSS CSS 2 CSS 3 JavaScript jQuery YUI MooTools Scriptaculous Prototype PHP Version 4 Version 5 ASP .NET C# Visual Basic HTML XHTML HTML 4 HTML 5 Web Development Tools Dreamweaver FTP SVN
Posted by UCD Web Developers at 1:21 PM 0 comments
