Posted by: sggoyal | April 16, 2009

MySQL Daily Backup Script

Create a script file :-  /usr/local/sbin/mysqlbackup.sh

Add below code :-

#!/bin/sh

# Current date
datum=`/bin/date +%Y%m%d-%H`

/usr/bin/mysqldump –user=root –password=RootPassword  \
      Database_name | gzip -9 > /home/sqlbackup/${filename}-${datum}.sql.gz
for file in “$( /usr/bin/find /home/sqlbackup -type f -mtime +5 )”
do
  /bin/rm -f $file
done

exit 0

crontab -e

Add Below Line :-

0 0 * * * /usr/local/sbin/mysqlbackup.sh &> /dev/null ( For Backup Daily)

Posted by: sggoyal | April 2, 2009

JSP/Java Code to Download csv file

<!–JSP Code of Download File

By Saurabh Goyal <sggoyal@gmail.com> –>

<%@ page contentType=”text/html; charset=iso-8859-1″ language=”java” import=”java.sql.*,javax.servlet.*,java.io.*” errorPage=”" %>

 

<%

try { 

 

String ROOT_PATH;

// Path of WebApplication Directy

ROOT_PATH = getServletContext().getRealPath(”/”);

FileInputStream in = new FileInputStream(ROOT_PATH+”syssum.csv”);// Here syssum.csv is source file to download

response.setContentType(”application/csv”);//Sets the MIME header 

response.setHeader(”Content-Disposition”, “attachment; filename=syssum.csv”);// Here syssum.csv is name of file to download

 

int i; 

while ((i=in.read()) != -1) { 

out.write(i); 

in.close(); 

out.close(); 

 

}

catch(Exception e) 

System.out.println(”…error while loading: “+e.toString());

%><html><head></head><body>Error: can’t open file syssum.csv</body></html><%

}

%>

Posted by: sggoyal | March 2, 2009

Configure CakePHP CTP Files in Dreamweaver

For Configure/Opening CakePHP CTP Files in Dreamweaver 3 files that you need to edit:-

C:\Program Files\(Adobe or Macromedia)\(Adobe )Dreamweaver(version like 8 or cs3)\configuration

Open up “Extensions.txt” and on the first line at the very end add THTML and CTP separated by commas, so the line should read:

  1. ,MASTER,THTML,CTP:All Documents  

Similarly add these two extensions to the “:PHP Files” line.

  1. PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files  

Next open the “DocumentTypes” folder and edit the “MMDocumentTypes.xml” file, just open it up using notepad or wordpad. Search for the line which has an id “PHP_MySQL” and add the THTML/CTP file extensions to both the “winfileextension” and “macfileextension” so the line should read:

  1. winfileextension=“php,php3,php4,php5,thtml,ctp”    
  2. macfileextension=“php,php3,php4,php5,thtml,ctp”  

The final file is another version of the “Extensions.txt” which is located in your “Documents and Settings” Folder in my case this is “C:\Documents and Settings\(User_Name)\Application Data\(Adobe or Macromedia)\(Adobe )Dreamweaver(version like 8 or cs3)\configuration” just add the very same things you inserted earlier in “Extensions.txt” .

Older Posts »

Categories