Happy New Year! 2012

Posted January 2nd, 2012 in Personal by Louie Miranda

Yahoo! Happy New Year!

Batch copy then rename multiple files on linux

Posted December 29th, 2011 in Linux, Operating Systems by Louie Miranda

You can use this script to rename multiple files on linux.

for i in us_*;
do cp $i `echo $i|sed ‘s/us_/nz_/g`;
done

The first line will loop to your files matching us_*. Then it will copy the listed files, piping it to sed to do a quick replacement from us_* to uk_*.

Hope this helps :)

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'
              )); ?>

Free Telephone Calls from Gmail

Posted August 26th, 2010 in News, Technology by Louie Miranda

Gmail voice and video chat makes it easy to stay in touch with friends and family using your computer’s microphone and speakers. But until now, this required both people to be at their computers, signed into Gmail at the same time. Given that most of us don’t spend all day in front of our computers, we thought, “wouldn’t it be nice if you could call people directly on their phones?”

Starting today, you can call any phone right from Gmail.

Continue Reading »

Happy Birthday Debian

Posted August 16th, 2010 in Linux, Operating Systems by Louie Miranda

Happy Birthday Debian! My favorite flavor in the whole wide world! :)

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 »

Let the change start within

Posted June 30th, 2010 in Uncategorized by Louie Miranda

A few hours from now the Filipino people will have a new president. May he guide the people and be truthful to his words. Goodluck!