Monday, August 16, 2010

Sphinx extended query syntax

One advice I should give is about the syntax of query.

I your text-search involves more than one attribute, then you have two choices to build your query like:
1. Query: @attr1 "*keyword*" | @attr2 "*keyword*" | @attr3 "*keyword*"
2. Query: @(attr1|attr2|attr3) "*keyword*"

Now benchmarking:
1st Query, on 1000 iterations, took 23.2s of pure sphinx time
2nd Query, on 1000 iterations, took 16.2s of pure sphinx time.

Make you conclusions... ;)

PS: I also tried 3rd approach:
I made concatenated attribute, named it @attr1_attr2_attr3 in sphinx's configuration file, and query's format was like:
@attr1_attr2_attr3 "*keyword*"... 1000 iterations of this type of query, took 17.9 seconds... much better than 1st one, but still 2nd is better.

Wednesday, August 11, 2010

Bromine first install. Fatal error

I love those tricky moments, when you have to dance with a tambourine around your pc, to make it work using our galaxy logic etc.

So, the problem: I got following error when first started, freshly unzipped bromine project:


Notice: Trying to get property of non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

Fatal error: Call to a member function cd() on a non-object in /usr/home/.../www/cake/libs/cache/file.php on line 244

It's under FreeBSD (that should be important moment I guess).

You wanna know how this SHOULD be fixed?
Here is what I've found:

Go to www/app/config/core.php's line stating:
date_default_timezone_set('UTC');
and uncomment it.

Cake engine does not like when this line is commented out and acts unpredictably

IE8 dynamically created tables

I had to generate tables and append them to DOM dynamically (on ajax data requests responded).

IE8 acted as a bad-ass teacher to me, cuz I forgot to use tbody tag. So hopefully that helps:

BAD code:
var table = document.createElement("table");
var tr = document.createElement("tr");
table.appendChild(tr);
...
document.appendChild(table);

GOOD code:
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr = document.createElement("tr");
tbody.appendChild(tr);
table.appendChild(tbody);
...
document.appendChild(table);

Otherwise IE ignores the content of your table and shows it with zero height and zero width.

I should mention, that IE8's Developer Tools did help me to find that out ;)

Niivisi

HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

When creating dynamically generated pages, you can meet following error in IE browser:

HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

That "KB927917" secret code also comes along with

Line: 0
Character: 0
Source: 0

So now you "know" where to dig to.

So I met one. And it was odd, cuz my JS is runing on Jquery's document.ready event, when everything should be ready:

$(document).ready(function(){
... my js ...
});

But it does not make any sense for IE? No. For FF3, Chrome, etc. does, but not for IE. So what does?

$(document).ready(function(){
setInterval("documentIsReallyReadyNowEvenInIE();",1000);
});
function documentIsReallyReadyNowEvenInIE() {
... my js ...
}

Вот-так-то

Monday, June 21, 2010

JQuery droppable "unspecified error" in IE

I was implementing some Drag'N'Drop algoritms using JQuery .draggable & .droppable plugins, when in IE got "unspecified error". Thanks to Microsoft, they finaly got released so called "Development Tools". Debugging my page using that, gave me exception inside jQuery's code. It was the line saying "d=b.getboundingclientrect()".

It got me a while to understand why that happens, and the answer is:
jQuery's event handles/listerners are not unbinded automatically from the elements you remove from the DOM... they keep firing. So every time you use something like $('...').droppable(...
you should also do $('...').droppable('destroy'), if you remove that $('...') from the DOM. I did.

Conclusion: $('...').droppable('destroy');


Friday, June 18, 2010

2010 FIFA WC

"2010 FIFA World Cup in SA... what's next? ISAF World Cup in Somali?"

VMware Workstation cannot connect to the virtual machine.

My VM was up for ~2 last weeks and it seemt to get tired, so it hung up today. Tried to restart VM, close VM, none worked.
- Closing VMWare workstation gave me error that VM is busy, so please wait for it to finish and then close ...
- Restarting VM was disabled, due to tireness I guess
- Windows's 7 resource manager said vmware.exe makes 0b/s writes and 0b/s reads to/from hard-drive

So it was obvious to me that the only solution is to find vmware.exe in processes list and kill it.

Runing it again and trying to play virtual machine gave me another riddle to solve:
"VMware Workstation cannot connect to the virtual machine. Make sure you have rights to run the program and to access all directories it uses and rights to access all directories for temporary files."

I'll skip all the sarcasm on the usefullness of this advise and come right to the solution:
"Restart the Host computer" and it works nice.

Strange , cuz I remember the other time, that vmware.exe was restarted same gentle way, there were no problems appeared.

It's also fair to mention that before restarting the host computer I tried google... found a lot of hints how to fix that problem... Good for me I did not start trying any of them.

Conclusion: killing vm from the processes list is not always good idea

Santé!