Tab navigation and tooltips
We use the tabifier javascript from barelyFitz in a few places in MethodBox. However, I wanted it to have a different, more descriptive tooltip than the tab title. The default code doesn’t seem to do this so I added a couple of little changes to make this happen.
You can see the complete file here but below is a quick synopsis of the changes:
added a boolean to keep track of whether you want a different tooltip than the tab title:
this.differentTooltip = true;
if this isn’t the behaviour you wanted then that’s ok:
if (!this.differentTooltip) {
t.headingText = t.div.title;
}
however, if the tooltip is to be different then make sure the
link for the tab is correct:
if (this.differentTooltip) {
DOM_a.title = t.tooltipText;
} else {
DOM_a.title = t.headingText;
}
Looping over javascript arrays with Prototype framework
Had an array in javascript and tried to loop over it using
for (x in array){
...some code
}
I was confused why it seemed to have lots more members than I had put in with contents that seemed to be functions. So I used console.log and firebug to print out the array members and saw that they were the methods you could call on an array object.
A quick google revealed that (see here)
using
for…inon arrays when using Prototype will enumerate all extended methods as well, such as those coming from theEnumerablemodule, and those Prototype puts in theArraynamespace
and that the best (only?) way to do it in Prototype is
myArray.each(function(item) {
// Your code working on item here…
});
It’s all sorted now!
RServe on OSX Snow Leopard
I always seem to have some difficulty getting the Rserve component of the R stats library up and running on OSX. Installing it via install.packages(”rserve”) from within R appears to work but when running R CMD Rserve I usually get some sort of error like:
/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: Rserve: not found
Compiling from source using the download from http://rosuda.org/Rserve/ never seems to work with all sorts of C related horror.
However, the Rserve component actually was installed but it looks like the paths/links were not quite right. Typing this:
R CMD /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve.so
Got everything up and running. Doing this:
cp /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve-bin.so /Library/Frameworks/R.framework/Resources/bin/Rserve
fixes it a bit more permanently
Obscure mysql bug number 1153 (08S01) (my packet’s too big)
Ok, here’s one you don’t see every day.
Importing a mysql dumpfile results in “ERROR 1153 (08S01) at line 265: Got a packet bigger than ‘max_allowed_packet’ bytes”
Errm.
Log in to a mysql console,
enter the magic commands:
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;
Modify your import to include the command:
–max_allowed_packet=100M
so you have something like
mysql –max_allowed_packet=100M -u user -p db_name < dump.sql
Try again
Your mileage may vary ( do they say kilometerage elsewhere?) so increase the allowed sizes if you have to.
Taming the Savage Beast (Forums)
We needed a forum for one of our web projects written in rails and a quick google revealed Savage Beast. It seemed to fit the bill although needed some css tweeks to co-exist with what we currently have. However, when clicking on its RSS feed icon it threw an ActionController::Request.relative_url_root method missing error which was fixed by creating the class request_error.rb in initializers with the code below:
class ActionController::Request
def relative_url_root
@@relative_url_root ||= case
when @env[”RAILS_RELATIVE_URL_ROOT”]
@env[”RAILS_RELATIVE_URL_ROOT”]
when server_software == ‘apache’
@env[”SCRIPT_NAME”].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, ”)
else
”
end
end
end
Based on bug reported here: http://railsforum.com/viewtopic.php?pid=73991#p73991.
It all seems to work fine now.


