Currently Browsing: Home » 2010 » June

Archive for June, 2010

Simple Snippet: Generate the DZone Button with PHP (Save HTTP Requests!)

The folks at DZone provide a great way for developers to share links in one, concentrated area. URLs which rank highly in their system (those that receive many “up” votes) often get quite a bit of traffic. As a result, many developers use the DZone button to provide their visitors a way to rate articles directly from their own website.

DZone

Do you use the DZone button on your website? If not, you should definitely consider it. Unfortunately, each one of these buttons requires the inclusion of a JavaScript file, which adds an HTTP request (and thus slows down the page). With some quick studying of the included JavaScript, it’s possible (not to mention quite easy) to generate this same button with only PHP, thus saving a request.

Read the rest of this entry »

Simple Snippet: Backup your Files through SSH

Today we’re introducing a new type of post at Lateral Code: the simple snippet. These articles are meant to provide you with concise, meaningful snippets of code for use on your website. To kickoff off the simple snippet, we begin with an important topic for any site: backups.

Have you ever lost important files? If you have, you know the importance of keeping backups.

Files

Backups could mean the difference between life and death for your site. It’s vital to constantly generate backups and even store them on a remote machine in order to ensure full protection. All it takes is a determined attacker to possibly corrupt all of your files. As a result, this simple snippet is focused on getting you started with the backup process.

Read the rest of this entry »

5 Must-Reads on JavaScript Inheritance

Do you know inheritance in JavaScript? Do you truly understand how it works? Are you aware that JavaScript uses a prototypal inheritance scheme that is often disfavored or disliked? Have you used a script on the web to adapt this scheme to classical inheritance?

Read

In these past few days, I’ve been writing a jQuery slider plugin with various transition effects. To make the code succinct, I decided to use a base Transition object that other objects, which define a specific type of transition, inherit from. This led me to the question of JavaScript inheritance.

Inheritance in JavaScript has been a controversial subject. Should a standard be set to use classical inheritance or should the base prototypal system be favored? Both paths have their own advantages and disadvantages. The readings listed below will hopefully give you enough information to choose which method you want to use.

Read the rest of this entry »

Coding a Color Manager with Object-Oriented PHP

Colors are a vital part of web design. They can easily make or break a design. Often times, designers are interested in modifying colors by mixing, fading, or brightening them. This will be the basis for today’s article.

Color Wheel

We’re going to go through the process of creating a simple color manager with object-oriented PHP. Rather than focusing on multiple forms of modification, our color manager will perform one basic function: fading. Given a base color (hexadecimal) and a fade percentage, we will calculate a new, faded color.

View the color manager Download the files

Read the rest of this entry »

How to Store Arrays in a Database

When working with databases, it is sometimes necessary to store an array in a MySQL field. Unfortunately, there is no way to directly pass in an array as a parameter. As a result, storing these data structures is a bit more complex, but by no means hard or impossible.

Array

Read the rest of this entry »

« Older Entries