Monday, March 30, 2009

Chegg application

  1. Demonstrate an efficient way to search the last 100 lines of a file containing roughly ten million lines for a sample string. This should function without having to process each line of the file (and without making use of the .tail. command or any external system commands). Any of the following languages can be used: PHP, C, C++, Java.
    
    
    run
    data (72M)
  2. Utilizing two common Object-Oriented design patterns, write a set of classes, which can be used to log a given message. The message should be logged to either a MySQL database or a file, depending on a configuration setting. There should be only one connection opened to the database (or the log file should only be opened once) throughout the use of the application. ). Any of the following languages can be used: PHP, Java, C++.
  3. Write a basic web application, following the Model-View-Controller/Modular design pattern. The following URLs should be functional:
    • http://www.server.com/index.php?page=showTime - Displays the current system time.
    • http://www.server.com/index.php?page=showDate - Displays the current system date.
    • http://www.server.com/index.php?page=showVersion - Displays the current PHP / Java version.
    Each page should be represented by an individual class. Any of the following languages can be used: PHP, C, C++, Java.

Tuesday, March 24, 2009

code highlighting test

  
   public interface Logger
{
    public function log($destination, $data) {}
}

public class DatabaseLogger implements Logger
{
    public function __construct() {
        // open file handle, singleton
    }

    public function log($data) {
        // write to file
    }

    public function __destruct() {
        // close file handle
    }
}

public class FileLogger implements Logger
{
    public function __construct() {
        // open database connection, singleton
    }

    public function log($data) {
        $data = mysql_real_escape_string($data);
        // write to database
    }

    public function __destruct() {
        // close database connection
    }
}

public class LoggerFactory