Please Backup Your Mysql !!!

October 26th, 2007 by sanil

One day , while i am viewing my website, i got the error message is that, your mysql table has been corrupted. I wonder what happened to my database. I used phpmyadmin for its repair. But no use. Gone is gone !!!

All this happened only because of the lack perfect backup of mysql database. You can backup your mysql database in some simple step. I think you know the mysql command mysqldump. This will create an sql file for your database. See example,

mysqldump -u<your_db_username> -p<your_db_password> databasename > /path/to/backup.sql

If you want to save this sql backup in a remote server, use scp command

scp /path/to/bakup.sql root@yourserverip:/path/to/remote/server

This will ask for your current useraccount’s password and remote server password. Thus your backup file is saved to a remote server

If you want to take backup periodically , add this command to your cron and execute as you wish , daily, weekly or monthly .

Go and enjoy programming , dont worry about backup, its already taken :)

Trac Installation

October 20th, 2007 by Sajith M.R

Trac

Trac is an issue tracking system with wiki support. It also provide interface to subversion. It can be used as Web Subversion.

Installation of trac >

use
apt-get install trac
or
yum install trac

depends on your operating system.

user this link for more installation help :http://trac.edgewall.org/wiki/TracDownload

After the installation, you have to setup the trac Environment Directory. For that create a folder any where in you system.

(mkdir myenv) and give full permission to that environment (chmod -R 777 myenv)

To make this directory as your trac environment , use the following command.

trac-admin /path/to/myenv initenv

It will ask for name of your project, mysql connection string, type of subverstion, repository path, and template of your trac.

1) Provide a name for your project

2) If you are not using mysql, the trac by default use Sqlite database . Just enter the option for blank

3) Enter type of subversion there. Just type ’svn’ if you are using svn subversion.

4) Enter the path to your repository

5) Leave the template option blank. Lets change that later.

Now your trac environment is ready.

You can change the above configuration form the trac.ini file in the trac environment folder.

Some useful links :

http://trac.edgewall.org/wiki/TracAdmin
http://trac.edgewall.org/wiki/TracIni
http://trac.edgewall.org/wiki/TracEnvironment

Now lets start trac as standalone . (There are two more option to start trac)

http://trac.edgewall.org/wiki/TracStandalone

For that you can use tracd

eg: tracd -p 8080 /path/to/projectenv

here -p is your portnumber.

If you want to set your hostname also use,

tracd –hostname=localhost -p 8080 /path/to/project

For starting tracd as a daemon , use -d option
eg: tracd -d -p 8080 /path/to/projectenv

if you want to add more than one project through a single port , use

tracd -p 8080 /path/to/project1 /path/to/project2

another way to start multiple project trac is :

tracd -p 8080 -e /path/to/parentenv

Read More »

Web Developer - Mozilla Plugin

October 20th, 2007 by Sajith M.R

If you are a web developer, You can use mozilla’s Web Developer Plugin . In my previous posts i have mentioned some more plugins for mozilla viz yslow and firebug.

This web developer plugin helps you in various manner such as manage form, inputs, images, rulers, javascript etc.

You can download this api from http://chrispederick.com/work/web-developer

Thanks

Sajith.M.R

www , www1 and www2

October 19th, 2007 by Sajith M.R

www , www1 and www2

We know world wide web, the internet web, simply www, and we are very femilier with www.hostname.com

somebody always need a www before any host name to indicate , he is using an url :)

Agree, but now a days i have been hearing that www1 or www2

eg: www1.freewebs.com/sajithmr

what is the difference between www and www1.

Dont worry , they are merely sub domains like, mail.google.com or course.sajithmr.com . Nothing more .

But some organization uses these “special subdomains” differnet purpose such as load balancing, or categorization or role based routing.

Load Balancing means , the initial request to www server may redirect to less busy server such as www1 or www2.

Somebody fears about the serach engine’s apporch on this subdomains. Since www1 and www2 provides same content in some case, and since search engine considers www1 and www2 as two different domains,
content duplication (a violation to search engines rule ) may be reported. If www1 and www2 have a perment redirection (301) i think (Only i think) the duplication may not be a problem.

And lets come into the latter one. Role based routings.

For example http://www.potsdam.edu is the main site of postdam university. But they are using http://www2.potsdam.edu for their students contribution with descriptions and implementation notes etc

