Sunday, July 8, 2012

iptables redirect port

Sometimes you may want to allow users access certain ports. To do so run the following command:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

This will allow all HTTP (80) traffic to be redirected to port 3000.

Friday, July 6, 2012

jQuery single draggable in droppable

jQuery UI is a library that works with jQuery which allows you to easily drag and drop elements.

However, sometimes when you have more draggables and wish to let only one reside inside a droppable, you may need to take actions.

Here is some self explaining code that does just that:

$('.item').draggable({
  opacity: 0.35,
  revert: true,
  snap: true,
  zIndex: 2800
});

$('.box').droppable({
  greedy: true,
  drop: function(e, ui) {
    $(this).droppable('option', 'accept', ui.draggable);
    $(this).append(ui.draggable);
  },
  out: function(e, ui) {
    $(this).droppable('option', 'accept', '.item');
  }
});