JavaScript string newline character?

I’ve just tested a few browsers using this silly bit of JavaScript:  Run code snippetExpand snippet IE8 and Opera 9 on Windows use \r\n. All the other browsers I tested (Safari 4 and Firefox 3.5 on Windows, and Firefox 3.0 on Linux) use \n. They can all handle \n just fine when setting the value, though IE and Opera … Read more

Floating div positioning

. I need a floating rectangle (100% width, 100px height) to appear exactly 20px above the bottom of a page. How can I do that? The code below shows the rectangle at the bottom of the browser window not the page – so if the page is taller than what can fit in the screen, … Read more

XQuery data and text() function

text() is used to match something. For example if we have this structure: Doing //b/text() will return the text node ‘hello ‘ just like //b/element() will return the element c. data($arg) is a function that returns the atomic value of a node, for example data(//b) will return ‘hello world’. If you use the data($arg) function … Read more

Is there a difference between /\s/g and /\s+/g?

In the first regex, each space character is being replaced, character by character, with the empty string. In the second regex, each contiguous string of space characters is being replaced with the empty string because of the +. However, just like how 0 multiplied by anything else is 0, it seems as if both methods strip spaces in exactly the … Read more

how does the ampersand(&) sign work in c++?

To start, note that is a special pointer ( == memory address) to the class its in. First, an object is instantiated: Next, a pointer is instantiated: Next, the memory address of a is assigned to the pointer b: Next, the method CDummy::isitme(CDummy &param) is called: A test is evaluated inside this method: Here’s the tricky part. param is an … Read more