Tuesday, May 25th, 2010 | Author: admin

You don’t like to show your users a  standard and simple http error pages. OK Then let’s see how to manage to send the users to a different page, and create your custom error pages.

  1. In httpd.conf file,
    <Directory /var/www/>
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    to

    <Directory /var/www/>
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

  2. Create .htaccess file, unless you do have one. It’s very simple to create a .htaccess file. Open some text editor and save the blank file name as .htaccess. Do not use any extension for the file name, just .htaccess. And don’t forget to put a dot before the file name.
    Write the page url in it, where you will redirect the user to:
    ErrorDocument 404 /404page.html
    or you can just give a message:
    ErrorDocument 404 “The page you are looking is no longer exists.”
  3. Create a html file with the name you given in the .htaccess. So for our example we will create 404page.html in root directory.
  4. Call a page, that does not in your root directory.

! And don’t forget to restart your apache server, after you do some changes in apache’s configuration file httpd.conf.

You can extend this example for any other http errors. Use just one .htaccess file per directory.

Category: About  | Leave a Comment
Friday, May 21st, 2010 | Author: admin

You have two date fields, one is for start date and another one is for end date.  You want to compare and ensure that date fields are in the correct order, like start date is before end date and other way around.

HTML Code:

<html>
<head>
</head>
<body>
<div>
Start Date :<input type=”text” name=”str_date” id=”str_date” size=”10″ value=”" onchange=”controlDate(this.id, ‘end_date’);” />
End Date :<input type=”text” name=”end_date” id=”end_date” size=”10″ value=”" onchange=”controlDate(this.id, ’str_date’);” />
</div>
</body>
</html>

You see, we add onchange javascript function to fields. And add below javascript code in the head of your page.

Javascript Code:

<script>
function controlDate(objId, dateId){
str_first_date = document.getElementById(objId).value;
str_second_date = document.getElementById(dateId).value;
first_date = conv_to_date(str_first_date);
second_date = conv_to_date(str_second_date);
if(objId == “str_date” && second_date != “”)
{
if(first_date > second_date)
{
alert(”Start date must be before end date!”);
document.getElementById(objId).value = “”;
return false;
}

}
if(objId == “end_date” && second_date != “”)
{
if(first_date < second_date)
{
alert(”End date must be after start date!”);
document.getElementById(objId).value = “”;
return false;
}

}
}

function conv_to_date(date_val)
{

var startYear = parseInt(date_val.substr(6,4), 10);
var startMonth = parseInt(date_val.substr(3,2), 10) - 1; // as per Residuum’s comment
var startDay = parseInt(date_val.substr(0,2), 10);
var dt = new Date(startYear, startMonth, startDay);
return dt;
}
</script>

Category: About  | Leave a Comment
Monday, May 03rd, 2010 | Author: admin

If you’re using templates in your project, you may want to use one template more than once. But what if you want to show some elements in one programme and hide these elements in second one. You constantly, write your ordinary two line of javascript code in the head of your html code. That’s where the problem occurs.

For example, you write the code below and run it in your browser,

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<title></title>
<script>
var e = document.getElementById(’mydiv’);
e.style.display = ‘none’;
</script>
</head>

<body>
<div id=”mydiv”>
Hello, How are you today?
</div>
</body>
</html>

Then you will get an javascript error: e is null. Because you can’t change the style of an element with javascript before the element is loaded in your page. But if you’re stubborn like me, you can write your javascript code end of your page.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<title></title>

</head>
<body>
<div id=”mydiv”>
Hello, How are you today?
</div>
</body>
</html>
<script>
var e = document.getElementById(’mydiv’);
e.style.display = ‘none’;
</script>

I tested the code above, in IE6 and FF.

Category: About  | Leave a Comment
Thursday, April 22nd, 2010 | Author: admin

I’ve faced with this error when I tried to join one table with two different tables, in oracle 8i. Someone told me that this is imposibble to overcome and I should write some function and call the function in select statement. I insisted to solve the problem in one query because I wanted to believe that this should be done in Oracle somehow.  Moral of a fable, I found the solution in Ask Tom ( http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3681127952930 ) and I want to share it.

I’m using the same example,

Query that’s giving the error:

SELECT
TIME_DIM.MONTH,
CUSTOMER_DIM.CUSTOMER_NAME,
SUM(SALES_FACTS.HOURS)
FROM
TIME_DIM,
CUSTOMER_DIM,
SALES_FACTS
WHERE
( SALES_FACTS.CUSTOMER_FK(+)=CUSTOMER_DIM.CUSTOMER_PK )
AND ( TIME_DIM.TIME_PK=SALES_FACTS.TIME_FK(+) )
GROUP BY
TIME_DIM.DAY,
CUSTOMER_DIM.CUSTOMER_NAME

