среда, 26 сентября 2012 г.

bash, colored output

Params:
Linux A230512 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Qt: 4.8.1

KDE Development Platform: 4.8.5 (4.8.5)
Yakuake: 2.9.8


Problem:
Need colored bash output.

Solution:
Edit your ~/.bashrc configuration file.
Find this parameter force_color_prompt and set it to yes.
force_color_prompt=yes

четверг, 13 сентября 2012 г.

Enable $HTTP_SERVER_VARS and $HTTP_GET_VARS in PHP5

Params:
PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch

Problem:
In php4 project not defined variables $HTTP_SERVER_VARS and $HTTP_GET_VARS

Solution:
Enable php directives register_globals and register_long_arrays
You can do it in your php.ini configuration file, but the best way do it in .htaccess file in your specific project.

понедельник, 10 сентября 2012 г.

Git remove submodule

Params:
git version 1.7.9.5

Problem:
Bundles DoctrineFixturesBundle and DoctrineMigrationsBundle has changed repository URLs and namespaces. So I can't update submodules.

Solution:
1) Remove appropriate sections in .git/config file:
pattern: git config -f .git/config --remove-section submodule.$submodulepath
> git config -f .git/config --remove-section submodule.vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle
> git config -f .git/config --remove-section submodule.vendor/bundles/Symfony/Bundle/DoctrineMigrationsBundle
It also remove appropriate sections in .gitmodules file, if not, use this command:
pattern: git config -f .gitmodules --remove-section submodule.$submodulepath
2) pattern: git rm --cached $submodulepath
> git rm --cached vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle
> git rm --cached vendor/bundles/Symfony/Bundle/DoctrineMigrationsBundle

3) Commit this changes:
> git commit -m "Remove submodules DoctrineFixturesBundle and DoctrineMigrationsBundle"

Midnight Commander color scheme and code highlight

Params:
Linux A230512 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
GNU Midnight Commander 4.8.1

Problem:
Need another color scheme and code highlightes in Midnight Commander.

Solution:
Configuration file for mc-4.8.1 located here:
~/.config/mc/ini

1) Enable code highlightes in mc editor.
Change highlight parameter in mc config file to 1:
editor_syntax_highlighting=1
May be you need to copy misc/filehighlight.ini file from mc source to /etc/mc directory.

2) Apply custom color scheme. 
Set appropriate parameter:
[Color]
base_color=lightgray,default:normal=lightgray,default:selected=black,green:marked=yellow,default:markselect=white,green:errors=white,red:menu=lightgray,default:reverse=black,lightgray:dnormal=white,default:dfocus=black,green:dhotnormal=brightgreen,default:dhotfocus=brightgreen,green:viewunderline=brightred,default:menuhot=yellow,default:menusel=white,black:menuhotsel=yellow,black:helpnormal=black,lightgray:helpitalic=red,lightgray:helpbold=blue,lightgray:helplink=black,cyan:helpslink=yellow,default:gauge=white,black:input=black,green:directory=white,default:executable=brightgreen,default:link=brightcyan,default:stalelink=brightred,default:device=brightmagenta,default:core=red,default:special=black,default:editnormal=lightgray,default:editbold=yellow,default:editmarked=black,cyan:errdhotnormal=yellow,red:errdhotfocus=yellow,lightgray

!!! IMPORTANT !!!  - use nano or vi or ... to edit mc ini file, but not internal mc-editor,
otherwise your changes will be lost
!

PS: Thanks to this post author. 

http://plug-and-pray.blogspot.com/2009/09/editing-midnight-commanders-color.html
Her color scheme is beauty.

пятница, 7 сентября 2012 г.

Composer time out error

Params:
php5.3

Problem:
Error while installing dependencies. Command:
> php composer.phar install
returned the error:
[Composer\Downloader\TransportException]
......... file could not be downloaded: failed to open stream: Connection timed out


Solution:
Set higher timeout for composer, run command:
> COMPOSER_PROCESS_TIMEOUT=1000 php composer.phar install
If you get error again try to set higher timeout. For example 3000 against 1000.



четверг, 6 сентября 2012 г.

KnpMenuBundle and Twitter Bootstrap styles

Params:
Symfony2.1 RC2 and appropriate KnpMenuBundle
Twitter Bootstrap 2.1

Problem:
Need to customize Menu by Bootstrap css classes.
For example, I need to add attribute class="nav" to <ul> element of generated menu.