Here these two subdomains (www and www2) are using for different role implementation

Please comment this article if you know more about this www subdomains

Refer this blog : http://blogsandbucks.com/what-is-www2-or-www1/

Thanks and Regards
Sajith M.R

Importance of 301 Permanent Redirection

October 19th, 2007 by Sajith M.R

Permanent Redirection


What is the difference between http://www.myhostname.com and http://myhostname.com ?

In most of the case you will get the same website. But if this is the actual scenario , why we redundantly use www, is it only for time consuming ?

Class B web development says that , no need to use www, we have to make a permanent redirection from www.myhost.com to myhost.com. This is what they called no-www

Refer : http://no-www.org/

Then from where does this www come ? Lets ask to w3c. Their answer is, when you host a domain name, say foo.com, for easy understanding they used
ftp.foo.com for their ftp server, and mail.foo.com for their smtp server (mail server). So they used aliaas name www for webserver. Thus www.foo.com came into action.

Refer: http://www.w3.org/Provider/Style/www.html

Anyway www is there. Then for which domain we will give importance. www.foo.com or mere foo.com

For a normal users angle there is no difference, expect he have to type 3 more letter in browsers location bar. But think about search engines, such a google.

When they use urls for page rank and back link calculations (for getting the relavacy and importance of a url), they consider www.foo.com and foo.com as two different domain.

The page rank for your url may get splitted into two better www and no-www url. This is a big factor in SEO (Search Engine Optimization).

So the solution for this is, you have redirect one form to other permanently (301),

either www.foo.com to foo.com
or
foo.com to www.foo.com

You can done this either via your apache’s configuration file or in .htaccess file in your web root.

The Rewrite rule for this redirection is as follows :

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourwebsitename\.com
RewriteRule ^(.*)$ http://www.yourwebsitename.com/$1 [R=permanent,L]

or

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourwebsitename\.com
RewriteRule ^(.*)$ http://yourwebsitename.com/$1 [R=permanent,L]

or in php you can do,

<?php
// Permanent redirection
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.somacon.com/”);
exit();

?>

Remember normal redirection never guide search engine by giving the information that the url is permanently shifted or moved

SVN - Subversion

October 19th, 2007 by Sajith M.R

Subversion

Setup Subversion (svn) >>

Depends on your linux version use package managers
apt-get install subversion
or
yum install subversion

How can i create respository ?

Create a folder which you want to make as repository.

svnadmin create /path/to/folder

If you check the folder after this comment, you can see some files there viz
conf dav db format hooks locks README.txt

Your Repository is okay now. For more http://subversion.tigris.org/project_packages.html

How can i set a port and host for checkin/checkout and commit the project , simply add contents to respository ?

You can use svnserve for this purpose.

svnserve -d -r /path/to/repository

This will listen the default port 3690. You can access this repository via svn://hostname.com

You can use options –listen-port and –listen-host for changing the port and host .

Then the svn checkout action will be like this : svn checkout svn://host.example.com/project1

How can I set Authentication to this repository ??

You can see a conf directory in your repository folder. There you can see three files
authz, passwd, svnserve.conf

edit svnserve.conf

Uncomment the following for setting access control:

anon-access = read // This means anybody can read the repository (checkout)
auth-access = write // Only authorized member can write / update repository

anon-access = none // This means only authorized member can read the repository

Read More »

mencoder - Video Convertion Tool

October 16th, 2007 by Sajith M.R

 At the time of the development of mobshare, we had faced a huge problem in the  convertion of a video format to other formats. Since our video contents are user generated, and we are providing facility to upload any format of the video. But for showing that video we used flash player, the player which is supported by all the browsers. So we need to convert all the video format into flv . In our earlier stage of developments we used ffmpeg, which is another video convertion tool. But it had many problems in some format, and we could not convert videos into flv with audio support, and another factor is our operating system was linux.

Mencoder gave us all the solution for video convertion problem. If you install mencoder by enabling all the support, you can convert any video into any format with a lot of convertion options such as resolution, frame rate, frame size, audio rate etc .

Example convertion: (WMV to AVI)

mencoder movie.wmv -o movie.avi -ovc lavc -oac lavc   

For more details click here: http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide

Have a nice day, 
Regards Sajith 

Download YouTube Videos

