Latest Entries »

Sunday, November 7, 2010

solution for prototype.js and jquery.js conflict problems

Jquery have provide a solution for prototype.js and jquery.js conflicts. There is one caveat: By default, jQuery uses "$" as a shortcut for "jQuery". However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:


<script src="prototype.js"><⁄script>
<script src="jquery.js"><⁄script>
<script>
var $j =jQuery.noConflict();
$j(document).ready(function(){

⁄ ⁄ Use jQuery via $j(...)
$j('#button1').click(function(){
var textbox1 = $j('#textbox1').val();
alert(textbox1);

});

⁄ ⁄ Use Prototype with $(...)
$('someid').hide();

}
<⁄script>

Monday, October 18, 2010

How to set Cent OS date and time


By entering following command line, we can change the system date of Cent OS


[root@localhost ~]# date <month by 2 digits><date by 2 digits><hour by 2 digits in 24 hour format><minutes by 2 digits><year by 4 digits>


eg:
        date 101812472010

Saturday, September 25, 2010

How to create mysql stored procedure (without using mysql-query-browser)


How to create mysql stored procedure (without using mysql-query-browser)

In here I'm explaning to simple creating mysql stored procedure without using mysql query browser. So let’s say hello using mysql stored procedure.

1) First you have to open text editor to write the mysql procdure code. So windows users can use notepad and linux users can use vim for that.  File name is “hello.sql”. The file format should be “.sql”.


2) Write the following code on your text editor,  and save.

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`hello` $$
CREATE PROCEDURE `test`.`hello`()
BEGIN
SELECT 'hello';
END $$

DELIMITER ;


3) Explanation about the code

Normally mysql user ";" as the end of a statement (delimiter).  But since stored procedures contain semicolons in the procedure body, we need to use a different delimiter to identify the end of the procedure. Therefore in here I’m using “$$” as delimiter of the procedures. To define the delimiter we can use DELIMITER key word as the first line of the above code.

DROP PROCEDURE IF EXISTS `test`.`hello`$$ ” line will remove the stored procedure if it already exists in the test database. In here you can see I have use “$$” procedure delimiter as the end of the statement.

CREATE PROCEDURE `test`.`hello`() “ line is the start of a stored procedure definition. “hello” is the name of the procedure.

BEGIN “ line is the start of the stored procedure program.

Between BEGIN and END we can write the procedure program with using sql stetments. And we use “;” as the delimiter in the program. “SELECT 'hello'; “ is the simplest sql statement.

END $$ ” line ends the procedure program, and it use “$$” delimiter.

After the end of procedure we should redefine the delimiter to “;” for normal use by "DELIMITER ;".


4) Now you should log on to the mysql database in command line. 
(Windows users should go to the C:\Program Files\MySQL\MySQL Server 5.1…\bin\ where the mysql.exe located)
# Mysql –u –p


5) After login to the mysql you should type SOURCE Hello.sql

Example for linux:
mysql> SOURCE /home/Hello.sql

Example for windows: 
mysql > SOURCE D:/Hello.sql


6) After that you should type following code to run the procedure.
CALL test.hello(); 
or 
USE test;
CALL hello();

The out put,
+-------+
| Hello |
+-------+
| Hello |
+-------+

Wednesday, August 18, 2010

Database Normalization (1 to 3rd form)

In the relational database design, normalization is a systematic way of ensuring that a database structure is suitable for querying without insertion, update, and deletion anomalies that could lead to a loss of data integrity.

1st Normal Form
============
First you have to know what are the multivalued and composite attributes to understand the 1st normal form.

Multivalued Attribute is a attribute which can have more then a single value. For an example we can take a  person's telephone number. We can take many numbers as telephone number (Home tel number,Mobile number, tel number at office). To remove a multivalued attribute we have to divide the attribute.
Example: If we have attribute called "telephone", then we can divide it as "home telephone", "mobile number", "office number".

Composite attribute is a attribute which have several attributes. For an example the address attribute is can take as composite attribute. To remove this attribute we can divide the attribute to the sub attributes.
Example: If we have attribute called "address", then we can divide it to "no.", "street1", "street2", "city", "country".

These kind of attributes (multivalued and composite) should removed from the relation schema to get first normal form relation.

2nd Normal Form
=============
In the 2nd normal form it consider two dependencies called Functional dependencies and Partial dependencies. And also you should have the knowledge of primary key of a relational schema.

Functional dependency occurs when one attribute in a relation uniquely determines another attribute.

Partial dependency occurs when non-key attribute in a relation uniquely determines by sub set of primary key attribute set. Therefore to occur these kind of dependencies the primary key should contain more than one attributes.

All attributes in a relational schema should be fully functionally depend on the primary key of that relational schema. It means there should not occur any partial dependencies.

3rd Normal Form
=============
relational schema which have no transitive dependencies, called 3rd normal formed relational schema. transitive dependency occurs when a non-key attribute in a relational schema depends on another non-key attribute.

