qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
246,162 | <p>can we output a .jpg image or .gif image in C? <p>I mean can we print a picture as output with the help of a C program?<p>Aslo can we write a script in C language for HTML pages as can be written in JavaScript? <p>Can the browsers operate on it?<p>If not possible is there any plugin for any of the browsers?
<p>Any e... | [
{
"answer_id": 246165,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": false,
"text": "<p>That's a lot of questions!</p>\n\n<p>You can generate JPEG and PNG files from C using <a href=\"http://www.ijg.org/\" rel... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31116/"
] | can we output a .jpg image or .gif image in C? I mean can we print a picture as output with the help of a C program?Aslo can we write a script in C language for HTML pages as can be written in JavaScript? Can the browsers operate on it?If not possible is there any plugin for any of the browsers?
Any example code or lin... | You can generate a web page from a C program by using the [Common Gateway Interface](http://hoohoo.ncsa.uiuc.edu/cgi/) (CGI). The C program is compiled and runs on the server, this is different from Javascript which runs on the browser.
You can also generate images via CGI too. Just set the content type appropriately,... |
246,192 | <p>Instead of hardcoding the default @author template I would like Eclipse to use user's real name taken from account information (in Linux - but Windows solution is also welcome). Entering it somewhere into Eclipse configuration would be acceptable, too, alas I can't find the right place.</p>
| [
{
"answer_id": 246264,
"author": "Davide Inglima",
"author_id": 32041,
"author_profile": "https://Stackoverflow.com/users/32041",
"pm_score": 9,
"selected": true,
"text": "<p>It seems that your best bet is to redefine the java <code>user.name</code> variable either at your command line, ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29576/"
] | Instead of hardcoding the default @author template I would like Eclipse to use user's real name taken from account information (in Linux - but Windows solution is also welcome). Entering it somewhere into Eclipse configuration would be acceptable, too, alas I can't find the right place. | It seems that your best bet is to redefine the java `user.name` variable either at your command line, or using the `eclipse.ini` file in your eclipse install root directory.
This seems to work fine for me:
```
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Duser... |
246,193 | <p>While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of</p>
<pre><code>Name : Value
Name2 : Value2
</code></pre>
<p>etc.</p>
<p>The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form... | [
{
"answer_id": 246203,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 4,
"selected": false,
"text": "<p>You can use <a href=\"http://www.w3schools.com/js/js_obj_math.asp\" rel=\"noreferrer\">Math.round()</a> for roun... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18673/"
] | While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of
```
Name : Value
Name2 : Value2
```
etc.
The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form `2.20011E+17`. What I want to ou... | You hav to convert your input into a number and then round them:
```
function toInteger(number){
return Math.round( // round to nearest integer
Number(number) // type cast your input
);
};
```
Or as a one liner:
```
function toInt(n){ return Math.round(Number(n)); };
```
Testing with different value... |
246,215 | <p>I am writing a shell script that takes file paths as input.</p>
<p>For this reason, I need to generate recursive file listings with full paths. For example, the file <code>bar</code> has the path:</p>
<pre><code>/home/ken/foo/bar
</code></pre>
<p>but, as far as I can see, both <code>ls</code> and <code>find</code... | [
{
"answer_id": 246220,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 10,
"selected": true,
"text": "<p>If you give <code>find</code> an absolute path to start with, it will print absolute paths. For instance, to f... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | I am writing a shell script that takes file paths as input.
For this reason, I need to generate recursive file listings with full paths. For example, the file `bar` has the path:
```
/home/ken/foo/bar
```
but, as far as I can see, both `ls` and `find` only give relative path listings:
```
./foo/bar (from the fol... | If you give `find` an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory:
```
find "$(pwd)" -name .htaccess
```
or if your shell expands `$PWD` to the current directory:
```
find "$PWD" -name .htaccess
```
`find` simply prepends the path i... |
246,223 | <p>Is there any way to export data (not necessarily schema) to an access database via asp.net?</p>
<p>The server has no office components installed and the process must occur via a webpage (like an excel export).</p>
| [
{
"answer_id": 246265,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "<p>Here is a very detailed article. It is something I stumbled upon, not an approach I am familiar with:</p>\n\n<p><a href... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23230/"
] | Is there any way to export data (not necessarily schema) to an access database via asp.net?
The server has no office components installed and the process must occur via a webpage (like an excel export). | You have to do it programatically.
1. Open the source table
2. Create a new AccessDB using ADO Extensions (as shown above)
3. Create the table in the AccessDB by reading the source schema (CREATE TABLE X ...)
4. Iterate thought the source table inserting the records in the Access table
Note: Code from <http://www.fre... |
246,225 | <p>I need to create a midnight DateTime</p>
<p>I've just done this:</p>
<pre><code>DateTime endTime = DateTime.Now;
endTime.Subtract(endTime.TimeOfDay);
</code></pre>
<p>Haven't test it yet, I'm assuming it works but is there a better/cleaner way?</p>
| [
{
"answer_id": 246229,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 9,
"selected": true,
"text": "<p>Just use <code>foo.Date</code>, or <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.datetime.today\" r... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25462/"
] | I need to create a midnight DateTime
I've just done this:
```
DateTime endTime = DateTime.Now;
endTime.Subtract(endTime.TimeOfDay);
```
Haven't test it yet, I'm assuming it works but is there a better/cleaner way? | Just use `foo.Date`, or [`DateTime.Today`](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.today) for today's date |
246,227 | <p>There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header?</p>
| [
{
"answer_id": 246260,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": -1,
"selected": false,
"text": "<p>Are you asking about the Server header value in the response? You can try changing that with an add_header directive, but ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] | There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header? | Like Apache, this is a quick edit to the source and recompile. From [Calomel.org](https://calomel.org/nginx.html):
>
> The Server: string is the header which
> is sent back to the client to tell
> them what type of http server you are
> running and possibly what version.
> This string is used by places like
> Al... |
246,228 | <p>If I make a JFrame like this</p>
<pre><code>public static void main(String[] args) {
new JFrame().setVisible(true);
}
</code></pre>
<p>then after closing the window the appication doesn't stop (I need to kill it).</p>
<p>What is the proper way of showing application's main windows ?</p>
<p>I'd also like to... | [
{
"answer_id": 246234,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 6,
"selected": true,
"text": "<p>You should call the <code>setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</code> in your JFrame.</p>\n\n<p>Example code... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24028/"
] | If I make a JFrame like this
```
public static void main(String[] args) {
new JFrame().setVisible(true);
}
```
then after closing the window the appication doesn't stop (I need to kill it).
What is the proper way of showing application's main windows ?
I'd also like to know a reason of a proposed solution.
... | You should call the `setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);` in your JFrame.
Example code:
```
public static void main(String[] args) {
Runnable guiCreator = new Runnable() {
public void run() {
JFrame fenster = new JFrame("Hallo Welt mit Swing");
fenster.setDefaultCloseOp... |
246,232 | <p>I have the following text</p>
<pre><code>tooooooooooooon
</code></pre>
<p>According to this book I'm reading, when the <code>?</code> follows after any quantifier, it becomes non greedy.</p>
<p>My regex <code>to*?n</code> is still returning <code>tooooooooooooon</code>.</p>
<p>It should return <code>ton</code> s... | [
{
"answer_id": 246236,
"author": "Hank",
"author_id": 7610,
"author_profile": "https://Stackoverflow.com/users/7610",
"pm_score": 2,
"selected": false,
"text": "<p>The string you are searching in (the haystack as it were) does not contain the substring \"ton\".</p>\n\n<p>It does however ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | I have the following text
```
tooooooooooooon
```
According to this book I'm reading, when the `?` follows after any quantifier, it becomes non greedy.
My regex `to*?n` is still returning `tooooooooooooon`.
It should return `ton` shouldn't it?
Any idea why? | A regular expression can only match a fragment of text that actually exists.
Because the substring 'ton' doesn't exist anywhere in your string, it can't be the result of a match. A match will only return a substring of the original string
EDIT: To be clear, if you were using the string below, with an extra 'n'
```
t... |
246,249 | <p>Is there any way to add iCal event to the iPhone Calendar from the custom App?</p>
| [
{
"answer_id": 249141,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": 4,
"selected": false,
"text": "<p>Yes there still is no API for this (2.1). But it seemed like at WWDC a lot of people were already interested in the func... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26980/"
] | Is there any way to add iCal event to the iPhone Calendar from the custom App? | Based on [Apple Documentation](https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/EventKitProgGuide/ReadingAndWritingEvents.html#//apple_ref/doc/uid/TP40004775-SW1), this has changed a bit as of iOS 6.0.
1) You should request access to the user's calendar via "requestAccessToEntityType... |
246,272 | <p>I have a problem with how ASP.Net generates the <strong>img</strong> tag.
I have a server control like this: </p>
<pre><code><asp:Image runat="server" ID="someWarning" ImageUrl="~/images/warning.gif" AlternateText="Warning" />
</code></pre>
<p>I expect it to generate this: </p>
<pre><code><img id="ctl00_... | [
{
"answer_id": 246282,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 2,
"selected": true,
"text": "<p>Looks like it's trying to use a custom handler (ashx) to deliver the image. Do you have any additional modules that may be o... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2099426/"
] | I have a problem with how ASP.Net generates the **img** tag.
I have a server control like this:
```
<asp:Image runat="server" ID="someWarning" ImageUrl="~/images/warning.gif" AlternateText="Warning" />
```
I expect it to generate this:
```
<img id="ctl00_ContentPlaceHolder1_ctl00_someWarning" src="../images/warni... | Looks like it's trying to use a custom handler (ashx) to deliver the image. Do you have any additional modules that may be overriding the default behaviour of the asp:Image?
Your JavaScript won't work because the image tag has not been given an ID in the HTML that was generated. |
246,274 | <p>I want to be able to run a function in my firefox sidebar js file when the selected tab in the main content window is reloaded or changed. So the sidebar can change depending on the site the user is looking at. </p>
<p>Anyone able to point me in the right direction?</p>
| [
{
"answer_id": 301756,
"author": "user11198",
"author_id": 11198,
"author_profile": "https://Stackoverflow.com/users/11198",
"pm_score": 2,
"selected": false,
"text": "<p>My solution pilfered from somewhere but can't remember where: </p>\n\n<pre><code>//add the load eventListener to the... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11198/"
] | I want to be able to run a function in my firefox sidebar js file when the selected tab in the main content window is reloaded or changed. So the sidebar can change depending on the site the user is looking at.
Anyone able to point me in the right direction? | My solution pilfered from somewhere but can't remember where:
```
//add the load eventListener to the window object
window.addEventListener("load", function() { functioname.init(); }, true);
var functionname = {
//add the listener for the document load event
init: function() {
var appcontent = document.get... |
246,275 | <p>I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.</p>
<p>For example:</p>
<p>git status in git-build branch:</p>
<pre><code># On branch git-build
# Chan... | [
{
"answer_id": 246285,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>The modified files are not put in the repository until you add <em>and</em> commit them. If you switch back to your to... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25453/"
] | I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.
For example:
git status in git-build branch:
```
# On branch git-build
# Changes to be committed:
# ... | This is the default behaviour of git.
You can use **-f** flag to checkout to do "clean checkout" if you like. |
246,280 | <p>I have seen a function whose prototype is:</p>
<pre><code>int myfunc(void** ppt)
</code></pre>
<p>This function is called in a C file as
a = myfunc(mystruct **var1);</p>
<p>where mystruct is typedef for one of structure we have. </p>
<p>This works without any compilation errors in MSVC6.0, But when I compil... | [
{
"answer_id": 246288,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "<p><code>void**</code> <em>is</em> valid but, based on your error message, you probably have to explicitly cast the argum... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] | I have seen a function whose prototype is:
```
int myfunc(void** ppt)
```
This function is called in a C file as
a = myfunc(mystruct \*\*var1);
where mystruct is typedef for one of structure we have.
This works without any compilation errors in MSVC6.0, But when I compile it with some other C compiler, it gives... | `void**` *is* valid but, based on your error message, you probably have to explicitly cast the argument as follows:
```
mystruct **var1;
x = myfunc ((void**) var1);
```
That's because the `myfunc` function is expecting the `void**` type. While `void*` can be implicitly cast to any other pointer, that is not so for t... |
246,293 | <p>Is there any good practice related to dynamic_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw.
Should I check for both? And if I catch bad_cast or detect NULL I probably can't recover anyway...
For now, I'm using assert to check if ... | [
{
"answer_id": 246313,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 1,
"selected": false,
"text": "<p>It depends... ;-)</p>\n\n<p>If I really expected the <code>dynamic_cast</code> to give me something usable, for exa... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579/"
] | Is there any good practice related to dynamic\_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad\_cast it can throw.
Should I check for both? And if I catch bad\_cast or detect NULL I probably can't recover anyway...
For now, I'm using assert to check if ... | If the `dynamic_cast` *should* succeed, it would be good practice to use `boost::polymorphic_downcast` instead, which goes a little something like this:
```
assert(dynamic_cast<T*>(o) == static_cast<T*>(o));
return static_cast<T*>(o);
```
This way, you will detect errors in the debug build while at the same time avo... |
246,296 | <p>What possible reasons could exist for MySQL giving the error <code>“Access denied for user 'xxx'@'yyy'”</code> when trying to access a database using PHP-mysqli and working fine when using the command-line mysql tool with exactly the same username, password, socket, database and host?<br>
<strong>Update:</strong><br... | [
{
"answer_id": 246312,
"author": "Huibert Gill",
"author_id": 1254442,
"author_profile": "https://Stackoverflow.com/users/1254442",
"pm_score": 3,
"selected": false,
"text": "<p>Sometimes in php/mysql there is a difference between localhost and 127.0.0.1</p>\n\n<p>In mysql you grant acce... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11940/"
] | What possible reasons could exist for MySQL giving the error `“Access denied for user 'xxx'@'yyy'”` when trying to access a database using PHP-mysqli and working fine when using the command-line mysql tool with exactly the same username, password, socket, database and host?
**Update:**
There were indeed three use... | In case anyone’s still interested: I never did solve this particular problem. It really seems like the problem was with the hardware I was running MySQL on. I’ve never seen anything remotely like it since. |
246,306 | <p>How do I convert a keycode to a keychar in .NET?</p>
| [
{
"answer_id": 246309,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 4,
"selected": false,
"text": "<p>In VB.NET:</p>\n\n<pre><code>ChrW(70)\n</code></pre>\n\n<p>In C# you can cast:</p>\n\n<pre><code>(char) 70\n</code></pre>\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I convert a keycode to a keychar in .NET? | In VB.NET:
```
ChrW(70)
```
In C# you can cast:
```
(char) 70
``` |
246,315 | <p>I'm trying to compile such code:</p>
<pre><code>#include <iostream>
using namespace std;
class CPosition
{
private:
int itsX,itsY;
public:
void Show();
void Set(int,int);
};
void CPosition::Set(int a, int b)
{
itsX=a;
itsY=b;
}
void CPosition::Show()
{
cout << "x:" << it... | [
{
"answer_id": 246324,
"author": "Keith Nicholas",
"author_id": 10431,
"author_profile": "https://Stackoverflow.com/users/10431",
"pm_score": 1,
"selected": false,
"text": "<p>errr, no, Position isnt visible in the function \"main\"</p>\n\n<p>Make it public... or put a public getter f... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32312/"
] | I'm trying to compile such code:
```
#include <iostream>
using namespace std;
class CPosition
{
private:
int itsX,itsY;
public:
void Show();
void Set(int,int);
};
void CPosition::Set(int a, int b)
{
itsX=a;
itsY=b;
}
void CPosition::Show()
{
cout << "x:" << itsX << " y:" << itsY << endl;
}
... | In addition to the normal getter you should also have a const getter.
Please note the return by reference. This allows you any call to SetXX() to affect the copy of Position inside CCube and not the copy that you have been updating.
```
class CCube
{
private:
CPosition Position;
public:
CPos... |
246,321 | <p>Here's a very simple question. I have an SP that inserts a row into a table and at the end there's the statement RETURN @@IDENTITY. What I can't seem to find is a way to retrieve this value in C#. I'm using the Enterprise library and using the method:</p>
<pre><code>db.ExecuteNonQuery(cmd);
</code></pre>
<p>I've t... | [
{
"answer_id": 246332,
"author": "Craig Norton",
"author_id": 24804,
"author_profile": "https://Stackoverflow.com/users/24804",
"pm_score": 3,
"selected": true,
"text": "<pre><code>Dim c as new sqlcommand(\"...\")\n\nDim d As New SqlParameter()\nd.Direction = ParameterDirection.ReturnVal... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] | Here's a very simple question. I have an SP that inserts a row into a table and at the end there's the statement RETURN @@IDENTITY. What I can't seem to find is a way to retrieve this value in C#. I'm using the Enterprise library and using the method:
```
db.ExecuteNonQuery(cmd);
```
I've tried **cmd.Parameters[0].V... | ```
Dim c as new sqlcommand("...")
Dim d As New SqlParameter()
d.Direction = ParameterDirection.ReturnValue
c.parameters.add(d)
c.executeNonQuery
(@@IDENTITY) = d.value
```
It is more or less like this...either this or just return the value from a stored procedure as an output parameter. |
246,329 | <p>This might be a naive question. I have to manually edit a .WXS file to make it support select features from command line.</p>
<p>For example, there are 3 features in .WXS file.</p>
<pre><code><Feature Id="AllFeature" Level='1'>
<Feature Id="Feature1" Level='1'> </Feature>
<Feature Id... | [
{
"answer_id": 246920,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 6,
"selected": true,
"text": "<p>I would change Feature1, Feature2 and Feature3 to Components, then would declare something like this:</p>\n\n<pre><c... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] | This might be a naive question. I have to manually edit a .WXS file to make it support select features from command line.
For example, there are 3 features in .WXS file.
```
<Feature Id="AllFeature" Level='1'>
<Feature Id="Feature1" Level='1'> </Feature>
<Feature Id="Feature2" Level='1'> </Feature>
<Fe... | I would change Feature1, Feature2 and Feature3 to Components, then would declare something like this:
```
<Feature Id="FEATUREA" Title="Super" Level="1" >
<ComponentRef Id="Component1" />
<ComponentRef Id="Component2" />
</Feature>
<Feature Id="FEATUREB" Title="Super1" Level="1" >
<ComponentRef Id="Component1" ... |
246,357 | <p>I am reading WIX script written by others. There are some code really confuses me. </p>
<pre><code><Custom Action='UnLoadSchedulerPerfCounters' After='InstallInitialize'>
<![CDATA[(Installed) AND (!Scheduler = 3)]]>
</Custom>
<Custom Action='RollbackSchedulerPerfCounters' After='WriteRegist... | [
{
"answer_id": 246411,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 4,
"selected": true,
"text": "<p>From <a href=\"http://www.tramontana.co.hu/wix/lesson5.php#5.3\" rel=\"nofollow noreferrer\">http://www.tramontana.co.hu/wix... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] | I am reading WIX script written by others. There are some code really confuses me.
```
<Custom Action='UnLoadSchedulerPerfCounters' After='InstallInitialize'>
<![CDATA[(Installed) AND (!Scheduler = 3)]]>
</Custom>
<Custom Action='RollbackSchedulerPerfCounters' After='WriteRegistryValues'>
<![CDATA[(&Sched... | From <http://www.tramontana.co.hu/wix/lesson5.php#5.3>:
>
> Prepending some special characters to
> the names will give them extra
> meaning:
>
>
>
> ```
> % environment variable (name is case insensitive)
> $ action state of component
> ? installed state of component
> & action state of feature
... |
246,364 | <p>I'm working on a piece of library code around <code>IDisposable</code>. The managed path (via <code>using</code>) is easily testable. I'm wondering about the finalizer though: Is calling <a href="http://msdn.microsoft.com/en-us/library/xe0c2357.aspx" rel="noreferrer"><code>System.GC.Collect()</code></a> sufficient t... | [
{
"answer_id": 246366,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 0,
"selected": false,
"text": "<p>Could you mock out an <code>IDisposable</code> interface and expect a call to <code>Dispose</code>? That would at least le... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] | I'm working on a piece of library code around `IDisposable`. The managed path (via `using`) is easily testable. I'm wondering about the finalizer though: Is calling [`System.GC.Collect()`](http://msdn.microsoft.com/en-us/library/xe0c2357.aspx) sufficient to force the finalizer to run? | No, the GC.Collect() call is asynchronous, you would also need to call this:
```
System.GC.WaitForPendingFinalizers();
``` |
246,367 | <p>My programming environment includes scripts for setting up my autobuild on a clean machine.</p>
<p>One step uses a vbscript to configure a website on IIS that is used to monitor the build.</p>
<p>On a particular machine I will be running apache on port 80 for a separate task.</p>
<p>I would like my vbscript to se... | [
{
"answer_id": 246366,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 0,
"selected": false,
"text": "<p>Could you mock out an <code>IDisposable</code> interface and expect a call to <code>Dispose</code>? That would at least le... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5427/"
] | My programming environment includes scripts for setting up my autobuild on a clean machine.
One step uses a vbscript to configure a website on IIS that is used to monitor the build.
On a particular machine I will be running apache on port 80 for a separate task.
I would like my vbscript to set the port to 8080 for t... | No, the GC.Collect() call is asynchronous, you would also need to call this:
```
System.GC.WaitForPendingFinalizers();
``` |
246,400 | <p>What is the best way of working with calculated fields of Propel objects?</p>
<p>Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when ... | [
{
"answer_id": 246900,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Add an attribute \"orders_count\" to a Customer, and then write something like this:</p>\n\n<pre><code>class Order {\n...\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2706/"
] | What is the best way of working with calculated fields of Propel objects?
Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when using it o... | There are several choices. First, is to create a view in your DB that will do the counts for you, similar to my answer [here](https://stackoverflow.com/questions/234785/#235267). I do this for a current Symfony project I work on where the read-only attributes for a given table are actually much, much wider than the tab... |
246,407 | <p>Does anyone know how could I programatically disable/enable sleep mode on Windows Mobile?</p>
<p>Thanks!</p>
| [
{
"answer_id": 246423,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 1,
"selected": false,
"text": "<p>Probably by modifying the \"System Power States\" as <a href=\"http://www.codeproject.com/KB/mobile/WiMoPower1.aspx\" rel=\"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | Does anyone know how could I programatically disable/enable sleep mode on Windows Mobile?
Thanks! | If you want your program to not be put to sleep while it's running, the best way is to create a KeepAlive type function that calls SystemIdleTimerReset, SHIdleTimerReset and simulates a key touch. Then you need to call it a lot, basically everywhere.
```
#include <windows.h>
#include <commctrl.h>
extern "C"
{
voi... |
246,430 | <p>0x34363932353433373538323038353135353439</p>
| [
{
"answer_id": 246437,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile": "https://Stackoverflow.com/users/20520",
"pm_score": 2,
"selected": false,
"text": "<p>From the Unix / cygwin command line, you can use bc.</p>\n\n<pre><code>$ bc\nibase=16\n343639323534333735383... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | 0x34363932353433373538323038353135353439 | From the Unix / cygwin command line, you can use bc.
```
$ bc
ibase=16
34363932353433373538323038353135353439
1164362276596472215941024063897591129839055929
```
There is also [an online version](http://sciencesoft.at/bc/?lang=en). If you want to do it in code you should use an arbitrary precision library facility, l... |
246,438 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/358874/how-can-i-use-a-carriage-return-in-a-html-tooltip">How can I use a carriage return in a HTML tooltip?</a> </p>
</blockquote>
<p>I'd like to know if it's possible to force a newline to show in the tooltip... | [
{
"answer_id": 246439,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 2,
"selected": false,
"text": "<p>This should be OK, but is Internet Explorer specific:</p>\n\n<pre><code><td title=\"lineone\nlinetwo \netc...\">\n</code... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15616/"
] | >
> **Possible Duplicate:**
>
> [How can I use a carriage return in a HTML tooltip?](https://stackoverflow.com/questions/358874/how-can-i-use-a-carriage-return-in-a-html-tooltip)
>
>
>
I'd like to know if it's possible to force a newline to show in the tooltip when using title property of a TD.
something like ... | This should now work with Internet Explorer, Firefox v12+ and Chrome 28+
```
<img src="'../images/foo.gif'"
alt="line 1
line 2" title="line 1
line 2">
```
Try a JavaScript tooltip library for a better result, something like [OverLib](https://github.com/overlib/overlib). |
246,443 | <p>I am experiencing some strange behavior of embedded audio (wav file) on HTML page.
I've got a page <code>https://server.com/listen-to-sound</code>, and a Wav file embedded in it via <code><EMBED/></code> tag, like this:</p>
<pre><code><embed src='https://server.com/path-to-sound' hidden="true" autostart="t... | [
{
"answer_id": 246553,
"author": "netsuo",
"author_id": 27911,
"author_profile": "https://Stackoverflow.com/users/27911",
"pm_score": 0,
"selected": false,
"text": "<p>I could'nt find any informations on this, but have you tried playing sound from Javascript ? I don't know if it's a viab... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17707/"
] | I am experiencing some strange behavior of embedded audio (wav file) on HTML page.
I've got a page `https://server.com/listen-to-sound`, and a Wav file embedded in it via `<EMBED/>` tag, like this:
```
<embed src='https://server.com/path-to-sound' hidden="true" autostart="true" />
```
The page `https://server.com/li... | I think the main reason is acting different on each computer/browser you're using is because it is a non-standard tag.
Getting media to play inside a web page has always been a bit of a pain. You may try something like this:
```
<object type="audio/x-wav" data="data/test.wav" width="200" height="20">
<param name="s... |
246,445 | <p>I have a <code>char* p</code>, which points to a <code>\0</code>-terminated string. How do I create a C++ <code>string</code> from it in an exception-safe way?</p>
<p>Here is an unsafe version:</p>
<pre><code>string foo()
{
char *p = get_string();
string str( p );
free( p );
return str;
}
</code></pre>
<... | [
{
"answer_id": 246457,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <code>shared_ptr</code> from <a href=\"http://en.cppreference.com/w/cpp/memory/shared_ptr\" rel=\"noreferrer\"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] | I have a `char* p`, which points to a `\0`-terminated string. How do I create a C++ `string` from it in an exception-safe way?
Here is an unsafe version:
```
string foo()
{
char *p = get_string();
string str( p );
free( p );
return str;
}
```
An obvious solution would be to try-catch - any easier ways? | You can use `shared_ptr` from [C++11](http://en.cppreference.com/w/cpp/memory/shared_ptr) or [Boost](http://www.boost.org/libs/smart_ptr/):
```
string
foo()
{
shared_ptr<char> p(get_string(), &free);
string str(p.get());
return str;
}
```
This uses a very specific feature of `shared_ptr` not available in... |
246,498 | <p>I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.</p>
<p>In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of... | [
{
"answer_id": 246512,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 1,
"selected": false,
"text": "<p>You'll have to create a custom object for that. Your custom object will contain two values:</p>\n\n<ul>\n<li>a DateTime ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42109/"
] | I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.
In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where the... | [Jon's answer](https://stackoverflow.com/questions/246498/creating-a-datetime-in-a-specific-time-zone-in-c-fx-35#246512) talks about [TimeZone](http://msdn.microsoft.com/en-us/library/system.timezone.aspx), but I'd suggest using [TimeZoneInfo](http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx) instead.
... |
246,503 | <p>OK, I am trying to generate the rDoc for paperclip, but the rake task is choking on another plugin before it gets to it, so this is out of the question:</p>
<pre><code>rake doc:plugins
</code></pre>
<p>I could go and fix up the broken plugin, but I'm busy and lazy, so I just want to generate the docs for paperclip... | [
{
"answer_id": 246507,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 4,
"selected": true,
"text": "<p>Unbelievably, I've just figured it out!</p>\n\n<pre><code>rake doc:plugins:paperclip\n</code></pre>\n\n<p>That was simp... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] | OK, I am trying to generate the rDoc for paperclip, but the rake task is choking on another plugin before it gets to it, so this is out of the question:
```
rake doc:plugins
```
I could go and fix up the broken plugin, but I'm busy and lazy, so I just want to generate the docs for paperclip. Is there any way of doin... | Unbelievably, I've just figured it out!
```
rake doc:plugins:paperclip
```
That was simple. |
246,520 | <p>I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:</p>
<pre><code> string login = User.Identity.Name.ToString();
</code></pre>
<p>But I don't need their login name I want their DisplayName. I've been banging my head for a couple hours n... | [
{
"answer_id": 246655,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": false,
"text": "<p>See related question: <a href=\"https://stackoverflow.com/questions/132277/active-directory-retrieve-user-information\">Act... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] | I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:
```
string login = User.Identity.Name.ToString();
```
But I don't need their login name I want their DisplayName. I've been banging my head for a couple hours now...
Can I access my org... | How about this:
```
private static string GetFullName()
{
try
{
DirectoryEntry de = new DirectoryEntry("WinNT://" + Environment.UserDomainName + "/" + Environment.UserName);
return de.Properties["displayName"].Value.ToString();
}
catch { return null; }
}
... |
246,525 | <p>I'm using Python's Imaging Library and I would like to draw some bezier curves.
I guess I could calculate pixel by pixel but I'm hoping there is something simpler.</p>
| [
{
"answer_id": 246628,
"author": "Jasper Bekkers",
"author_id": 31486,
"author_profile": "https://Stackoverflow.com/users/31486",
"pm_score": 5,
"selected": true,
"text": "<p>A bezier curve isn't that hard to draw yourself. Given three points <code>A</code>, <code>B</code>, <code>C</code... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] | I'm using Python's Imaging Library and I would like to draw some bezier curves.
I guess I could calculate pixel by pixel but I'm hoping there is something simpler. | A bezier curve isn't that hard to draw yourself. Given three points `A`, `B`, `C` you require three linear interpolations in order to draw the curve. We use the scalar `t` as the parameter for the linear interpolation:
```
P0 = A * t + (1 - t) * B
P1 = B * t + (1 - t) * C
```
This interpolates between two edges we'v... |
246,540 | <p>This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - <strong>the page that <em>somebody else</em> requested!</strong></p>
<p>Clues:</p>
<ul>
<li>The ... | [
{
"answer_id": 246566,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 3,
"selected": false,
"text": "<p>Could it be the thread-safety of your servlets?</p>\n\n<p>Do your servlets store any information in instance members.</p>... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000/"
] | This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - **the page that *somebody else* requested!**
Clues:
* The pages being delivered are those that anoth... | We switched Apache from proxying with AJP to proxying with HTTP. So far it appears to have solved the issue, or at least vastly reduced it - the problem hasn't been reported in months, and the app's use has increased since then.
The change is in Apache's httpd.conf. Having started with `mod_jk`:
```
JkMount /portal a... |
246,542 | <p>There was no endpoint listening at http;//localhost:8080/xdxservice/xdsrepository that could accept the message. This is often caused by an incorrect address or SOAP action. </p>
| [
{
"answer_id": 246556,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 0,
"selected": false,
"text": "<p>the url should have a .svc extention, no? (answered in comments)</p>\n\n<p>Are you running the WCF in ASP.NET or the... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There was no endpoint listening at http;//localhost:8080/xdxservice/xdsrepository that could accept the message. This is often caused by an incorrect address or SOAP action. | Probably a typo in the question, but your URL is invalid.
```
http;//localhost:8080/xdxservice/xdsrepository
```
should have a colon rather than a semi-colon
```
http://localhost:8080/xdxservice/xdsrepository
```
This may well not be your problem, but I thought it was worth pointing out. |
246,559 | <p>I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder.
I want to use built in Windows tools, e.g. DOS commands. </p>
| [
{
"answer_id": 246573,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not aware of any command line tools that do this directly, but you could create a batch script to loop through sub fol... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32333/"
] | I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder.
I want to use built in Windows tools, e.g. DOS commands. | ```
mkdir targetDir
for /r %x in (*.dll, *pdb) do copy "%x" targetDir\
```
Use /Y at the end of the above command if you are copying multiple files and don't want to keep answering "Yes". |
246,564 | <p>If a variable is declared as <code>static</code> in a function's scope it is only initialized once and retains its value between function calls. What exactly is its lifetime? When do its constructor and destructor get called?</p>
<pre><code>void foo()
{
static string plonk = "When will I die?";
}
</code></pre... | [
{
"answer_id": 246568,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 9,
"selected": true,
"text": "<p>The lifetime of function <code>static</code> variables begins the first time<sup>[0]</sup> the program flow encounters the d... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | If a variable is declared as `static` in a function's scope it is only initialized once and retains its value between function calls. What exactly is its lifetime? When do its constructor and destructor get called?
```
void foo()
{
static string plonk = "When will I die?";
}
``` | The lifetime of function `static` variables begins the first time[0] the program flow encounters the declaration and it ends at program termination. This means that the run-time must perform some book keeping in order to destruct it only if it was actually constructed.
Additionally, since the standard says that the de... |
246,577 | <p>I am writing an RSS feed (for fun) and was looking at the spec <a href="http://cyber.law.harvard.edu/rss/rss.html" rel="noreferrer">here</a>.</p>
<blockquote>
<p>RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.</p>
</blo... | [
{
"answer_id": 246593,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 5,
"selected": false,
"text": "<p>No, RSS is an XML-based format, and JSON is an different language rather than some kind of dialect. RSS readers won't un... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3431280/"
] | I am writing an RSS feed (for fun) and was looking at the spec [here](http://cyber.law.harvard.edu/rss/rss.html).
>
> RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.
>
>
>
Obviously this means that I am not serving 'pur... | You're right that the client *reading* the feed would have to have custom support for whatever the particulars of your JSON were. So you'd either need to make a custom feed reader to consume that information, or someone would have to propose a JSON feed standard, and it'd have to be widely adopted.
Well, I think your ... |
246,623 | <p>I want do something like this:</p>
<pre><code>Result = 'MyString' in [string1, string2, string3, string4];
</code></pre>
<p>This can't be used with strings and I don't want to do something like this:</p>
<pre><code>Result = (('MyString' = string1) or ('MyString' = string2));
</code></pre>
<p>Also I think that cr... | [
{
"answer_id": 246660,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 2,
"selected": false,
"text": "<p>Here is a function that does the job:</p>\n\n<pre><code>function StringInArray(Value: string; Strings: array of string... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] | I want do something like this:
```
Result = 'MyString' in [string1, string2, string3, string4];
```
This can't be used with strings and I don't want to do something like this:
```
Result = (('MyString' = string1) or ('MyString' = string2));
```
Also I think that creating a StringList to do just this is too comple... | You could use `AnsiIndexText(const AnsiString AText, const array of string AValues):integer` or `MatchStr(const AText: string; const AValues: array of string): Boolean;` (Both from `StrUtils` unit)
Something like:
```
Result := (AnsiIndexText('Hi',['Hello','Hi','Foo','Bar']) > -1);
```
or
```
Result := MatchStr('H... |
246,636 | <p>My WCF Service uses wsHttpBinding and works fine from the client when the service is gerenated by the client using the default options as follows:</p>
<pre><code>RServiceClient R = new RServiceClient();
</code></pre>
<p>However, at some point I'll need to be able to specify the location of the service, presumably ... | [
{
"answer_id": 246646,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using MessageSecurity with certificates? this could be a certificate issue (wrong hostname, self-s... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445/"
] | My WCF Service uses wsHttpBinding and works fine from the client when the service is gerenated by the client using the default options as follows:
```
RServiceClient R = new RServiceClient();
```
However, at some point I'll need to be able to specify the location of the service, presumably by changing the endpoint a... | By default, wsHttpBinding uses Windows authentication. I'm not sure how hosting in IIS affects that scenario.
If you don't want security turned on, you can add an element for security and set the mode element to "None" to the config on both ends to turn off the default setting.
I think this may do the trick -- I've ... |
246,644 | <p>Here is a simplified version of my database model. I have two tables: "Image", and "HostingProvider" which look like this:</p>
<p><strong>[Image]</strong></p>
<ul>
<li>id</li>
<li>filename</li>
<li>hostingprovider_id</li>
</ul>
<p><strong>[HostingProvider]</strong></p>
<ul>
<li>id</li>
<li>base_url</li>
</ul>
... | [
{
"answer_id": 246769,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 0,
"selected": false,
"text": "<pre><code>public class Image {\n public virtual HostingProvider HostingProvider { get; set; } // NHibernate takes ca... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13145/"
] | Here is a simplified version of my database model. I have two tables: "Image", and "HostingProvider" which look like this:
**[Image]**
* id
* filename
* hostingprovider\_id
**[HostingProvider]**
* id
* base\_url
Image HostingproviderId is a many-to-one foreign key relationship to the HostingProvider table. (Each i... | What you're looking for is this:
<http://ayende.com/Blog/archive/2007/04/24/Multi-Table-Entities-in-NHibernate.aspx>
Here's a peek of what it looks like:
```
<class name="Person">
<id name="Id" column="person_id" unsaved-value="0">
<generator class="native"/>
</id>
<property na... |
246,656 | <p>I am trying to match the folder name in a relative path using C#. I am using the expression: <code>"/(.*)?/"</code> and reversing the matching from left to right to right to left.
When I pass <code>"images/gringo/"</code> into the regular expression, it correctly gives me <code>"gringo"</code> in the first group - I... | [
{
"answer_id": 246663,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": false,
"text": "<p>You're probably better off using the <a href=\"http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to match the folder name in a relative path using C#. I am using the expression: `"/(.*)?/"` and reversing the matching from left to right to right to left.
When I pass `"images/gringo/"` into the regular expression, it correctly gives me `"gringo"` in the first group - I'm only interested in what is betwee... | You're probably better off using the [System.IO.DirectoryInfo](http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx) class to interpret your relative path. You can then pick off folder or file names using its members:
```
DirectoryInfo di = new DirectoryInfo("images/gringo/");
Console.Out.WriteLine(di.... |
246,667 | <p>I have a table in Access 2007 with 11,000 rows and about 20 columns. I want to create a form button that exports the table to an Excel sheet. The code need to be VBA.</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 246663,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": false,
"text": "<p>You're probably better off using the <a href=\"http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table in Access 2007 with 11,000 rows and about 20 columns. I want to create a form button that exports the table to an Excel sheet. The code need to be VBA.
Any Ideas? | You're probably better off using the [System.IO.DirectoryInfo](http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx) class to interpret your relative path. You can then pick off folder or file names using its members:
```
DirectoryInfo di = new DirectoryInfo("images/gringo/");
Console.Out.WriteLine(di.... |
246,671 | <p>Is it possible to import csv data into mysql and automatically create the column names, as in can I create just the table, or must I create the table names as well?</p>
<p>Is it possible to check for duplicate entries upon importing? I have an identifier field, but dont know how to make it so it will not be importe... | [
{
"answer_id": 246679,
"author": "tante",
"author_id": 2065014,
"author_profile": "https://Stackoverflow.com/users/2065014",
"pm_score": 0,
"selected": false,
"text": "<p>Sure, but you'll probably have to write a few lines of code yourself, it can be done with very little code. Checking ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | Is it possible to import csv data into mysql and automatically create the column names, as in can I create just the table, or must I create the table names as well?
Is it possible to check for duplicate entries upon importing? I have an identifier field, but dont know how to make it so it will not be imported twice.
... | As tante said you'll have to handle the table creation yourself, but as far as importing csv is concerned you should have a look at [LOAD DATA INFILE](http://dev.mysql.com/doc/refman/5.0/en/load-data.html)
```
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[CHAR... |
246,697 | <p>I need to create some windows service which will execute every N period of time.<br>
The question is:<br>
Which timer control should I use: <code>System.Timers.Timer</code> or <code>System.Threading.Timer</code> one? Does it influence on something? </p>
<p>I am asking because I heard many evidences to non correct ... | [
{
"answer_id": 246706,
"author": "Tim Robinson",
"author_id": 32133,
"author_profile": "https://Stackoverflow.com/users/32133",
"pm_score": 3,
"selected": false,
"text": "<p>Either one should work OK. In fact, System.Threading.Timer uses System.Timers.Timer internally.</p>\n\n<p>Having s... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to create some windows service which will execute every N period of time.
The question is:
Which timer control should I use: `System.Timers.Timer` or `System.Threading.Timer` one? Does it influence on something?
I am asking because I heard many evidences to non correct work of `System.Timers.Timer` in wi... | Both [`System.Timers.Timer`](http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx) and [`System.Threading.Timer`](http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx) will work for services.
The timers you want to avoid are [`System.Web.UI.Timer`](http://msdn.microsoft.com/en-us/library/sys... |
246,701 | <p>Why do database guys go on about normalisation? </p>
<p>What is it? How does it help? </p>
<p>Does it apply to anything outside of databases? </p>
| [
{
"answer_id": 246722,
"author": "Ilya Kochetov",
"author_id": 15329,
"author_profile": "https://Stackoverflow.com/users/15329",
"pm_score": 4,
"selected": false,
"text": "<p>Most importantly it serves to remove duplication from the database records.\nFor example if you have more than on... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7211/"
] | Why do database guys go on about normalisation?
What is it? How does it help?
Does it apply to anything outside of databases? | Normalization is basically to design a database schema such that duplicate and redundant data is avoided. If the same information is repeated in multiple places in the database, there is the risk that it is updated in one place but not the other, leading to data corruption.
There is a number of normalization levels fr... |
246,710 | <p>How do I implement the singleton pattern in C#? I want to put my constants and some basic functions in it as I use those everywhere in my project. I want to have them 'Global' and not need to manually bind them every object I create.</p>
| [
{
"answer_id": 246737,
"author": "cciotti",
"author_id": 16834,
"author_profile": "https://Stackoverflow.com/users/16834",
"pm_score": 2,
"selected": false,
"text": "<p>I would recommend you read the article <a href=\"http://msdn.microsoft.com/en-us/library/ms954629.aspx\" rel=\"nofollow... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22562/"
] | How do I implement the singleton pattern in C#? I want to put my constants and some basic functions in it as I use those everywhere in my project. I want to have them 'Global' and not need to manually bind them every object I create. | If you are just storing some global values and have some methods that don't need state, you don't need singleton. Just make the class and its properties/methods static.
```
public static class GlobalSomething
{
public static int NumberOfSomething { get; set; }
public static string MangleString( string someValue... |
246,723 | <p>Which functions are available within Delphi to play a sound-file?</p>
| [
{
"answer_id": 246756,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>A full tutorial is available at: <a href=\"http://sheepdogguides.com/dt3f.htm\" rel=\"nofollow noreferrer\">http:/... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32354/"
] | Which functions are available within Delphi to play a sound-file? | Here's the fastest way:
```
uses MMSystem;
procedure TForm1.Button1Click(Sender: TObject);
begin
sndPlaySound('C:\Windows\Media\Tada.wav',
SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
sndPlaySound(nil, 0); // Stops the sound
end;
``` |
246,725 | <p>When starting a django application using <code>python manage.py shell</code>, I get an InteractiveConsole shell - I can use tab completion, etc.</p>
<pre><code>Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more in... | [
{
"answer_id": 246774,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 5,
"selected": false,
"text": "<p>I think django does something like <a href=\"https://docs.python.org/library/rlcompleter.html\" rel=\"nofollow noref... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | When starting a django application using `python manage.py shell`, I get an InteractiveConsole shell - I can use tab completion, etc.
```
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveCo... | I may have found a way to do it.
Create a file .pythonrc
```
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
```
then in your .bashrc file, add
```
export PYTH... |
246,762 | <p>I have a Spring Interceptor which attempts to add an HTTP header in the postHandle() method.</p>
<pre><code>public void postHandle(HttpServletRequest req, HttpServletResponse resp,
Object obj1, ModelAndView mv)
throws Exception {
response.setHeader("SomeHeaderSet", "set");
resp... | [
{
"answer_id": 246851,
"author": "Jonathan",
"author_id": 28209,
"author_profile": "https://Stackoverflow.com/users/28209",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried setting the headers in the preHandle method? If that doesn't work try writing a Filter for the containe... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7888/"
] | I have a Spring Interceptor which attempts to add an HTTP header in the postHandle() method.
```
public void postHandle(HttpServletRequest req, HttpServletResponse resp,
Object obj1, ModelAndView mv)
throws Exception {
response.setHeader("SomeHeaderSet", "set");
response.addHeader... | Well, I figured it out...Kinda...
Turns out, same issue with Jetty and Tomcat (figured MAYBE it was a container issue). So...
Debugged to ensure that the response object contained the correct header value up until Spring returned back to the container. Result: The HttpServletResponse instance still had the correct he... |
246,766 | <p>I'm using Castle ActiveRecord, but this question applies to NHibernate, too, since a solution that works with NHibernate should work for ActiveRecord. Anyway, what I have is an underlying table structure like this:</p>
<p>TableA -hasMany-> TableB</p>
<p>I have corresponding objects EntityA and EntityB. EntityA h... | [
{
"answer_id": 246988,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 0,
"selected": false,
"text": "<p>Just this:</p>\n\n<pre><code>[Property] public int ParentId { get; set; }\n</code></pre>\n\n<p>...assuming <code>Pare... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32353/"
] | I'm using Castle ActiveRecord, but this question applies to NHibernate, too, since a solution that works with NHibernate should work for ActiveRecord. Anyway, what I have is an underlying table structure like this:
TableA -hasMany-> TableB
I have corresponding objects EntityA and EntityB. EntityA has an IList of Enti... | Lazy loading is exactly what you want - and it's not a hack either, it's a well tested and baked in part of NHIbernate and an important tool when performance tuning any substantial NHibernate app.
If you were to mark your "parent" EntityA as lazy loaded, referring to EntityB.Parent.Id would not load EntityA at all (as... |
246,791 | <p>I'm consuming a third-party resource (a .dll) in a web service, and my problem is, that invoking this resource (calling a method) is done asynchronous - I need to subscribe to an event, to get the answer for my request. How do I do that in a c# web service?</p>
<p><strong>Update:</strong></p>
<p>With regard to <a ... | [
{
"answer_id": 246892,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 0,
"selected": false,
"text": "<p>From <a href=\"http://msdn.microsoft.com/en-us/library/aa719796.aspx\" rel=\"nofollow noreferrer\">MSDN docs</a>:</... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm consuming a third-party resource (a .dll) in a web service, and my problem is, that invoking this resource (calling a method) is done asynchronous - I need to subscribe to an event, to get the answer for my request. How do I do that in a c# web service?
**Update:**
With regard to [Sunny's answer](https://stackove... | If the 3rd party component does not support the standard asynchronous programming model (i.e it does not use IAsyncResult), you can still achieve synchronization using AutoResetEvent or ManualResetEvent. To do this, declare a field of type AutoResetEvent in your web service class:
```
AutoResetEvent processingComplete... |
246,806 | <p>Is there any method?
My computer is AMD64.</p>
<pre><code>::std::string str;
BOOL loadU(const wchar_t* lpszPathName, int flag = 0);
</code></pre>
<p>When I used: </p>
<pre><code>loadU(&str);
</code></pre>
<p>the VS2005 compiler says:</p>
<pre><code>Error 7 error C2664:: cannot convert parameter 1 from 'std:... | [
{
"answer_id": 246811,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 7,
"selected": true,
"text": "<p>If you have a std::wstring object, you can call <code>c_str()</code> on it to get a <code>wchar_t*</code>:</p>\n\n<pre>... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] | Is there any method?
My computer is AMD64.
```
::std::string str;
BOOL loadU(const wchar_t* lpszPathName, int flag = 0);
```
When I used:
```
loadU(&str);
```
the VS2005 compiler says:
```
Error 7 error C2664:: cannot convert parameter 1 from 'std::string *__w64 ' to 'const wchar_t *'
```
How can I do it? | If you have a std::wstring object, you can call `c_str()` on it to get a `wchar_t*`:
```
std::wstring name( L"Steve Nash" );
const wchar_t* szName = name.c_str();
```
Since you are operating on a narrow string, however, you would first need to widen it. There are various options here; one is to use Windows' built-in... |
246,814 | <p>I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function.</p>
<p>Is the best approach to:</p>
<ol>
<li>Write a function that returns false if not found, true if found... | [
{
"answer_id": 246836,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 2,
"selected": false,
"text": "<p>I would choose option 2. Although I think I would just use -1 not -999.</p>\n\n<p>Richard Harrison is right that a named ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335036/"
] | I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function.
Is the best approach to:
1. Write a function that returns false if not found, true if found, and the found row ... | Personally I would not do either with that method name.
I would instead make two methods:
```
TryFindSpecificRow
FindSpecificRow
```
This would follow the pattern of Int32.Parse/TryParse, and in C# they could look like this:
```
public static Boolean TryFindSpecificRow(DataTable table, out Int32 rowNumber)
{
i... |
246,817 | <p>I want to automate SVN adds using NAnt. I want to add to SVN all new files in a given directory. The NAnt script will successfully execute the add command, however it displays the Tortoise SVN add dialog and this is not acceptable because it will execute on a build server running CruiseControl. The build server is r... | [
{
"answer_id": 246833,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 1,
"selected": false,
"text": "<p>don't use tortoise!</p>\n\n<p>just drop to command line svn.</p>\n\n<pre><code>c:\\>svn add ...\n</code></pre>\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to automate SVN adds using NAnt. I want to add to SVN all new files in a given directory. The NAnt script will successfully execute the add command, however it displays the Tortoise SVN add dialog and this is not acceptable because it will execute on a build server running CruiseControl. The build server is runn... | Don't use tortoisesvn. Get a [commandline svn client](http://www.collab.net/downloads/subversion/). |
246,822 | <p>I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid".</p>
<p>I believe the problem is in the encryption portion, because the... | [
{
"answer_id": 246878,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 0,
"selected": false,
"text": "<p>I strongly suspect that it's the call to Encoding.Unicode.GetString that's causing the problem. You need to ensur... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610/"
] | I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid".
I believe the problem is in the encryption portion, because the decryption p... | On the advice of a colleague, I opted for Convert.ToBase64String. Works well. Corrected program below.
```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
namespace ... |
246,841 | <p>We may tag a question with multiple tags in StackOverflow website, I'm wondering how to find out the most related questions with common tags.</p>
<p>Assume we have 100 questions in a database, each question has several tags. Let's say user is browsing a specific question, and we want to make the system to display t... | [
{
"answer_id": 246847,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "<p>Not entirely sure what you mean, but <a href=\"https://stackoverflow.com/tags\">the Tags page</a> lists tags in order of pop... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We may tag a question with multiple tags in StackOverflow website, I'm wondering how to find out the most related questions with common tags.
Assume we have 100 questions in a database, each question has several tags. Let's say user is browsing a specific question, and we want to make the system to display the related... | Perhaps something like:
```
select qt.question_id, count(*)
from question_tags qt
where qt.tag in
( select qt2.tag
from question_tags qt2
where qt2.question_id = 123
)
group by qt.question_id
order by 2 desc
``` |
246,849 | <p>we're currently planning a larger WPF LoB application and i wonder what others think being the best practice for storing lots of UI settings e.g.</p>
<ul>
<li>Expander States</li>
<li>Menu orders</li>
<li>Sizing Properties</li>
<li>etc...</li>
</ul>
<p>i don't like the idea of having dozens of stored values using ... | [
{
"answer_id": 246860,
"author": "DancesWithBamboo",
"author_id": 1334,
"author_profile": "https://Stackoverflow.com/users/1334",
"pm_score": 1,
"selected": false,
"text": "<p>Seems to be losing popularity for some reason; but the registry has always been an appropriate place for these k... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] | we're currently planning a larger WPF LoB application and i wonder what others think being the best practice for storing lots of UI settings e.g.
* Expander States
* Menu orders
* Sizing Properties
* etc...
i don't like the idea of having dozens of stored values using the delivered SettingsProvider (i.e. App.config f... | We store the preferences file here:
```
Environment.SpecialFolder.ApplicationData
```
Store it as xml "preferences" file so it's not so hard to get to and change if it ever gets corrupted.
So far this has worked much better than the registry for us, it's cleaner and easier to blow out if anything gets corrupted or ... |
246,859 | <p>Could somebody give me a brief overview of the differences between HTTP 1.0 and HTTP 1.1? I've spent some time with both of the RFCs, but haven't been able to pull out a lot of difference between them. Wikipedia says this:</p>
<blockquote>
<p><strong>HTTP/1.1 (1997-1999)</strong></p>
<p>Current version; persistent... | [
{
"answer_id": 246897,
"author": "Leandro López",
"author_id": 22695,
"author_profile": "https://Stackoverflow.com/users/22695",
"pm_score": 3,
"selected": false,
"text": "<p>One of the first differences that I can recall from top of my head are multiple domains running in the same serve... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | Could somebody give me a brief overview of the differences between HTTP 1.0 and HTTP 1.1? I've spent some time with both of the RFCs, but haven't been able to pull out a lot of difference between them. Wikipedia says this:
>
> **HTTP/1.1 (1997-1999)**
>
>
> Current version; persistent connections enabled by default... | **Proxy support and the Host field:**
HTTP 1.1 has a required Host header by spec.
HTTP 1.0 does not officially require a Host header, but it doesn't hurt to add one, and many applications (proxies) expect to see the Host header regardless of the protocol version.
Example:
```
GET / HTTP/1.1
Host: www.blahblahblahb... |
246,870 | <p>Each of my clients can have many todo items and every todo item has a due date.</p>
<p>What would be the query for discovering the next undone todo item by due date for each file? In the event that a client has more than one todo, the one with the lowest id is the correct one.</p>
<p>Assuming the following minima... | [
{
"answer_id": 246918,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": -1,
"selected": false,
"text": "<p>The following should get you close, first get the min time for each client, then lookup the client/todo inform... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Each of my clients can have many todo items and every todo item has a due date.
What would be the query for discovering the next undone todo item by due date for each file? In the event that a client has more than one todo, the one with the lowest id is the correct one.
Assuming the following minimal schema:
```
cli... | I haven't tested this yet, so you may have to tweak it:
```
SELECT
TD1.client_id,
TD1.id,
TD1.description,
TD1.timestamp_due
FROM
Todos TD1
LEFT OUTER JOIN Todos TD2 ON
TD2.client_id = TD1.client_id AND
TD2.timestamp_completed IS NULL AND
(
TD2.timestamp_due < TD1.timestamp_due ... |
246,876 | <pre><code>$doba = explode("/", $dob);
$date = date("Y-m-d", mktime(0,0,0, $doba[0], $doba[1], $doba[2]));
</code></pre>
<p>The above code turns any date i pass through into 1999-11-30 and i know it was working yesterday. Date is correct when I echo $doba. Anyone have any ideas?</p>
<p>Cheers</p>
| [
{
"answer_id": 246891,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 3,
"selected": true,
"text": "<p>What is the format of <code>$doba</code>? Remember <code>mktime</code>'s syntax goes hour, minute, second, <strong>month, day... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | ```
$doba = explode("/", $dob);
$date = date("Y-m-d", mktime(0,0,0, $doba[0], $doba[1], $doba[2]));
```
The above code turns any date i pass through into 1999-11-30 and i know it was working yesterday. Date is correct when I echo $doba. Anyone have any ideas?
Cheers | What is the format of `$doba`? Remember `mktime`'s syntax goes hour, minute, second, **month, day year** which can be confusing.
Here's some examples:
```
$doba = explode('/', '1991/08/03');
echo(date('Y-m-d', mktime(0,0,0, $doba[1], $doba[2], $doba[0]);
$doba = explode('/', '03/08/1991');
echo(date('Y-m-d', mktime(... |
246,884 | <p>I haven´t experience in making setup, but I all ready make mine but now I need help because when I made a new version I want that the user double click the shortcut and it do the update if there are any.</p>
<p>The application is in <code>c#</code>.</p>
<p>Could you help?</p>
| [
{
"answer_id": 246955,
"author": "Dan Walker",
"author_id": 752,
"author_profile": "https://Stackoverflow.com/users/752",
"pm_score": 1,
"selected": false,
"text": "<p>Here's how I have implemented an updater program I wrote earlier.</p>\n\n<p>First off, you grab an ini file off of your ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32115/"
] | I haven´t experience in making setup, but I all ready make mine but now I need help because when I made a new version I want that the user double click the shortcut and it do the update if there are any.
The application is in `c#`.
Could you help? | Here's how I have implemented an updater program I wrote earlier.
First off, you grab an ini file off of your server. This file will contain information about the latest version and where the setup file is. Getting that file isn't too hard.
```
WebClient wc = new WebClient();
wc.Downlo... |
246,890 | <p>I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp</p>
<p>Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?</p>
<p>I would normally just delete those files, but the owner... | [
{
"answer_id": 246899,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>The best bet is to do either a meta refresh in the actual homepage.asp page, it is quick and dirty, but works.<... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] | I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp
Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?
I would normally just delete those files, but the owner(s) wanted to keep ... | Put this in the old homepage.asp
```
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/index.cfm"
%>
``` |
246,905 | <p>I just finished a 2d platformer in C++/Allegro. Its still in an incomplete stage...</p>
<p>I wonder how to go about a peer-review from people who are into game development.
I would like to review my project on grounds of </p>
<ol>
<li>game play</li>
<li>Collision detection</li>
<li>use of OOP</li>
<li>programming ... | [
{
"answer_id": 246942,
"author": "Abhishek Mishra",
"author_id": 8786,
"author_profile": "https://Stackoverflow.com/users/8786",
"pm_score": 1,
"selected": false,
"text": "<p><strong>RECAP from previous episode -</strong></p>\n\n<p>I do not understand why people vote you down and offensi... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8786/"
] | I just finished a 2d platformer in C++/Allegro. Its still in an incomplete stage...
I wonder how to go about a peer-review from people who are into game development.
I would like to review my project on grounds of
1. game play
2. Collision detection
3. use of OOP
4. programming of sounds, effects etc
5. any further ... | The first thing I noticed in your source code is that you've got most of your game logic is in the main.cpp file, with the nesting going as deep as 11 tabs! For code organizational purposes, this is a nightmare. Of course, I did this too on my first game. :) The first thing you can do is simplify your main game loop to... |
246,912 | <p>Currently there are 2 pages in a jsp file: one of them displays the data and the second one is used for pagination. The task is to include exactly the same paginator table above the data table. Sorry, couldn't resist to draw it :)</p>
<pre><code>|-----------------------------------------|
| Pag... | [
{
"answer_id": 246975,
"author": "pkaeding",
"author_id": 4257,
"author_profile": "https://Stackoverflow.com/users/4257",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps you can define the pagination stuff in a separate jsp, and then include it twice into your main jsp. For exampl... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15187/"
] | Currently there are 2 pages in a jsp file: one of them displays the data and the second one is used for pagination. The task is to include exactly the same paginator table above the data table. Sorry, couldn't resist to draw it :)
```
|-----------------------------------------|
| Page 2 of 200 < ... | The four mechanisms of abstracting within JSP today are the jsp:include tag, the <%@ include> directive, custom tag libraries, and custom tag files.
jsp:include inserts the results of executing another JSP page, so you could do:
```
<jsp:include "page_naviagtor.jsp"/>
<table id="results">...</table>
<jsp:include "pag... |
246,919 | <p>What is the best way to implement the page view counter like the ones they have here on the site where each question has a "Views" counter?</p>
<p>Factoring in Performance and Scalability issues.</p>
| [
{
"answer_id": 246968,
"author": "François",
"author_id": 32379,
"author_profile": "https://Stackoverflow.com/users/32379",
"pm_score": 3,
"selected": false,
"text": "<p>An efficient way may be :\nStore your counters in the Application object, you may persist it to file/DB periodically a... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | What is the best way to implement the page view counter like the ones they have here on the site where each question has a "Views" counter?
Factoring in Performance and Scalability issues. | The counter i optimized works like this:
```
UPDATE page_views SET counter = counter + 1 WHERE page_id = x
if (affected_rows == 0 ) {
INSERT INTO page_views (page_id, counter) VALUES (x, 1)
}
```
This way you run 2 query for the first view, the other views require only 1 query. |
246,921 | <p>I was thinking about the idea of using Ajax instead of TagLib. The most elegant way would be: Using Java Annotation.
The idea is, designers or anybody can make the HTML without any taglib ,just using the "standard" HTML tags with id or name, and call the Javascript. That way any WYSIWYG can be used, developer don't... | [
{
"answer_id": 247043,
"author": "Peter",
"author_id": 26483,
"author_profile": "https://Stackoverflow.com/users/26483",
"pm_score": 2,
"selected": false,
"text": "<p>When i see your topic title i thought:</p>\n\n<p>You cant use Ajax in stead of a taglib. AJAX is javascript on the client... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438405/"
] | I was thinking about the idea of using Ajax instead of TagLib. The most elegant way would be: Using Java Annotation.
The idea is, designers or anybody can make the HTML without any taglib ,just using the "standard" HTML tags with id or name, and call the Javascript. That way any WYSIWYG can be used, developer don't ha... | When i see your topic title i thought:
You cant use Ajax in stead of a taglib. AJAX is javascript on the client and the taglib is java code on the server.
After reading your post i thought, ah he whats to do what [link text][1] does
But then not entrily the same.
[1]: <http://code.google.com/webtoolkit/> GWT |
246,930 | <p>I see these two acronyms being thrown around and I was wondering if there are any differences between a GUID and a UUID?</p>
| [
{
"answer_id": 246935,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 9,
"selected": false,
"text": "<p>GUID is Microsoft's implementation of the UUID standard.</p>\n<p>Per <a href=\"https://en.wikipedia.org/w/index.php?title=... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I see these two acronyms being thrown around and I was wondering if there are any differences between a GUID and a UUID? | The **simple answer** is: \*\*no difference, they are the same thing.
**2020-08-20 Update**: While GUIDs (as used by Microsoft) and UUIDs (as defined by RFC4122) look similar and serve similar purposes, there are subtle-but-occasionally-important differences. Specifically, [some Microsoft GUID docs](https://learn.micr... |
246,931 | <p>I have two models, Article and Post that both inherit from a base model called ContentBase.</p>
<p>You can leave comments on both Articles and Posts, so I am using a Polymorphic Association between Comments and Article or Post.</p>
<p>However, since both Article and Post inherit from ContentBase, the commentable_t... | [
{
"answer_id": 247445,
"author": "Micah",
"author_id": 19964,
"author_profile": "https://Stackoverflow.com/users/19964",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you want to do that. For polymorphic associations, you want the XXX_type field to be the base model class,... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1396/"
] | I have two models, Article and Post that both inherit from a base model called ContentBase.
You can leave comments on both Articles and Posts, so I am using a Polymorphic Association between Comments and Article or Post.
However, since both Article and Post inherit from ContentBase, the commentable\_type field ends u... | What's in the ContentBase class? Can you move that code into a module instead of using inheritance?
```
Module BaseContent
def self.included(base)
base.class_eval do
validates_presence_of :somefield
validates_length_of :someotherfield
def my_method
"hello"
... |
246,963 | <p>Say I have a class called PermissionManager which should only exist once for my system and basically fulfills the function of managing various permissions for various actions in my application. Now I have some class in my application which needs to be able to check a certain permission in one of its methods. This cl... | [
{
"answer_id": 246987,
"author": "Trap",
"author_id": 7839,
"author_profile": "https://Stackoverflow.com/users/7839",
"pm_score": 0,
"selected": false,
"text": "<p>The singleton pattern is not bad by itself, what makes it ugly is the way it's commonly used, as being the requirement of on... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] | Say I have a class called PermissionManager which should only exist once for my system and basically fulfills the function of managing various permissions for various actions in my application. Now I have some class in my application which needs to be able to check a certain permission in one of its methods. This class... | If you are using a dependency-injection framework, then the common way to handle this is to either pass in a PermissionsManager object in the constructor or to have a property of type PermissionsManager that the framework sets for you.
If this is not feasible, then having users get an instance of this class via facto... |
246,966 | <p>I've found that given a form in a HTML page like this:</p>
<pre><code><form name="form">
<input type="image" name="foo"
src="somewhere.gif" alt="image" value="blah"/>
<input type="text" name="bar" value="blah"/>
</form>
</code></pre>
<p>When accessing the elements via the D... | [
{
"answer_id": 247002,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like that's the behavior of the <code>elements</code> property in all browsers.</p>\n\n<p>However, you s... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've found that given a form in a HTML page like this:
```
<form name="form">
<input type="image" name="foo"
src="somewhere.gif" alt="image" value="blah"/>
<input type="text" name="bar" value="blah"/>
</form>
```
When accessing the elements via the DOM in Javascript, there is *no* element for the im... | It looks like that's the behavior of the `elements` property in all browsers.
However, you should still be able to access it through the DOM in JavaScript using the `childNodes` property.
For your example:
```
document.forms[0].childNodes.length; // equals 5 (2 inputs and 3 text nodes).
document.forms[0].childNodes[... |
246,969 | <p>I want to do something like this:</p>
<pre><code>const
MyFirstConstArray: array[0..1] of string = ('Hi', 'Foo');
MySecondConstArrayWhichIncludesTheFirstOne: array[0..2] of string =
MyFirstConstArray + ('Bar');
</code></pre>
<p>Basically I want the following result:</p>
<pre><code>MyFirstConstArray ->... | [
{
"answer_id": 247063,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think so. You'll have to do it in code. If these are global constants, you can do the initialization in the 'initial... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] | I want to do something like this:
```
const
MyFirstConstArray: array[0..1] of string = ('Hi', 'Foo');
MySecondConstArrayWhichIncludesTheFirstOne: array[0..2] of string =
MyFirstConstArray + ('Bar');
```
Basically I want the following result:
```
MyFirstConstArray -> ('Hi', 'Foo');
MySecondConstArrayWhichI... | AFAIK, you can't do that.
But if the goal is to ensure you declare your actual constant string only once, I suggest you declare the individual strings and then group them in arrays:
```
const
MyConst1 = 'Hi';
MyConst2 = 'Foo';
MyConst3 = 'Bar';
MyFirstConstArray: array[0..1] of string = (MyConst1, MyConst2... |
246,977 | <p>I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact?</p>
<p>(<a href="https://en.wikipedia.org/wiki/Flexible_array_member" rel="noreferrer">Flexible array members</a> are a C feature introduce... | [
{
"answer_id": 247038,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 4,
"selected": false,
"text": "<p>You meant...</p>\n\n<pre><code>struct header\n{\n size_t len;\n unsigned char data[];\n}; \n</code></pre>\n\n<p>In C, that'... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact?
([Flexible array members](https://en.wikipedia.org/wiki/Flexible_array_member) are a C feature introduced in C99 whereby one can declare the l... | It is an accepted "fact" that using goto is poor software engineering practice. That doesn't make it true. There are times when goto is useful, particularly when handling cleanup and when porting from assembler.
Flexible array members strike me as having one main use, off the top of my head, which is mapping legacy d... |
246,981 | <p>Does anyone have any idea what is wrong with this create statement for mysql? </p>
<p>EDIT: now it states the error is near: revised VARCHAR(20), paypal_accept TINYINT, pre_terminat' at line 4</p>
<p>Thanks for the help everyone</p>
<p>Still errors after using sql beautifier though</p>
<pre><code>CREATE TABLE A... | [
{
"answer_id": 246993,
"author": "Kirk Strauser",
"author_id": 32538,
"author_profile": "https://Stackoverflow.com/users/32538",
"pm_score": 1,
"selected": false,
"text": "<p>\"VARCHAR(20),\" doesn't assign a name.</p>\n"
},
{
"answer_id": 246996,
"author": "dove",
"autho... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | Does anyone have any idea what is wrong with this create statement for mysql?
EDIT: now it states the error is near: revised VARCHAR(20), paypal\_accept TINYINT, pre\_terminat' at line 4
Thanks for the help everyone
Still errors after using sql beautifier though
```
CREATE TABLE AUCTIONS (
ARTICLE_NO VARCHA... | I believe the column names "START" and "CONDITION" are 'special' words in MySQL? All I did was simply paste the beautified code into Query Browser and noticed that some column names were 'blue'... :P |
246,983 | <p>What's the most efficient way of getting the value of the SERIAL column after the INSERT statement? I.e. I am looking for a way to replicate <code>@@IDENTITY</code> or <code>SCOPE_IDENTITY</code> functionality of MS SQL</p>
| [
{
"answer_id": 247159,
"author": "Brian Schmitt",
"author_id": 30492,
"author_profile": "https://Stackoverflow.com/users/30492",
"pm_score": 1,
"selected": false,
"text": "<p>I have seen this used.</p>\n<pre><code>if LOCAL_SQLCA^.sqlcode = 0 then\n/* return serial */\n Result := LOCAL_S... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15329/"
] | What's the most efficient way of getting the value of the SERIAL column after the INSERT statement? I.e. I am looking for a way to replicate `@@IDENTITY` or `SCOPE_IDENTITY` functionality of MS SQL | The value of the last SERIAL insert is stored in the SQLCA record, as the second entry in the sqlerrd array. Brian's answer is correct for ESQL/C, but you haven't mentioned what language you're using.
If you're writing a stored procedure, the value can be found thus:
```
LET new_id = DBINFO('sqlca.sqlerrd1');
```
I... |
247,006 | <p>I've got a PHP application which needs to grab the contents from another web page, and the web page I'm reading needs a cookie.</p>
<p>I've found info on how to make this call once i have the cookie ( <a href="http://groups.google.com/group/comp.lang.php/msg/4f618114ab15ae2a" rel="nofollow noreferrer">http://groups... | [
{
"answer_id": 247080,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>You'd probably be better off using <a href=\"http://www.php.net/curl\" rel=\"noreferrer\">cURL</a>.\nUse <a href=\"http://w... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a PHP application which needs to grab the contents from another web page, and the web page I'm reading needs a cookie.
I've found info on how to make this call once i have the cookie ( <http://groups.google.com/group/comp.lang.php/msg/4f618114ab15ae2a> ), however I've no idea how to generate the cookie, or ho... | You'd probably be better off using [cURL](http://www.php.net/curl).
Use [curl\_setopt](http://www.php.net/manual/en/function.curl-setopt.php) to set up the cookie handling options.
If this is just a one-off thing, you could use Firefox with [Live HTTP Headers](http://livehttpheaders.mozdev.org/) to get the header, the... |
247,023 | <p>I have a structure like this:</p>
<pre><code><ul>
<li>text1</li>
<li>text2</li>
<li>text3</li>
</ul>
</code></pre>
<p>How do I use javascript or jQuery to get the text as an array?</p>
<pre><code>['text1', 'text2', 'text3']
</code></pre>
<p>My plan after this... | [
{
"answer_id": 247057,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 8,
"selected": true,
"text": "<pre><code>var optionTexts = [];\n$(\"ul li\").each(function() { optionTexts.push($(this).text()) });\n</code></pre>\n\n<p>...sho... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] | I have a structure like this:
```
<ul>
<li>text1</li>
<li>text2</li>
<li>text3</li>
</ul>
```
How do I use javascript or jQuery to get the text as an array?
```
['text1', 'text2', 'text3']
```
My plan after this is to assemble it into a string, probably using `.join(', ')`, and get it in a format like this:... | ```
var optionTexts = [];
$("ul li").each(function() { optionTexts.push($(this).text()) });
```
...should do the trick. To get the final output you're looking for, `join()` plus some concatenation will do nicely:
```
var quotedCSV = '"' + optionTexts.join('", "') + '"';
``` |
247,045 | <p>Been a while since I've dealt with ASP.NET and this is the first time I've had to deal with master pages. Been following tutorials everything is fine except a problem I'm having with the footer.</p>
<p>The master page has divs for topContent, mainContent and footerContent. In mainContent I have a ContentPlaceHold... | [
{
"answer_id": 247077,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>This doesn't sound like a master page issue, this sounds like an HTML/CSS layouting issue. What you haven't stated is whethe... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15891/"
] | Been a while since I've dealt with ASP.NET and this is the first time I've had to deal with master pages. Been following tutorials everything is fine except a problem I'm having with the footer.
The master page has divs for topContent, mainContent and footerContent. In mainContent I have a ContentPlaceHolder.
The def... | This doesn't sound like a master page issue, this sounds like an HTML/CSS layouting issue. What you haven't stated is whether your DIVs are absolutely positioned or whether they occur within page flow.
Normally, assuming you're NOT positioning those DIVs absolutely, the header DIV will be statically sized, the footer ... |
247,053 | <p>On Linux, feenableexcept and fedisableexcept can be used to control the generation of SIGFPE interrupts on floating point exceptions. How can I do this on Mac OS X Intel?</p>
<p>Inline assembly for enabling floating point interrupts is provided in <a href="http://developer.apple.com/documentation/Performance/Conce... | [
{
"answer_id": 252590,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 3,
"selected": false,
"text": "<p>On Mac OS X this is moderately complicated. OS X uses the SSE unit for all FP math by default, not the x87 FP uni... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16480/"
] | On Linux, feenableexcept and fedisableexcept can be used to control the generation of SIGFPE interrupts on floating point exceptions. How can I do this on Mac OS X Intel?
Inline assembly for enabling floating point interrupts is provided in <http://developer.apple.com/documentation/Performance/Conceptual/Mac_OSX_Numer... | Exceptions for sse can be enabled using `_MM_SET_EXCEPTION_MASK` from `xmmintrin.h`. For example, to enable invalid (nan) exceptions, do
```
#include <xmmintrin.h>
...
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
``` |
247,059 | <p>In C# there is the static property <a href="http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx" rel="noreferrer">Environment.Newline</a> that changed depending on the running platform.</p>
<p>Is there anything similar in Java?</p>
| [
{
"answer_id": 247069,
"author": "Tom Lokhorst",
"author_id": 2597,
"author_profile": "https://Stackoverflow.com/users/2597",
"pm_score": 9,
"selected": true,
"text": "<p><strong>As of Java 7 (and Android API level 19):</strong></p>\n\n<pre><code>System.lineSeparator()\n</code></pre>\n\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20480/"
] | In C# there is the static property [Environment.Newline](http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx) that changed depending on the running platform.
Is there anything similar in Java? | **As of Java 7 (and Android API level 19):**
```
System.lineSeparator()
```
Documentation: [Java Platform SE 7](https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#lineSeparator%28%29)
---
**For older versions of Java, use:**
```
System.getProperty("line.separator");
```
See <https://java.sun.com/do... |
247,066 | <p>I want the most performat way to read and parse a file.</p>
<p>Is it possible to read a file in .NET, but not load the entire file into memory? i.e. just load the file line by line as I parse the content of each row?</p>
<p>Does XmlTextReader load the entire file into memory or does it stream the file into memory... | [
{
"answer_id": 247081,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure about XMLTextReader, but you can read a file line by line using the FileReader objects. )</p>\n"
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want the most performat way to read and parse a file.
Is it possible to read a file in .NET, but not load the entire file into memory? i.e. just load the file line by line as I parse the content of each row?
Does XmlTextReader load the entire file into memory or does it stream the file into memory as it reads the f... | You could use the ReadLine method of StreamReader Class:
```
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("c:\\test.txt");
while((line = file.ReadLine()) != null)
{
Console.WriteLine (line);
}
file.Close();
```
For XML files I would go ... |
247,093 | <p>I want to change the registry values on the pocketPC. I ran the following code:</p>
<pre><code>if(enabled)
{
dwData = 120;
}
if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\Timeouts\\BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
{
return FALSE;
... | [
{
"answer_id": 247323,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>RegSetValueEx returns a descriptive error code. You can get a human-readable message out of this error code using FormatMes... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I want to change the registry values on the pocketPC. I ran the following code:
```
if(enabled)
{
dwData = 120;
}
if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\Timeouts\\BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
{
return FALSE;
}
```
but it doe... | There are a two problems with what you are doing:
1: RegSetValueEx does not take a path, only a valuename. So you need to open the key path first.
e.g.
```
HKEY key;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Power\\Timeouts", 0, 0, &key))
{
if(RegSetValueEx(key, _T... |
247,106 | <p>Looking at this loop that copies one c-string to another:</p>
<pre><code>void strcpyr(char *s, char *t)
{
while(*s++=*t++)// Why does this work?
;
}
</code></pre>
<p>Why do we not check for the '\0' character in the while loop, like this?</p>
<pre><code>while((*s++=*r++)!='\0')..
</code></pre>
<p>How... | [
{
"answer_id": 247122,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 2,
"selected": false,
"text": "<p>When we hit the <code>'\\0'</code> in the string initially pointed to by <code>t</code>, the <code>*s++=*t++</code>,... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Looking at this loop that copies one c-string to another:
```
void strcpyr(char *s, char *t)
{
while(*s++=*t++)// Why does this work?
;
}
```
Why do we not check for the '\0' character in the while loop, like this?
```
while((*s++=*r++)!='\0')..
```
How does the first loop terminate? | The statement \*s++=\*t++ not only assigns the next character from t to s but also returns the current value of \*t as the result of the expression. The while loop terminates on any false value, including '\0'.
Think of it this way. If you did:
```
char c = *s++ = *t++;
```
in addition to copying a char from \*t to... |
247,110 | <p>I'm getting started on building a REST API for a project I'm working on, and it led me to do a little research as to the best way to build an API using RoR. I find out pretty quickly that by default, models are open to the world and can be called via URL by simply putting a ".xml" at the end of the URL and passing a... | [
{
"answer_id": 247162,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": false,
"text": "<p>I'm facing similar questions as you at the moment because i'm also building out a REST api for a rails application.</p>\n\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23458/"
] | I'm getting started on building a REST API for a project I'm working on, and it led me to do a little research as to the best way to build an API using RoR. I find out pretty quickly that by default, models are open to the world and can be called via URL by simply putting a ".xml" at the end of the URL and passing appr... | There are several schemes for authenticating API requests, and they're different than normal authentication provided by plugins like restful\_authentication or acts\_as\_authenticated. Most importantly, clients will not be maintaining sessions, so there's no concept of a login.
**HTTP Authentication**
You can use bas... |
247,128 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content">Resizing an iframe based on content</a> </p>
</blockquote>
<p>I'm loading an iFrame and want the parent to automatically change the height based upon the height of th... | [
{
"answer_id": 247160,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": false,
"text": "<p>On any other element, I would use the <code>scrollHeight</code> of the DOM object and set the height accordingly. I don't k... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123/"
] | >
> **Possible Duplicate:**
>
> [Resizing an iframe based on content](https://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content)
>
>
>
I'm loading an iFrame and want the parent to automatically change the height based upon the height of the iFrame's content.
To simply things, all pages be... | On any other element, I would use the `scrollHeight` of the DOM object and set the height accordingly. I don't know if this would work on an iframe (because they're a bit kooky about everything) but it's certainly worth a try.
Edit: Having had a look around, the popular consensus is setting the height from within the ... |
247,135 | <p>I use <a href="http://xpath.alephzarro.com/" rel="noreferrer">XPather Browser</a> to check my XPATH expressions on an HTML page.</p>
<p>My end goal is to use these expressions in Selenium for the testing of my user interfaces.</p>
<p>I got an HTML file with a content similar to this:</p>
<pre>
<tr>
<td... | [
{
"answer_id": 247158,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Search for <code>&nbsp;</code> or only <code>nbsp</code> - did you try this?</p>\n"
},
{
"answer_id": 247368,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16927/"
] | I use [XPather Browser](http://xpath.alephzarro.com/) to check my XPATH expressions on an HTML page.
My end goal is to use these expressions in Selenium for the testing of my user interfaces.
I got an HTML file with a content similar to this:
```
<tr>
<td>abc</td>
<td> </td>
</tr>
```
I want to select a ... | It seems that [OpenQA](http://www.openqa.org/), guys behind Selenium, have already addressed this problem. They defined some variables to explicitely match whitespaces. In my case, I need to use an XPATH similar to `//td[text()="${nbsp}"]`.
I reproduced here the text from OpenQA concerning this issue (found [here](htt... |
247,149 | <pre><code><?php
/**
* My codebase is littered with the same conditionals over and over
* again. I'm trying to refactor using inheritance and the Factory
* pattern and I've had some success but I'm now stuck.
*
* I'm stuck because I want to derive a new class from the one
* returned by the Factory. But I can... | [
{
"answer_id": 247172,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 1,
"selected": false,
"text": "<p>If the IndexView code really is the same then you don't need inheritance, but composition. Add, in your base Layo... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
<?php
/**
* My codebase is littered with the same conditionals over and over
* again. I'm trying to refactor using inheritance and the Factory
* pattern and I've had some success but I'm now stuck.
*
* I'm stuck because I want to derive a new class from the one
* returned by the Factory. But I can't do that... | If the IndexView code really is the same then you don't need inheritance, but composition. Add, in your base LayoutView class, an instance of IndexView that then you'll be able to call from each \*LayoutView.
Inheritance is due only when the relationship between objects is is-a. I deduce that an IndexView is not a Lay... |
247,156 | <p>I'm having a disagreement with someone over how best to implement a simple method that takes an array of integers, and returns the highest integer (using C# 2.0).</p>
<p>Below are the two implementations - I have my own opinion of which is better, and why, but I'd appreciate any impartial opinions.</p>
<p><strong>... | [
{
"answer_id": 247170,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>I prefer <strong>Option B</strong> as it only traverses the collection exactly once. </p>\n\n<p>In <strong>Option A</stron... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm having a disagreement with someone over how best to implement a simple method that takes an array of integers, and returns the highest integer (using C# 2.0).
Below are the two implementations - I have my own opinion of which is better, and why, but I'd appreciate any impartial opinions.
**Option A**
```
public ... | Ôption B of course.
A is ugly :
* Catch(Exception) is a really bad practice
* You shoul not rely on exception for null ref, out of range,...
* Sorting is way complexier than iteration
Complexity :
* A will be O(n log(n)) and even O(n²) in worst case
* B worst case is O(n) |
247,161 | <p>How can I transform a <code>String</code> value into an <code>InputStreamReader</code>?</p>
| [
{
"answer_id": 247169,
"author": "Dan Dyer",
"author_id": 5171,
"author_profile": "https://Stackoverflow.com/users/5171",
"pm_score": 5,
"selected": false,
"text": "<p>Does it have to be specifically an InputStreamReader? How about using <a href=\"http://java.sun.com/javase/6/docs/api/j... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4038/"
] | How can I transform a `String` value into an `InputStreamReader`? | [ByteArrayInputStream](http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html) also does the trick:
```
InputStream is = new ByteArrayInputStream( myString.getBytes( charset ) );
```
Then convert to reader:
```
InputStreamReader reader = new InputStreamReader(is);
``` |
247,167 | <p>Looking for a bit of regex help.
I'd like to design an expression that matches a string with "<em>foo</em>" OR "<em>bar</em>", but not both "<em>foo</em>" AND "<em>bar</em>"</p>
<p>If I do something like...</p>
<pre><code>/((foo)|(bar))/
</code></pre>
<p>It'll match "<em>foobar</em>". Not what I'm looking for. So... | [
{
"answer_id": 247177,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this with a single regex but I suggest for the sake of readability you do something like...</p>\n\n<pre><cod... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26001/"
] | Looking for a bit of regex help.
I'd like to design an expression that matches a string with "*foo*" OR "*bar*", but not both "*foo*" AND "*bar*"
If I do something like...
```
/((foo)|(bar))/
```
It'll match "*foobar*". Not what I'm looking for. So, how can I make regex match only when one term or the other is pres... | You can do this with a single regex but I suggest for the sake of readability you do something like...
```
(/foo/ and not /bar/) || (/bar/ and not /foo/)
``` |
247,209 | <p>As JavaScript frameworks like jQuery make client side web applications richer and more functional, I've started to notice one problem...</p>
<p><strong>How in the world do you keep this organized?</strong></p>
<ul>
<li>Put all your handlers in one spot and write functions for all the events?</li>
<li>Create functi... | [
{
"answer_id": 247223,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": false,
"text": "<p>You can break up your scripts into separate files for development, then create a \"release\" version where you cram them a... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] | As JavaScript frameworks like jQuery make client side web applications richer and more functional, I've started to notice one problem...
**How in the world do you keep this organized?**
* Put all your handlers in one spot and write functions for all the events?
* Create function/classes to wrap all your functionality... | It would be a lot nicer if javascript had namespaces built in, but I find that organizing things like Dustin Diaz describes [here](http://www.dustindiaz.com/namespace-your-javascript/) helps me a lot.
```
var DED = (function() {
var private_var;
function private_method()
{
// do stuff here
}... |
247,228 | <p>How can I run a stored procedure from a CL program? RUNSQLSTM requires a source member, but I just want to build a command so users can pass in variables easily, so this won't work.</p>
| [
{
"answer_id": 247457,
"author": "Kwebble",
"author_id": 4167,
"author_profile": "https://Stackoverflow.com/users/4167",
"pm_score": 2,
"selected": false,
"text": "<p>There may be 2 options:</p>\n\n<p>In the CL program create a temporary source member. Construct the SQL statement with th... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I run a stored procedure from a CL program? RUNSQLSTM requires a source member, but I just want to build a command so users can pass in variables easily, so this won't work. | You can call the system program `QZDFMDB2` and pass it one parameter with the SQL string to execute. In this case the SQL string is the call to your stored procedure:
```
CALL PGM(QZDFMDB2) PARM('CALL PROCEDURE (''XYZ'', ''ABC'')')
```
To substitute in your values use a variable for the PARM:
```
DCL VAR(&CALL)... |
247,245 | <p>I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible. </p>
<p>Is there a way to add a link or to change the email opened to an html email vs a text email?</p>
<p>Something like:</p>
<pre><code><a href="mailto:test@test.test?body=The message... | [
{
"answer_id": 247351,
"author": "GavinCattell",
"author_id": 21644,
"author_profile": "https://Stackoverflow.com/users/21644",
"pm_score": 3,
"selected": false,
"text": "<p>It isn't possible as far as I can tell, since a link needs HTML, and mailto links don't create an HTML email.</p>\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13341/"
] | I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible.
Is there a way to add a link or to change the email opened to an html email vs a text email?
Something like:
```
<a href="mailto:test@test.test?body=The message's first paragraph.%0A%0aSecond p... | Section 2 of [RFC 2368](https://www.rfc-editor.org/rfc/rfc2368 "RFC 2368") says that the `body` field is supposed to be in `text/plain` format, so you can't do HTML.
However even if you use plain text it's possible that some modern mail clients would render a URL as a clickable link anyway, though. |
247,252 | <p>One of the "best practice" is accessing data via stored procedures. I understand why is this scenario good.
My motivation is split database and application logic ( the tables can me changed, if the behaviour of stored procedures are same ), defence for SQL injection ( users can not execute "select * from some_tables... | [
{
"answer_id": 247288,
"author": "Peter",
"author_id": 5189,
"author_profile": "https://Stackoverflow.com/users/5189",
"pm_score": 3,
"selected": false,
"text": "<p>For reading data, you do not need a stored procedure for security or to separate out logic, you can use views. </p>\n\n<p>J... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20382/"
] | One of the "best practice" is accessing data via stored procedures. I understand why is this scenario good.
My motivation is split database and application logic ( the tables can me changed, if the behaviour of stored procedures are same ), defence for SQL injection ( users can not execute "select \* from some\_tables"... | First: for your delete routine, your where clause should only include the primary key.
Second: for your update routine, do not try to optimize before you have working code. In fact, do not try to optimize until you can profile your application and see where the bottlenecks are. I can tell you for sure that updating on... |
247,284 | <p>I have a form I am submitting using jQuery's ajaxSubmit function from the Forms plugin. I'm trying to add a form name/value pair to the form data just before submission occurs. My plan is to modify the form data in the beforeSubmit event handler.</p>
<p>Given a function that looks like:</p>
<pre><code>function han... | [
{
"answer_id": 247776,
"author": "Brian Vallelunga",
"author_id": 2656,
"author_profile": "https://Stackoverflow.com/users/2656",
"pm_score": 5,
"selected": true,
"text": "<p>After an hour of experimentation, I figured out a solution. To append a value to the form data, the following cod... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2656/"
] | I have a form I am submitting using jQuery's ajaxSubmit function from the Forms plugin. I'm trying to add a form name/value pair to the form data just before submission occurs. My plan is to modify the form data in the beforeSubmit event handler.
Given a function that looks like:
```
function handleActionFormBeforeSu... | After an hour of experimentation, I figured out a solution. To append a value to the form data, the following code will work.
```
function handleActionFormBeforeSubmit(formData, form, options) {
// Add a name/value pair indicating this is an asynchronous call.
// This works with the ASP.NET MVC framework's Re... |
247,304 | <p>I'm not sure how password hashing works (will be implementing it later), but need to create database schema now.</p>
<p>I'm thinking of limiting passwords to 4-20 characters, but as I understand after encrypting hash string will be of different length.</p>
<p>So, how to store these passwords in the database?</p>
| [
{
"answer_id": 247314,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 3,
"selected": false,
"text": "<p>As a fixed length string (VARCHAR(n) or however MySQL calls it).\nA hash has always a fixed length of for example 12 chara... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28098/"
] | I'm not sure how password hashing works (will be implementing it later), but need to create database schema now.
I'm thinking of limiting passwords to 4-20 characters, but as I understand after encrypting hash string will be of different length.
So, how to store these passwords in the database? | Update: Simply using a hash function is not strong enough for storing passwords. You should read [the answer from Gilles on this thread](https://stackoverflow.com/a/55753734/20860) for a more detailed explanation.
For passwords, use a key-strengthening hash algorithm like Bcrypt or Argon2i. For example, in PHP, use th... |
247,305 | <p>I am using the jQuery tableSorter plugin on a page.</p>
<p>Unfortunatley, the table that is being sorted is dynamically modified, and when I sort after adding an element, the element disappears, restoring the table to the state that it was in when the tableSorter was created.</p>
<p>Is there any way that i can fo... | [
{
"answer_id": 247319,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https://Stackoverflow.com/users/2204759",
"pm_score": 6,
"selected": true,
"text": "<p>I believe you can trigger an update using something like:</p>\n\n<pre><code>$(table).trigger(\"update\")\n</code></pre>... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32392/"
] | I am using the jQuery tableSorter plugin on a page.
Unfortunatley, the table that is being sorted is dynamically modified, and when I sort after adding an element, the element disappears, restoring the table to the state that it was in when the tableSorter was created.
Is there any way that i can force tableSorter to... | I believe you can trigger an update using something like:
```
$(table).trigger("update")
``` |
247,313 | <p>If I had a phone number like this </p>
<pre><code>string phone = "6365555796";
</code></pre>
<p>Which I store with only numeric characters in my database <strong>(as a string)</strong>, is it possible to output the number like this: </p>
<pre><code>"636-555-5796"
</code></pre>
<p>Similar to how I could if I we... | [
{
"answer_id": 247332,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 1,
"selected": false,
"text": "<p>Why not just do something like this?</p>\n\n<pre><code>string phoneText = \"6365555796\";\nlong phoneNum = long.P... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | If I had a phone number like this
```
string phone = "6365555796";
```
Which I store with only numeric characters in my database **(as a string)**, is it possible to output the number like this:
```
"636-555-5796"
```
Similar to how I could if I were using a number:
```
long phone = 6365555796;
string output ... | Best I can think of without having to convert to a long/number and so it fits one line is:
```
string number = "1234567890";
string formattedNumber = string.Format("{0}-{1}-{2}", number.Substring(0,3), number.Substring(3,3), number.Substring(6));
``` |
247,318 | <p>Calling addChild with an empty string as the value (or even with whitespace) seems to cause a redundant SimpleXml node to be added inside the node instead of adding just the node with no value.</p>
<p>Here's a quick demo of what happens:</p>
<pre><code>[description] => !4jh5jh1uio4jh5ij14j34io5j!
</code></pre>
... | [
{
"answer_id": 247370,
"author": "Stephen Walcher",
"author_id": 25375,
"author_profile": "https://Stackoverflow.com/users/25375",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe I'm not understanding the question right but, it seems to me that when you use the addChild method, you'r... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32300/"
] | Calling addChild with an empty string as the value (or even with whitespace) seems to cause a redundant SimpleXml node to be added inside the node instead of adding just the node with no value.
Here's a quick demo of what happens:
```
[description] => !4jh5jh1uio4jh5ij14j34io5j!
```
And here's with an empty string:... | I think I figured out what is going on. Given code like this:
```
$xml = new SimpleXMLElement('<xml></xml>');
$xml->addChild('node','value');
print_r($xml);
$xml = new SimpleXMLElement('<xml></xml>');
$xml->addChild('node','');
print_r($xml);
$xml = new SimpleXMLElement('<xml></xml>');
$xml->addChild('node');
print_... |
247,329 | <p>Unfortunately on my project, we generate a lot of the HTML code in JavaScript like this:</p>
<pre><code>var html = new StringBuffer();
html.append("<td class=\"gr-my-deals\"><a href=\"").append(deal.url).append("\" target=\"_blank\">").append(deal.description).append("</a></td>");
</code></p... | [
{
"answer_id": 247383,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 2,
"selected": false,
"text": "<p>Here is a stringFormat function that helps eliminate concatenation and ugly replacment values. </p>\n\n<pre><code>function st... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | Unfortunately on my project, we generate a lot of the HTML code in JavaScript like this:
```
var html = new StringBuffer();
html.append("<td class=\"gr-my-deals\"><a href=\"").append(deal.url).append("\" target=\"_blank\">").append(deal.description).append("</a></td>");
```
I have 2 specific complaints about this:
... | Here is a stringFormat function that helps eliminate concatenation and ugly replacment values.
```
function stringFormat( str ) {
for( i = 0; i < arguments.length; i++ ) {
var r = new RegExp( '\\{' + ( i ) + '\\}','gm' );
str = str.replace( r, arguments[ i + 1 ] );
}
return str;
}
`... |