Quick tip: How to run php script like application

It’s really quick tip:
Sometimes you need to make a shell script which need to be executed either on regular basis, or like infinite loop.

You always can run it by:

/usr/bin/php /path/to/script.php

but if you add a shebang line, the script can be run as standalone application.

Example:

#!/usr/bin/php -q
<?php
//Your php code goes there
?>

Then you can run it like:

/path/to/script.php

Hope this helps

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

How to use Opencart default admin over Joomla’s Component like jCart/Mijoshop or other CMS

This article is going to explain how to run a Opencart default admin with Joomla Opencart Extensions like jCart and mijoshop. This could apply to any other CMS which provide bridge between opencart and the CMS.

Some background

Opencart components are usually a opencart installation, wrapped with some code, so it will appear in Joomla or other CMS as a part of the site. Because of collisions between Joomla’s javascript libs and some opencart extensions, which heavily uses javascript they couldn’t work on the Joomla Opencart Admin. For this very reason, the following steps need to be done. The result – you will get fully functional opencart Admin, linked to the frontend of your shop. This way you can use extensions like Bulk Product Update PRO or similar.
Continue reading

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

How to check your php project (many files in a folder) for parse errors

Hey hadn’t wrote anything for a while here, but this is so brilliand and convenient, so I couldn’t resist to share it.

It’s about to check your project for obvious errors before releasing the changes on the production server. I found this answer in StackOverflow, but the solution is for SVN repository and while currently I am working with snv it suits me, but looking forward to migrate to Git, I was thinking “Wasn’t it nice to check the all php files within a folder?”

So here is the solution:

for i in $(find . -iname \*.php ) ; do php -l $i ; done | grep "Parse error"

This should be executed in terminal (at least in Ubuntu it is straight forward) and it print all files which had Parse errors within the folder. I think it’s a must for any php developer who release their code in production server. I already put it as alias in my .bashrc, but I will add it in my “build” script too.

Probably it could be optimized, but for me is pretty much enough.

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

Prestashop :: adding text blocks in the template

Here you can see how you can add html and text on various places of your template.

Presta is very good written e-commerce platform and class overwriing is piece of cake. So, here is the code:

1. Create a file under {presta_dir}/override/classes and name it Tools.php.
2. Copy and paste that code in the new file:

<?php
/**
 * Tools override class
 */

class Tools extends ToolsCore{
    public static function getPage($link_rewrite = null){
        global $cookie;
        $page = Db::getInstance()->getRow("SELECT * FROM "._DB_PREFIX_."cms_lang WHERE id_lang='".(int)($cookie->id_lang)."' AND link_rewrite LIKE '".$link_rewrite."'");
        return $page['content'];
    }
}

Note: if you already have this file just copy only the function and place it inside the Tools class.

3. That’s it :) Go and create a new CMS page under Prestashop Admin (Tools->CMS). Add a nice “friendly url” and put your your text in the body.
4. How to use the function in the template: Go to your template file files and insert the following code:

{Tools::getPage('your-seo-friendly-url-cms-page');}

Don’t forget to delete the cache.

Conclusion: The code is not 100% MVC, but it’s working straight away. As benefit your texts will be multilingual, and especially when you need to put them on places where there is no hooks, This would save a lot of time and effort.

Hope this helps.

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

Deadline tool – deadlinez.com

Over the weekend I had an idea and after day and a half (mostly spent in design) the final “product” is ready. It’s a tool for deadlines.

The idea: It came when I had tough conversation with a client of mine about some money which he owe. I wrote a short email notifing him that if he don’t pay within 2 weeks, we are stopping the supprt and cutting one of his main functionality (since he didn’t pay for it) of his app. And I was thinking: Woudn’t be nice to have a tool which could track the deadline like “You have 14 days, 23 Hours and 30 Minutes to pay is, otherwise – no support” – short and clear. Well this is what the Deadline tool is doing. Here it is:

deadlinez.com

The main functionaliy: At the first screen you need to select date and time then the deadline is reached as well as the target name and the task (message) which need to be completed. When you submit the form it will create a short url which is the actual counter. This url can be send to the target.

deadlinez.com - Deadline tool

You can also set target’s e-mail as well as yours. If you did it you will receive a mail with a link when the deadline is reached. so both parties will be notified.

deadlinez.com - Deadline tool

Few ideas for deadlines:

  • Set deadline for business client (like me :))
  • Set deadline to your roommate to move out
  • Set your personal deadline to reach some level of income, or career growth
  • Set deadline to your govermnent…

Or whatever you imagine. Please use this for fun mostly!

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

Error: invalid XML tag syntax and Extplorer

A client of mine uses standalone version of Extplorer as Client section of his website. Because they are Studio for Printing materials, it’s normal, that their “production” is quite large as file size.

Recently they asked me to increase the max_upload_filesize to more than 4-5Gb. In the php.ini I’ve set max_upload_filesize=60G, but when someone try to login, it hangs and in the Firebug console it says “invalid XML tag syntax”.

The solution was to replace 60G with 6000G which is equivalent to ~6Gb. After that change the extplorer start working normally.

Hope this will help someone.

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

Codecademy – Javascript tutorials for newbies

It’s not every day you see a tutorial set that really makes you smile, but Codeyear’s attempt to teach people Javascript through weekly courses and projects is admirable, especially given the quality of the site, the clarity of the courses, and the potential for knowledgeable programmers to start writing similar courses for other languages, such as Python.

To top it all off, they’re using a badge and points system to encourage people to complete new courses, which is a great way to motivate people to finish what they’re learning and move on to something new. In addition, it also means that as they see their projects come to life, they can show people how far they’ve progressed and encourage a little online competition – which, if you’re a partycasino.com fan, is never a bad thing.
Continue reading

jQuery .submit() trigger problem

Recently I experience the following problem, when I call this code it triggers an error in FireBug:

$('input[name="s"]').parents('form').submit();

With “human” words: I trired to find a input with a spefic name, then find the form wrapping this input and try to submit it. Strangely, but it trows an error in jQuery lib.
Continue reading

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

How to Effectively Deploy Call Center Software

An important component of the modern work environment is the call center. Finding ways to effectively implement a software application to enhance the productivity of employees is critical to improving customer satisfaction.
After choosing a call center software that will meet a business’s need, the next step is to effectively deploy the application.
Continue reading

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

How Converged Networks Will Revolutionize Telecommunications

Phone calls aren’t what they used to be. The antiquated system of wires and telephones that once crisscrossed the country becomes increasingly irrelevant as more companies and consumers switch to voice calling over data networks.

Called Voice over IP, this technology uses high speed Internet connections, private networks and internal LANs to deliver enhanced telephone services at a lower price. Very soon, data networks will handle nearly three-quarters of all phone calls. As different types of networks converge, they soon will handle almost every form of communication.
Continue reading