Recently I had to run a link checker on a relatively large site. I used a few link checkers in the past but Xenu’s Link Sleuth is pretty fast and user-friendly.
For more information, visit
Recently I had to run a link checker on a relatively large site. I used a few link checkers in the past but Xenu’s Link Sleuth is pretty fast and user-friendly.
For more information, visit
Here are some Firefox / Firebug extensions that are really useful for web developers
– Firebug
– FireShot
– YSlow
– Web Developer
– FireCookie
– senSEO
– Page Speed for Firefox
– jQuerify
Validating user-submitted form data is necessary and is often done against just ASCII (English) characters. But, as more websites are catering to an international market, many need to validate against foreign / unicode characters such as the letter é in the word extérieures. Since regular expressions are often used to compare user-submitted data against accepted patterns, these regexes need to be match against unicode characters in order to support non-ASCII characters. Here’s an example conversion from an ASCII regex to a Unicode one that also matches à through ă.
ASCII: ^([a-zA-Z0-9]+)$
UNICODE: ^([u0030-u0039u0041-u0056u0061-u007au00c0-u0103]+)$
Continue reading PHP Unicode Regular Expressions for Form Validation
With so many different screens resolutions on the market, from super wide monitors to Retina-display iPads to low-res 800×600 resolutions for people who prefer seeing everything big, most web developers will need to know how their websites look in different resolutions. One easy way to do this is using a Firefox plug-in called Web Developer. It has many features including the ability to turn on and off CSS and Javascript, will validate your page.
For more information, visit https://addons.mozilla.org/en-US/firefox/addon/web-developer/?src=ss
Many people, especially web developers, often need to capture all or part of their screen or all of a website as an image. This can be used for uploading proof of shipment when the post office loses your package, for showing people a bug or typo on a website that needs to be fixed, or anything else. Another feature that especially benefit developers is the ability to find the dimensions of any part of your screen. Google Chrome’s Developer Tools shows you the dimensions of highlighted elements. But, if you want to manually select a part of your screen and find its dimensions, a Firefox plugin called FireShot works very well. It also allows you to take screenshots and save the image to your computer or in your clipboard, among other options.
For more information, visit https://addons.mozilla.org/en-US/firefox/addon/fireshot/
Sometimes you need to store data but you don’t want to store it in a database. For example, many configuration data is stored in simple text files. Here’s one way to store data in a structured format (using an array) in a text file and have the data easily in a local variable for use.
[cc lang=”php”]
// DATA.PHP
array (
“fieldname” => “firstname”,
“rule” => “required”,
“error_msg” => “Please fill in first name”,
),
“rule2” => array (
“fieldname” => “email”,
“rule” => “required”,
“error_msg” => “”,
)
);
?>
[/cc]
[cc lang=”php”]
// INDEX.PHP
[/cc]
Put all your JS within an anonymous function using the following template
(function ($) { 'use strict'; // global variables go here var foo, bar; // put code that can be executed before the document is ready, e.g. $(window).on('hashchange', function() { foo = true; } $('#content').on('click', "a", function() { foo = false; } // functions go here function filterByCheckbox() { } function validate() { // some code $("input").trigger("validationPassed"); } // put code that must/should be triggered after the document is ready $(document).on ("ready", (function () { // on load code goes here, e.g. filterByCheckbox(); foo = true; $('div.reports ul.tabs').append("abc"); // on event handlers (click, focus, submit, etc) go here, e.g. $("select").on("change", function() { // something }); $("select").on("blur",validate); $("select").on("validationPassed", function() { // something }); }); }(jQuery));
Put each separate code block that serves a separate purpose in a separate template above. Since Javascript is asynchronous, it can execute each code in each block / template simultaneously instead of one at a time.
Never trigger events using element.event(). Always use jQuery to handle events in a cross-browser way, e.g.
BAD
window.hashchange = function() { }
GOOD
$(window).on('hashchange', function() { });
For events, always use the jquery “on” and “off” functions to attach/bind and detach/unbind events. .live() is deprecated so use “on” with a subselector.
Normally, when you bind an event handler to an element, you do something like:
$("a").on('click', function (event) { ...
When binding event handlers to elements that are dynamically-generated, you’ll want to do it when the element is in the document, so use this format:
$(document).on('click', " a", function (event) { ...
Use classes instead of IDs to be safe and make coding easier.
For each page, add an ID to the body element that mirrors the URL to the page, e.g
www.somesite.com/products/fish/(index.php or index.html)
<body id=”products-fish”>
www.somesite.com/products/kites/
<body id=”products-kite”>
This will make it easier to override styles in specific pages without having naming conflicts.
Note to self:
Always use unicode modifier (/u) in preg_* functions, e.g.
preg_match(“/php/u”, “PHP is the web scripting language of choice.”)
When creating sprites containing many images, it can be hard and time-consuming to find the position images in the sprite. To simplify this process, create a Photoshop file with a grid of horizontal and vertical guides spaced X pixels apart from each other and turn Snap To Grid on.
Here’s a grid you can use …
Coming whenever I have time (which is not often).