пятница, 25 ноября 2011 г.

Gentoo emerge: "Digest verification failed"

Params:
Linux moon 2.6.39-gentoo-r3 #4 SMP Wed Aug 31 17:44:51 EEST 2011 i686 AMD Athlon(tm) XP 2000+ AuthenticAMD GNU/Linux


Problem:
I have this error when trying emerge some applications

Calculating dependencies |  * Digest verification failed:
 * /usr/portage/dev-python/pygobject/pygobject-2.28.6.ebuild
 * Reason: Filesize does not match recorded size
 * Got: 3824
 * Expected: 3826
... done!


Solution:
> emerge --sync
> ebuild /usr/portage/dev-python/pygobject/pygobject-2.28.6.ebuild digest
> emerge --sync


But if you have a bulk of this warning, or you have also this warning:
A file is not listed in the Manifest '<package_ebuild>'
Then read this solution http://uommo.blogspot.com/2011/12/gentoo-emerge-file-is-not-listed-in.html

понедельник, 14 ноября 2011 г.

LDOCE5 no sound solution.

Params:
Linux solar 2.6.38-gentoo-r6 #21 SMP Wed Nov 9 21:29:55 EET 2011 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux
You must had installed and configured 'alsa-oss'

Problem:
No sound in LDOCE5 application.

Solution:
Add 'aoss' to exec ldoce5 command.
Desktop link:
Edit desktop file ldoce5.desktop. Add 'aoss' in the command on Exec line
Exec=aoss '/<path_to_ldoce5_install_dir>/ldoce5//ldoce5'


Also you can create command in user '~/.bashrc' file. Add this line in your .bashrc file
alias ldoce5="aoss /<path_to_ldoce5_install_dir>/ldoce5/ldoce5"
And after reboot you can use 'ldoce5' command to execute application with fixed sound.

May be you have "aoss32" instead "aoss", it also working, trying.

вторник, 1 ноября 2011 г.

PHP sendmail, save mails in local filesystem folder

Params:
OS: Gentoo
Language: PHP 5.3.8

Problem:
Save mails sended from PHP script in local filesystem folder.
View them by KMail

Solution:
Make all changes relative to your distro.
1) Create script fakesendmail.sh

#!/bin/sh 
prefix="/home/<my_username>/temp/sendmail/new"
numPath="/home/<my_username>/temp/sendmail"
if [ ! -f $numPath/num ]; then
    echo "0" > $numPath/num
fi
num=`cat $numPath/num`
num=$(($num + 1))
echo $num > $numPath/num 
name="$prefix/letter_$num.txt"
while read line
do
     echo $line >> $name
done
chmod 777 $name


/bin/true


I saved it in folder /home/<my_username>/Applications/

Don't forget set appropriate pathes in script.

2) Make this script executable: console> chmod +x fakesendmail.sh


3) Create folders for mails: 


console> mkdir 
/home/<my_username>/temp/sendmail/


console> mkdir 
/home/<my_username>/temp/sendmail/cur


console> mkdir 
/home/<my_username>/temp/sendmail/new


console> mkdir 
/home/<my_username>/temp/sendmail/tmp


4) Change folder properties: console> chmod 777 -R 
/home/<my_username>/temp/sendmail/


5) Make changes in php.ini file (on gentoo: /etc/php/apache2-php5.3/php.ini)


Change path to sendmail script to our new script:


sendmail_path = /home/<my_username>/Applications/fakesendmail.sh
6) Open KMail and create new incoming account.
Kontact->Settings->Configure KMail->Accounts->Add Account
In opened window choose "Maildir mailbox" and set appropriate folder "
/home/<my_username>/temp/sendmail"



воскресенье, 30 октября 2011 г.

Regular expression to ignore escaped quotes within quotes

Params:
Language: PHP

Problem:
I have string:
$text = '[[["my tree \",and to and \"\" something \'\"else","moe derevo \" , a takzhe i\" \"nechto \" drugoe",""]],,"en",,[["en"]],2]';
I need only quoted part of it:  my tree \",and to and \"\" something \'\"else


Solution:

$pattern = '/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"/imsu'; // Use this regular expression
$match = '';
preg_match($pattern, $text, $match);
var_dump($match[1]);

And you will see: my tree \",and to and \"\" something \'\"else

вторник, 25 октября 2011 г.

Magento database add table prefix

Problem:
Store setup was without database table prefix.
Now I need to move magento database to existing db with tables from another application.

Parameters:
Magento version 1.6.0

Solution:
Create script "add_db_prefix.php" in your store public catalog. Listing:


<?php
$database_host = "localhost"; // Here database server, ip or domain name
$database_user = "<your_db_user>";
$database_password = "<your_db_user_password>";
$magento_database = "<your_db_name>";
$table_prefix = "mage_"; // Table prefix wich you want!!!

$db = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($magento_database);
$result = mysql_query("SHOW TABLES") or die('Err');
while (($row = mysql_fetch_array($result)) != false) {
    $old_table = $row[0];
    if (preg_match('/'.$table_prefix.'/', $old_table)) {
        echo "Table $old_table already done<br/>\n";
        continue;
    }

    $new_table = $table_prefix.$old_table;
    echo "Renaming $old_table to $new_table<br/>\n";
    $query = "RENAME TABLE `$old_table`  TO `$new_table`";
    mysql_query($query);
}
?>

Do not forget change db conection data in script!
Follow to the url: http://<your_store_domain_name>/add_db_prefix.php
Now all tables in db with new prefix.
And of course you need setup table prefix in your store config file.
Edit config: "app/etc/local.xml"
Find string: "<table_prefix><![CDATA[]]></table_prefix>"
Put there your new table prefix: "<table_prefix><![CDATA[mage_]]></table_prefix>"

среда, 19 октября 2011 г.

Magento Admin Notification bugfix

Magento v.1.6
Trouble:
Every time when I am login to the admin panel see this message:"Reminder: Change Magento`s default phone numbers and callouts before site launch"
It's really damn annoying.


Sollution:
Copy the file app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php
to app/code/local/Mage/AdminNotification/Model/Resource 
Create these folders if they does not exists.
And edit this php script.
Line 102. Find:
$select = $adapter->select()
                ->from($this->getMainTable())
                ->where('url=?', $item['url']);
Replace it by:$select = $adapter->select()
                ->
from($this->getMainTable())
                ->
where('url=? OR url IS NULL', $item['url'])
                ->
where('title=?', $item['title']);

Delete all your notifications.


Thanks to Payserv http://www.magentocommerce.com/boards/viewthread/246247/

понедельник, 3 октября 2011 г.

Move Magento store to another server


Actions
  • Create DB backup (phpmyadmin or etc.)
  • Import backup to server DB.
  • Copy all magento files to the server.
  • Edit config for DB connection. (app/etc/local.xml)
  • Clear Magento cache folder (var/cache/)

In phpmyadmin.
  1. open table core_config_data
  2. Find rows where column "path" equal "web/unsecure/base_url" and "web/secure/base_url".
  3. Edit these rows. Set appropriate site domain name.