Starting mysql in fedora 8 through terminal

Starting mysql in fedora 8 through terminal
===========================================

MySQL Error:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

Solution:
1. login as root in terminal
[Amol@localhost ~]$ su
Password:

2. Start the mysqld:
[root@localhost Amol]# /sbin/service mysqld start

You will get the following:
Initializing MySQL database: Installing MySQL system tables…

OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h localhost password ‘new-password’
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com [ OK ]
Starting MySQL: [ OK ]

3. Now access the mysql prompt:
[root@localhost Amol]# mysql -u root

You will get the following:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

4. Create the database:
[root@localhost
project_directory]# rake db:create

5. Migrate the database:
[root@localhost
project_directory]# rake db:migrate

6. Loading the database:
[root@localhost project_directory]# rake db:fixtures:load

7. Now test your url http://localhost:3000 in a browser

Opening an url in same window

Opening an url in same window

First create the javascript function:

function selfWindow(){
window.location.href = ‘http://www.ambedkar.org’;
}

then call that function on ‘onClick’ event on button or on anchor link
<input type=”button” onclick=”selfWindow();” value=”open”>

<a href=”#” onclick=”selfWindow();“>Open this</a>

Customizing default browse button

Customizing the default browse button is now a very easy stuff :)



You will need only four things:
  1. File filed
  2. Javascript function
  3. CSS classes and ID
  4. Browse button image

Follow this process:

1. Javascript function:

  <script type=’text/javascript’>
    function fileForm(){
      document.overForm.overInput.value = document.realForm.realInput.value;
    }
</script>


2. CSS Classes and ID:

  .fileUpload {
    -moz-opacity:0;
/* for Firefox */
    -khtml-opacity: 0; /* for Safari */
    filter:alpha(opacity: 0); /* for IE */
  }
  span.realSpan, span.overSpan{
    position: absolute;
    middle: 10px;
    left: 10px;
  }
  span.realSpan{z-index: 20;}
  span.overSpan{z-index: 10;}
  #fileInputs{float:left;}


3. File filed:

  <span class=”realSpan”>
    <form name=’realForm’>
      <input type=’file’ class=’fileUpload’ name=’realInput’ onkeyup=’fileForm();’ onmouseout=’fileForm();’ style=”cursor:pointer;”>
    </form>
  </span>
  <span class=”overSpan”>
    <form name=’overForm’>
      <div id=”fileInputs” style=”clear:both;”>
      <div id=”fileInputs”><input type=’text’ name=’overInput’></div>
      <div id=”fileInputs”><input type=’image’ src=’browse_btn.jpg’ style=”cursor:arrow;” onmouseover=”window.status=”; return true;”></div>
    </form>
  </span>

Thats it!

You can refer these links for huge description:
http://www.michaelmcgrady.com/simple.jsp
http://www.quirksmode.org/dom/inputfile.html

Placing default cursor in textbox in Rails

The default cursor means when the page loads in a browser, the cursor should be in/on a particular part, say textbox or textarea.

There is a simple javascript method focus() to place the default cursor:

<script type=”text/javascript”>
   document.getElementById(id).focus();
<script>

But this will not work in rails. Why? Because the page not refreshed in rails.
To overcome this I found one solution, which has crossbrowser compatibility.

def set_focus(id)
  <<-END
  <script language=”javascript”>
     document.getElement ById(“#{id}”).focus();
     if(navigator.appName == “Microsoft Internet Explorer”){
        document.getElementById(“#{id}”).focus();
     }
  </script>
   END
end

Display logo in browser’s address bar

There are two methods to display logo in browser’s address bar:

1. <link rel=”icon” href=”iconname.ico” type=”image/x-icon” />

2. <link rel=”shortcut icon” href=”favicon.ico” type=”image/x-icon” />

…but it has crossbrowser issue.

The first method works in IE only. If we use both methods that will also works in IE only. To overcome this, use second method:
<link rel=”shortcut icon” href=”favicon.ico” type=”image/x-icon” />

so that your logo will display in IE and Firefox as well.