April 17th, 2008

Posted in
php,
snippets,
vtiger
After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That’s a huge usability issue (read: waste of time) when you are creating invoices or filling out your calendar.
Anyway, all the more reason to place it on my blog, with the all right keywords!
And now, for the solution:
Quoting onwealdandy
However, I fixed the performance issue with a work around that doesn’t make much sense, but worked. I read this forum post a few days ago, but couldn’t see how commenting out debug print lines would speed things up. But, that did the trick. However, I did narrow it down to the exact variable causing the ruckus ($list_result) , so I only had to comment out just a few lines in ListViewUtils.php. (any debug log lines with $list_result)
Even with logging set to FATAL, the slowness would occur. When you did set logging to DEBUG, one instance would show the correct information in the debug log for the debug log lines .. basically what you would expect when printing $list_result (which is a recordset object) .. the object id … “Object id #40″ … however on the slow machine it would actually print the 2000+ records which were returned by the query.
There must be a bug in php or apache or mysql ( no idea) that returns the entire result set to $list_result when its evaluated for printing. My guess is that the libmysql.dll must have a default _tostring method in there in some versions. BE CAREFUL .. since there its not documented which versions do this … for the record, my troubled instance was running php5.2.5, apache 2.2.6, and mysql 5.0.45
You can find the original vTiger topic here: http://forums.vtiger.com/viewtopic.php?p=64335
Share This
February 11th, 2008

Posted in
php,
snippets
Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to “1″, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative.
Appearantly you can use the input wrappers to go around this setting. Perhaps you could find this useful in the future
<php
if(!$HTTP_RAW_POST_DATA){
$HTTP_RAW_POST_DATA = file_get_contents(’php://input’);
if(empty($HTTP_RAW_POST_DATA))
{
// die here
}
}
Share This
December 15th, 2007

Posted in
free services,
freebies,
snippets
Although, to you foreigners, it may seem like there is not going to be a Belgium in the near future …
For a project of mine, I had to find a database that contained all cities of Belgium with their postal codes and GPS locations (longitude & latitude). Since I couldn’t find such a database (or I had to pay too f***ing much) I decided to create one myself.
Since I’m such a commie, I’ve decided to share this database with anyone that needs it! Please refer to this page to download the database. At this time it’s only available in Dutch. Maybe some day I’ll take the time to translate it into english. Maybe some cash would make me work faster? Send your donations to PayPal address: thomas@rdlt.com …
Download database of all cities in Belgium with postal code and GPS location!
Download een database met alle steden in België met postcode en GPS locatie!

Share This
September 14th, 2007

Posted in
php,
snippets
Okay, maybe I’m overrating it, but I still love it for debugging purposes… unless you are using the CLI.
function pre($array)
{
echo ‘<pre>’;
echo print_r($array);
echo ‘</pre>’;
}
Share This
August 31st, 2007

Posted in
javascript,
snippets
I needed the equivalent of str_replace in JavaScript and was able to fish up this nifty piece of code! Enjoy.
/**
* str_replace
*
* This function returns a string or an array with all occurrences of
* [search] in [subject] replaced with the given [replace] value.
* If you don’t need fancy replacing rules (like regular expressions), you should always use this function.
*
* @param string search
* @param string replace
* @param string string
*/
function str_replace (search, replace, subject)
{
var result = “”;
var oldi = 0;
for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}
Share This