Wednesday, August 27, 2014

Install PDFtk in Windows and Linux




PDFtk  is our friendly graphical tool for quickly merging and splitting PDF documents and pages. It is free and can be downloaded from:
https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
Foe Windows, run exe file
For Redhat Linux:
$        wget http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-1.el6.x86_64.rpm
$        sudo yum install jre-gcj
$        sudo rpm -Uvh pdftk-the-pdf-toolkit/pdftk-2.02-1.el6.x86_64.rpm
$        PATH
$        which pdftk

Install Texlive in Windows and Linux




TeX Live is a free software distribution for the TeX typesetting system that includes major TeX-related programs, macro packages, and fonts. Textlive can be installed in Windows or Linux. (Around 3GB)
Texlive can be downloaded from:
https://www.tug.org/texlive/acquire-netinstall.html

For Windows, run
install-tl-windows.exe

For Redhat Linux
 $  wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
$  tar xf install-tl-unx.tar.gz
$  cd 'directory where file extracted'
$  sudo ./intall-tl
$  O
$  L
  
        Choose the following:
    (1)   New value for binary directory [/usr/local/bin]: /usr/bin
    (Type /usr/bin.)
    (2)   New value for man directory [/usr/man]:
    (Do not type anything.)
    (3)   New value for info directory [/usr/info]:
    (Do not type anything.)
$  R
$  I

Monday, August 25, 2014

Split huge CSV files into serveral files using CSV splitter




When you have a huge CSV file to import to PHPMyAdmin, you will get a message file too large.
You can use CSV splitter to split the huge CSV file into several small size files:
CSV splitter can be downloaded from:
http://www.freedownloadsplace.com/CSV-Splitter-Download-41523.htm
After you extract the compressed file, you will getCSVSplitter.exe.
Run the exe file, the description of input:
CSV file: the path to the CSV that you wanted to split.
Number of lines: the maximum number of lines/rows in each splitted piece.
Max Pieces: limit the number of output files. 0 means unlimited.

The output files will be under a new folder in the same directory of parent file, folder name is parent file add _Pieces.
Note:
Note: the first line of parent file  is treated as title and  will appear  in all child files.
remove unnecessary ones according to your need.

Rename a databse in PHPMYAdmin




I want to update my database wiki in localhost  from another server using PHPMyAdmin.
1. In PHPMyAdmin, select database you want to rename, click Operation at the top menu and rename the database, for example rename wiki to wikiold
2. Click Databases at top menu and  create database wiki.
3. Export wiki database  from another server in sql format using PHPMyAdmin.
4. Import wiki database to localhost in PHPMyAdmin.

localhost wiki database is updated.

Wednesday, August 20, 2014

Compare difference in two MySQL tables




 I have two same  MySQL tables  courses_offered and courses_offered_temp, courses_offered_id
is the primary key, Now I want to  compare difference in these two MySQL tables
SELECT courses_offered_temp.courses_offered_id FROM courses_offered_temp WHERE courses_offered_temp.courses_offered_id NOT IN(SELECT courses_offered.courses_offered_id FROM courses_offered)

Copy MySQL table and ignore error, rename table




Supposed we have courses_offered table copied from courses_offered_temp:
CREATE TABLE  courses_offered LIKE courses_offered_temp;
I already enter some data in  courses_offered, now I want to copy data from courses_offered_temp.
As some of them may repeat, I need to ignore the error to continue:
INSERT IGNORE INTO `courses_offered` SELECT * FROM `courses_offered_temp` ; 
 INSERT IGNORE is used here.
Rename MySQl table  `course_tutorial_schedule` TO `course_tutorial_schedule_old`:
RENAME TABLE  `course_tutorial_schedule` TO `course_tutorial_schedule_old`;

Create triggers in PHPMyAdmin




To create triggers in PHPMyAdmin, click More at the top menu, click Triggers.
1) Click Add trigger
2) create a trigger name such as date trigger
3) input table name for your trigger in Table
4) Select Time from:  Before, After
5) Select INSERT, UPDATE, DELETE
6) In Definition: for example, I want  my CreateionDate column equal to current timing
BEGIN
    SET NEW.CreationDate = NOW();
END
7) Definer: enter your your email address

Monday, August 18, 2014

MySQL primary key and Unique key constraint


I created a user database in MySQL, the id is the primary key and I also want telephone number and country as a Unique key constraint:
CREATE TABLE IF NOT EXISTS `users` (
 `id` int(16) NOT NULL AUTO_INCREMENT,
 `phone` int(16) DEFAULT NULL,
  `country` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQUE_CONSTRAINTS` (`phone`,`country`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 

You can also do iti\n PHPMyAdmin:
1) Click Structure in PHPMyADmin,
2) at bottom, click Relation view, first you need to create index,
3) at bottom, click +Indexes
4) After you create index, the dropdown menu will show under Foreign key Constraint (INNODB).
5) After you select table and column,
constraint name, ON DELETE and ON UPDATE inputs will show up.

Thursday, August 7, 2014

mod_auth_cas.so error: undefined symbol: SSL_connect




I have installed mod_auth_cas.so in Redhat Linux, when I restart Apache, the error message:
 Starting httpd: httpd: Syntax error on line 151 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modues/mod_auth_cas.so into server: /etc/httpd/modules/mod_auth_cas.so: undefined symbol: SSL_connect
                                                           [FAILED]

I check the httpd log:  /var/log/httpd/error_log
[error] MOD_AUTH_CAS: CASCookiePath '/dev/null' is not a directory or does not end in a trailing '/'!
To fix this problem: change the default "CASCookiePath" from "/dev/null" to a real path.
e.g.,
mkdir -p /var/www/cas
chmod 775 /var/www/cas
chown apache.apache /var/www/cas

Change /etc/httpd/conf.d/cas_auth.conf as following:
#
# mod_auth_cas is an Apache 2.0/2.2 compliant module that supports the
# CASv1 and CASv2 protocols
#
<IfModule !mod_ssl.c>
    LoadModule ssl_module modules/mod_ssl.so
</IfModule>
LoadModule auth_cas_module modules/mod_auth_cas.so
<IfModule mod_auth_cas.c>
CASDebug on
CASCookiePath /var/www/cas/
</IfModule>

In httpd.conf, you should not add
LoadModule auth_cas_module modules/mod_auth_cas.so
as it is already loaded by /etc/httpd/conf.d/cas_auth.conf

Install APXS in Redhat Linux




APache eXtenSion tool (APXS) is a tool for building and installing extension modules for the Apache HyperText Transfer Protocol (HTTP) server, to build a dynamic shared object (DSO) from  object files which then can be loaded into the Apache server under runtime via the LoadModule directive from mod_so.

To  Install apxs in Redhat Linux
sudo yum install httpd-devel 
sudo updatedb
 locate apxs 
 apxs application will be in
/usr/sbin/apxs

To use the APache eXtenSion tool (APXS) to compile and install this
object as a dynamically shared object (DSO), for example
apxs -i -c mod_auth_cas.c