Dec 19, 2011

Nagios: SMS Notification

Dec 15, 2011

Mysql: Tuning Your Mysql Server

This post is jut the link where I get some tips on how to tune my mysql server and some important parameter need to consider in tuning your mysql server. I'm not sure yet if this really work because I did't try to hold a large traffic to mysql server. But this also work for me in small data.

Dec 11, 2011

Web Server: Tuning Apache Server

Nov 29, 2011

Linux: Arch dependent binaries in noarch package

create RPM

The error was encounter where I trying to create RPM that contains binary files. This files was the binary files from nagios plugin. Solution Add the data below on the upper section of your specs file

%define _binaries_in_noarch_packages_terminate_build 0
Reference: fedora-devel

Nov 25, 2011

Magento: Overriding Model

<Globe_Review before="Mage_Review">Globe_Review</Globe_Review>

Magento overriding core files blocks models resources controllers

Nov 16, 2011

Magento: Overriding Product Controller.

Edit you Package/Module/etc/config.xml

<?xml version="1.0"?>
... Your Other config here ....
<Package_Catalog before="Mage_Catalog">Package_Catalog</Package_Catalog>

Now your controller already ready.

class Package_Catalog_ProductController extends Mage_Catalog_ProductController
public function viewAction(){
echo __METHOD__;

Try to access:

Nov 15, 2011

Magento: Custom category Field.

Add one row to eav_attribute

INSERT INTO `fl_mage`.`eav_attribute`
`attribute_id` =0, -- AUto
`attribute_model`=NULL ,
`backend_model`=NULL ,
`backend_table`=NULL ,
`frontend_model` =NULL,
`frontend_input` ='text',
`frontend_label`='Url' ,
`frontend_class`=NULL ,
`source_model`=NULL ,
`is_required` '0',
`is_user_defined`='0' ,
`default_value` =NULL,
`is_unique` ='0',

Add other one row to eav_entity_attribute

INSERT INTO `fl_mage`.`eav_entity_attribute`
`entity_attribute_id` =NULL,
`entity_type_id` =3,
`attribute_set_id` =3,
`attribute_group_id` =3,
`attribute_id`=163, --Must be same to eav_attribute

Finally one more row to catalog_eav_attribute

INSERT INTO `catalog_eav_attribute`

That's simple as is, you can find the charm there. Happy reading.

TIPS: If you are confuse try to look the eav_attribute and compare the data on your admin category page.


Sep 26, 2011

Java Heap Parameters


Sep 21, 2011

Magento: How to check if has access to page?




$adminSession = Mage::getSingleton('admin/session');
// Checks the permission for managing of products

// Checks the permission for the order creation in Magento Admin

// Checks the permission for the order view in Magento Admin

Defining acl resources custom and admin menu

Sep 19, 2011

Magento: Get parent product for configurable product.

$_product = Mage::getModel('catalog/product')->load(YOUR_SIMPLE_PRODUCT_ID);
$parentIdArray = $_product->loadParentProductIds()->getData('parent_product_ids');

Get associated configurable product

* Load product by product id
$product = Mage::getModel('catalog/product')->(YOUR_PRODUCT_ID);

* Get child products id (only ids)
$childIds = Mage::getModel('catalog/product_type_configurable')

* Get children products (all associated children products data)
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);


Linux; VI reference

Nice One

Sep 18, 2011

Mageno: Create Empty Template.

In your controller action issued this command.

$this->loadLayout(false); // Issue this to disable loading of your layout
$this->getResponse()->setHeader('Content-Type','text/xml'); // Set this depending on you file content type

* .... Put you other code here
$this->renderLayout(); // Finally render your layout

For complete details see also the source Custom controller actions result in blank template

Linux: How to create Public key using private key

$ ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/

Linux: Find file by size

find -type f -size +200 -exec gzip -q{}\;
find PATH -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

Find files larger than size x

Sep 14, 2011

Symfony: Propel Custom Join

In Didn't try this yet. May I update this page after I test in my self too. Thsi will serve a reference for the mentime.


Symfony: Propel Custom Query

Here's sample Code

$connection = Propel::getConnection();
$query = 'SELECT MAX(?) AS max FROM ?';
$statement = $connection->prepareStatement($query);
$statement->setString(1, ArticlePeer::CREATED_AT);
$statement->setString(2, ArticlePeer::TABLE_NAME);
$resultset = $statement->executeQuery();
$max = $resultset->getInt('max')


Magento models.



Aug 25, 2011

Magento: GRID Important functions

Adding Edit link on a row

