Pingdom’s HTTP Custom Monitoring

Posted November 4th, 2010 in Database, Hosting, Internet, Linux, Operating Systems, PHP, Programming, Technology by Louie Miranda

Pingdom is a great company that focuses on your server’s health and I’ve been using them.

Then I found this excellent PHP script that Jon Stacey wrote on his blog.

pingdom-core.php

This is my core services check. It makes sure that web services and MySQL are operational. Simply configure the script with the username and password of a MySQL database. If the script cannot make a connection to the database server, then a ‘MYSQL DOWN’ status will be returned to Pingdom. Of course, if the script doesn’t respond at all, then the web service is down and Pingdom will report a down status.

pingdom-server.php

This script is intended to be an early warning system. It will raise the alarm if something looks out of the ordinary so that I can be prepared for a possible service failure. The following server vitals are checked: swap usage, hard drive usage, and cpu usage. If any one of these goes beyond the preset thresholds, a down status will be returned to Pingdom.

You might be thinking that checks like these could be done with a monitoring script on the server without using Pingdom at all, and there is merit to that argument. However, if you run out of memory and your system comes crashing to a halt, that probably means that services like email, which you would have used to alert yourself to the problem, would no longer be working. By performing these checks remotely, you can sleep a little easier. Plus, Pingdom will generate nifty looking graphs, and I like graphs.

pingdom.php –Added on 12/4/2009–

This script is a combination of pingdom-core.php and pingdom-server.php if you’re using the free acount

You can check his website for all the updates at http://jonsview.com/how-i-use-pingdoms-http-custom-feature.

CakePHP Fulltext Search with Pagination

Posted October 28th, 2010 in CakePHP, Database, MySQL, PHP, Programming by Louie Miranda

This is a working code that I was able to implement for my e-commerce application that uses cakephp full text search with pagination.

<?php
$this->paginate['Publication']['conditions'] = "MATCH(Publication.Code, Publication.Name, Publication.Language) AGAINST ('".$input."' IN BOOLEAN MODE)";
$this->paginate['Publication']['fields'] = "*, MATCH(Publication.Code, Publication.Name, Publication.Language) AGAINST ('".$input."' IN BOOLEAN MODE) AS score";
$this->paginate['Publication']['order'] = "score DESC";
$results = $this->paginate('Publication');
?>

Please make sure that you are using MyISAM on MySQL to fully implement this and you where able to set the full-text capability of the table.

I tried CakePHP Search Plugin

Posted October 28th, 2010 in CakePHP, Database, MySQL, PHP, Programming, Projects by Louie Miranda

So, I tried CakePHP Search Plugin on my current project that I am creating for an e-commerce website.

The search plugin is an easy way to include search into your application. Using this plugin you will able to have paginable search in any controller. Plugin support simple methods to search inside models using strict and non-strict comparing, but also allows you to implement any complex type of searching.

I’ve search my products table and id use the following types parameter.

  • like, This type of search used when you need to search using ‘LIKE’ sql keyword.
  • value, This type of search very usefull when you need exact compare. So if you have select box in your view as a filter than you definetely should use value type.

Overall, it is a great plugin. Although, it did not fit my current requirements for now. :( .  But, I will definitely use it in my future projects.

Have a look here: http://cakedc.com/downloads/view/cakephp_search_plugin

CakePHP Self Adjusting Credit Card Year

Posted October 18th, 2010 in CakePHP, PHP, Programming by Louie Miranda

When I used to program on PEAR, I’ve used the following code to auto-generate succeeding years.

$form->addElement('date', 'CCexpiry', 'Credit Card Expiration',
			  array('format' => 'F-Y',
					'minYear' => date('Y'),
					'maxYear' => date('Y') + 10));

Now, when I used CakePHP (1.2/1.3). They have a similar approach that we can all use.

<?php echo $this->Form->input('cc_expy',
              array('div' => false, 'label' => false, 'type' => 'date',
              'maxYear' => date('Y', strtotime('+ 7 years')),
              'minYear' => date('Y'),
              'dateFormat' => 'Y',
              'default' => date('Y'),
              'orderYear' => 'asc'
              )); ?>

CakePHP: Validate dependent field (select dropdown + input field)

Posted July 15th, 2010 in CakePHP, PHP, Programming, Projects by Louie Miranda

Earlier this week, I was working on a project where I needed to validate two dependent fields.

< ?php echo input('office', array('type' => 'select', 'options' => $nd[0])); ?>
< ?php echo input('office_other', array('maxlength' => '255', 'size' => '35', 'label' => 'Other Office')); ?>

The “office” field is a select (drop down box) from my data array(). What I needed is to be able to add another data from a field and name it as “office_other” where it would initially capture and re-list again new offices if it does not exist.

Continue Reading »

Two of my favorite Eclipse Plugins

Posted April 16th, 2010 in PHP, Programming, Technology by Louie Miranda

Just want to share my two favorite Eclipse Plugin.

  1. AnyEdit tools plugin for Eclipse
  2. FileSync plugin for Eclipse

All made by Andrei Loskutov

Continue Reading »

A code to deeply remove multiple quote’s (\\\\’) and make it just a single quote ‘ and so on

Posted April 15th, 2010 in PHP, Programming by Louie Miranda

The PHP string function “stripslashes” only remove’s a certain “\” on a string. Here’s a good code I found to deeply remove multiple \\\\\ on a string.

Continue Reading »

Add a file extension to vim syntax highlighting

Posted December 4th, 2009 in Linux, Operating Systems, PHP, Programming by Louie Miranda

I am trying to edit my template files containing *.ctp and on vim, you usually won’t see any syntax highlighting if it is not a known file extension.

So, to activate it for my *.ctp templates. Just add this on your ~/.vimrc file

:syntax on
:filetype on
:au BufNewFile,BufRead *.ctp set filetype=xml

Save and re-edit your *.ctp file.

PHP Adding leading zero's

Posted August 11th, 2009 in PHP, Programming by Louie Miranda

My additional notes.

1
2
sprintf("%02d",$data['arraydate']['F']))
sprintf or str_pad

Found a very neat PHP File Upload Progress Bar/Meter

Posted April 2nd, 2009 in PHP, Programming, Projects, Technology by Louie Miranda

I’ve been looking for a good PHP File Upload Progress Bar/Meter on the web and found this very neat app. I am going to link it here for future reference.

http://www.johnboy.com/about-us/news/a-useful-php-file-upload-progress-meter

Continue Reading »