Micro How To

Very small how to article

Install Only Security Updates Using Yum

In a previous article we discussed how toinstall, remove, update and search for software packages using yum. In this post we discuss how to install only security updates using yum.


Attaching External SVN Repositories - svn:externals

The scenario:

  • You are using subversion as the version control software for your project
  • Your project depends on other projects, perhaps third party libraries
  • The other projects also use subversion as the version control software for their project

How To Set SVN_EDITOR Environment Variable To Vim

Problem: You are trying to use the command svn propedit svn:externals and you are receiving the error:

svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found

Solution: Set vim as your SVN_EDITOR

Command:

export SVN_EDITOR=vim

To permanently set this environment variable put the below line in your ~/.bash_profile file.

export SVN_EDITOR=vim

Did it solve your problem?


How To Access Action Helper In A Front Controller Plugin?

<?php
Zend_Controller_Action_HelperBroker
::getStaticHelper('helpername');
?>

For example, you can access the redirector helper from within your front controller plugin:

<?php
$redirector 
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
?>


How To Print The PHP Version In A PHP Script

Somebody recently asked me how to print the PHP version from within the PHP script. The answer is very simple and requires only two words to print the PHP version. Here is the script


<?php
echo PHP_VERSION;
?>

PHP_VERSION is a predefined constant. It contains the value of the PHP version.

A sample output is as follows.

[sudheer@localhost cli]$ php php_version.php 
5.2.6
[sudheer@localhost cli]$ 


How To Access The Request Object From Any Part Of Your Application

The request object contains the name of the module, controller, action and the request parameters. Sometimes, you might want to access the request object outside the controller or controller plugin.

For example a user on #zftalk just asked
"how can I access request object within form's method?"

The front controller instance is a singleton. This means we can get the instance of the front controller from any part of our application using the static method getInstance().


Scrolling In Firefox Is Horribly Slow

Is scrolling vertically on web pages in your Firefox horribly slow?

I encountered this issue recently on Fedora 10. Initially, I suspected the binary NVIDIA driver. But I was wrong. I found a simple solution.

Disable smooth scrolling in the Firefox preferences.

  • On the Firefox window click Edit
  • Click Preferences
  • Click Advanced tab
  • Click Use Smooth Scrolling to uncheck the checkbox
  • Click Close

Viola.


How To Round A Number To The Specified Number Of Decimal Places

The code speaks for itself.

<script language="text/javascript">
myNumber = 22/7;
//To round the myNumber to 2 number of decimal places we use the toFixed() method
rounded = myNumber.toFixed(2);
alert("My number is " + rounded);
</script>


Disabling View And Layout

If you are using MVC components of Zend Framework, you will come across situations where you will have to disable view and layout. To do so you use the viewRenderer and layout action helpers and call the setNoRenderer() and disableLayout() methods respectively.

How to disable the view?

In your controller action

<?php
$this
->_helper->viewRenderer->setNoRender(true);
?>

How to disable the layout?

In your controller action

<?php
$this
->_helper->layout->disableLayout()
?>

Did the code snippet solve your problem?


How To Reset KWallet Password

The problem: You fire a KDE application, the application requires a password to continue, the KWallet window pops up asking for its password. You try your frequently used passwords. None of them work.

This happened to me when I tried to open a password protected PDF document with Okular. I knew I never set the KWallet password on this computer.

The solution: To reset your KWallet password, delete the kwalllet directory.
Type this in your command line:

rm -rf ~/.kde/share/apps/kwallet/


Syndicate content