protected function _prepareColumns()
// .... Some other code here
'header' => Mage::helper('catalog')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
'caption' => Mage::helper('catalog')->__('Edit'),
'url' => array(
'field' => 'id'
'filter' => false,
'sortable' => false,
'index' => 'stores',

Removing the Pager/Filter

Normally this is default on the magento grid already.

public function __construct()
$this->setFilterVisibility(false); // Remove Seach filtering
$this->setPagerVisibility(false); // Remove Pager of the grid

Adding Mass proccess on the Grid

protected function _prepareMassaction()
$this->getMassactionBlock()->addItem('delete', array(
'label'=> Mage::helper('download')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('download')->__('Are you sure?')

$this->getMassactionBlock()->addItem('status', array(
'label'=> Mage::helper('download')->__('Change status'),
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
'additional' => array(
'visibility' => array(
'name' => 'status',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('download')->__('Status'),
'values' => array("x1" => "Yow", "x2"=>"secret")

Aug 23, 2011

Linux: Get SSL certificate

openssl s_client -connect


Magento: Exporting button on your data in a grid.

Adding Export button

In your Grid class(Package_Module_Block_Grid), find the method named _prepareColumns and add the code below.
$this->addExportType('*/*/exportCsv', Mage::helper('download')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('download')->__('XML'));

Implement Export method/Action

In your action controller class (Package_Module_Adminhtml_DownloadController) create two methods.

class Globe_Download_Adminhtml_DownloadController extends Mage_Adminhtml_Controller_Action{

public function exportXmlAction() {
public function exportCvsAction() {
protected function _prepareDownloadResponse($fileName, $content, $contentType = 'application/octet-stream', $contentLength = null)
$session = Mage::getSingleton('admin/session');
if ($session->isFirstPageAfterLogin()) {
return $this;
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
->setHeader('Content-Disposition', 'attachment; filename=' . $fileName)
->setHeader('Last-Modified', date('r'))
->sendHeaders(); // Need to call this method after all you send the Headers.
if (!is_null($content)) {
return $this;


Thanks to the other author for sharing what they knows about magento development. In this post I only put the part of the code that I understand or I use it in my application.


Zend: Join Statement and example

Aug 21, 2011

Magento: Add custom renderer for a custom column grid

Good Example Here:

Aug 7, 2011

Linix: Create/Extract tar file

Create tar.gz file

tar -cvzf mytarfile.tar.gz <directory>

this means:
-c = create new archive
-v = be verbose
-z = compress using gzip
-f = filename to create for the new archive

Extract tar.gz file

tar -xzf mytarfile.tar.gz

Create tar.bz2 file

tar -cvjf mytarfile.tar.gz <directory>

this means:
-c = create new archive
-v = be verbose
-j = compress using bzip2
-f = filename to create for the new archive

Extract tar.bz2 file

tar -xpjf file.tar.bz2

Aug 3, 2011

Linux: perl-Net-SSLeay dependency error when installing Memcached with yum

Needs to update the packages.
Get data packages here depends on your system.

How to install reviewboard in centOS?

Requirements: Database:
MySQL v5.0.31 or newer
Web Server:
Apache + mod_python or fastcgi lighttpd + fastcgi
Start reviewboard Installation

TO BE CONTINUED: Thanks for visiting

Magento: Custom admin module.


Jul 28, 2011

Magento: Forms prototype javascript validation

Custom Form Validation
Adding Javascript validation to your own forms is extremely simple. First, you need to create a Form (form.js) object to represent your form.

Acknowledge to the Original Poster.

Jul 26, 2011

Email: Sendmail puts exclamation marks(!) in a body/content of email.

I past day I encountering the error on email message. In some part on the email has added special character !.

Reason Causing the Case:
Ask check on the blog one blogger I found that the email have only limit of character every line, and this is only 1000. In every after 1000 character in one line this will happen, it added exclamation mark(!).

You must need to break the line before reached the 1000 character length.

As acknowledge to the Author.

Jul 7, 2011

Jul 6, 2011

Symfony: Create project

php symfony/data/bin/symfony generate:project PROJECT_NAME --orm=Propel

php symfony configure:database "mysql:host=localhost;dbname=DB_NAME" DB_USER DB_PASS

php symfony generate:app frontend

symfony propel:generate-module --with-show --non-verbose-templates frontend registration Registration

Jun 29, 2011

tail: cannot watch `/var/log/messages': No space left on device


$ sudo su
# sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 8192
# sysctl -w fs.inotify.max_user_watches=16384
fs.inotify.max_user_watches = 16384

Im not sure why we need to higher the



Jun 27, 2011

Symfony/Zend: Download Attach File in the Action Controller.


public function executeDownload(sfWebRequest $request)  
$response = $this->getContext()->getResponse();  
$response->addCacheControlHttpHeader('Cache-control','must-revalidate, post-check=0, pre-check=0');  
$response->setHttpHeader('Content-Transfer-Encoding', 'binary', TRUE);  
$response->setHttpHeader('Content-Disposition','attachment; filename='.$request->getParameter('filename'), TRUE);  
$response->sendHttpHeaders(); // Need to send the HttpHeaders to handle a large file size
return sfView::NONE;  

* Always dont omit the line to send the headers


$this->getResponse()->setHeader("Expires", "0");
$this->getResponse()->setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
$this->getResponse()->setHeader("Cache-Control","private", false);
$this->getResponse()->setHeader("Content-Disposition","attachment; filename=\"xxx.mp3\"");
$this->getResponse()->setHeader("Content-Length", filesize('xxx.mp3'));
$this->getResponse()->setHeader("Content-Description","File Transfer");
$this->getResponse()->sendHeaders(); // Need to send the HttpHeaders to handle a large file size

Jun 14, 2011

Magento: Saving Attribute

Magento: Saving Attribute

$_product->getResource()->saveAttribute($_product, 'vas_rating');

For bulk UPDATE

//Get the product Ids you want to affect. For me it was all downloadable products
$downloadableProductIds = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE)
//Now create an array of attribute_code => values
$attributeData = array('my_attribute_code' => 'my_attribute_value);
//Set the store to affect. I used admin to change all default values
$storeId = 0; //A.K.A Admin
//Now Update the attribute(s) for the given products.
->updateAttributes($downloadableProductIds, $attributeData, $storeId);

Jun 5, 2011

MYSQL: Error 1062 - Duplicate key


In some reason this mostly happened when your slave server already out of synchronization to the master server.

The exercise, we need to skip that error Duplicate key and can be done by adding the line in the mysql config my.cnf

slave-skip-errors = 1062

If you encounter this kind of error. Just easy, you need only to skip the counter by by 1 until you fix it.

mysql> SLAVE STOP;

Jun 3, 2011

May 31, 2011

May 24, 2011

Search and replace in multiple files.

  • find app/code/local/Flux/Catalog/ -name "*.php" -print | xargs sed -i 's/Mage_Catalog/Flux_Catalog/g'

  • perl -w -i -p -e "s/search_text/replace_text/g" filename

  • perl -w -i -p -e "s/search_text/replace_text/g" *.php

  • find /www_root -name "*.php"|xargs perl -w -i -p -e "s/Perl is good/perl is great/g"

Linux User Expiration

Check password expiration date

[winsftp@FRNAPROD ~]$ chage -l username
Sample Output:
[winsftp@FRNAPROD ~]$ chage -l fluxsftp
Last password change : Jul 07, 2012
Password expires : Aug 06, 2012 Password inactive : never
Account expires : never
Minimum number of days between password change : 30
Maximum number of days between password change : 30
Number of days of warning before password expires : 7

May 19, 2011

HTACCESS: Rewrite all HTTP request to HTTPS

RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]


May 18, 2011

JS Prototype - How to access value in FORM input text?

For example, if you have an input named "company" in a form with an ID "contact":

var form = $('contact');
var input = form['company'];


// but, the preferred call is:
$(input).getValue(); // we used the $() method so the node gets extended

// you can also use the shortcut

Mar 22, 2011

Simple CSS TAB

border-radius: 5px 5px 0 0;
-moz-border-radius: 15px 5px 0 0;
-webkit-border-top-left-radius: 15px;
-webkit-border-top-right-radius: 5px

Orginal page

Feb 2, 2011

Java - Absolute path

Tricks here is first create a temporary and get the absolute path.

package com.mkyong.file;


public class GetTempFilePathExample
public static void main(String[] args)
//create a temp file
File temp = File.createTempFile("temp-file-name", ".tmp");

System.out.println("Temp file : " + temp.getAbsolutePath());

//Get tempropary file path
String absolutePath = temp.getAbsolutePath();
String tempFilePath = absolutePath.

System.out.println("Temp file path : " + tempFilePath);
}catch(IOException e){

Jan 25, 2011

Java Simple Code

PHp var_dump for Java Equivalent

import java.lang.reflect.*;
//o Object..
Field[] fields = o.getClass().getDeclaredFields();
for (int i = 1; i < fields.length; i++
try {
System.out.println(fields[i].getName() + " - " + fields[i].get(o));
} catch (java.lang.IllegalAccessException e) {

Jan 23, 2011

Setting Up WikiPedia


Extract the file.

Set the config dir to writable.

Access the site

Configure the database setting

Set to private data

edit the includes/DefaultSetting.php

$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = true;
$wgGroupPermissions['*']['createtalk'] = true;
$wgGroupPermissions['*']['writeapi'] = true;


$wgGroupPermissions['user']['createaccount'] = true;
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['edit'] = true;
$wgGroupPermissions['user']['createpage'] = true;
$wgGroupPermissions['user']['createtalk'] = true;
$wgGroupPermissions['user']['writeapi'] = true;