Archive for June, 2009

Freemarker: XML Xpath Expression

Tuesday, June 30th, 2009
[#list doc["book/chapter[title='Ch1']/para"] as p]
<p>${p}</p>
[/#list]

See XPath Freemarker doc for more info.

jQuery: Add an Element to an existing jQuery Object

Monday, June 29th, 2009
var $first = $("#mySingleElement");
var $allLis = $("li");
//to add the $first to $allLis jQuery object
$allLis[$allLis.length++] = $first.get(0)

I know, kind of ugly, but did not find a better way.

See also: how-to-add-elements-to-a-jQuery-object-without-copying-it

Eclipse: Remove my Aptana welcome screen

Monday, June 29th, 2009
  1. Go to¬†Window –> Preferences –> Aptana –> My Aptana/Message Center
  2. Check “Never display after startup”

Or in some version go to: Preferences > Aptana > Startup Page (and check the “Never …”

jQuery: Ajax Load HTML fragment

Wednesday, June 17th, 2009
 $("#feeds").load("feeds.php", {limit: 25}, function(){
   alert("The last 25 entries in the feed have been loaded");
 });

jQuery Doc: Load

jQuery: HTML Encode Trick

Wednesday, June 17th, 2009
$('<div/>').text('This is fun & stuff').html();

Source: debuggable.com

jQuery: Hover over out

Wednesday, June 17th, 2009
  <ul>
    <li>Milk</li>
    <li>Bread</li>
    <li class='fade'>Chips</li>
    <li class='fade'>Socks</li>
  </ul>
$("li").hover(
      function () {
        $(this).append($(" ***"));
      },
      function () {
        $(this).find("span:last").remove();
      }
);

jQuery Hover Doc

Spring:Bean definition inheritance

Monday, June 8th, 2009
<bean id="inheritedTestBean" abstract="true"
    class="org.springframework.beans.TestBean">
  <property name="name" value="parent"/>
  <property name="age" value="1"/>
</bean>

<bean id="inheritsWithDifferentClass"
      class="org.springframework.beans.DerivedTestBean"
      parent="inheritedTestBean" init-method="initialize">

  <property name="name" value="override"/>
  <!-- the age property value of 1 will be inherited from  parent -->

</bean>

See Spring Doc: Bean definition inheritance

MySQL: Force Drop Table with Foreign Keys

Saturday, June 6th, 2009

If you try to drop a table that has some foreign keys, you will get an exception.

mysql> SET foreign_key_checks = 0;
mysql> drop table ...
mysql> SET foreign_key_checks = 1;