Sep 18, 2014

JS - Infinite scroll sample code.

// START OF INFINITE SCROLLING FUNCTION
var base_url = config.base_url;
var offset = 1;
var request_ajax = true;
var ajax_is_on = false;
var objHeight = $(window).height() - 50;
var last_scroll_top = 0;
    
    
var type = '0';
var csrftoken = $("meta[name='csrf-token']").attr('content');
var csrfname = $("meta[name='csrf-name']").attr('content');
$(window).scroll(function(event) {
  var st = $(this).scrollTop();
  if(st > last_scroll_top){
    if ($(window).scrollTop() + 100 > $(document).height() - $(window).height()) {
      if (request_ajax === true && ajax_is_on === false) {
        ajax_is_on = true; 
        $.ajax({
          url: base_url + 'category_more',
          data:{page_number:offset,id_cat:'459',type:type, parameters:'[]', csrfname : csrftoken},
          type: 'post',
          dataType: 'JSON',
          onLoading:jQuery(".loading").html('<img src="/assets/images/orange_loader.gif" />').show(),
          success: function(d) {
            if(d == "0"){
              ajax_is_on = true;
            }else{ 
              if(d.substring(0,5)  == ""){
                $($.parseHTML(d.trim())).appendTo($('#product_content'));
                ajax_is_on = true;
              }else{
                $($.parseHTML(d.trim())).appendTo($('#product_content'));
                ajax_is_on = false;
                offset += 1;   
              }
            }
            jQuery(".loading").fadeOut();    
          }
        });
      }
    }
  }
  last_scroll_top = st;
});
// END OF INFINITE SCROLLING FUNCTION

Sep 10, 2014

How to resize/increase tmpfs partition.

Increasing linux tmpfs partition have two way to do.

1. Modify you /etc/fstab and put the below. Setting below set the tmpfs size to 2GB
LABEL=/     /           ext4    defaults,noatime  1   1
tmpfs       /dev/shm    tmpfs   defaults        0   0
devpts      /dev/pts    devpts  gid=5,mode=620  0   0
sysfs       /sys        sysfs   defaults        0   0
proc        /proc       proc    defaults        0   0

Add size=2G inline to tmpfs besize defaults.
tmpfs       /dev/shm    tmpfs   defaults,size=2G        0   0
After you modify and save your changes, remount the partitions by issuing command below
# mount -o remount /dev/shm
And you done. Or try easier way below.




2. Or if you want the easier way, issue command below to set the tmpfs to 2GB.
sudo mount -o remount,size=2048M tmpfs /dev/shm
NOTE: The breakdown of doing this, this setting will revert after the system was rebooted, so I recommend to modify the /etc/fstab