Smart A. S. blog

Alexei Shuga, the web developer

MediaTemple vs Linode

without comments

I’ve been using both services for private data and testing environments for a while now. This is going to be quick and short resume.

While plans I’ve used – “512 mb” from Linode ($19.95 p/m) and “ve Server 512Mb” from Mediatemple ($30 p/m) – have comparably equivalent hardware features (there is only one difference – you may get “burstable” RAM from Mediatemple, but that’s not the “real” feature and this is probably the problem despite the fact that it seems to be a real value added offer), there are tons of issues with MediaTemple.

Here are the issues that make Linode a real killer:

a) Pay for what you use (e.g. you create a virtual machine for $19.99 and cancel a week later, you will get 3/4 of what you’ve paid back! MT will eat your money). This is actually what I believe is one of the best features for active developers. For example, usually I create proof-of-concepts or other stuff related to the client needs and sometimes it has to take one week only (e.g., it is either to be closed or moved to clients account later). This is not about the money, but about the freedom of actions. I can easily deploy 10 VPSes farm and stress-test one of the solutions for a couple of days and it’s going to take approx $13 at Linode

b) Stability. Linode’s XEN works stable, while MT Virtuozzo did not work well for me

c) Support. I’ve seen questions answered by Linode stuff within 5 minutes! Beat that!

d) Community. Libraries/tutorials, Forum, IRC and lots of other helpful stuff.

e) You can pick your own datacenter. While MT offers Virginia datacenter, Linode at the moment offers you choose from 5: four datacenters in 4 US states and 1 in the UK. You can easily test/simulate geotargeted load balancing and other features.

So, today I cancelled my Mediatemple service and “resized” my Linode maching to 1.5Gb plan.

ps. No holy wars or any offense meant. MT is a good VPS hosting provider, it’s just the features offered by Linode are really cool for me as a developer and probably for other developers.

Written by Alexei Shulga

September 5th, 2011 at 3:30 pm

Posted in Uncategorized

Tagged with , ,

On passing Zend PHP 5.3 exam

with 6 comments

I passed the Zend PHP 5.3 exam (code: 200-530) on Nov 9th, 2010 and would like to share some thoughts and feedback.

First of all, the exam is quite complex, yet it’s pretty much easy to pass if you’re writing PHP code using latest additions like namespaces, late static binding or lambda functions. Even if you do not use these techniques in your code, but you’re aware of them and saw PHP syntax for those features (including restrictions like “namespace” keyword proper placement), it would not be a problem for a candidate to pass Zend PHP 5.3 exam.

I did not get myself prepared for the exam as I was too busy working and spending time with my family, but I saw that a couple of people suggested to read Zend PHP 5.3 Study Guide (included with your voucher purchase). Yet I’d definitely not recommend using this guide as it contains lots of errors and inconsistencies and even wrong answers for sample exam questions.

Here is a short abstract that should illustrate that the guide could mislead potential exam candidate

FILESYSTEM
basename(): RETURNS FILENAME COMPONENT OF A PATH
chmod(): CHANGES THE FILE MODE
copy(): COPIES A FILE
delete(): DELETES A FILE

No offense to Zend, but they should not release the document until it’s verified and contains only minor issues (at this time they offer Beta 1.3 version of the document). On the contrary – use manual. And I mean it. There is no better book on PHP to get prepared for the exam other than it’s manual. That’s the only advise I can give if someone interested.

Next, the questions.

PHP 5.3 exam questions are a bit easier than those I saw for PHP5, but the answers are much “better” (read trickier) now. The questions I answered covered lots of PHP topics sometimes, a single question encapsulates several PHP topics and it would be hard to choose the right answer without knowing all of them.

I answered all questions in 40 minutes, marked around 20 for review later and spent some time looking for traps and pitfalls in those 20. And I found that I choose two wrong answers in marked for review questions. So I spent exactly one hour on the test (the same for previous PHP5 exam) which means that allowed 1.5 hours for 70 questions are more than enough.

A bit of not good news. I encountered three questions that were really, totally and devastatingly stupid. As I can not share the real questions, I’ll share the concept and approach. How about this: what is the best approach towards coding?

Possible answers (pick only one):

  1. Thin model, fat controller
  2. Fat controller, thin model

Anyway, I really encourage interested parties in taking the exam.

Below you’ll find the topics covered by the questions I answered and the approximate number of questions related to the topics to get the idea of what is being asked:

XML (SimpleXML, DOM, XPath, etc) – 11

AJAX (incl. JSON) – 4

HTML and Forms (POST data, security, escaping, etc) – 15

Headers, sessions, cookies, etc – 8

New PHP 5.3 features – 7

Strings and regex – 15

OOP and design patterns – 7

Arrays – 30,

DB (PDO, storing/displaying data) – 6

Email – 3

etc.

Also, I got about 11 “type-in” questions and there were about 6 question on the order of function parameters.

Eventually, you’ll have this nice graphic page on your web-site/resume:

Zend certified php 5.3 engineer logo

Written by Alexei Shulga

