Why is processing a sorted array faster than an unsorted array?

Here is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster.

Continue reading “Why is processing a sorted array faster than an unsorted array?”

Inroduction to Writing PHP Command-Line (CLI) Scripts

Added by on July 9th, 2010, filed under PHP, Web Development

In this tutorial, I will show you how to get started with writing command-line interface (CLI) scripts using PHP. Here are a few reasons why you might want to write a CLI application in PHP:

  • You want to write a tool for admin-ing your server, but you’re more comfortable using PHP
  • You don’t need to output any content to a public-facing web page

Continue reading “Inroduction to Writing PHP Command-Line (CLI) Scripts”

Best MVC Practices

Best MVC Practices

Although Model-View-Controller (MVC) is known by nearly every Web developer, how to properly use MVC in real application development still eludes many people. The central idea behind MVC is code reusability and separation of concerns. In this section, we describe some general guidelines on how to better follow MVC when developing a Yii application. Continue reading “Best MVC Practices”