October 16th, 2007 by Sajith M.R

How can i download YouTube Videos to my system. ? Everybody have this question. YouTube uses flash player for playing video files.

The advantage of flash player is , most of the web browsers now support swf files. The format of the video is FLV. So if you download the video from youtube , you only get the flv format of the video. So you need flv player in your system. Windows Media Player’s Latest version supports flv file format .

But it is impossible to download the flv file directly from the youtube site. If you take “view source” you cant see any flv files or any “save target as link” there. There are a lot of websites and web tools to download flv files from youtube video url. But these all are not working now, since youtube have changed there default website structure and implemention of the flv player. So these above sites will give you a result “Invalid URL Entry”.

Here the ultimate and simple way to download any video or audio which is playing from your browser (not only youtube videos) can be downloaded using “Firebug”, Mozilla’s Plugin.

Read my article on How to install Firebug from here

Steps for downloading flv video are:

1) Take the YouTube Video in your mozilla browser.

2) From the All/Net tab you can see all the downloading contents. From that find which url is downloading an flv file.

3) Today i can see a get_video link, it may not be same as the youtube all the time. If you + (expand) that, You can see the header part of that file,

saying :Content Type: video/flv

4) Right Click on that link and click copy location. This is the url for your flv file. Download using browser or any download manager like flashget etc.

NB1 : Youtube may change this soon :)

NB2: This can be used for downloading any streaming video or audio content. [ Happy ?? :) ]

Some other urls for downloading Youtube Videos:

http://www.googleneedle.com

http://www.techcrunch.com/get-youtube-movie/

http://keepvid.com/

http://www.youtubex.com/

Thank You and Enjoy Videos

Regards

Sajith.M.R

Mobshare

October 5th, 2007 by Sajith M.R

www.mobshare.in

 

Mobshare is an innovative platform that allows users to share their camera phone images, audio files, videos, blogs etc through an online platform. With a mobshare registration, a user is allowed to create his personal web-space with which he/she can upload his/her camera phone images/videos through MMS* and immediately view it on the internet or mobile phone browsers. The medium allows a user to document his wide range of experiences through photographs & share it with his friends, relatives or larger communities of the user’s choice. The technology presents an opportunity to unlock the combined addictive power of the Internet & mobile phone messaging. * - you can also upload online or even email.

Creating Mobshare Account
You can create yourown account in mobshare. What you need for an account is
a mobile number. When you register with mobshare, you will get yourown mobshare webpage say http://www.yourname.mobshare.in and you will get an mms email account yourname@mobshare.in.
Personal Mobshare Account?
A personal mobshare account is one where only you can post pictures, videos
or whatever. For example, you mobshare account page maybe, www.yourname.mobshare.in
- Others can only view, give their opinion (comment) or rate your postings.
The mobshare email id (like maybe yourname@mobshare.in) of your personal mobshare
account identifies with your mobile phone number and hence restricts others
from posting to your account directly. The posts sent by other users will be
stored in the inbox, waiting for your approval to go public.

You can also create communities
A community allows anyone to post, even though you own and administer it. The
mobshare email id required to post content is displayed at the top of the community
home. The Community link in the homepage lists all community accounts in mobshare.
You may join a community or unjoin it at any point of time.

Read More »

Check all checkboxes (javascript)

October 5th, 2007 by Sajith M.R

javascript checkbox select all

Here is the javascript code for checking all the checkboxes inside an html document.

<script>
function checkAll()
{

var inputs = document.getElementsByTagName(’input’);
var checkboxes = [];
for (var i = 0; i < inputs.length; i++) {

  if (inputs[i].type == ‘checkbox’) {
inputs[i].checked =true;

}
}
}

</script>

Onclick Select All and Copy to Clipboard (javascript)

October 5th, 2007 by Sajith M.R

javascript clipboard

In sometimes, in html , if you want to select the text for a textbox or a textarea , you can use the following script

<script type=”text/javascript”>

function select_all(obj)

{ var text_val=eval(obj);

text_val.focus();

text_val.select();

if (!document.all) return; // IE only

r= text_val.createTextRange();

r.execCommand(\\’copy\\’);

} </script>
The html part is:

<input value=”http://www.sajithmr.com” onclick=”select_all(this)” name=”url” type=”text” />The above script will select all the text for input field and copy to clipboard (for IE only)