Saturday, March 16, 2013

axlsx vs simple_xlsx

simple_xlsx:

text = getRandomString(15)
serializer = SimpleXlsx::Serializer.new("test2.xlsx") do |doc|
  doc.add_sheet("Report") do |sheet|
    (1...3000).map{
      row = []
      (1...1800).map{
        row.push text
      }
      sheet.add_row row 
    }
  end
end

axlsx:
text = getRandomString(15)
package = Axlsx::Package.new
workbook = package.workbook
workbook.add_worksheet(:name=>"Report") do |sheet|
  (1...3000).map{
    row = []
    (1...1800).map{
      row.push text
    }
    sheet.add_row row 
  }
end
package.serialize("test.xlsx")

Results:
simple_xlsx:
Memory Usage: 17836kb, elapsed: 61.828213seconds.
axlsx:
Memory Usage: 2118256kb, elapsed: 177.089469seconds.

17+Mb vs 2+Gb, 61s vs 177s

File output seems to result in same size: 14+Mb

it would be nice if axlsx could write to file directly instead of serialize in the end.



Friday, March 15, 2013

JSTree DND


jQuery("#treeidhere").bind("move_node.jstree", function (e, data) {
  console.log("from id: " + data.rslt.obj.attr("data-id"));
  console.log("to id: " +  (data.rslt.parent === -: data.rslt.parent.attr("data-id"));
  console.log("position: " + data.rslt.position);//starts from 0

});

Thursday, March 14, 2013

Social shares in php


Example of social share: twitter, Facebook, linkedin

Note: if url contains ? might cause linked in share to fail...     ---HEADER---
<meta property="og:title" content="Title here">
<meta property="og:description" content="Description here">
<meta property="og:image" content="http://your domain.com/uri here">
---HEADER---


Thursday, March 7, 2013

Prestashop redirect to module configure

When you need to create an AdminTab to redirect to a module configure,
create a class which extends AdminTab

class Admin[NameHere]Tab extends AdminTab

public function display() {

  Tools::redirectAdmin("index.php?controller=AdminModules&configure=[NameHere]&token=" . Tools::getAdminTokenLite("AdminModules"));
}

this will pass in the admin token as required...

prestashop jquery version

to upgrade,
copy jquery min file to js/jquery/

and then edit config/defines.inc.php

define('_PS_JQUERY_VERSION_', '[version here]');

example:
#copy:
js/jquery/jquery-1.9.1.min.js

--------
define('_PS_JQUERY_VERSION_', '1.9.1');

Tuesday, March 5, 2013

cpanel retrieving mail log

sudo grep [domainname] /var/log/exim_mainlog


Sunday, March 3, 2013

prestashop disable right column via hook?

need to disable right or left column via hook?
do these:

create a module,
makesure to hook onto displayFooter


$this->context->smarty->assign("HOOK_LEFT_COLUMN", "");
$this->context->smarty->assign("HOOK_RIGHT_COLUMN", "");


Alternative way is to go into Modules > Positions And edit the module, and add in exception page name onto the exception box. It's separated by comma.