Monday, August 16, 2010

Simple Linux shell script ( for beginners)

Here I'm going to show you how to write a simple Linux shell script to print "Hello World" in the Linux command line.

Step 1 : To go to the home folder, type "cd /home" and press 'Enter' key.

Step 2 : To open a new file, type "vi hello.sh" and press 'Enter' key.

Step 3 : Press 'Insert' key and write following code;


#!/bin/sh
#clear for clear the screen
clear
#echo for print Hello World
echo "Hello World"


Step 4 : Press 'Esc' key and type ":wq" and press 'Enter' key to save the file.

Step 5 : Now type "ls" to list the file and check the file was created.

Step 6 : Now type "chmod +x hello.sh" and press 'Enter' key to make it as executable file.

Step 7 : Check the files again by typing "ls". the file will be show in green color.

Step 8 : To run the shell script, type "./hello.sh" and press 'Enter' key. This will print "Hello World" in your screen.

This is the simplest shell script that you can star get familiar with writing Linux shell scripts, and explore the advance shell scripts.

Wednesday, July 28, 2010

Easy way to select numerical data from MySQL table

I'll explain this using a example,


Lets thing we have table called EMP and column called SALARY.
Now suppose there are numerical data and string data in the SALARY column. (ex: 12000, 25000, not available, null...)
For this kind of columns we can use following method to select only numerical data;


SELECT SALARY FROM EMP WHERE (SALARY+0)!=0;

Monday, July 26, 2010

Things that Microsoft could Never Explain....!!!


This is pretty funny and awesome...
-------------------------------------------------------------------------------------------------------------
MAGIC 1


An Indian found that nobody can create a FOLDER anywhere on the Computer which can be named as "CON". This is something funny and inexplicable? At Microsoft the whole Team, couldn't answer why this happened! TRY IT NOW, IT WILL NOT CREATE A "CON" FOLDER


-------------------------------------------------------------------------------------------------------------

MAGIC 2


For those of you using Windows, do the following:


1.) Open notepad application
2.) Type "Bush hid the facts" (without the quotes)
3.) Save it as whatever you want.
4.) Close it, and re-open it.


Noticed the weird bug? No one can explain!


-------------------------------------------------------------------------------------------------------------

MAGIC 3


Again this is something funny and can't be explained? At Microsoft the whole Team, including Bill Gates, couldn't answer why this happened!


It was discovered by a Brazilian. Try it out yourself?


Open Microsoft Word and type


=rand (200, 99)




And then press ENTER
And see the
magic...! 



-------------------------------------------------------------------------------------------------------------

Magic 4 
  
Did you know that a flight number from one of the planes that hit one of the two WTC towers on 9/11 was Q33 NY. In Notepad / WordPad or MS Word, type that flight number i.e Q33 NY. Increase the font size to 72. Change the font to Wingdings. ….. u will be amazed by the findings!!!



-------------------------------------------------------------------------------------------------------------









Saturday, July 17, 2010

Brief introduction about Asterisk

Asterisk is a software that use to handle voice communications. It is created in 1999 by Mark Spencer of Digium.

Normally its installed as a server and attached telephones to make calls to one another, and to connect to other telephone services including the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services.

IP PBX systems, VoIP gateways and conference servers are same of application that we can develop using Asterisk. It is used by small businesses, large businesses, call centers, carriers and governments worldwide. I'm not going to describe about these application but if you are not familiar with this application, then you can simply search them on Wikipedia.

It is a free opensource software and originally design for Linux. But now Asterisk also runs on a variety of different operating systems including NetBSD, OpenBSD, FreeBSD, Mac OS X, and Solaris. And it is available for Microsoft Windows as AsteriskWin32. But still it is most stable on Linux and recommended OSs are Debian, Fedora, CentOS. And also other Linux OSs like Gentoo, SuSE, Mandrake and Slackware.

Friday, July 16, 2010

How to recover hidden data in your pen driver

  1. go to the cmd (press Window key + R -> type "cmd" -> press Enter)
  2. go to your pen drive by type ":" (eg: C:\>f:)
  3. take a view of all hidden file in your pen by typing "dir /ah" (eg f:\>dir /ah)
  4. type "attrib [name of file/folder] -r -a -s -h"
  5. type "attrib -r -a -s -h" to unhide the file (attrib test.txt -r -a -s -h)
  6. if the file name is longer than 6 charactors, the type like this, "attrib filena~1 -r -a -s -h" (filename.txt is the file name)
  • Use this command "attrib -s -h -r f:\*.* /s /d" to solve your problem in once for all file and folders (f: is the pen diver)

Wednesday, May 26, 2010

Power leaking from PC casing

