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)

20130830

sahi - how to get/fetch html table cell (td) content value

to get a table cell contents/value use .innerHTML

the variable $rpNameRow1, after the _fetch() call, will contain the value "My Name":

    var $rpNameRow1 = _fetch(_cell("routeplanListForm:routeDetailTable:0:rpName").innerHTML);
    _click(_link("Navn", _in(_tableHeader("routeplanListForm:routeDetailTable:rpNameheader"))));
    _wait(10000, _cell("routeplanListForm:routeDetailTable:0:rpName").innerHTML != $rpNameRow1);

sahi - how to get/fetch html text (textbox) input tag value

to get a textbox's value use .value
 
the variable $street is sent in with a value of "My Street 1":

    _setValue(_textbox("editTAParty:street"), $street);
    _wait(10000, _textbox("editTAParty:street").value == $street);

sahi - how to get/fetch html select input tag selected value and/or selected index number

to get a select list's selected index use .options.selectedIndex

UPDATE 20130902: .value didn't seem to work

if you want the selected option's value (label) use .value _getSelectedText(_select("editTAParty:role"))

which will give you the label text as it is seen in the browser, e.g.: "Despatch"

the variable $role is sent in with a value of 1:

    _setSelected(_select("editTAParty:role"), $role);
    _wait(10000, _select("editTAParty:role").options.selectedIndex == $role);


so if your code isn't using index numbers for setting the select, then use _getSelectedText instead:
_wait(10000, _getSelectedText(_select("editTAParty:role")) == $role);

sahi - use "wait" ( _wait ) to make your scripts *faster*

yes it sounds odd, but using _wait appropriately can actually make your scripts run faster, without having to worry whether any script command got skipped because something happened too fast (e.g. maybe because of ajax?) :)

i've found that if i don't insert _wait calls in sahi scripts, then sometimes certain operations get skipped, so my code used to consist of some guesstimated wait periods for certain operations, like this:
    _setValue(_textbox("editTAParty:contact"), $email);
    _wait(500);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);
    _wait(500);


but if you use the advanced _wait functionality, then nothing will get skipped and your scripts will run as fast as possible. here's an example:
    _setValue(_textbox("editTAParty:contact"), $email);
    _wait(10000, _textbox("editTAParty:contact").value == $email);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);
    _wait(10000, _select("editTAParty:Party_languageIN").options.selectedIndex == $language);


basically, these wait calls mean to proceed with execution of the next step immediately as soon as the condition is fulfilled (or after 10 seconds--whichever comes first).

10000 means 10 seconds (10000 milliseconds). i set a high number since i don't anticipate any operation in the app that i'm testing to ever taking longer than 10 seconds.

UPDATE 20130902

just tested a full implementation of this on a script with 320 steps and reduced the run time from 7:30 to 1:47 :)

sahi - how to print javascript timestamp date and time in console





var $now = new Date().getFullYear() + "." + new Date().getMonth() + "." + new Date().getDate() + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + "." + new Date().getMilliseconds();
 


_debug($now);

In the grey "Sahi Controller" console you'll see something like this:
_debug("2013.7.30 12:1:20.777");

20130822

jrebel - xhtml files not getting reloaded after change/edit

yesterday i was changing some xhtml files while running my app in debug mode in eclipse, but the changes weren't showing up in the browser and i wasn't seeing any reloading msgs in the console, although my jrebel.log file was showing that changes had been registered:
2013-08-22 13:30:49.979 INFO  [IntelliJFSNotify] Event 'CHANGE' on: '/home/me/workspaceEclipse/myapp/WebContent/webcomponents/fragments/listTransportRequests.xhtml'

i found this post today JRebel, JSF and automatic reload of xhtml files so i opened my web.xml file to see if these elements were there:
<context-param>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>0</param-value>
</context-param>
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>


and they were, except the values were different:
<context-param>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>2</param-value>
</context-param>
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>false</param-value>
</context-param>


when i changed them to 0 and true, then saved the web.xml file, i suddenly saw some output on the console that one of my xhtml files had been changed. then i changed the values back to their original values and jrebel was still reloading them. i stopped the server, rebuilt my project, redeployed in debug and it was still working.... so i'm a little confused...

at least it's working now though :)

ubuntu 13.04 - how to install proprietary amd/ati graphics drivers on Sony Vaio VPCSE laptop

after 4 hours of endless attempts at trying dozens of people's tutorials, i finally was able to install the amd catalyst drivers on my sony vaio vpcse ( Radeon HD 6600M/6700M/7600M Series ) using a ppa and some additional necessary tasks. here's what i did:

open a terminal

first uninstall any fglrx drivers that are installed:
sudo sh /usr/share/ati/fglrx-uninstall.sh
sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev*