November 12th, 2010 at 6:35 pm

Posted in Uncategorized

Protected: Unholy book of freelancer: Commandment #20

without comments

This post is password protected. To view it please enter your password below:


Written by Alexei Shulga

March 21st, 2010 at 6:30 am

Compile your PHP code

without comments

Facebook shared their PHP to C++ code translator called HipHop that opens up a possibility to compile your code using gcc. Facebook reports that it can fasten up your code up to 50%. Moreover, it’s free!

However, HipHop has it’s drawbacks (some of the are good features, not drawbacks):

  • No Windows support (great!)
  • No eval() and create_function() support (that’s also great)
  • Lots of modules are unsupported at the moment
  • Some other minor drawbacks (e.g. function_exists() might not work the way you expect it to work)

In any case – it is worth a try. Grab HipHop here.

Some analytics on HipHop from Marco Tabini, Ilia Alshanetsky

Written by Alexei Shulga

February 7th, 2010 at 7:29 am

Posted in web development

Tagged with , , , ,

Did you hide your SVN?

without comments

If you use SVN on your development or production server, try and add “/.svn/entries” to your website root, so the URL would look like this http://yoursite.com/.svn/entries (note the absence of the trailing slash).

Those who aware of the possible outcomes of letting svn resources be accessible from the Internet can skip this post. Others using SVN, be aware.

Using the .svn resources exposed to the world, I can get such information as the repository address (in conjunction with other data, it’s likely to have a working copy of the repo), developers login, corresponding deployment information, etc.

The problem is very common and you can even try to steal valuable information from leaders of the industry ( the first one that comes to my mind is classmates.com – .svn resources are open at the time of writing this post). Moreover, there are web-sites on the Internet that allow anonymous checkout of their own code.

The problem can be solved within 5 minutes and the recipe is widely-known ( check out google results ).

Written by Alexei Shulga

September 24th, 2009 at 12:41 am

CakePHP schema TIMESTAMP field create error solution

without comments

What a dissapointment! CakePHP schema generation feature does not handle DB TIMESTAMP fields default values correctly. While we wait for the official fix, we can use a quickfix for the issue.

The code responsible for column creation is in the cake/libs/model/datasources/dbo_source.php file. Scan for the “function buildColumn()”. The particular place where default DB fields values are handled is this:

if (($column['type'] == 'integer' || $column['type'] == 'float' ) && isset($column['default'])
&& $column['default'] === '') {
$column['default'] = null;
}

if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
$out .= ' ' . $this->columns['primary_key']['name'];
} elseif (isset($column['key']) && $column['key'] == 'primary') {
$out .= ' NOT NULL';
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
} elseif (isset($column['default'])) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type);
} elseif (isset($column['null']) && $column['null'] == true) {
$out .= ' DEFAULT NULL';
} elseif (isset($column['null']) && $column['null'] == false) {
$out .= ' NOT NULL';
}
return $out;
Our fix will be as simple as it can be yet it will serve the purpose of correct column generation. Let's see what we can do:
if (($column['type'] == 'integer' || $column['type'] == 'float' ) && isset($column['default'])
&& $column['default'] === '') {
$column['default'] = null;
} elseif ($column['type'] =='timestamp' && $column['default'] != 'CURRENT_TIMESTAMP') {
                        $column['default'] = '2000-01-01 00:00:00';
                }

if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
$out .= ' ' . $this->columns['primary_key']['name'];
} elseif (isset($column['key']) && $column['key'] == 'primary') {
$out .= ' NOT NULL';
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
            if ($column['type'] == 'timestamp' && $column['default']=='CURRENT_TIMESTAMP'){
               $out .= ' DEFAULT CURRENT_TIMESTAMP NOT NULL';
            } else {
               $out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
            }
} elseif (isset($column['default'])) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type);
} elseif (isset($column['null']) && $column['null'] == true) {
$out .= ' DEFAULT NULL';
} elseif (isset($column['null']) && $column['null'] == false) {
$out .= ' NOT NULL';
}
return $out;
}
 

Actually, we added a trick for all the next timestamp fields (except the one with CURRENT_TIMESTAMP default value) to have arbitrary not NULL default values.

Another trick is to have CURRENT_TIMESTAMP default value unquoted by CakePHP schema code (which actually prevents the schema script from running).

Tricks above are pretty dumb, but I’d not bother with the perfect solution as we’re going to have one from “the clean IP” really soon (I hope).

Written by Alexei Shulga

August 17th, 2009 at 2:50 am

Hey, Apache! Do you mod-rewrite?

without comments

The quickest way to check if apache’s module mod_rewrite is running is by running this command

sudo apache2ctl -M 2>&1| grep -i rewrite

Now, if you want to enable mod_rewrite, run the following command:

sudo a2enmod rewrite

And finally, restart apache server:

sudo apache2ctl restart

ps. Do not forget to set up correct value for the AllowOverride apache directive to enable correct .htaccess behaviour for your code.

Written by Alexei Shulga

August 15th, 2009 at 6:28 pm

You're encouraged to check out my developer resume.