Most of PC users are having troubles with power leaking from their PC casing. There are may have lot of reasons. But most of the time the reason is improper power connection. If you use good power connection with proper 3 pin plug point, then most of the time the problems with power leaking are get solved. We are normally use low price multiplugs for supply power to Monitor, CPU, Speaker/Sub-woofer, Router,Printer, etc. These low price multiplugs have no earth connections for it's 3 pin outputs. So it is not recommend to use low quality multiplugs for PCs. CPU and Monitor must plugged to 3 pin plug points.

Tuesday, May 11, 2010

About Prototype popular javaScript framework

Prototype is a JavaScript framework that aims to ease development of dynamic web application. This framework enables you to deal with lot of JavaScript features like Ajax, DOM extensions, JSON objects, etc. Refer following link to get some idea about Prototype JS framework, I'll give some sample codes for explain how to user these features later.
http://www.prototypejs.org/learn

Friday, May 7, 2010

How to modify or remove php session variables

First you have to open the session for modify or remove session variables.
session_start();

To change a variable, just overwrite it.
$_SESSION['name']='your_name';

To remove a single variable in the session.
unset($_SESSION['name']);

To remove all the variables in the session. (without destroying the session)
session_unset();

To destroy the session.
session_destroy();

Wednesday, May 5, 2010

How to detact javascript is enable or not in the client browser

There are various kind of solution to check the javascript support of client browser. In here I'll provide a solution to block client access who have not enabled javascript in his/her browser.

In this example I user index.html which clients want to visit. And user enable_js.html which will redirect clients from index.html page when their browser not support to javascript.


<noscript>
<meta equiv="refresh" content="0;URL=enable_js.html">
</noscript>


Add above code into the body (between body tags) of index.html. This part will redirect clients who user browsers which not support for javascript to enable_js.html. If javascript is enable, then nothing happent from this code.



<h2 id="nojs" style="font-family: Verdana,Arial,Helvetica,sans-serif; color: rgb(204, 0, 0);">
JavaScript is turned off in your web browser. Turn it ON (Enable) to access the website, then refresh the page.
</h2>
<script>
document.getElementById("nojs").style.display="none";
alert("Javascript enabled successfully! Press ok to continue");
window.location = "index.html";
</script>


Add above code into the body of enable_js.html. This will display error massage when javascript is disable in client's browser. After enable javascript and refresh this page will provide alert with informing the javascript is successfully working. And after press ok it will redirect to the index.html.

Tuesday, April 20, 2010

How to use different types of page numbering formats in a same word .doc file

When we writing well formatted project reports, use (i), (ii), (iii)... page numbering format for pages before the main chapters. For main chapters we use kind of 1, 2, 3... formats. There are few steps to manage this page numberings for different parts.

Steps for MS Office 2007

Lets think we need to add (i), (ii), (iii)... page numbering format for first 5 pages and 1, 2, 3... page numbering format for rest of the doc.

Step1: Goto page 5 click on that page (Lets think the doc start at page 1, not 0)

Step2: Page Layout tab -> Breaks (in the Page Setup section) -> Section Break -> Next Page
This will start a new new section and it start at page 6.

Step3: Goto any page in first section (page1 - page5) and click on it.

Step4 : Insert tab -> Page Number (in the Header Footer section) -> Format Page Numbers...
-> Choose i, ii, iii.... number format (in the Page Number Format dialog box) -> Ok

Step5: Do the same above steps to set page numbers to next section with selecting the 1, 2, 3...
number format

Friday, April 2, 2010

Some free software ER diagramming tools

RISE Editor

http://www.risetobloome.com/

Thursday, April 1, 2010

UML tool for draw UML diagrams fast (a free software)

Free UML Tool for Fast UML Diagrams

UMLet is an open-source UML tool with a simple user interface: draw UML diagrams fast, export diagrams to eps, pdf, jpg, svg, and clipboard, share diagrams using Eclipse, and create new, custom UML elements.

download : http://www.umlet.com/changes.htm


ArgoUML

http://argouml-downloads.tigris.org/

Wednesday, March 24, 2010

flash tutorials

http://www.webdesigntutorials.net/flash_tutorials.php

Monday, March 15, 2010

To get the the first N records in a SQL query differs acording to database platforms.

Here's some samples:

Microsoft SQL Server

SELECT TOP 10 column FROM table

PostgreSQL and MySQL

SELECT column FROM table
LIMIT 10

Oracle

SELECT column FROM table
WHERE ROWNUM <= 10

Sybase

SET rowcount 10
SELECT column FROM table

Firebird

SELECT FIRST 10 column 
FROM table

Monday, January 18, 2010

How to send HTTP request using PHP?

There is a predefined php class called HttpRequest. By using this class we can create object for handle HTTP requests. There are list of function to handle it. Refer PHP manual and get some idea about this class.

In WAMP before use this objects you need to make some changes in php.ini file. Add following line into the php.ini file (somewhere near in the extension).

"extension=php_http.dll"


Example
======

user HttpRequest object to handle get method http request

$r= new HttpRequest('www.example.com?valueone=1&valuetwo=2', HttpRequest::METH_GET);
$r->send();
echo $r->getResponseBody();