May 27th, 2008
I am amazed with Hardy Herdon. It’s the best OS I’ve ever used. The only thing that was bugging me is that I was not able to install x64 version of Zend PDT. In my opinion it’s the best free PHP IDE around. The solution is very easy trough.
- Download Eclipse IDE for Java EE Developers from Eclipse downloads. It includes all the plugins PDT needs. You’ll be missing some with the vanilla Eclipse.
- Run it, and go to Help -> Software Updates -> Find and Install… Click Next and add a new remote site. Name: PDT, URL: http://downloads.zend.com/pdt
- Thick the new remote site and click Finish. When asked to choose which plugins to install, be sure to deselect the debugger. It’s not available for 64bit systems as far as I know and you’ll get an error proceeding with it.
- When you finish the process and restart Eclipse you’ve got it working.
This guide assumes you have 64bit Java working on your system. On Ubuntu it’s just a matter of installing a package in Synaptic.
Posted in Miscellanous | 1 Comment »
January 18th, 2008
CakePHP is quite a mature framework. Yet I often run into troubles with some more exotic hosting companies.
Yesterday I was deploying a site hosted at 1 & 1 Internet Ltd. For a few hours I was trying everything but still I got the same 500 internal error. Finally I traced the problem to mod_rewrite. It turned out that I need to add RewriteBase to all Cake’s .htaccess files. So if you’re deploying your lovely new site to 1 & 1 your root .htaccess file might look like this:
# Turn on PHP 5
AddType x-mapp-php5 .php
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
mysqli_connect and socket support
Some web hosts use sockets for MySQL connection. Socket is the 6th parameter in mysqli_connect (or mysql_connect). Cake does not know about this 6th parameter. I submitted a ticked some time ago, but it was closed and the change not implemented.
The solution is however very simple. Depending on what driver you use, edit file dbo_mysqli.php or (dbo_mysql) in cake/libs/model/datasources/dbo/ and on line 94 (CakePHP 1.2 rev 6311) add the 6th parameter to the mysqli_connect function. Don’t forget to add the default socket value (I use null) to the $_baseConfig private variable of the DboMysqli class you’re just editing.
Posted in CakePHP | 2 Comments »
December 14th, 2006
Update: My solution does not work in IE. Look at this article for comprehensive info.
While working on Chatcreator’s Chatbox I run into problems with JavaScript’s setTimeout function. I would like to write down what I learned. It may save you some time, next time you’ll need to use this function.
Shortly about setTimeout
setTimeout is a simple JavaScript function used to repeatedly call some function after a specified amount of time. It takes two required parameters and an unspecified number of optional ones. Like this:
setTimeout(functionToCall, time, param1, param2, ....);functionToCall is the name of the function which will be called after time millisecond. You either use reference like in the example above or a string representing a call to the function:
setTimeout('functionToCall()', time, ...)The optional parameters can be used to pass any number of parameters to our functionToCall.
Where’s the catch?
Everything works as expected until you try to call a method inside your ‘class’ (there are no real classes in JavaScript). Something like this won’t work:
setTimeout(this.methodToCall, time);Passing a string representation instead of reference doesn’t work either.
The solution
I found the solution after a while searching in Google Code Search. The above example needs to be rewritten like this:
setTimeout(function(thisObj) { thisObj.methodToCall(); }, time, this);Here we are passing reference to our class as an optional parameter of the setTimeout function. In the called function we catch it and suddenly we can use it to call our method. I have no idea why such a simple thing needs to be so complicated but it only demonstrates that you need to learn a few tricks when you want to do real OOP in JavaScript.
Posted in JavaScript | 28 Comments »
November 3rd, 2006
When you leave your blog not-so-very-updated for some time you’ll start to notice some bad things. Traffic slowly declines and the more you don’t post the lazier you are to write something new. But I don’t want to talk about that.
I made quite a big decision lately – I left the college (willingly). My main reason was that I was, with time, more and more interested and occupied by my freelance career. It escalated to such a point that I had to make a decision. Stay in the school or left and fully concentrate on my business. I chose the later. There was no reason for me to stay – I was simply bored in school. There was very little useful knowledge that I was gaining there. Our programming classes, the only ones that I enjoyed at least a bit, became a joke in the 3rd semester. But I don’t regret my time spent there. I met a lot of great people and learned something too.
I am quite excited. Finally I can concentrate on things that I really enjoy doing. I am confident that this is the right way for me to go, but, well, time will tell.
Posted in Miscellanous, Personal | 3 Comments »
September 28th, 2006
Recently I started using this wonderful PHP framework called CakePHP. It really moves the whole web development process to another level. It has got the MVC pattern, great community, good documentation, lots of people writing about it and there is the WebBaker. WebBaker is a PHP script that let’s you easily create all the files you need for your MVC pattern (model, controller, views). This saves you a lot of precious minutes.
The CakePHP and WebBaker combination is deadly. You can have a functional element in your site like in 1 minute. All you need to do is create a table in the database and use WebBaker to generate appropriate files. At this point when you have written exactly 0 lines of code you have a fully functional interface where you can list, view, edit, add and delete items from database. This is possible due to the excellent scaffold functionality build in Cake. Then you can start writing your own code and smoothly replace the scaffolds. Try it, you’ll never want to go back.
Posted in CakePHP, PHP | No Comments »