HowTo clear subclipse plugin for Eclipse IDE and subversion password on windows xp/vista
This method works if subclipse plugin for Eclipse is setup to use JavaHL , open cmd with administrative privileges in %APPDATA%\Subversion\auth\svn.simple , there is files with auth settings for each repository , remove the necessary , also in some cases you should clear keyring cache :
cd %APPDATA%\Subversion\auth\svn.simple C:\Users\someuser\AppData\Roaming\Subversion\auth\svn.simple>del * cd %ECLIPSE_FOLDER%\configuration\org.eclipse.core.runtime del .keyring
Don’t forget to restart eclipse .
How to get first and last day of the month with php
Using PHP’s mktime function , the last day of any given month can be expressed as the “0″ day of the next month , therefore :
$lastDayOftheMonthTimestamp = mktime(0,0,0,$currentMonthNumeric + 1,0,$currentFullYear);
Full example :
$currentTime = time(); $dateTime = getdate($currentTime); $currentFullYear = $dateTime["year"]; $currentMonthNumeric = $dateTime["mon"]; $firstDayOfTheMonth = date('Y-m-d',mktime(0,0,0,$currentMonthNumeric,1,$currentFullYear)); $lastDayOfTheMonth = date('Y-m-d',mktime(0,0,0,$currentMonthNumeric + 1,0,$currentFullYear)); echo $firstDayOfTheMonth.PHP_EOL; echo $lastDayOfTheMonth .PHP_EOL;
Result :
2009-02-01 2009-02-28
Howto make pages controller like in CakePhp with Zend_Action_Controller
CakePhp framework comes with controller class extension called PagesController , this extension serves very productive propose , it checks what actions was called and renders view template with same name .
For example if user accesses url http://micrub.info/pages/examples/ , the controller should search for view template in PagesController views directory , like app/views/pages/examples.ctp , if page isn’t found 404 headers should be returned to the browser .
This approach is very MVC oriented , person which is responsible to add new static content to a view layer doesn’t depends on programmer , he simple adds or removes a new pages without any need to have access to the businesses logic layer , working with which demands much deeper understanding of the web development field .
One of the first things that I have done when started to work with Zend Framework was to create same future within Zend Framework based project template .
In order to provide such a future , Zend_Controller_Action class was extended , magic php function __call() was overwritten in order to create proxy method which checks for existing view template and handle exceptions like :
- template is not found , return HTTP 404
- other application exception , return HTTP 500
Why is __call() function was overwritten ?
When Zend_Controller_Action extended class is dispatched and action function isn’t defined in it , php’s magic function __call() is called . Its default implementation throws Zend_controller_Action exceptions and if front controller bootstrapped not to throw exceptions )( $front->throwExceptions(false); ), ErrorController is set , a proper HTTP statuses can be returned to the browser for PagesController exceptions .
require_once 'Zend/Controller/Action.php'; class PagesController extends Zend_Controller_Action { /** * Checks if view template file is found in one of script paths for this controller . */ protected function checkScript($name) { $paths = $this->view->getScriptPaths(); foreach ($paths as $dir) { $path2script = $dir . str_ireplace('/',DIRECTORY_SEPARATOR,$name); <strong>// for some reason , without this one action name isn't compatible on winXP </strong> if (is_readable($path2script)) { return true; } } return false; } /** * Proxy for undefined methods. Default behavior is to throw an * exception on undefined methods, however this function was * overridden to provide run-time dispatching. * * @param string $methodName * @param array $args */ public function __call($methodName, $args) { if ('Action' == substr($methodName, -6)) { // Zend_Controller_actions methods name must be formatted like this "exampleAction". $action = substr($methodName, 0, strlen($methodName) - 6); $script = $this->getViewScript($action); if(!$this->checkScript($script)){ throw new Zend_Controller_Action_Exception(sprintf('Pages Action script "%s" does not exist and was not trapped in __call()', $script), 404); } }else{ throw new Zend_Controller_Action_Exception(sprintf('Illegal action name "%s" was called and not trapped in __call()', $action), 500); } } }
HowTo: set sun’s java enabled on Ubuntu
In order to enable sun’s java after installation through synaptic check list of ubuntu’s java alternatives :
1 | sudo update-java-alternatives -l |
You should get something like this :
1 2 | java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun java-gcj 1042 /usr/lib/jvm/java-gcj |
Now enable your preferred java alternative :
1 | sudo update-java-alternatives -s java-1.5.0-sun |
Ensure that it’s enabled :
1 2 3 4 | :~$ java -version java version "1.5.0_16" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02) Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing) |