Seva Lapsha at Work

Seva Lapsha working as Java/PHP Developer

Archive for the ‘web’ Category

SyntaxHighlighter

without comments

Shame on me! I’ve discovered that wordpress.com provides syntaxHighlighter functionality just today. So I hurry to report that the only 2 posts in this blog, which contain code snippets have been immediately converted:

<a href="http://sevalapsha.wordpress.com/2008/06/26/copy-nodes-xml-documents-java-dom/">
    Copying nodes between XML documents with Java DOM
</a>
&amp;
<a href="http://sevalapsha.wordpress.com/2008/08/11/prototype-google-analytics-javascript/">
    Prototype styled Google Analytics javascript snippet
</a>

BTW, isn’t it weird I don’t have one snipped in PHP yet?

Written by Seva

2009-09-16 (September 16) at 09:14:52

Posted in html, java, javascript, php, software, web, xml

Tagged with

Moving on

without comments

Today was the 1st day of me working in the new company (yes, my dear friend, I bid farewell to Nielsen Online) – EasyToBook GmbH – as Software Architect. Unfortunately I’ve got no chance to either design any architecture or to develop any software yet, but succeeded to meet nice and talented people and spent some sweet time reading the documentation.

Written by Seva

2009-08-26 (August 26) at 10:21:12

Posted in development, future, php, software, web

Tagged with

PHP Frameworks popularity estimation

with 2 comments

About 2.5 years passed since I posted the development activity comparison of major PHP frameworks. Since then I’ve got about 4.5k hits from search engines, which IMHO is not such a bad sample to summarize people’s interest in each of them.

Again, no conclusions – just pure numbers :)

http://tr.im/lnXq:

Query Hits Zend CakePHP Symfony CodeIgniter Prado Seagull eZ
zend framework vs cakephp 573 573 573 0 0 0 0 0
zend vs cakephp 319 319 319 0 0 0 0 0
cakephp symfony 258 0 258 258 0 0 0 0
zend vs symfony 254 254 0 254 0 0 0 0
cakephp vs zend framework 217 217 217 0 0 0 0 0
symfony vs zend 210 210 0 210 0 0 0 0
zend framework vs symfony 187 187 0 187 0 0 0 0
symfony vs cakephp 185 0 185 185 0 0 0 0
zend framework vs 176 176 0 0 0 0 0 0
codeigniter vs zend framework 143 143 0 0 143 0 0 0
prado framework 139 0 0 0 0 139 0 0
cakephp vs zend 139 139 139 0 0 0 0 0
symfony vs zend framework 138 138 0 138 0 0 0 0
zend framework cakephp 131 131 131 0 0 0 0 0
prado vs zend 103 103 0 0 0 103 0 0
zend framework vs codeigniter 84 84 0 0 84 0 0 0
cakephp vs symfony 82 0 82 82 0 0 0 0
prado vs cakephp 81 0 81 0 0 81 0 0
prado vs symfony 80 0 0 80 0 80 0 0
zend vs codeigniter 76 76 0 0 76 0 0 0
zend or cakephp 69 69 69 0 0 0 0 0
codeigniter vs cakephp 68 0 68 0 68 0 0 0
codeigniter vs zend 62 62 0 0 62 0 0 0
zend vs code igniter 60 60 0 0 60 0 0 0
cakephp zend framework 59 59 59 0 0 0 0 0
codeigniter vs symfony 55 0 0 55 55 0 0 0
cakephp symfony zend 52 52 52 52 0 0 0 0
cakephp vs prado 50 0 50 0 0 50 0 0
symfony zend framework 48 48 0 48 0 0 0 0
cakephp vs codeigniter 48 0 48 0 48 0 0 0
zend framework vs code igniter 46 46 0 0 46 0 0 0
zend framework vs. cakephp 46 46 46 0 0 0 0 0
symfony vs codeigniter 45 0 0 45 45 0 0 0
symfony vs prado 39 0 0 39 0 39 0 0
zend vs prado 37 37 0 0 0 37 0 0
zend cakephp 37 37 37 0 0 0 0 0
zend framework symfony 36 36 0 36 0 0 0 0
zend framework or cakephp 35 35 35 0 0 0 0 0
prado symfony 35 0 0 35 0 35 0 0
seagull vs cakephp 34 0 34 0 0 0 34 0
zend framework versus cakephp 32 32 32 0 0 0 0 0
Total 4568 3369 2515 1704 687 564 34 0
Interest Ratio
73.75% 55.06% 37.30% 15.04% 12.35% 0.74% 0.00%

Written by Seva

2009-05-15 (May 15) at 01:33:24

Prototype styled Google Analytics javascript snippet

without comments

Recently I’ve created a prototype styled javascript snippet to enable google analytics on one of my sites. Save this code in google.analytics.js file and include it from the head tag of the page just after including of the prototype.js:

gaTrackerId = 'ss-ddddddd-d'; // insert your tracker id here
document.observe('dom:loaded', function() {
    var gaJsHost = (
        'https:' == document.location.protocol
            ? 'https://ssl.'
            : 'http://www.'
    ) + 'google-analytics.com/ga.js';
    var script = new Element('script', { 'src': gaJsHost});
    var gaTrack = function() {
        if (
            !script.readyState
            || /loaded|complete/.test(script.readyState)
        ) {
            var pageTracker = _gat._getTracker(gaTrackerId);
            pageTracker._trackPageview();
        }
    };
    script.observe('load', gaTrack);
    script.observe('readystatechange', gaTrack);
    document.body.appendChild(script);
});

Written by Seva

2008-08-11 (August 11) at 08:00:07

