Wednesday, December 3, 2014

Waiting for AJAX

If you need to transfer execution of your page to somewhere else, but want to make sure you don't have any pending (jquery) ajax calls, use the $.active variable as below:

// 
// wait for pending ajax calls to finish first
// 
var timer = setInterval(function() {
 if ($.active==0) {
  clearInterval(timer);
  window.location.assign("www.google.com");
 }
}, 500);

Tuesday, December 2, 2014

How to delete multiple keys in Redis

At the command prompt:

#redis-cli KEYS "some-prefix*" | xargs redis-cli DEL

where "some-prefix" is the key prefix you want to delete.