Archive for the ‘Programming’ Category

Update all records in a MongoDB collection

Wednesday, May 16th, 2012

One way to fast update all records in a MongoDB collection is to send an update with multi flag true. Example:

db.my_collection.update({},{ $set: { "Price" : 100 } }, false, true );

Get the current module, controller and action name in Zend Framework view

Thursday, April 12th, 2012

I use below script to show current module, controller, action name in Zend view.

$request = Zend_Controller_Front::getInstance()->getRequest();
echo 'Module: '.$request->getModuleName().' ';
echo 'Controller: '.$request->getControllerName().' ';
echo 'Action: '.$request->getActionName().' ';

List open ports on your machine

Tuesday, March 6th, 2012

To show which processes are listening to which ports on a Linux machine you can use:

netstat -atp | grep -i "listen"

On Mac OS X you can use:

lsof -i | grep -i "listen" 

Disabling the Laptop TouchPad in Linux

Friday, May 20th, 2011

If you have attached an external mouse to your laptop, you may not need touchpad which may be accidentally touch. I’ve made a short script to disable and enable the touchpad.
1: Disabling the TouchPad

#!/bin/sh
dev=`xinput --list | grep PS/2 | grep Generic | cut -f2-2 | cut -c 4-10`
export DISPLAY=:0
xinput set-int-prop $dev "Device Enabled" 8 0
echo "Device id=$dev has been disabled"

2: Enabling the TouchPad

#!/bin/sh
dev=`xinput --list | grep PS/2 | grep Generic | cut -f2-2 | cut -c 4-10`
export DISPLAY=:0
xinput set-int-prop $dev "Device Enabled" 8 1
echo "Device id=$dev has been enabled"