Technology
Tracking DMV wait times
So I was required to visit one of our favorite state agencies, the DMV. Its been a while, and when i showed up the line was wrapping around the building. So i went home to spare my day, and figure out a better way to accomplish this civic duty.
With some general knowledge of the existing public data, I attempted to track the wait times for all my local DMV's. and figure out where and when a good time to go to the DMV would be.
Going to the DMV website I found some interesting stats
This data provides a general overview but not the specifics im looking for. After a little more digging I wass able to find "some what" real time wait time on the DMW website:So i proceeded to scrape those wait times into a MYSQL database every 15 minutes for each location. Making use of that much data can be difficult, so i need to make a way to visualize the data, so i employed google charts. If your interested in seeing the ongoing results of this project click here
I was able to figure out the best time and location, which i will publish online after I finish my dealings with the DMV. So be sure to check back or subscribe to my site for an update.
Why using Frameworks is a MUST
A coders example of why frameworks are a MUST in application development.
-
- Frameworks reduce the amount of code required to complete a task.
- It reduces the overhead cost and time (learning curve) of bringing onboard new developers to an existing project
- Helps keep your code clean and organized as your project grows
- The more displined you are in adhering to MVC pattern, means less time and less cost in future development
CodeIgniter is right for you if:
- You want a framework with a small footprint.
- You need exceptional performance.
- You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.
- You want a framework that requires nearly zero configuration.
- You want a framework that does not require you to use the command line.
- You want a framework that does not require you to adhere to restrictive coding rules.
- You are not interested in large-scale monolithic libraries like PEAR.
- You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).
- You eschew complexity, favoring simple solutions.
- You need clear, thorough documentation.
Now for the good stuff…
Querying Data from SQL
CodeIgniter (4 Lines of code)
$query = $this->db->get('table_name');
foreach ($query->result() as $row)
{
echo $row->title;
}
VS
PHP (LOTS OF LINES OF CODE) Using Codeigniter all the configuartion settings are automatically loaded and avaliable EVERYWHERE and ANYWHERE
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
This is just one example, to learn more about working with SQL via codeigniter
HELPERS
Toolbox of useful Code aka Collection of Functions that help simply coding such as
Dealing with Dates, Arrays, HTML, Forms, Cookies, Sessions, etc
Example Dates HELPER
//Makes all Date Helper Functions readily avaliable
$this->load->helper('name');
$bad_date = '199605';
// Should Produce: 1996-05-01
$better_date = nice_date($bad_date, 'Y-m-d');
For a complete list of CI helpers available
Libraries (Object Oriented Library of Common Tools)
Example of sending complex emails
//Load Library
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
Without Framework you would have to add third party files SUCH as PHPMailer and add Includes on top of each page, coding alot more method calls
PAGINATION LIBRARY Codeigniter
$this->load->library('pagination');
$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = 200;
$config['per_page'] = 20;
$this->pagination->initialize($config);
echo $this->pagination->create_links();
Check out the list of libraries for almost everything you could possibly need
Black Fly Aircraft coming in 2019
Real world example of unintentional consequences
Some people, best stay away from technology, rather than tell you, go see for yourself and Google “inurl:main.cgi linksys” (minus the “)….click on a few links and fulfill that inner “peeping tom” in you (don’t worry your secrets safe with me)