Menu

Tuesday, November 30, 2010

'jQuery' is undefined

Don't forget to import jquery library first!

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

After that, you may import another jquery files (If you have).

Tuesday, November 23, 2010

Don't forget to delete "rake.gemspec"

C:/Ruby192/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can't find executable r
ake for rake-0.8.7 (Gem::Exception)
from C:/Ruby192/bin/rake:19:in `<main>'

If you encounter the above error when you enter "rake db:create" command , delete "rake.gemspec" in C:/Ruby192/lib/ruby/1.9.1/gems/specifications or C:\Ruby192\lib\ruby\gems\1.9.1\specifications

Tuesday, November 16, 2010

MySQL Commands (1)

- Create a database: mysql> create database [databasename];
- List all databases: mysql> show databases;
- Use another database: mysql> use [db name];
- Show all tables in DB: mysql> show tables;
- Show field formats: mysql> describe [table name];
- Delete a database: mysql> drop database [database name];
- Delete a table: mysql> drop table [table name];
- Dump all databases for backup: -u root -p --opt >/tmp/alldatabases.sql
mysqldump -u username -ppassword –all-databases > dump.sql
- Dump one database for backup:
-u username -p --databases databasename >/tmp/databasename.sql
ysqldump -u username -ppassword database_name > dump.sql
Export A MySQL Database Structures Only
mysqldump -u username -ppassword –no-data database_name > dump.sql
Backup Only Data of a MySQL Database
mysqldump -u username -ppassword –no-create-info database_name >dump.sql
- Dump a table from a database:
-c -u username -p databasename tablename > /tmp/databasename.tablename.sql
- Restore database (or database table) from backup:
-u username -p databasename < /tmp/databasename.sql

How to import .sql into DB in RoR

In database.yml:


development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: DBName_development

  pool: 5
  username: root
  password: Your Password (If you have)
  host: localhost


test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: DBName_test
  pool: 5
  username: root
  password:  Your Password (If you have)
  host: localhost


production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: DBName_production
  pool: 5
  username: root
  password: Your Password (If you have)
  host: localhost



After editing the database.yml file, go to the root of the Rails application via command-line


--->  rake db:create

This command will create the database or DBName_development in MySQL.



The following command can be used to your import SQL file (.sql) into DBName_development:



mysql -u root -p app_development < path_to_.sql/filename.sql
If SQL file is in another directory, for example, you can use ~/Desktop/filename.sql

A complete migration can be applied to the development database from the command line (inside your application's RAILS_ROOT directory):  rake db:migrate

Change root password in MySQL

- When you want to access mysql via command-line, you must use ---> mysql -uroot -p instead of ---> mysql -u root -p

- To change root password --->
$ mysql -uroot -p
mysql> use mysql;
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='USER';
To reload privileges:

mysql> flush privileges;
mysql> quit

Monday, November 15, 2010

RoR

- To create RoR project:  rails new {directory name}

- Before running server, you should make sure that you are inside the directory of your rails application.

- To start the server: rails server

- To stop the server: ctrl+c

- To delete all files that rails generated for you:

  • rd /S /Q {directory name}   <<--- For Windows
  • rm -rf {directory name}  <<--- UNIX
- Copy libmysql.dll into E:\Ruby192\bin (C:\Program Files\MySQL\MySQL Workbench 5.2 CE)

To bind RoR and MySQL together: gem install mysql

- To delete RubyGems libraries (previously versions): gem cleanup

- To create a database with MySQL: rails new {directory name} --database=mysql   <<--- Don't swap the location of each word


- Don't forget "rails new" command when you create a new rails application!!!

Wednesday, November 3, 2010

Fix web page's size

Fix web page's size
Put in the <head> to fix web page's size

<script language="javascript">
window.onload=function(){
 window.moveTo(0,0);
 window.resizeTo(screen.availWidth,screen.availHeight);
}
</script>

Monday, November 1, 2010

Curve Corner

If you want to make curve corner, add these lines into your css file:

/* Begin: Making curve corners */
 border: 0px solid #cce5fc;
 border-radius: 10px;   /*IE9*/
 -moz-border-radius: 10px;   /*Firefox*/
 -webkit-border-radius: 10px;   /*Safari/Chrome */
 -o-border-radius: 10px;   /*Opera*/
 /* End: Making curve corners */

After you add these lines, you'll see curve corner if you access the web page via IE9, Firefox, Safari, Chrome, and Opera browsers.


*For IE browser, these lines of code support IE9 only.
The following picture is the result when you access the web page using IE8.