Solution:
Using methods setAttribute(), setChildrenAttributes(), ...
Example:
$menu = $factory->createItem('root');
$menu->setChildrenAttributes(array('class' => 'nav'));
$menu->addChild('Home', array('route' => 'bst_app_homepage'));
...
The output will be:
<ul class="nav">
   <li>...</li>
</ul>

пятница, 31 августа 2012 г.

Symfony2 composer install error

Params:
PHP 5.3.10-1ubuntu3.2
Symfony 2.1 RC2

Problem:
After command
> php composer.phar install
I have error:
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for jms/security-extra-bundle == 1.2.9999999.9999999-dev -> satisfiable by jms/security-extra-bundle 1.2.x-dev.
    - Can only install one of: jms/security-extra-bundle dev-master, jms/security-extra-bundle 1.2.x-dev.
    - Installation request for jms/security-extra-bundle == 9999999-dev -> satisfiable by jms/security-extra-bundle dev-master.

Solution:
1) Remove composer.lock file from your project directory
   > rm composer.lock
2) Re-install all packages again, run command:
   > php composer.phar install

It will take some time, but the problem will be solved.

вторник, 29 мая 2012 г.

пятница, 18 мая 2012 г.

Enable Apache mod_status in Gentoo

Params:
OS: Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
Apache-2.2

Problem:
I need enable apache module mod_status.


Solution:
Edit apache conf file: "/etc/conf.d/apache2"
Add option "-D STATUS" to the directive "APACHE2_OPTS"
Example string:
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -D STATUS"

Restart apache and follow here "http://localhost/server-status"

суббота, 10 марта 2012 г.

Magento cms home page with products and pager

Params:
Magento 1.6.0

Problem:
Display products on home page with pager.

Solution:
Without programming you can display products only from one category.
Edit home page in admin panel of your shop.
Admin panel -> CMS -> Pages -> Home page
Insert into "Design" tab the following code
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
   <action method="setCategoryId">
      <category_id>18</category_id>
   </action>
   <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
      <block type="page/html_pager" name="product_list_toolbar_pager"/>
   </block>
   <action method="setToolbarBlockName">
      <name>product_list_toolbar</name>
   </action>
</block>
</reference>
Change the category_id value for your needs.

четверг, 23 февраля 2012 г.

Gentoo install libgtk-x11-2.0.so.0

Params:
OS: Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux

Problem:
I trying to run LDOCE5 and have this error:
Error while loading shared libraries: libgtk-x11-2.0.so.0
32bit applications need 32bit libraries, but I have 64bit system.

Solution: 
Many 32bit libraries on 64bit gentoo you can install with package app-emulation/emul-linux-x86-gtklibs. Also this package has needed libgtk-x11-2.0.so.0
> emerge app-emulation/emul-linux-x86-gtklibs  -av

суббота, 18 февраля 2012 г.

Enable MySQL query cache, in Gentoo

Params:

   - OS: Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
   - MySQL: mysql  Ver 14.14 Distrib 5.1.61, for pc-linux-gnu (x86_64) using readline 5.1

Problem:
No problem :) I need to enable query cache in mysql for testing my site with high load.

Solution:
Edit mysql config file "/etc/mysql/my.cnf".
Add those options to the "[mysqld]" section:
query-cache-type = 1
query-cache-size = 10M

Restart mysql daemon:
/etc/init.d/mysql restart

To check cache enabled or not, run this query:
show variables like '%query_cache%';
And you will see that (and other options):
have_query_cache YES
query_cache_type ON

суббота, 4 февраля 2012 г.

Magento disable user subscribe success email notification

Params:
Magento 1.6.0

Problem:
In Magento admin you can not disable email notification when user subscribe.  So, look to this solution

Solution:
Find script:
/app/code/core/Mage/Newsletter/Model/Subscriber.php
and comment folloving line in function subscribe($email) :
$this->sendConfirmationSuccessEmail();


PS:
This is bad solution, because  when you upgrade your store to the new version
those changes will be overwritten. If you not so lazy, create package for yourself ;)

пятница, 3 февраля 2012 г.

Magento change amount of emails sended at once

Params:
Magento 1.6.0

Problem:
In Magento I need decrease of emails count wich will be send by cron at once.  Set this value to 8
and send emails every 5 minutes against default 15.

Solution:
Find and edit the following scriots by example.

Change count of emails in one action:
app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
$countOfSubscritions = 8;
app/code/core/Mage/Newsletter/Model/Observer.php
$countOfSubscritions = 8

