Jun 29, 2011

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

Solution:

$ 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


Reference:
tail-cannot-watch-varlogmessages-no

kernel-inotify-watch-limit-reached

Jun 27, 2011

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

Synfony


public function executeDownload(sfWebRequest $request)  
{  
$response = $this->getContext()->getResponse();  
$response->clearHttpHeaders();  
$response->addCacheControlHttpHeader('Cache-control','must-revalidate, post-check=0, pre-check=0');  
$response->setContentType('application/octet-stream',TRUE);      
$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
readfile(readfile('xxx.mp3'));  
return sfView::NONE;  
}

* Always dont omit the line to send the headers

Zend


$this->getResponse()->setHeader("Pragma","public");
$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-Type","audio/x-mp3");
$this->getResponse()->setHeader("Content-Disposition","attachment; filename=\"xxx.mp3\"");
$this->getResponse()->setHeader("Content-Transfer-Encoding","binary");
$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
$this->getResponse()->setBody(readfile('xxx.mp3'));

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)
->getAllIds();
//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.
Mage::getSingleton('catalog/product_action')
->updateAttributes($downloadableProductIds, $attributeData, $storeId);

Jun 5, 2011

MYSQL: Error 1062 - Duplicate key

Slave Replicate SLAVE_SKIP_COUNTER


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;
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
mysql> START SLAVE;

Jun 3, 2011