26 Nisan 2008 Cumartesi

Javascript İle Gizleme/Gösterme

HTML sayfamızdaki herhangi bir alanın gizlenmesi ya da görünür hale gelmesini displayözelliğini kullanarak yapabiliriz.
Alanın gizlenmesi için bu özelliğin değerini display: none şeklinde değiştirmeliyiz.
Gizli bir alanın görünür hale gelmesi için bu özelliğin değerini display: block şeklinde değiştirmeliyiz.

Aşağıdaki örnekte new_artist_region alanı görünmezdir:

<span id="new_artist_region" style="display: none;">
<input name="new_artist" type="text">
</span>



Aşağıdaki örnekte ise new_artist_region alanı görünür durumdadır:

<span id="new_artist_region" style="display: block;">
<input name="new_artist" type="text">
</span>



Aşağıda ise, javascript kullanarak bir alanın nasıl görünür/görünmez hale geldiğini görüyoruz:

<script language="Javascript">
function showhide(area_id){
var area = document.getElementById(area_id);
if (area.style.display == "block") area.style.display = "none";
else if (area.style.display == "none") area.style.display = "block";
}

</script>
<input type="checkbox" name="new_artist" onclick="showhide('new_artist')">New Artist
<span id="new_artist" style="display: none">
<input type="text" name="new_artist">
</span>

25 Nisan 2008 Cuma

How To Export Query Results In Mysql

Use "INTO OUTFILE" directive in your queries to export data from mysql into a text file.

mysql> select * from videos order by artist INTO OUTFILE "c:\videos.csv"
Query OK, 3269 rows affected (0.05 sec)


Use "FIELDS TERMINATED BY" directive to determine delimiter between fields.

mysql> select * from videos order by artist INTO OUTFILE "c:\videos.csv" FIELDS TERMINATED BY "|";
Query OK, 3269 rows affected (0.06 sec)


If you do not specify absolute path in "INTO OUTFILE" directive, the file will be recorded in current database's path. For example, assume that mysql is installed in "D:\dev\mysql" and the current database is "video_db"; then the path of videos.csv would be "D:\dev\mysql\data\video_db".

24 Nisan 2008 Perşembe

How To Change MySql Root Password

In this example, I am going to change mysql root account's password from 1234 to 123456 using SQL. The queries are so self-explanatory. So, there is no need to describe them.

D:\dev\xampp\mysql\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a Source distribution

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

mysql> use mysql;
Database changed
mysql> update user set password=PASSWORD("123456") where User="root";
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

D:\dev\xampp\mysql\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51a Source distribution

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

mysql>

14 Nisan 2008 Pazartesi

Some Mysql-Specific Commands

Following is a list of some of mysql specific commands that I frequently use. You should be connected to mysql server through the command-line to execute the commands.

>show databases;
Display the list of databases hosted by the mysql server

>use db;
Selects the database to be working on.

>desc table;
Describes the metadata of the table;

>show tables;
Display tables of the selected database

>source test.sql;
execute an SQL script file

8 Nisan 2008 Salı

How To Kill A Process In Windows: TASKKILL

What is taskkill?

To kill a process in Windows using command-line use TASKKILL command.

If you know the name of the process use /im switch. Following command terminates Windows Media Player:

taskkill /im wmplayer.exe

If you know the process id, use /pid switch. Following command terminates the process identified by PID=1545:

taskkill /pid 1545

If you want to kill the parent process and its child processes, namely tree-kill, use /t switch. Following command terminates the process identified by PID=1545:

taskkill /t /pid 1545

If you want to force the process to be terminated, use /f switch. Following command terminates the process forcefully:

taskkill /f /pid 1545

5 Nisan 2008 Cumartesi

Why Doesn't PrintWriter Work?

Even though you may call method PrintWriter.println(), you may not get any output. This is because PrintWriter is auto-flush off by default. Check the code below:

 1 public class Test {
2 public static void main(String[] args) {
3 OutputStream out1 = System.out;
4 PrintWriter out = new PrintWriter(out1);
5 out.println("hello");
6 System.out.println("text is about to be flushed.");
7 out.flush();
8 }
9 }

The output is as follows:
text is about to be flushed.
hello

To enable auto-flush, you must initialize PrintWriter as follows:
PrintWriter out = new PrintWriter(out1, true);