Currently Browsing: Home

JavaScript Fade Effect without Libraries

Using JavaScript libraries like jQuery and Mootools does simplify your code, but this comes with the price of an added footprint. Often times, the same effects can be accomplished in raw JavaScript with little to no hassle. Indeed, this tutorial will explain how to create the classic fade effect without resorting to jQuery or Mootools.

Fade

The fade effect, as its name denotes, is an animation used to fade an element off of a page. You can find a demo of it in the jQuery documentation.

Read the rest of this entry »

Streamlining MySQL Insert Queries

PHP and MySQL have often been known as two peas in a pod. Unfortunately, when you use PHP to insert information into a MySQL database, you often have to write large queries that take up much of your time. Not only that, but you also have to clean user input. This quick tip aims to streamline your efficiency by writing a simple function to do this job for you.

Write helper functions

Helper functions

Before we start working on the main program, we first need to create two helper functions which will be used later on:

Read the rest of this entry »

How Can This Image Detect My Browser!?

Take a look at this image in Firefox or Opera. Now view it again in any other browser. Notice a difference?

In case you don’t have multiple browsers, here’s a screenshot of a side-by-side comparison of Firefox and Safari:
comparison in ff/safari

So how is it possible that this PNG file can magically detect what browser you’re using? Read on to find out.

Read the rest of this entry »

Under the Hood: Custom WordPress Pagination System

If you use WordPress, you know that after a few months of blogging, there are far too many posts to display simultaneously. To reduce the loading time of your website, you could consider a pagination system, in which you display only a certain number of posts per page. By giving the user the ability to navigate through pages, your posts will all be available and left intact.

Pagination

Pagination? How?

Unfortunately, changing the posts per page option under your WordPress reading settings does not automatically create pagination; rather, you have two options:

  1. Use WordPress’ in-built functions (posts_nav_link, previous_posts_link and/or next_posts_link) to allow the user to navigate between pages.
  2. Create your own pagination system.

The main problem with the first option is that WordPress only allows the user to go to the next or previous page; there is no way to jump a set of pages without having to visit everything in-between. Consequently, the bottleneck is in the user-experience.

With the second option, the burden is on the developer. Even though it requires more coding, the user experience is not compromised. As a result, today’s article will focus on how to write your own custom WordPress pagination system. To view a demo, see Lateral Code’s pagination.

Read the rest of this entry »

Automated Uptime Verification

If you have ever administered a website, you know that downtime is unavoidable. Creating a system to automatically check if your website is up can help deal with downtime and provide a better user experience. Doing so is quite simple if you have the following tools available:

Automated Uptime Verification

  • A web server other that that on which the website is hosted
  • Cron (if you do not have this, you can use an online service)
  • PHP with libcurl support
  • PHP with mail support (optional)

Read the rest of this entry »