Web 2.0 Porn Sites run Zend Framework

with 2 comments

I never mentioned here, but in my pre-previous developer’s life I was working in a small adult internet company. Right now one of my collegues called me on IM to ask a question about an error he suddenly got fro one of the sites he affiliates to. This is the error:

Fatal error: Uncaught exception ‘Zend_Db_Adapter_Exception’ with message ‘SQLSTATE[00000] [1040] Too many connections’ in /www/zt/root/library/Zend/Db/Adapter/Pdo/Abstract.php:129

Stack trace:

#0 /www/zt/root/library/Zend/Db/Adapter/Abstract.php(216): Zend_Db_Adapter_Pdo_Abstract->_connect()

#1 /www/zt/root/library/Zend/Db/Adapter/Pdo/Abstract.php(204): Zend_Db_Adapter_Abstract->query(‘????SELECT?????…’, Array)

#2 /www/zt/root/mvc/models/User.php(490): Zend_Db_Adapter_Pdo_Abstract->query(‘????SELECT?????…’)

#3 /www/zt/root/mvc/models/User.php(91): User->attachVideosByIp()

#4 /www/zt/root/bootstrap.php(35): User->__construct()

#5 /www/zt/root/index.php(7): require(‘/www/zt/root/bo…’)

#6 {main}

thrown in /www/zt/root/library/Zend/Db/Adapter/Pdo/Abstract.php on line 129

Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0

BTW, the site (it was Zoo Tube) is not really bad (according to Google cache) and even seems to be a clone of another Web 2.0 porn site – Red Tube, which makes me think ZF is really becomes a trend in real world and and real money projects. Isn’t it amazing?

Written by Seva

2008-04-26 (April 26) at 02:29:10

Zend Framework vs. CakePHP, Symfony, Seagull, WACT, Prado, TRAX, eZ and CodeIgniter

with 14 comments

In contraversal with what it might seem, I won’t compare features of the mentioned projects. For that purpose you may just read this nice article by Dennis Pallett.

Instead, I will share you what I learned with help of [in]famous Ohloh project – the codebase, activity and participants dynamics comparison of the mentioned projects.

Well, I’ll not make any conclusions – just observe the facts.

Codebase:
(lines of code)


  Zend Framework   CakePHP   Symfony


  Zend Framework   Seagull   WACT


  Zend Framework   PRADO   TRAX


  Zend Framework   eZ   CodeIgniter

Activity:
(commits)

  Zend Framework   CakePHP   Symfony


  Zend Framework   Seagull   WACT


  Zend Framework   PRADO   TRAX


  Zend Framework   eZ   CodeIgniter

Participants:
(active committers)


  Zend Framework   CakePHP   Symfony


  Zend Framework   Seagull   WACT

  Zend Framework   PRADO   TRAX


  Zend Framework   eZ   CodeIgniter

Enjoy.

Written by Seva

2007-11-13 (November 13) at 01:38:51

Integration of Zend Framework and Prototype Ajax

with 3 comments

Last two days I’ve worked on implementing an example of integration of Zend Framework’s MVC and Prototype’s Ajax for HTML Forms submission and validation.

The solution consist of 2 parts:

1. There is a new View Helper to create an Ajax-enabled form.

This part mostly consists of JavaScript code, which alters default HTML Form behavior to submit the input element values to the action’s URL with Ajax, if form’s method is set to ‘ajax’.

In addition the form itself listens to submission result events and (by default) marks input elements if they are invalid.

2. There is a new customized abstract base Controller which replaces default ViewRenderer with a new one, which:

a) detects whether the request was received from Ajax.
b) if true, will not render the view, but instead will output with the input validation information, if either.

Well, the development is not really over yet, but what I originally wanted to say is I’ve just realized how I miss writing good old JS. :)

By the way, I need to repeat [ad:start] how happy I am to have PHP, HTML and JavaScript editors in one powerful standardized environment (Eclipse) – what I never had in the past, before PDT, WST & ATF came to the picture [ad:end] :) ).

Written by Seva

2007-10-29 (October 29) at 10:49:00

Debug PHP and JavaScript simultaneously

without comments

Yesterday me and Roy had a brainstorm session on future Zend Neon (Commercial version of PDT) and ATF integration and “occidently” found a way of debugging of an URL with both Zend’s PHPand Mozilla’s JavaScript debuggers in one session.

Surprise! It’s possible with neither patching nor hacking. I’m not going to show the exact steps of this, but the idea is very simple:

As you probably don’t know, to debug URL on a server which has Zend Debugger installed it’s enough to pass several simple parameters with the HTTP request (either in the query string or as cookies), like client IP and port, debug type etc., to start the debug session. Afterwards the debugger contacts the client machine, where a Neon’s Debug Daemon listens for incoming connections. The Daemon then raises up a new Launch Configuration.

When Neon’s Debug URL action is executed, it just appends the needed debug parameters to the passed URL and sends the updated URL either to the browser. Just grab this URL and start Mozilla JavaScript Debug Launch with it!

As the result 2 simultaneous launch configurations will start; the first activated session will be PHP’s one and then, after the browser will start receiving content from the server, JavaScript’s one will come into the picture.

Voila!

Moreover, if you enabled all-pages (cookie based) PHP debugging, it will go further with your AJAX (AJAH/AJAJ) requests!

Now the only problem :) is you cannot set breakpoints of both PHP and JavaScript types in the PHP source file, since it doesn’t match the final responce which will be passed to the browser, so you should enable the option to suspend the JavaScript execution immediately after it starts to add breakpoints to the responce HTML source.

Written by Seva

2007-10-20 (October 20) at 12:54:00