Change newsletter exec cron  time interval:
/app/code/core/Mage/Newsletter/etc/config.xml
<crontab><jobs><newsletter_send_all><schedule>
<cron_expr>*/5 * * * *</cron_expr>


PS:
This is bad solution, because  when you upgrade your store to the new version
those changes will be overwritten. If you not so lazy, create package for yourself ;)

воскресенье, 15 января 2012 г.

UT2004 game no sound

Params:
Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux

Problem:
No sound in game Unreal Tournament 2004.

Solution:
UT2004 uses openal lib. So you must have this lib in system.
If you run the game by this binary "Games/ut2004/System/ut2004-bin" (32bit system), 
you must have /usr/lib32/openal.so.
Or if you use binary"Games/ut2004/System/ut2004-bin-linux-amd64" (64bit system),
you must have /usr/lib64/openal.so.
On my Gentoo amd64 it wasn't installed (case second). So just type in console:
> emerge media-libs/openal -av

Gentoo error: not found libstdc++.so.5

Params:
- Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
- gcc (Gentoo 4.5.3-r1 p1.0, pie-0.4.5) 4.5.3

Problem:
When I run applicaton it give me this error:
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory


Solution:
> emerge app-emulation/emul-linux-x86-compat -av
It will install also sys-libs/libstdc++-v3
Also, may be you need to create a symbolic link in your application to this shared library.

понедельник, 9 января 2012 г.

Configure Zend Debugger

Params:
Linux Gentoo 3.1.6
PHP 5.3.8-pl0-gentoo
Apache 2.2.21-r1

Problem:
Need to configure Zend Debugger.

Solution:
1) Download Zend Debugger from site zend.com
2) Unpack archive to the temporary folder.
3) Find ZendDebugger.so file with version compatibale to your PHP version
For example, I have PHP version 5.3.8 so my ZendDebugger.so file located in 5.3.x folder.
4) Copy ZendDebugger.so to the folder accesibale by apache.
For example: /home/<user_name>/Applications/ZendDebugger/ZendDebugger.so
5) Edit php.ini. Location of php.ini depends by system. For Gentoo is here: /etc/php/apache2-php5.3/php.ini
6) Add following lines to the end of php.ini:

[Zend]
zend_extension=/home/<user_name>/Applications/ZendDebugger/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always
About this and additional options you can read in internet.
7) Restart the apache. In gentoo just execute /etc/init.d/apache2 restart
8) Check debugger. Look to the phpinfo() if all "ok!" you will see section "Zend Debugger" with config options.
9) Fix errors. If you can't see "Zend Debugger" section look to the apache error log file and fix the errors.
Log file in Gentoo: /var/log/apache2/error_log
In my case I have this errors:
* Failed loading /home/<user_name>/Applications/ZendDebugger/ZendDebugger.so:  libssl.so.0.9.8: cannot open shared object file: No such file or directory
* Failed loading /home/<user_name>/Applications/ZendDebugger/ZendDebugger.so:  libcrypto.so.0.9.8: cannot open shared object file: No such file or directory
So I create soft links to the existing libs "libssl.so.1.0.0" and "libcrypto.so.1.0.0"
> ln -s /usr/lib/libssl.so.1.0.0 /home/<user_name>/Applications/ZendDebugger/
> ln -s /usr/lib/libcrypto.so.1.0.0 /home/<user_name>/Applications/ZendDebugger/
links must be in the same folder with ZendDebugger.so

That's all.

суббота, 7 января 2012 г.

Configure Apache to interpret PHP scripts

Params:
- Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux,
- PHP 5.3.8-pl0-gentoo,
- Apache/2.2.21 (Unix)

Problem:
Apache not interpret php scripts, theirs content printed in browser.

Solution:
Edit apache config file /etc/conf.d/apache2 (don't forget this is gentoo!)
Find string where defined parameter APACHE2_OPTS and add "-D PHP5" to his value.

Kjots data migrate to new version (Kjots 4.6 -> Kjots 4.7.3)

Params:
Linux solar 3.1.6-gentoo #16 SMP Thu Jan 5 14:49:10 GMT 2012 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
KDE 4.7.3

Problem:
Upgrade kde from 4.6 to 4.7.4 and need to migrate my Kjots data to new application version.

Solution:
Open console, and input commands (current user account, not root):
> cd ~/.kde4/share/apps/kjots
> kjotsmigrator --interactive