2009-11-15

Never ever reinstall a Linux box

Recently I had a weird problem. My Firefox was producing a segmentation fault on random pages, svn dropped messages like

svn: /usr/lib/liblber-2.4.so.2: no version information available (required by /usr/lib/libldap_r-2.4.so.2)
svn: relocation error: /usr/lib/libldap_r-2.4.so.2: symbol ber_sockbuf_io_tcp, version OPENLDAP_2.4_2 not defined in file liblber-2.4.so.2 with link time reference
and refused to work. When I tried to reinstall Firefox, Synaptic urged me to run "sudo dpkg --configure -a", which in turn produced some totally cryptic errors. Reinstallation attempt of libldap ended in an epic fail bringing my whole system down.

I was going to reinstall the Ubuntu 9.04, but decided to call Dmitry Stolyarov of TrueOffice fame. At first, he asked me if I had tried reinstalling libldap.

— Sure. — I replied. — I did that through Synaptic, but it froze my system.
— Synaptic, you say... Run "sudo apt-get install libldap-2.4-2 --reinstall"
— But, hey, I've already done it!
— Give it another try.

Damn! This time it worked. From now on, I won't trust GUI tools when things don't work the way they should.

2009-06-12

Display a symfony form without labels

Paste this in configure():
$format = $this->widgetSchema->getFormFormatter()->getRowFormat();
$format = str_replace('%label%', '', $format);
$this->widgetSchema->getFormFormatter()->setRowFormat($format);

2009-06-07

Change color of all links in a page on click without JS

This should've been an April Fools's post :)

To accomplish the above, place this in your css:
a:visited {
  color: #777777;
}
and change all hrefs to "#777777". Then load the page, click on a link and - Whoa!

2009-04-25

Get is_secure of current action

Ever wondered if a currently running action is secure? Try
$sf_context->getActionStack()->getLastEntry()->getActionInstance()->isSecure()

2009-04-21

Calling submit method doesn't trigger onsubmit event

First, this is the proper behavior, as David Flanagan writes in his book.

Second, how to overcome this?

Suppose you have TinyMCE control embedded in a form. It sets his callback on a form's onsubmit to clean himself up and write all the stuff back to parent textarea. If you have a link that triggers submit(), just create a hidden <input type="submit"> and call click() on it.

Click on submit button does trigger the onsubmit event of a form, giving TinyMCE a chance to properly save his contents.

2009-03-03

Dev controllers in the wild

Funny how many people forget to hide their dev controllers after deployment.

2009-03-02

Handy Eclipse shortcut

There is a hotkey in Eclipse which behavior is close to Alt+Tab: press Alt+[left arrow]/[right arrow] to jump between your opened editors.