Wednesday, December 30, 2015

MySql dump - exclude tables by pattern

In this example we want to ignore tables that prefix with lhm_ or _(underscore)

Create bash script with the following lines

#Generate --ignore-table clause
IGNORE=`mysql -A -N -umyuser -pmypass -hmyserver -e"select group_concat(DISTINCT d.ig ORDER BY d.ig ASC SEPARATOR ' ') from (select concat('--ignore_table=myDatabase.',table_name) as ig from information_schema.tables where (table_name like 'lhm_%' or table_name like '\_%')  and table_schema='mydatabase') d;"`


#Run mysqldump with the generated $IGNORE
mysqldump -umyuser -pmypass -hmyserver --routines --no-data --compact --triggers --hex-blob $IGNORE mydatabase -r 'dump.sql'

Thursday, July 18, 2013

Hebrew encoding

Fix encoding

node-iconv -t UTF-8 -f ISO-8859-8 in.srt > out.srt

Here are some guidelines to choose the from (-f) encoding 



בשלוש הדוגמאות האלו רואים עברית הפוכה. שימו לב שבדוגמה הראשונה סימן הקריאה הוא בצד ימין ובשתי הדוגמאות האחרונות הוא בצד שמאל. 
 זה קידוד CP-1255 הוצג כ- ISO-8859-8 
 זה ISO-8859-8 הוצג כ- CP-1255 
 זה ISO-8859-8 הוצג כ- MacHebrew 
בעית קידוד נוספת שגורמת לתופעה דומה היא ציון ISO-8859-8 במקום ISO-8859-8-I או להפך. אז תבדקו גם את האפשרות הזאת.

ארבע הדוגמות הבאות כוללות ביתים שגויים, לכן הופעת סימן היהלום. שימו לב שרק בדוגמה האחרונה מופיע סימן הקריאה בצד שמאל. 
 זה UTF-8 הוצג כ- CP-1255 
 זה UTF-8 הוצג כ- ISO-8859-8 
 זה CP-1255 הוצג כ- UTF-8 
 זה ISO-8859-8 הוצג כ- UTF-8

המצב הזה קל לזיהוי בגלל הצלבים המפרידים בין סימן לסימן. 
 זה UTF-8 הוצג כ- ISO-8859-1

הכתב ה"שבדי" הוא תוצאה של הצגת קידודים אחרים בתור קידוד לטיני: 
 זה CP-1255 הוצג כ- ISO-8859-1 
 זה ISO-8859-8 הוצג כ- ISO-8859-1

מצב זה הוא די נדיר. כאן רואים קידודים שונים המוצגים כקידוד של י.ב.מ.
 זה CP-1255 הוצג כ- IBM-862 
 זה ISO-8859-8 הוצג כ- IBM-862

שני מצבים אלו גם כן נדירים. שניהם נגרמים כתוצאה מהצגת UTF-8 בתור קידודים שונים. 
 זה UTF-8 הוצג כ- IBM-862 
 זה UTF-8 הוצג כ- MacHebrew



Friday, July 15, 2011

Make current directory DocumentRoot in apache

Create the following bash file and put it in the directory you want to use as apache root directory

#!/bin/sh
sed 's!\DocumentRoot .*!DocumentRoot '"`pwd`"'!' /etc/apache2/sites-available/default > default
sudo mv default  /etc/apache2/sites-available/
sudo /etc/init.d/apache2 restart

Friday, April 8, 2011

Connect Oracle with CakePHP

Tested with Windows XP and XAMPP 
1. Install XAMPP
2. Install OracleXEUniv
3. In php.iniuncomment the following line:
     extension=php_oci8.dll
4. Set app/config/database.php :
var $default = array('driver' => 'oracle',
             'connect' => 'oci',
            'persistent' => false,
            'host' => 'localhost',
            'port'=>1521,
            'login' => 'root',
            'password' => 'pass',
            'schema'=>'schama_name',
            'database' => 'localhost:1521/xe',
            'prefix' => ''
         );

Tuesday, January 25, 2011

Connect Cakephp application to remote database via SSH

Tested on ubuntu 10.4
Edit /etc/ssh/sshd_config on your local machine
Add:
AllowTcpForwarding yes
GatewayPorts yes

restart sshd
sudo /etc/init.d/ssh restart


Edit /etc/mysql/my.cnf on remote machine.
Uncomment the following line.
bind-address           = 127.0.0.1

restart mysql
sudo restart mysql

On you local machine run the following command
ssh -i e-keypair -f remoteuser@remote.com -N -L 4444:localhost:3306
If you are not using ssh key you will be prompt for remote user assword

Edit database.php

var $default = array(
        'driver' => 'mysqli',
        'persistent' => false,
        'host' => '127.0.0.1',
        'port'=>4444,
        'login' => 'user',
        'password' => 'pass',
        'database' => 'schema',
        'prefix' => '',
        );

Tuesday, December 21, 2010

Configure ubuntu server to host CakePHP

The following instructions was tested with ami-480df921 on Amazon web services (Ubuntu Lucid 10.4)


1. Update and upgrade the system

sudo aptitude update && sudo aptitude upgrade



2. Reboot
sudo reboot


3. install Lamp
sudo tasksel install lamp-server


4. Check installation
http://yourserver/
Output:

It works!

This is the default web page for this server.
The web server software is running but no content has been added, yet.



5. Enable mod_rewrite

sudo a2enmod rewrite


6. Edit /etc/apache2/sites-available/

<Directory /var/www/myproject>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

7. Copy your app folder to /var/www and replace "myproject"  from step 6 with your folder name.
Its also possible to copy the project folder to any other directory in your server and create a symlink under /var/www.

cd /var/www
sudo ln -s path/to/my/project/folder myproject

8.Check your site
sudo /etc/init.d/apache2 restart
http://yourserver/myproject

9. Enable writing on tmp folder
cd /myproject/app
chmod -R 777 tmp 

10. Set database connection in myproject/app/config/database.php


Thursday, December 2, 2010

Configure apache to host domain and subdomain - ubuntu

1. Copy default configuration file

cd /etc/apache2/sites-available/
cp default mydomain.co.il [or mysubdomain.mydomain.co.il]

2. Disable default site

sudo a2dissite default
sudo /etc/init.d/apache2 reload
sudo rm /etc/apache2/sites-available/default

3. Edit mysubdomain.mydomain.co.il the to look like this:
<VirtualHost *:80>
ServerAdmin siteadmin@mydomain
ServerName mysubdomain.mydomain.co.il
DocumentRoot /var/www/mysubdomain/
<directory>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
</directory>

...
...
</VirtualHost>






4. Create link in site-enabled folder and reload apache configuration file

sudo a2ensite mysubdomain.mydomain.co.il
sudo /etc/init.d/apache2 reload

5. Repeat for every domain/subdomain.

Based on http://phobienbuon.com/archives/202
Tested on Ubuntu 10.4