Wednesday, March 20, 2013
cpanel compiling php 5.4 modules
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make clean
make
make test
make install
this works well with mongodb
Example for mongodb:
git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make clean
make
make test
make install
vi /usr/lib/php.ini
add
extension=mongo.so
Tuesday, March 19, 2013
PHP facebook logout?
//for some reason, facebook getlogouturl does not seems to be able to populate access_token byitself.
//Therefore this method forces it to attach the access token:
$logoutUrl = $facebook->getLogoutUrl(array(
"next" => "yourdomain.com?logout=1", "access_token" => $facebook->getAccessToken()
));
$facebook->destroySession();
<script>
document.location.href="<?=$logoutUrl?>";
</script>
Prestashop smarty cache
Do not enable smarty cache on prestashop,
or all your screen will appear the same as last accessed screen, including admin screen.
its pretty messed up.
or all your screen will appear the same as last accessed screen, including admin screen.
its pretty messed up.
Sunday, March 17, 2013
Kloxo custom php.ini per domain
sudo cp /etc/php.ini /home/httpd/domain.com/
#edit /home/httpd/domain.com/php.ini as required
#then
sudo vi /home/apache/conf/domains/domain.com.conf
#and add this line in <ifmodule mod_php5.c="">
PHPINIDir /home/httpd/domain.com
#restart apache
/etc/init.d/httpd restart
This shall allow you to set allow passthru or system or exec call per domain.
#edit /home/httpd/domain.com/php.ini as required
#then
sudo vi /home/apache/conf/domains/domain.com.conf
#and add this line in <ifmodule mod_php5.c="">
PHPINIDir /home/httpd/domain.com
#restart apache
/etc/init.d/httpd restart
This shall allow you to set allow passthru or system or exec call per domain.
Saturday, March 16, 2013
axlsx vs simple_xlsx
simple_xlsx:
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.
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:
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 === -1 ? 0 : 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
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
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
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
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.
do these:
create a module,
makesure to hook onto displayFooter
$this->context->smarty->assign("HOOK_LEFT_COLUMN", "");
$this->context->smarty->assign("HOOK_RIGHT_COLUMN", "");
Subscribe to:
Posts (Atom)