Overview of PHP Intelligencer 2.2
Short overview of 2.2 Intelligencer version enhancements.
New features
Last in Queue
“Last in Queue” behavior is basically an attempt to fight with very aggressive autoloaders (like symfony has) which aim to be the last in the queue by re-registering itself. “Last in Queue” behavior means that the manager will register itself once again if it’s not the last in the queue. You will have an ability:
* to specify number of attempts
* whether to do it only once or every time a new class is loaded
Two circles
“Two circles” behavior is devised to fight with unnecessary intelligencer cache invalidations and scanning. The first circle: go through all intelligencers; if the intelligencer is cacheable, load from cache. If the first attempt is unsuccessful the second circle takes place: go through all the cacheable intelligencers, invalidate cache and ask to load the class once again.
Cache for Templates
Templates, the same as Rules, will have an ability to cache the results. The good news is that templates will cache and invalidate particular classes not a list of them.
Persistent Cache improvements
Persistent cache will have an option to create all the subdirs that are missing.
This is a preliminary plan. The future updates can be found in Overview of Intelligencer 2.2
PHP Intelligencer released – manage your autoloading
Intelligencer was released couple of days ago and hosted on google code.
Why should you use Intelligencer?
- You want to scan the contents of files and find all classes inside them. The framework provides the powerful instructions for searching with the cache support.
- You want to load the files according to the templates (e.g. Zend autoloading approach or Java class naming conventions)
- You want autoloaders to be prioritized
- You want your code to be independent from the locations of the sources
This framework is designed to prioritize and manage your class loadings. There are two very powerful built-in itnelligencers: rules and templates. They are based on two different loading ideas. Basically, if you want the intelligencer to scan the files for the classes, use the rules. If you are able to create a path to the class without scanning the files (like Zend autoloading approach or Java naming conventions)
I will give you a short example of the code. The example below demonstrates how Rules Intelligencer works:
// Every time an attempt to load the class is made you want the
// intelligencer to check the cache and try to load from it.
// If an attempt is unsuccessful, the cache should be invalidated and #
// the files should be rescanned.
itManager::getInstance()
->setIntelligencerAndCreate(new itRulesIntelligencer())
->setCache(new itPersistentCache('cache.php'))
->setRulesAndCreate(new itComplexRules())
->setPrefix(dirname(__FILE__).'/drapeko/home/')
->plusDir('JustClass')
->getIntelligencer()
->control();
I hope you enjoyed it. Please visit official page http://code.google.com/p/intelligencer and find documentation and many useful examples.
How to organize Version Control for database development
One lite practicable idea for organizing version control tree for database development is presented below:
The example of the svn tree is presented below:
/svn
/features
/user
/enable
create_user.sql
create_user_permissions.sql
pkg_user.pkb
pkg_user.pks
/disable
drop_user.sql
drop_user_permissions.sql
/comments
...
/scripts
create_user_all.php
drop_user_all.php
recreate_database.php
The root directory consists of “features” and “scripts” dirs:
- Features – Logical functional units; a list of features we have (for example, a user or comments)
- Each feature can be divided into “enable” and “disable” SQL scripts
- Each enable/disable dir consists of the list of SQL scripts
- Each feature can be divided into “enable” and “disable” SQL scripts
- Scripts – List of scripts (php/perl/bash etc) that aggregate the features files into one sql file. The output of the script is the SQL file that contains all the SQL statements you need to enable/disable the feature.
DB developers work result is a list of SQL and pl/bash scripts for different variations (e.g. creates for empty db, patches et.
/features
/user
/enable
create_user.sql
create_user_permissions.sql
pkg_user.pkb
pkg_user.pks
/disable
drop_user.sql
drop_user_permissions.sql
/comments
…
/scripts
create_user_all.php
drop_user_all.php
recreate_database.php
PHP, Create filesystem hierarchical array
You have a straightforward list of directories. Your task is to create an hierarchical array of these directories. How can you do it? The simplest way is presented below.
You have an array of directories (straightforward list of directories):
$array = array( '/home/drapeko/var', '/home/drapeko/var/y', '/home/drapeko', '/home', '/var/libexec' );
And you would like to transform this array to hierarchy of directories:
$array = array (
'home' => array (
'drapeko' => array (
'var' => array (
'y' => array()
)
)
),
'var' => array(
'libexec' => array()
)
);
How can you do it?
First of all the below function will help us.
/**
* This function converts real filesystem path to the string array representation.
*
* for example,
* '/home/drapeko/var/y will be converted to ['home']['drapeko']['var']['y']
*
*
* @param $path realpath of the directory
* @return string string array representation of the path
*/
function pathToArrayStr($path) {
$res_path = str_replace(
array(':/', ':\\', '/', '\\', DIRECTORY_SEPARATOR), '/', $path
);
// if the first or last symbol is '/' delete it (e.g. for linux)
$res_path = preg_replace(array("/^\//", "/\/$/"), '', $res_path);
// create string
$res_path = '[\''.str_replace('/', '\'][\'', $res_path).'\']';
return $res_path;
}
It simply converts the real path of the file to array string representation.
How can you use this function? I know it looks a little bit confusing. But it’s quite simple. Consider the example below:
$result = array();
$check = array();
foreach($array as $val) {
$str = pathToArrayStr($val);
foreach($check as $ck) {
if (strpos($ck, $str) !== false) {
continue 2;
}
}
$check[] = $str;
eval('$result'.$str.' = array();');
}
print_r($result);
Heh, how do you find it? This approach has helped me very much. I hope you will find it useful. :)
PHP Intelligencer, tiny autoload framework
Several months ago I wrote an article that included several interesting examples of __autoload function, some autoloading approaches and a tiny script that is able find interfaces/classes and generate arrays of associations among these classes/interfaces, their locations and extended/included classes/interfaces.
http://wp.drapeko.com/2009/03/28/autoloading-in-php/
I widely use this script and I’ve found it really convenient. I don’t have to think anymore of how to store my classes, what is the structure of the project etc. All this work is done by this script.
But… I have to launch it manually.
I’ve decided to go further and began to create a tiny framework called Intelligencer. This framework will extend functionality of the autoload generator script.
Some Intelligencers features:
- It is very tiny and does not depend on other frameworks and external libraries. It’s very easy to integrate it.
- It has an ability to store and control inheritance associations and relations between classes/interfaces and their locations.
- If something has changed Intelligencer will automatically regenerate (if necessary) lists of associations. It’s really very useful in the development stage.
- Intelligencer has a huge number of config settings. It’s flexible.
- Intelligencer supports environments. You can easily create your custom environments and switch between them.
- You can create several Intelligencers that will be responsible for different parts of your application.
- You can work with Intelligencer both on config level and API level.
If you use it, it will do all work for you. It’s an open source. Location - sourceforge.
The first release will come very soon.
Google Adsense Appeal letter
I began to use Google Adsense two months ago. One month ago my account was banned. Unfortunately, the first appeal was unsuccessful and I did not get any explanations. I don’t know the exact reason why I was banned. It makes me laugh but the number of ‘earned’ money was a little bit more than 10 dollars. But I’m really very interested in good relations with Google, that’s why several days ago I appealed for the second time.
I sent a letter below.
Dear Sir/Madam Appeal
I am writing for the second time regarding these misunderstanding. Your
previous letter made me very unhappy and I didn’t expect such a decision to
be made. I am indeed very interested in cooperation with Google and I am
convinced that there was a misunderstanding.
I claim that I have followed all the terms and conditions and I have not
broken any rules/ In particular, I have not place any forbidden content, I
didn’t click on the banners and I have not incited anybody to click on
them. What if somebody did it on purpose so as to deprive me? In that case
I have absolutely no protection against somebody’s bad intentions. My
account has been active only for a week. Is the statistics gathered during
such a short period of time sufficient to conclude this is indeed me who
tried to cheat Google?
I’d hate to lose the opportunity to work with Google and with AdSense in
particular. I have no intention to create other accounts under a different
name. I am not interested in illegal actions or unfair profit. I am ready
to uphold my rights and prove that. I would really want to have my account
annulled so as to start building the long-term and trustworthy relations
with Google.
I appeal to Google to reconsider the matter.
I look forward to hearing from you,
Yours faithfully,
Roman
Have you been in a similar situations? What is the result?
P.S. I decided to be independent from one particular adv company. I will try to implement one interesting idea very soon in terms of advertisement. Stay in touch. :)
Connect remotely to Unix/Linux using SSH with X-Windows support
Situation: you would like to connect remotely using SSH protocol to Linux/Unix OS from Windows environment and to run remotely a program that uses X-Windows (e.g. Eclipse) .
How can you do it?
- Download SSH client. The most popular is free PuTTY client (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
- Secondly download and install X-Windows server for your Windows environment. I suggest to use xming (http://sourceforge.net/projects/xming). xming installation tips are available here: http://gears.aset.psu.edu/hpc/guides/xming/
- Open Putty, go to Connection->SSH->X11 and enable X11 forwarding
- Connect to the remote host and launch the program

Oracle Advanced PL/SQL Developer Certified Professional 1z0-146
I took Oracle beta 1z1-146 exam in the end of January, 2009. Several days ago I checked prometric.com and discovered that this exam was passed. Now I’m one of the first Oracle Advanced PL/SQL Developer Certified Professional all over the world!!! it’s my second OCP :)

I did not find any dumps, any mock exams or any sample questions, while I was preparing for this exam. I used only these http://rapidshare.com/files/127182353/D52601GC10_netbks.com.rar official Oracle preparation slides (remember to switch comments – it’s a book). 1z1-146 exam was really tough. 165 questions in 180 minutes. Production exam requirements: time – 90 min, questions – 68. There is a difference, is not it?
If you are going to take one of Oracle beta exams and you have time and ability to stay calm, you are not interested to economize some money I suggest waiting for a production one. Pluses: 1) You will probably get results two weeks earlier then beta-takers 2) More time, less questions 3) It’s not so stressful 4) The probability to pass is much higher.
Do you agree? What is your experience in taking certification exams? :)
How to install Rational Rose on Windows XP Home Edition
How to install Rational Rose on Windows XP Home Edition?
If you are trying to do it, you probably get the following message:
“We are attempting to install on an unsupported operating system. We recommend that you install on a supported operating system. See your Rational product’s Release Notes for a complete list of supported operating systems and service packs.”
Fortunately, this restriction is artificial one. You can turn it off.
- Start -> Run -> cmd
- Go to the directory where Rational is installed (example, cd C:/Program Files/Rational)
- Find Rose.msi file. Usually it’s located in the SETUP folder. It can be called 1041_Rose.msi or something very similar.
- Type msiexec.exe /l*vx inst.log /i Rose.msi /c DISABLE_PLATFORM_BLOCKS=1
Looking for a new Job, interesting questions
A month ago I relocated to London. And now I’m looking for a job here. The process is quite boring. Agents, sites, applications, cover letters, CVs. And.. unfortunately no visible result yet. But sometimes potential employers ask to do interesting tasks. For example, one of them asked to answer the questions below:
| What is your favourite | What do you *think* of |
|
|
My version could be found below.