Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Skype and Gnome-Shell

I am fascinated by new Gnome 3. Not only let's say foreground is interesting but also what is behind. The whole concept of desktop, application oriented GUI, also gnome-shell seems to be very useful. Everything looks very easy.
One of nice feature is to set global presence of user. I think that this idea came up firstly with Ubuntu or previous version of GNOME. In fact I have never used it until now. When you switch your presence to Busy, whole system instantly will stop bothering you with some notification. 
Signal about presence  is emitted by SessionManager via DBus mechanism. This is another smart idea in GNOME. Of course programs need to watch for this signal. Empathy (or telepathy), Pidgin are prepared to observe presence signal. To be completely happy I have to force Skype to observe presence signal.
Cause extensions for Gnome-shell are written in JavaScript language (yes, it is the same JavaScript which is used by web developers) so writing new one is not so difficult. This short extension for gnome-shell, link presence signals from SessionManager with Skype.

How to install?

Simply download extension:
git clone https://github.com/MrTheodor/gnome-shell-ext-SkypeNotification.git

mkdir -p ~/.local/share/gnome-shell/extensions
cp -r gnome-shell-ext-SkypeNotification/SkypeNotification@krajniak.info ~/.local/share/gnome-shell/extensions
next restart gnome-shell by pressing Alt+F2 and typing r
Reposistory for plugin: https://github.com/MrTheodor/gnome-shell-ext-SkypeNotification

Zend Framework, Existst Validator


I've started to use Zend Framework in one of my web project. And here is existst Validator. I've noticed that ZF doesn't have that basic validator as exists.



This validator check if value existst in database. Two parametrs have to be given in constructor:


  • tableName - name of model class in which validator check value

  • fieldName - field name to compare in specified table


Validator use model class insted of database table name.



/**
* @author: teodor
* @date: 2008-07-04
* @description: PHP Class
*/

class Debra_Validate_Exists extends Zend_Validate_Abstract {
const MSG_EXISTS = "msg_exists";

protected $_messageTemplates = array(
self::MSG_EXISTS => "'%value%' already exists"
);

public $tableName;
public $fieldName;
/**
* Create Exists Validator. Check if spec value exists in database
*
* @param string $tableName
* @param string $fieldName
*/
public function __construct($tableName,$fieldName) {
$this->tableName = $tableName;
$this->fieldName = $fieldName;
}
/**
* Check if $value is valid
*
* @param unknown_type $value
* @return unknown
*/
public function isValid($value) {
$this->_setValue($value);
$tableName = new $this->tableName;
$select = $tableName->select()->where($this->fieldName . ' = ?',$value);
$rows = $tableName->fetchRow($select);
if(!empty($rows)) {
$this->_error();
return false;
}
return true;
}

}