(if it's not installed or the sh script isn't there, then don't worry)

install the fglrx ppa:
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install fglrx


check if this folder exists:
ls /usr/lib64

------
DO ONE OF THE FOLLOWING (A or B)
A. if /usr/lib64 doesn't exist, run this:
sudo mkdir /usr/lib64
sudo mkdir /usr/lib64/fglrx
sudo cp -dR /usr/lib/fglrx/* /usr/lib64/fglrx


B. if /usr/lib64 does exist, run this:
sudo mkdir /usr/lib64/fglrx
sudo cp -dR /usr/lib/fglrx/* /usr/lib64/fglrx


the flags -dR mean to copy all files, directories and symlinks, exactly as they are in the source folder you're copying from--everything gets preserved and you get an exact copy.
------

sudo aticonfig --adapter=all --initial

reboot

you should be able to login but unity will probably not work

open a terminal

GET UNITY TO WORK (i think this is the right order, IIRC)
gsettings reset org.compiz.core:/org/compiz/profiles/unity/plugins/core/ active-plugins
 

dconf reset -f /org/compiz/ && setsid unity

20130819

richfaces rich:inputNumberSpinner - how to disable form submit on enter key press

this tutorial has a quite complicated/lengthy solution, which involves recompiling source code: How to disable form submit on Enter and fix for RichFaces rich:inputNumberSpinner

my solution is way simpler:
open richfaces-ui-3.3.3.Final.jar in an archive manager

then open this file in a text editor (double click the file):
/org/richfaces/ui.pack.js

beginning around line 15151, you'll see the following lines:
}if(A.keyCode==13){if(this.spinner.required||""!=this.edit.value){this.edit.value=this.getValidValue(this.edit.value)
}if(this.edit.form){this.edit.form.submit()

change the second line so it looks like this:
}if(this.edit.form){/*COMMENTED OUT BY ME: this.edit.form.submit()*/

when you save the file ui.pack.js in the text editor, the archive manager should ask you if you want to update the jar file, choose Update

clear your browser cache, stop your app server, rebuild your project, then restart your server, then test it out in the browser and you should now be able to hit the enter key in a rich:inputNumberSpinner without submitting the form :)



see also: How to stop page refresh when hit enter button from rich:inputNumberSpinner field?

and here's the bug registered in the jboss issue tracker:
inputNumberSpinner: autosubmit of a form while pressing the ENTER KEY, validation is discarded and modal panel is closed

20130812

wireshark - how to packet sniff webservices messages xml data stream content

we are debugging an issue we have with webservices and one of our clients, so we wanted to see that actual content data he was sending to a webservice at a specific port, so we installed wireshark.

i configured it to filter packages with the following filter text:
tcp.dstport == 9001 and data


at the bottom of the screenshot you can see the actual xml data stream that was sent to the webservice.

and here's the wireshark capture interfaces configuration--i just used "any" which captures on all interfaces.



note: in ubuntu linux you have to start wireshark as root:
sudo wireshark

otherwise you'll get the error/warning "there are no interfaces on which a capture can be done"

Suggestion for increased security against brute force password cracking

imagine if your authentication engine gave you an error even though you entered a correct password--requiring you to enter the correct password at least twice

it would at least double the time it takes to brute force crack a password.

20130805

how to move raid disks to new ubuntu machine when the motherboard failed/died

we have a database server: mydbserver

there we installed oracle 11g (11.1) with a RAID 1 (mirror) disk setup.

today the motherboard on that machine died.

we have another ubuntu server machine (machine2).

we took out the disks on machine2 and replaced them with the disks from mydbserver and after we booted up again, everything worked and we were able to use the RAID disks without any additional processes/configurations :)


wow, that was easy :)

UPDATE 20130919

make sure on the new server that RAID in the BIOS is turned off/disabled

the simplest/easiest web server installation on ubuntu

if you already had python installed on your ubuntu machine, then you're all ready to go! if not, then do this:
sudo apt-get install python

when python is installed, just open a terminal and change directory to the folder where you have some html files you wanna test in a browser, then start the python simple http server:
cd
cd Desktop
python -m SimpleHTTPServer

then open your browser to:
http://localhost:8000

simple as that!

i figured this out because i wanted to test the tlk.io embedded web chat library.

so, in my Desktop folder i made a file called tlkio.html, with the following contents:
<html>
<body>
<div id="tlkio" data-channel="mytestwebchatchannel0192837465" style="width:100%;height:400px;"></div><script async src="http://tlk.io/embed.js" type="text/javascript"></script>
</body>
</html>


so, if i go to this url:
http://localhost:8000/tlkio.html

then i can see that the web chat works.