The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20130428

sahi - run block of code only if script called from another script

here's how you conditionally run a block of code in a sahi script (sahi_script2.sah), but only if that script first gets called by another sahi script (sahi_script1.sah).

#############sahi_script1.sah##############

//some sahi code ...

var $write_wd_to_file = true;

_include("sahi_script2.sah");    // RUN sahi_script2.sah

//some sahi code ...

########################################


#############sahi_script2.sah##############

//some sahi code ...

/*
IF YOU CALL sahi_script2.sah DIRECTLY, THEN THIS WONT GET RUN
*/
// $write_wd_to_file gets set in sahi_script1.sah
if($write_wd_to_file) {
    var $weeklyDepartureId = $routeplanName + "_WD";
    _writeToFile($weeklyDepartureId, "weekly_departure_id.txt", true);
    _wait(2000);
}

//some sahi code ...

########################################


sahi_script1.sah runs some code, then runs sahi_script2.sah, which writes a string to a file

if sahi_script2.sah gets runs directly, then that block of code won't get run and nothing will get written to a file.

20130423

call another sahi script from already running sahi script

i have a sahi script that would like to call an already existing sahi script first so i don't duplicate code. the answer was pretty simple:
#######UseCaseTest_2.sah######

_include("../run_this_script_first.sah"); // UseCaseTest 1
...
// then run this code:
...
#############

thanks to this thread:
http://sahi.co.in/forums/discussion/1046/writing-test-scripts-calling-other-scripts-with-passing-arguments-/p1

20130405

can't view chrome > help > help to see chrome version: "The site's security certificate is not trusted!"

i'm running chrome version 26.0.1410.43 on ubuntu 12.04 and when i try to view the version by doing this: chrome > help > help, i get the following error:

The site's security certificate is not trusted!
You attempted to reach support.google.com, but the server presented a certificate issued by an entity that is not trusted by your computer's operating system. This may mean that the server has generated its own security credentials, which Google Chrome cannot rely on for identity information, or an attacker may be trying to intercept your communications.
You cannot proceed because the website operator has requested heightened security for this domain.


the workaround:
chrome://version/

20130404

oracle sql - how to select column with string containing underscore _

underscore ( _ ) is a wildcard in oracle sql, so to get results of a row with a column containing a string with a literal underscore "wildcard" in it:
X_AGR_234253

you need to escape the underscore with a backslash ( \ ):
select * from my_table where my_column like 'X\_AGR%'

the underscore in an "sql select like" statement is like the regex period/full-stop wildcard ( . )

thanks to don:
http://www.dba-oracle.com/t_special_characters_like_sql_query.htm

geek humor of the day by don burleson: oracle on delete

http://www.dba-oracle.com/bk_on_delete_restrict_on_delete_no_action_tips.htm

"The author suggests that the default or NO ACTION would be a good set up for life. While I understand that it would be nice if young children didn't lose their parents, I think it is possible to look at that statement and say that a parent can't die until he has no children. I believe that no parent should have to bury their child, so perhaps the author didn't look into the statement enough."

20130402

clicking a link after session timeout showed login page xhtml code instead of a rendered jsf page

we had a weird error today. we saw that after our session timed out and then we clicked on something in our application, we were redirected to the login page, but we were able to see the jsf code in the browser, instead of seeing the login form.

we found out that the problem was in our web.xml.

here's the relevant code:

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
...
<error-page>
<error-code>403</error-code>
<location>/login.xhtml</location>
</error-page>


to fix the problem we changed it to this:

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
...
<error-page>
<error-code>403</error-code>
<location>/login.jsf</location>
</error-page>