Correct query is:

select ...
  from ( select * from time_dim, customer_dim ) A,
       sales_fact
 where a.customer_pk = sales_fact.customer_fk(+)
   and a.time_pk = sales_fact.time_fk(+)
 group by a.day, a.customer_name
Category: About  | Leave a Comment
Tuesday, November 17th, 2009 | Author: admin

Though I study with sql so often, I discovered something very important, today. That is the big difference between subqueries and join statements.
I have two tables named COMPANY and WORK_EXPERIENCE. In Company table there are company_id, company_name, company_country columns and in work_experience table there are id, company_id, employee_id and quit_date columns. So here what I’m trying to do is list all the companies names and the countries where they are in. Also list the number of employees that work in that company beside the name of the company in brackets. Like,
SQL1

So writing join statement like this:
SELECT dbo.ProperCase([company_name]) + ‘ (’ + cast(count(work_experience.id) as varchar) + ‘)’ COMPANY, COUNTRY_NAME
FROM [COMPANY]
INNER JOIN COUNTRY ON COMPANY.country_id = COUNTRY.country_id
LEFT JOIN WORK_EXPERIENCE ON COMPANY.company_id = WORK_EXPERIENCE.company_id
WHERE quit_date is null
group by COUNTRY_NAME

will bring our list but with an exception. If all rows related to one company in work_experience table have all values different than null in quit_date column, that company won’t be seen in the list. Because that is not what we want we can deal with this complication using subqueries.

SELECT COMPANY_NAME + ‘ (’ +
(select cast(count(WORK_EXPERIENCE.ID) as varchar) from WORK_EXPERIENCE WHERE
WORK_EXPERIENCE
.company_id = COMPANY.company_id and quit_date is null) + ‘)’ COMPANY, country_name
FROM [COMPANY]
INNER JOIN COUNTRY ON COMPANY.country_id = COUNTRY.country_id

And the main idea is explaining in  :
AllInterview.com
Majorly subqueries run independently and result of the
subquery used in the outer query(other than corelated subquery).
And in case of join a query only give the result when the
joining condition gets satisfied.

Category: About  | 2 Comments
Monday, December 29th, 2008 | Author: admin

Programcı olmaya karar verdiğim andan itibaren, her öğrendiğimi not defterime yazmaya başlamıştım. Bu notlarla bir site oluşturabilirdim tabii ama bunu yapacak vakit bulamıyordum. Mesleğe yeni başlamıştım, bir taraftan öğreniyordum bir taraftan çalışıyordum. Böylece meslekte 1.5 seneyi geride bıraktım. Artık notlarımı paylaşmamın tam zamanıydı. Bu aslında başta benim fikrim değildi. Bana bu mesleği kazandıran, bu hayatta kalabilmem için bana en değerli armağanlardan birini veren en değerli hocamın, meslektaşımın, yani babamın, fikir vermesi ve yönlendirmesi sonucu not defterimi sizlerle paylaşmaya karar verdim. Sırası gelmişken çok sevdiğim babama buradan çok teşekkür etmek istiyorum. Onun sayesinde buralara geldim. Sonsuz teşekkürler babacığım. Ve anneme sonsuz sabrı, yoğun çalışmalar esnasında evdeki her işe tek başına koştuğu ve babamla çalışmalarımız arasında karnımız acıktığında bize her zaman hazırladığı eşsiz lezzetli yemekleri için çok çok teşekkür etmek istiyorum. Son olarak da sevgili eşime ve ağabeyime, bana her zaman destek verdikleri için çok teşekkür ediyorum. İyiki varsınız.

Category: About  | Leave a Comment
Friday, December 05th, 2008 | Author: admin

I began to take notes, the moment that i decided to be a programmer. I wanted to make a site with these notes but I couldn’t find the time to do this because I was new in my career. I was working and learning at the same time. I’ve been working for 1.5 years in this job. Now it is the time to share my notes. This was not my idea, in the beginning. I started to make this site with my notes because someone gave me this idea. He is the one who is my precious teacher, my colleague, my father. He taught me everything which i know now. By the way i want to thank my dear father here. Thank you so much, daddy. And i want to thank my mother for her endless patience, doing all the job in the home when we were hard working and for all those delicious foods when we were hungry. At last i want to thank my dear husband and my brother for their support, everytime.

Category: About  | Leave a Comment