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 |
|---|---|---|---|---|---|---|
162,571 | <p>I've executed a JDBC query to obtain a resultset. Before iterating over it, I'd like to quickly find out how many rows were returned. How can I do this with high performance?</p>
<p>I'm using Java 6, Oracle 11g, and the latest Oracle JDBC drivers.</p>
| [
{
"answer_id": 162581,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>Short answer: you can't.</p>\n\n<p>Long answer: you can't, partly because the database may be lazily evaluating the q... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2959/"
] | I've executed a JDBC query to obtain a resultset. Before iterating over it, I'd like to quickly find out how many rows were returned. How can I do this with high performance?
I'm using Java 6, Oracle 11g, and the latest Oracle JDBC drivers. | You're going to have to do this as a separate query, for example:
```
SELECT COUNT(1) FROM table_name
```
Some JDBC drivers might tell you but this is optional behaviour and, more to the point, the driver may not know yet. This can be due to how the query is optimised eg two example execution strategies in Oracle ar... |
162,576 | <p>I've been battling PHP's email reading functions for the better part of two days. I'm writing a script to read emails from a mailbox and save any attachments onto the server. If you've ever done something similar, you might understand my pain: <strong>PHP doesn't play well with email!</strong></p>
<p>I've connected... | [
{
"answer_id": 162589,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 1,
"selected": false,
"text": "<p>MIME data is base-64 encoded, so I think you should be able to decode it using base64_decode</p>\n"
},
{
"answer_id... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] | I've been battling PHP's email reading functions for the better part of two days. I'm writing a script to read emails from a mailbox and save any attachments onto the server. If you've ever done something similar, you might understand my pain: **PHP doesn't play well with email!**
I've connected to the POP3 server and... | I found a quick guide how to treat emails with PHP: [here](http://www.linuxscope.net/articles/mailAttachmentsPHP.html).
At the bottom of that page there's a attachment-body `echo`:
```
if (substr($ContentType,0,4) == "text") {
echo imap_qprint($fileContent);
} else {
echo imap_base64($fileContent);
}
```
I guess th... |
162,617 | <p>When creating a new file with vim, I would like to automatically add some skeleton code.</p>
<p>For example, when creating a new xml file, I would like to add the first line:</p>
<pre><code> <?xml version="1.0"?>
</code></pre>
<p>Or when creating an html file, I would like to add:</p>
<pre><code><!DOCT... | [
{
"answer_id": 162654,
"author": "Oli",
"author_id": 22035,
"author_profile": "https://Stackoverflow.com/users/22035",
"pm_score": 1,
"selected": false,
"text": "<p>Here are two examples using python scripting.</p>\n\n<p>Add something like this in your .vimrc or another file sourced by y... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24076/"
] | When creating a new file with vim, I would like to automatically add some skeleton code.
For example, when creating a new xml file, I would like to add the first line:
```
<?xml version="1.0"?>
```
Or when creating an html file, I would like to add:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "h... | If you want to adapt your skeleton to the context, or to the user choices, have a look at the template-expander plugins listed on [vim.wikia](http://vim.wikia.com/wiki/Category:Automated_Text_Insertion) |
162,651 | <p>What is the difference between these two pieces of code</p>
<pre><code>type
IInterface1 = interface
procedure Proc1;
end;
IInterface2 = interface
procedure Proc2;
end;
TMyClass = class(TInterfacedObject, IInterface1, IInterface2)
protected
procedure Proc1;
procedure Proc2;
end;
</cod... | [
{
"answer_id": 162682,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming you meant</p>\n\n<pre><code>...\nIInterface2 = interface(Interface1)\n...\n</code></pre>\n\n<p>I interpret i... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22712/"
] | What is the difference between these two pieces of code
```
type
IInterface1 = interface
procedure Proc1;
end;
IInterface2 = interface
procedure Proc2;
end;
TMyClass = class(TInterfacedObject, IInterface1, IInterface2)
protected
procedure Proc1;
procedure Proc2;
end;
```
And the follo... | First off, I'm assuming that the second example's declaration for IInterface2 is a typo and should be
```
IInterface2 = interface(Interface1)
```
because inheriting from itself is nonsensical (even if the compiler accepted it).
And "inheriting" is the key word there for answering your question. In example 1 the two... |
162,674 | <p>When using tooltips to show a detailed description of a TreeNode, the tooltip is drawn on top of the node, as if it was completing the node's text. Also, if the text is long, the tooltip is positioned in a way that the <strong>text exceeds the screen</strong>. </p>
<p>But what I need is the tooltip to show right be... | [
{
"answer_id": 162769,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 2,
"selected": false,
"text": "<p>You need to define a ToolTip and write an MouseOverEventHandler for the TreeView. In the MouseOverEventHandler calculate th... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10833/"
] | When using tooltips to show a detailed description of a TreeNode, the tooltip is drawn on top of the node, as if it was completing the node's text. Also, if the text is long, the tooltip is positioned in a way that the **text exceeds the screen**.
But what I need is the tooltip to show right below the mouse pointer a... | I didn't find the answer I was looking for, but I somehow made it work the way I wanted.
Before, I was trying to set up the tooltip as follows:
```
private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
TreeNode node = treeView1.GetNodeAt(e.X, e.Y);
if (node !... |
162,677 | <p>How would I write a Perl CGI script that receives a file via a HTTP post and saves that to the file system?</p>
| [
{
"answer_id": 162724,
"author": "kender",
"author_id": 4172,
"author_profile": "https://Stackoverflow.com/users/4172",
"pm_score": 4,
"selected": true,
"text": "<p>Just a note: however you will write it, <strong>don't</strong> save it in a place accessible from your web-server.</p>\n\n<... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6701/"
] | How would I write a Perl CGI script that receives a file via a HTTP post and saves that to the file system? | Just a note: however you will write it, **don't** save it in a place accessible from your web-server.
And now to the point: below is a script which I was using for some time for photo-uploading. It might need some tweaking, but should show you the way.
As the image isnt uploaded to web-accesible directory, we then ha... |
162,681 | <p>Given the email address: "Jim" <jim@example.com></p>
<p>If I try to pass this to MailAddress I get the exception:</p>
<blockquote>
<p>The specified string is not in the form required for an e-mail address.</p>
</blockquote>
<p>How do I parse this address into a display name (Jim) and email address (jim@ex... | [
{
"answer_id": 162700,
"author": "Codewerks",
"author_id": 17729,
"author_profile": "https://Stackoverflow.com/users/17729",
"pm_score": 2,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>\"Jimbo <jim@example.com>\"\n</code></pre>\n"
},
{
"answer_id": 162701,
"aut... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4580/"
] | Given the email address: "Jim" <jim@example.com>
If I try to pass this to MailAddress I get the exception:
>
> The specified string is not in the form required for an e-mail address.
>
>
>
How do I parse this address into a display name (Jim) and email address (jim@example.com) in C#?
EDIT: I'm looking for C# c... | If you are looking to parse the email address manually, you want to read RFC2822 (<https://www.rfc-editor.org/rfc/rfc822.html#section-3.4>). Section 3.4 talks about the address format.
But parsing email addresses correctly is not easy and `MailAddress` should be able to handle most scenarios.
According to the MSDN do... |
162,696 | <p>A few years ago, I read a book that described how you could override the default event 'dispatcher' implementation in .NET with your own processor.</p>
<pre><code> class foo {
public event EventHandler myEvent;
...
}
...
myFoo.myEvent += myBar1.EventHandler;
myFoo.myEvent += my... | [
{
"answer_id": 162745,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I seem to remember something similar in Jeffrey Richter's CLR via C#. <strong>Edit:</strong> I definitely do remember that... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | A few years ago, I read a book that described how you could override the default event 'dispatcher' implementation in .NET with your own processor.
```
class foo {
public event EventHandler myEvent;
...
}
...
myFoo.myEvent += myBar1.EventHandler;
myFoo.myEvent += myBar2.EventHand... | It could have been one of many books or web articles.
There are various reasons why you might want to change how events are subscribed/unsubscribed:
* If you have many events, many of which may well not be subscribed to, you may want to use [EventHandlerList](http://msdn.microsoft.com/en-us/library/system.componentmo... |
162,727 | <p>I've got a text file full of records where each field in each record is a fixed width. My first approach would be to parse each record simply using string.Substring(). Is there a better way? </p>
<p>For example, the format could be described as:</p>
<pre><code><Field1(8)><Field2(16)><Field3(12)>... | [
{
"answer_id": 162772,
"author": "Will Hartung",
"author_id": 13663,
"author_profile": "https://Stackoverflow.com/users/13663",
"pm_score": 0,
"selected": false,
"text": "<p>Nope, Substring is fine. That's what it's for.</p>\n"
},
{
"answer_id": 162774,
"author": "Jon Skeet",... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2773/"
] | I've got a text file full of records where each field in each record is a fixed width. My first approach would be to parse each record simply using string.Substring(). Is there a better way?
For example, the format could be described as:
```
<Field1(8)><Field2(16)><Field3(12)>
```
And an example file with two reco... | Substring sounds good to me. The only downside I can immediately think of is that it means copying the data each time, but I wouldn't worry about that until you prove it's a bottleneck. Substring is simple :)
You *could* use a regex to match a whole record at a time and capture the fields, but I think that would be ov... |
162,730 | <p>I have a table column that needs to be limited to a certain width - say 100 pixels. At times the text in that column is wider than this and contains no spaces. For example:</p>
<pre><code>a_really_long_string_of_text_like_this_with_no_line_breaks_makes_the_table_unhappy
</code></pre>
<p>I would like to calculate ... | [
{
"answer_id": 162746,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 1,
"selected": false,
"text": "<p>Very very hard to do server-side. You can never know what fonts users have installed, and there are many things that affect... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13850/"
] | I have a table column that needs to be limited to a certain width - say 100 pixels. At times the text in that column is wider than this and contains no spaces. For example:
```
a_really_long_string_of_text_like_this_with_no_line_breaks_makes_the_table_unhappy
```
I would like to calculate the width of text server-si... | This would not only be impossible to do server-side, it would also not make sense. You don't what browser your client will be using, and you don't know what font settings on the client side will override whatever styling information you assign to a piece of HTML. You might think that you're using absolute positioning p... |
162,752 | <p>I am looking for an algorithm to calculate the next set of operations in a sequence. Here is the simple definition of the sequence.</p>
<ol>
<li>Task 1A will be done every 500 hours</li>
<li>Task 2A will be done every 1000 hours</li>
<li>Task 3A will be done every 1500 hours</li>
</ol>
<p>So at t=500, do 1A. At t=... | [
{
"answer_id": 162806,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "<p>If you have enough history to get the last two times each task was done you could reconstruct the original task s... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341/"
] | I am looking for an algorithm to calculate the next set of operations in a sequence. Here is the simple definition of the sequence.
1. Task 1A will be done every 500 hours
2. Task 2A will be done every 1000 hours
3. Task 3A will be done every 1500 hours
So at t=500, do 1A. At t=1000, do both 1A and 2A, at t=1500 do 1... | Bill the Lizard is right. Here is how to determine the task intervals from the history (in Python):
```
history = [list of tuples like (timestamp, (A, B, ...)), ordered by timestamp]
lastTaskTime = {}
taskIntervals = {}
for timestamp, tasks in history:
for task in tasks:
if task not in lastTaskTime:
... |
162,753 | <p>I am using a multi-dimensional dynamic array in delphi and am trying to figure this out:</p>
<p>I have 2 seperate values for the first index and second index that are totally seperate of each other.</p>
<p>As new values come I want to grow the array if that new value is outside of either bound.</p>
<p>For new val... | [
{
"answer_id": 162783,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 2,
"selected": false,
"text": "<p>It looks fine to me - if you change the last line to</p>\n\n<pre><code>SetLength(List, Length(List), y + 1);\n</code></pre>\... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16059/"
] | I am using a multi-dimensional dynamic array in delphi and am trying to figure this out:
I have 2 seperate values for the first index and second index that are totally seperate of each other.
As new values come I want to grow the array if that new value is outside of either bound.
For new values x, y
I check:
```
... | I think you forgot to use the second index on the second dimension;
Your code should probably read like this :
```
if Length(List) < (x + 1) then
SetLength(List, x + 1);
if Length(List[x]) < (y + 1) then
SetLength(List[x], y + 1);
```
Note the use of 'x' as the first dimension index when growing the second di... |
162,762 | <p>I recently deploy one web application in one of my development servers. I'm using oracle, asp.net and c#. When I run the application in the server everything works fine, but when I try to run the application outside of the server (using my pc, for example) i get this error:</p>
<pre><code>ORA-12154: TNS:could not r... | [
{
"answer_id": 162796,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried this yet? (from <a href=\"http://ora-12154.ora-code.com/\" rel=\"nofollow noreferrer\">http://ora-12154.ora... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24521/"
] | I recently deploy one web application in one of my development servers. I'm using oracle, asp.net and c#. When I run the application in the server everything works fine, but when I try to run the application outside of the server (using my pc, for example) i get this error:
```
ORA-12154: TNS:could not resolve the con... | Guess: An oracle client is not installed on Server B.
If you do have an oracle client installed then you can still put a tnsnames file in any location (Such as a directory on a network share). In order to do this, set a TNS\_ADMIN system variable (System Properties->Advanced->Environment Variables on XP) to the direct... |
162,798 | <p>One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:</p>
<pre><code>self.__value = 1
def value():
return self.__value
</code></pre>
<p>Is there a simple way of providing access to the private members of a class that I wish to s... | [
{
"answer_id": 162854,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 4,
"selected": true,
"text": "<p>Not conveniently, without further breaking encapsulation. The double-underscore attribute is name-mangled by prep... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] | One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:
```
self.__value = 1
def value():
return self.__value
```
Is there a simple way of providing access to the private members of a class that I wish to subclass? Often I wish to s... | Not conveniently, without further breaking encapsulation. The double-underscore attribute is name-mangled by prepending '\_ClassName' for the class it is being accessed in. So, if you have a 'ContainerThing' class that has a '\_\_value' attribute, the attribute is actually being stored as '`_ContainerThing__value`'. Ch... |
162,804 | <p>I have a char array in a C application that I have to split into parts of 250 so that I can send it along to another application that doesn't accept more at one time. </p>
<p>How would I do that? Platform: win32. </p>
| [
{
"answer_id": 162837,
"author": "jvasak",
"author_id": 5840,
"author_profile": "https://Stackoverflow.com/users/5840",
"pm_score": 3,
"selected": true,
"text": "<p>From the MSDN documentation:</p>\n\n<blockquote>\n <p>The strncpy function copies the initial count characters of strSourc... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10010/"
] | I have a char array in a C application that I have to split into parts of 250 so that I can send it along to another application that doesn't accept more at one time.
How would I do that? Platform: win32. | From the MSDN documentation:
>
> The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string. If count is greater than the length of strSource, the d... |
162,810 | <p>I am using Log4Net with the AdoNetAppender to log messages from a simple systray application into a SQL Server 2005 database.</p>
<p>I want to log the machine name along with the log message because this application will be running on multiple machines and I need to know on which one the message originated.</p>
<p... | [
{
"answer_id": 162979,
"author": "Thad",
"author_id": 24500,
"author_profile": "https://Stackoverflow.com/users/24500",
"pm_score": 4,
"selected": false,
"text": "<p>you can create a parameter similar to the following:</p>\n\n<pre><code><parameter>\n <parameterName value=\"@mac... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2834/"
] | I am using Log4Net with the AdoNetAppender to log messages from a simple systray application into a SQL Server 2005 database.
I want to log the machine name along with the log message because this application will be running on multiple machines and I need to know on which one the message originated.
But, I cannot fi... | You can use the pre-populated property `log4net:HostName`, for example:
```
<conversionPattern value="%property{log4net:HostName}" />
```
This way you don't need to populate the MDC. |
162,871 | <p>I'm quite new to NHibernate and starting to find my way around.</p>
<p>I have a domain model that is somewhat like a tree.</p>
<p>Funds have Periods have Selections have Audits<br>
Now I would like to get all Audits for a specific Fund</p>
<p>Would look like this if I made it in SQL</p>
<p>SELECT A.*<br>
FROM Au... | [
{
"answer_id": 162966,
"author": "Jasper",
"author_id": 18702,
"author_profile": "https://Stackoverflow.com/users/18702",
"pm_score": 1,
"selected": false,
"text": "<p>Try this </p>\n\n<pre><code>select elements(s.Audits)\nfrom Fund as f inner join Period as p inner join Selection as s ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11434/"
] | I'm quite new to NHibernate and starting to find my way around.
I have a domain model that is somewhat like a tree.
Funds have Periods have Selections have Audits
Now I would like to get all Audits for a specific Fund
Would look like this if I made it in SQL
SELECT A.\*
FROM Audit A
JOIN Selection S ON A.f... | Try this
```
select elements(s.Audits)
from Fund as f inner join Period as p inner join Selection as s
where f = myFundInstance
``` |
162,873 | <p>How do you include a file that is more than 2 directories back. I know you can use <code>../index.php</code> to include a file that is 2 directories back, but how do you do it for 3 directories back?
Does this make sense?
I tried <code>.../index.php</code> but it isn't working.</p>
<p>I have a file in <code>/game/f... | [
{
"answer_id": 162881,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 4,
"selected": false,
"text": "<pre><code>../../index.php \n</code></pre>\n\n<p> </p>\n"
},
{
"answer_id": ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you include a file that is more than 2 directories back. I know you can use `../index.php` to include a file that is 2 directories back, but how do you do it for 3 directories back?
Does this make sense?
I tried `.../index.php` but it isn't working.
I have a file in `/game/forum/files/index.php` and it uses PHP... | `..` selects the parent directory from the current. Of course, this can be chained:
```
../../index.php
```
This would be two directories up. |
162,874 | <p>I'm using <a href="http://enunciate.codehaus.org" rel="nofollow noreferrer">Enunciate</a> to build a prototype REST api and need to include a jar containing custom code as a library.</p>
<p>My Ant Script looks like this:</p>
<p></p>
<pre><code><!--include all jars-->
<path id="en.classpath">
<f... | [
{
"answer_id": 221420,
"author": "Miguel Ping",
"author_id": 22992,
"author_profile": "https://Stackoverflow.com/users/22992",
"pm_score": 2,
"selected": false,
"text": "<p>I never used enunciate, but as a quick hack you can add the jars to the war:</p>\n\n<pre><code><jar jarfile=\"${... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9518/"
] | I'm using [Enunciate](http://enunciate.codehaus.org) to build a prototype REST api and need to include a jar containing custom code as a library.
My Ant Script looks like this:
```
<!--include all jars-->
<path id="en.classpath">
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<... | As it turns out one of the jars we're attempting to include has a dependency listed in it's Manifest file of a jar that Enunciate depends on (freemarker). Enunciate automatically excludes freemarker and at first glance it seems as though it automatically excludes anything that depends on freemarker as well. If we remov... |
162,879 | <p>Let's say you have a class with a Uri property. Is there any way to get that property to accept both a string value and a Uri? How would you build it?</p>
<p>I'd like to be able to do something like one of the following, but neither are supported (using VB, since it lets you specify type in the Set declaration fo... | [
{
"answer_id": 162890,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "<p>I think you just need to provide an accompanying </p>\n\n<pre><code>Public Sub SetLink(ByVal value as String)\n _link =... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] | Let's say you have a class with a Uri property. Is there any way to get that property to accept both a string value and a Uri? How would you build it?
I'd like to be able to do something like one of the following, but neither are supported (using VB, since it lets you specify type in the Set declaration for the 2nd on... | Alternatively, you can of course forego overloading and just name the properties appropriately:
```
Public WriteOnly Property UriString() As String
Set(ByVal value As String)
m_Uri = new Uri(value)
End Set
End Property
```
Of course you don't have to make this `WriteOnly` but it seems appropriate. |
162,897 | <p>Given the following C function in a DLL:</p>
<pre><code>char * GetDir(char* path );
</code></pre>
<p>How would you P/Invoke this function into C# and marshal the char * properly.
.NET seems to know how to do LPCTSTR but when I can't figure out any marshaling that doesn't cause a NotSupportedException to fire when ... | [
{
"answer_id": 162922,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 4,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>[DllImport(\"your.dll\", CharSet = CharSet.Ansi)]\nstring GetDir(StringBuilder path);\n</code... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | Given the following C function in a DLL:
```
char * GetDir(char* path );
```
How would you P/Invoke this function into C# and marshal the char \* properly.
.NET seems to know how to do LPCTSTR but when I can't figure out any marshaling that doesn't cause a NotSupportedException to fire when calling this function. | OregonGhost's answer is only correct if the char\* returned from GetDir is either allocated in HGlobal or LocalAlloc. I can't remember which one but the CLR will assume that any string return type from a PInvoke function was allocated with one or the other.
A more robust way is to type the return of GetDir to be IntP... |
162,911 | <p>If I can do this, how do I call Java code (methods for instance) from within JavaScript code, in Wicket. </p>
| [
{
"answer_id": 163024,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming you mean JavaScript running on the client - you cause an HTTP redirect to be made to the server, and have your... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23486/"
] | If I can do this, how do I call Java code (methods for instance) from within JavaScript code, in Wicket. | erk. The correct answer would be ajax call backs. You can either manually code the js to hook into the wicket js, or you can setup the callbacks from wicket components in java.
For example, from AjaxLazyLoadPanel:
```
component.add( new AbstractDefaultAjaxBehavior() {
@Override
protected void ... |
162,931 | <p>I'm trying to create a Crystal Reports formula field (to calculate the percentage change in a price) that will return "N/A" if a particular report field is null, but return a number to two decimal places using accounting format (negative numbers surrounded by parentheses) if it is not.</p>
<p>The closest I have bee... | [
{
"answer_id": 163019,
"author": "Pyroglass",
"author_id": 21760,
"author_profile": "https://Stackoverflow.com/users/21760",
"pm_score": 4,
"selected": true,
"text": "<p>I think you are looking for <code>ToText(CCur(@Price}/{ValuationReport.YestPrice}*100-100))</code></p>\n\n<p>You can u... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3012/"
] | I'm trying to create a Crystal Reports formula field (to calculate the percentage change in a price) that will return "N/A" if a particular report field is null, but return a number to two decimal places using accounting format (negative numbers surrounded by parentheses) if it is not.
The closest I have been able to ... | I think you are looking for `ToText(CCur(@Price}/{ValuationReport.YestPrice}*100-100))`
You can use `CCur` to convert numbers or string to Curency formats. `CCur(number)` or `CCur(string)`
---
I think this may be what you are looking for,
`Replace (ToText(CCur({field})),"$" , "")` that will give the parentheses for... |
162,941 | <p>I know this is a really basic question, but I've just started with some basic C++ programming after coding a few projects with high-level languages. </p>
<p>Basically I have three questions:</p>
<ol>
<li>Why use pointers over normal variables?</li>
<li>When and where should I use pointers?</li>
<li>How do you use ... | [
{
"answer_id": 162971,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 5,
"selected": false,
"text": "<p>Pointers are one way of getting an indirect reference to another variable. Instead of holding the <em>value</em>... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know this is a really basic question, but I've just started with some basic C++ programming after coding a few projects with high-level languages.
Basically I have three questions:
1. Why use pointers over normal variables?
2. When and where should I use pointers?
3. How do you use pointers with arrays? | * Why use pointers over normal variables?
Short answer is: Don't. ;-) Pointers are to be used where you can't use anything else. It is either because the lack of appropriate functionality, missing data types or for pure perfomance. More below...
* When and where should I use pointers?
Short answer here is: Where you... |
162,960 | <p>So, I've been living with my cvs repositories for some time. Though there is a thing I miss - if i rename a file that is already in repository, I need to delete the one with old name from there and add the new one. Hence, I loose all my change-history. And sometimes there's a need to rename a file in alredy existing... | [
{
"answer_id": 162970,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 5,
"selected": true,
"text": "<p>Subversion can do this, but you have to do it with </p>\n\n<pre><code>svn move <oldfile> <newfile>... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] | So, I've been living with my cvs repositories for some time. Though there is a thing I miss - if i rename a file that is already in repository, I need to delete the one with old name from there and add the new one. Hence, I loose all my change-history. And sometimes there's a need to rename a file in alredy existing pr... | Subversion can do this, but you have to do it with
```
svn move <oldfile> <newfile>
```
Edit: And in this decade, we do `git mv <oldfile> <newfile>`, or just use `mv` and git usually figures it out on its own. |
162,986 | <p>I have a class that looks like this</p>
<pre><code>public class SomeClass
{
public SomeChildClass[] childArray;
}
</code></pre>
<p>which will output XML from the XMLSerializer like this:</p>
<pre><code><SomeClass>
<SomeChildClass>
...
</SomeChildClass>
<SomeChildClass>
... | [
{
"answer_id": 163047,
"author": "Craig Eddy",
"author_id": 5557,
"author_profile": "https://Stackoverflow.com/users/5557",
"pm_score": 0,
"selected": false,
"text": "<p>You may need to look into implementing System.Xml.Serialization.IXmlSerializable to accomplish this.</p>\n"
},
{
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3543/"
] | I have a class that looks like this
```
public class SomeClass
{
public SomeChildClass[] childArray;
}
```
which will output XML from the XMLSerializer like this:
```
<SomeClass>
<SomeChildClass>
...
</SomeChildClass>
<SomeChildClass>
...
</SomeChildClass>
</SomeClass>
```
But I want t... | The best approach would be to do what you said and add a property to the "SomeChildClass" like this
```
[XmlAttribute("Index")]
public int Order
{ { get; set; } }
```
Then however you are adding these items to your array, make sure that this property get's set. Then when you serialize....Presto! |
162,989 | <p>How does one dynamically load a new report from an embedded resource? I have created a reporting project that contains a report as an embedded resource. I added a second report file and use the following code to switch reports:</p>
<pre><code>this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportsApplicati... | [
{
"answer_id": 167132,
"author": "Craig Eddy",
"author_id": 5557,
"author_profile": "https://Stackoverflow.com/users/5557",
"pm_score": 4,
"selected": true,
"text": "<p>The answer: you have to call </p>\n\n<pre><code><ReportViewer>.Reset();\n</code></pre>\n\n<p>prior to changing th... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5557/"
] | How does one dynamically load a new report from an embedded resource? I have created a reporting project that contains a report as an embedded resource. I added a second report file and use the following code to switch reports:
```
this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportsApplication2.Report2.rd... | The answer: you have to call
```
<ReportViewer>.Reset();
```
prior to changing the value of ReportEmbeddedResource or calling LoadReportDefinition.
After you do so, you'll also have to call
```
<ReportViewer>.LocalReport.DataSources.Add( ... );
```
to re-establish the data sources. |
162,993 | <p>I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines:</p>
<pre><code>[System.ComponentModel.RunInstaller(true)]
public class MyApplicationManagementInstaller : DefaultManagementInstaller { }
</code></pre>
<p>I gather the purpose of t... | [
{
"answer_id": 164690,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>As I understand, DefaultManagementInstaller is ran by installutil.exe - if you don't include it, the class is not installed ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/162993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines:
```
[System.ComponentModel.RunInstaller(true)]
public class MyApplicationManagementInstaller : DefaultManagementInstaller { }
```
I gather the purpose of this installation is becaus... | As I understand, DefaultManagementInstaller is ran by installutil.exe - if you don't include it, the class is not installed in WMI. Maybe it is possible to create a 'setup project' or 'installer project' that runs it, but I'm not sure because I don't use Visual Studio.
[edit]
for remote instalation, an option could b... |
163,004 | <p>Say I have two tables I want to join.
Categories:</p>
<pre><code>id name
----------
1 Cars
2 Games
3 Pencils
</code></pre>
<p>And items:</p>
<pre><code>id categoryid itemname
---------------------------
1 1 Ford
2 1 BMW
3 1 VW
4 2 Tetris
5 ... | [
{
"answer_id": 163051,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 0,
"selected": false,
"text": "<p>Mysql lets you to have columns not included in grouping or aggregate, in which case they've got random values:</p>\n\n<pr... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15214/"
] | Say I have two tables I want to join.
Categories:
```
id name
----------
1 Cars
2 Games
3 Pencils
```
And items:
```
id categoryid itemname
---------------------------
1 1 Ford
2 1 BMW
3 1 VW
4 2 Tetris
5 2 Pong
6 3 F... | Just done a quick test. This seems to work:
```
mysql> select * from categories c, items i
-> where i.categoryid = c.id
-> group by c.id;
+------+---------+------+------------+----------------+
| id | name | id | categoryid | name |
+------+---------+------+------------+----------------+
| ... |
163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | [
{
"answer_id": 163093,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 2,
"selected": false,
"text": "<p>Do you mean <code>urllib2.urlopen</code>? There is no function called <code>openfile</code> in the <code>urllib2</c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6007/"
] | If I open a file using urllib2, like so:
```
remotefile = urllib2.urlopen('http://example.com/somefile.zip')
```
Is there an easy way to get the file name other then parsing the original URL?
EDIT: changed openfile to urlopen... not sure how that happened.
EDIT2: I ended up using:
```
filename = url.split('/')[-1... | Did you mean [urllib2.urlopen](http://www.python.org/doc/2.5.2/lib/module-urllib2.html#l2h-3928)?
You could potentially lift the *intended* filename *if* the server was sending a Content-Disposition header by checking `remotefile.info()['Content-Disposition']`, but as it is I think you'll just have to parse the url.
... |
163,022 | <p>I'd like to do some basic profiling of my code, but found that the DateTime.Now in C# only have a resolution of about 16 ms. There must be better time keeping constructs that I haven't yet found.</p>
| [
{
"answer_id": 163030,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 4,
"selected": false,
"text": "<p>The System.Diagnostics.StopWatch class is awesome for profiling.</p>\n\n<p>Here is a link to <a href=\"http://blogs.msdn... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2973/"
] | I'd like to do some basic profiling of my code, but found that the DateTime.Now in C# only have a resolution of about 16 ms. There must be better time keeping constructs that I haven't yet found. | Here is a sample bit of code to time an operation:
```
Dim sw As New Stopwatch()
sw.Start()
//Insert Code To Time
sw.Stop()
Dim ms As Long = sw.ElapsedMilliseconds
Console.WriteLine("Total Seconds Elapsed: " & ms / 1000)
```
EDIT:
And the neat thing is that it can resume as well.
```
Stopwatch sw = new Stopwatch()... |
163,092 | <p>In Ruby you can easily set a default value for a variable </p>
<pre><code>x ||= "default"
</code></pre>
<p>The above statement will set the value of x to "default" if x is nil or false</p>
<p>Is there a similar shortcut in PHP or do I have to use the longer form:</p>
<pre><code>$x = (isset($x))? $x : "default";
... | [
{
"answer_id": 163115,
"author": "jochil",
"author_id": 23794,
"author_profile": "https://Stackoverflow.com/users/23794",
"pm_score": 0,
"selected": false,
"text": "<p>I think your longer form is already the shortcut for php... and I wouldn't use it, because it is not good to read</p>\n\... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/796/"
] | In Ruby you can easily set a default value for a variable
```
x ||= "default"
```
The above statement will set the value of x to "default" if x is nil or false
Is there a similar shortcut in PHP or do I have to use the longer form:
```
$x = (isset($x))? $x : "default";
```
Are there any easier ways to handle th... | As of PHP 5.3 you can use the ternary operator while omitting the middle argument:
```
$x = $x ?: 'default';
``` |
163,098 | <p>I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF).</p>
<p>What can I do to automatically shrink these or keep them from getting so large?</p>
| [
{
"answer_id": 163114,
"author": "Forgotten Semicolon",
"author_id": 1960,
"author_profile": "https://Stackoverflow.com/users/1960",
"pm_score": 2,
"selected": false,
"text": "<p>DBCC SHRINKFILE.</p>\n\n<p><a href=\"http://support.microsoft.com/kb/907511\" rel=\"nofollow noreferrer\">Her... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2926/"
] | I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF).
What can I do to automatically shrink these or keep them from getting so large? | That should do the job
```
use master
go
dump transaction <YourDBName> with no_log
go
use <YourDBName>
go
DBCC SHRINKFILE (<YourDBNameLogFileName>, 100) -- where 100 is the size you may want to shrink it to in MB, change it to your needs
go
-- then you can call to check that all went fine
dbcc checkdb(<YourDBName>)
`... |
163,162 | <p>I am trying to use the <code>Directory.GetFiles()</code> method to retrieve a list of files of multiple types, such as <code>mp3</code>'s and <code>jpg</code>'s. I have tried both of the following with no luck:</p>
<pre><code>Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories);
Directory.Get... | [
{
"answer_id": 163203,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 3,
"selected": false,
"text": "<p>Nope. Try the following:</p>\n\n<pre><code>List<string> _searchPatternList = new List<string>();\n ...\n ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2470/"
] | I am trying to use the `Directory.GetFiles()` method to retrieve a list of files of multiple types, such as `mp3`'s and `jpg`'s. I have tried both of the following with no luck:
```
Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories);
Directory.GetFiles("C:\\path", "*.mp3;*.jpg", SearchOption.Al... | For .NET 4.0 and later,
```
var files = Directory.EnumerateFiles("C:\\path", "*.*", SearchOption.AllDirectories)
.Where(s => s.EndsWith(".mp3") || s.EndsWith(".jpg"));
```
For earlier versions of .NET,
```
var files = Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories)
.Where... |
163,183 | <p>I'm encountering some peculiarities with LINQ to SQL.</p>
<p>With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this:</p>
<pre><code> var list = dataContext.MyLists.Single(x => x.ID == myId);
var items = from i... | [
{
"answer_id": 163248,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 3,
"selected": false,
"text": "<p>In the first query, you have already got the data back from the database by the time the second line runs (var ite... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366/"
] | I'm encountering some peculiarities with LINQ to SQL.
With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this:
```
var list = dataContext.MyLists.Single(x => x.ID == myId);
var items = from i in list.MyItems
... | I'd do the SQL part without doing the formatting, then do the formatting on the client side:
```
var items = list.MyItems.Select(item => new { item.ID, item.Sector, item.Description,
item.CompleteDate, item.DueDate })
.AsEnumerable() // Don't do th... |
163,184 | <p>I need to convert inline css style attributes to their HTML tag equivelants. The solution I have works but runs VERY slowly using the Microsoft .Net Regex namespace and long documents (~40 pages of html). I've tried several variations but with no useful results. I've done a little wrapping around executing the ex... | [
{
"answer_id": 163211,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 3,
"selected": false,
"text": "<p>I believe the problem is that if it finds a <code>span</code>|<code>font</code> tag, which has no style attr... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to convert inline css style attributes to their HTML tag equivelants. The solution I have works but runs VERY slowly using the Microsoft .Net Regex namespace and long documents (~40 pages of html). I've tried several variations but with no useful results. I've done a little wrapping around executing the expressi... | I believe the problem is that if it finds a `span`|`font` tag, which has no style attribute defined, it will continue looking for it until the end of the document because of the `.\*?`. I haven't tested it, but changing it to `[^>]\*?` might improve performance.
Make sure you apply that change for all `.\*?` you have;... |
163,207 | <p>I need to call a method that accepts a stream argument. The method loads text into the stream, which would normally be a file. I'd like to simply populate a string with the contents of the stream, instead of writing it to a file. How do I do this?</p>
| [
{
"answer_id": 163217,
"author": "user8032",
"author_id": 8032,
"author_profile": "https://Stackoverflow.com/users/8032",
"pm_score": 2,
"selected": false,
"text": "<p>Look up MemoryStream class</p>\n"
},
{
"answer_id": 163226,
"author": "Wolfwyrd",
"author_id": 15570,
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20625/"
] | I need to call a method that accepts a stream argument. The method loads text into the stream, which would normally be a file. I'd like to simply populate a string with the contents of the stream, instead of writing it to a file. How do I do this? | Use a MemoryStream with a StreamReader. Something like:
```
using (MemoryStream ms = new MemoryStream())
using (StreamReader sr = new StreamReader(ms))
{
// pass the memory stream to method
ms.Seek(0, SeekOrigin.Begin); // added from itsmatt
string s = sr.ReadToEnd();
}
``` |
163,246 | <p>In Oracle, I can re-create a view with a single statement, as shown here:</p>
<pre><code>CREATE OR REPLACE VIEW MY_VIEW AS
SELECT SOME_FIELD
FROM SOME_TABLE
WHERE SOME_CONDITIONS
</code></pre>
<p>As the syntax implies, this will drop the old view and re-create it with whatever definition I've given.</p>
<p>Is the... | [
{
"answer_id": 163260,
"author": "DaveK",
"author_id": 4244,
"author_profile": "https://Stackoverflow.com/users/4244",
"pm_score": 6,
"selected": false,
"text": "<p>You can use 'IF EXISTS' to check if the view exists and drop if it does.</p>\n\n<pre>\nIF EXISTS (SELECT TABLE_NAME FROM IN... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | In Oracle, I can re-create a view with a single statement, as shown here:
```
CREATE OR REPLACE VIEW MY_VIEW AS
SELECT SOME_FIELD
FROM SOME_TABLE
WHERE SOME_CONDITIONS
```
As the syntax implies, this will drop the old view and re-create it with whatever definition I've given.
Is there an equivalent in MSSQL (SQL Se... | The solutions above though they will get the job done do so at the risk of dropping user permissions. I prefer to do my create or replace views or stored procedures as follows.
```
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_myView]'))
EXEC sp_executesql N'CREATE VIEW [dbo].[vw_m... |
163,302 | <p>I'm trying to have the modrewrite rules skip the directory <code>vip</code>. I've tried a number of things as you can see below, but to no avail.</p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteRule ^vip$ - [PT]
RewriteRule ^vip/.$ - [PT]
#RewriteCond %{REQUEST_... | [
{
"answer_id": 163401,
"author": "Peter Howe",
"author_id": 24106,
"author_profile": "https://Stackoverflow.com/users/24106",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not sure if I understand your objective, but the following might do what you're after?</p>\n\n<pre><code>Rewrit... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24557/"
] | I'm trying to have the modrewrite rules skip the directory `vip`. I've tried a number of things as you can see below, but to no avail.
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteRule ^vip$ - [PT]
RewriteRule ^vip/.$ - [PT]
#RewriteCond %{REQUEST_URI} !/vip
RewriteCond %{REQU... | Try putting this before any other rules.
```
RewriteRule ^vip - [L,NC]
```
It will match any URI beginning `vip`.
* The `-` means do nothing.
* The `L` means this should be last rule; ignore everything following.
* The `NC` means no-case (so "VIP" is also matched).
Note that it matches anything *beginning* `vip`... |
163,311 | <p>I am using an asp:Calander and I have an object that has a beginning date and an ending date. I need to get all the dates between these two dates and place them in an array so i can then render corresponding dates on the calander with different CSS</p>
| [
{
"answer_id": 163325,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 2,
"selected": false,
"text": "<pre><code>DateTime startDate;\nDateTime endDate;\n\nDateTime currentDate = startDate;\nList<DateTime> dates = new... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16820/"
] | I am using an asp:Calander and I have an object that has a beginning date and an ending date. I need to get all the dates between these two dates and place them in an array so i can then render corresponding dates on the calander with different CSS | I voted up AlbertEin because he gave a good answer, but do you really need a collection to hold all the dates? When you are rendering the day, couldn't you just check if the date is withing the specified range, and then render it differently, no need for a collection. Here's some code to demonstrate
```
DateTime Range... |
163,336 | <p>Say for example you just queried a database and you recieved this 2D array.</p>
<pre><code>$results = array(
array('id' => 1, 'name' => 'red' , 'spin' => 1),
array('id' => 2, 'name' => 'green', 'spin' => -1),
array('id' => 3, 'name' => 'blue' , 'spin' => .5)
);
</code></pre>... | [
{
"answer_id": 163421,
"author": "Devon",
"author_id": 13850,
"author_profile": "https://Stackoverflow.com/users/13850",
"pm_score": 3,
"selected": false,
"text": "<p>Simply put, no.</p>\n\n<p>You will need to use a loop or a callback function like <a href=\"http://us3.php.net/function.a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17919/"
] | Say for example you just queried a database and you recieved this 2D array.
```
$results = array(
array('id' => 1, 'name' => 'red' , 'spin' => 1),
array('id' => 2, 'name' => 'green', 'spin' => -1),
array('id' => 3, 'name' => 'blue' , 'spin' => .5)
);
```
I often find myself writing loops like this.
``... | As of June 20th in PHP-5.5 there is a new function [array\_column](http://us2.php.net/array_column)
For example:
```
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe'
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_na... |
163,355 | <p>I'm on SQL Server 2005 and I am getting an error which I am pretty sure should not be getting.</p>
<pre><code>Msg 512, Level 16, State 1, Procedure spGetSavedSearchesByAdminUser, Line 8 Subquery
returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the ... | [
{
"answer_id": 163371,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know that you can use the CASE statement inside of an IN clause like that. I'd suggest rewriting that bit t... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/262613/"
] | I'm on SQL Server 2005 and I am getting an error which I am pretty sure should not be getting.
```
Msg 512, Level 16, State 1, Procedure spGetSavedSearchesByAdminUser, Line 8 Subquery
returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the subquery is used as an exp... | Try rearranging the query so that the boolean expression occurs inside the subselect, e.g.
```
ALTER PROCEDURE [dbo].[spGetSavedSearchesByAdminUser]
@strUserName varchar(50)
,@bitQuickSearch bit = 0
AS
BEGIN
SELECT [intSearchID] ,strSearchTypeCode ,[strSearchName]
FROM [tblAdminSearches]
WHE... |
163,360 | <p>I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java <code>String</code> flavor and pasted it into Java code, it does not work. The following class prints <code>false</code>:... | [
{
"answer_id": 163398,
"author": "TomC",
"author_id": 13183,
"author_profile": "https://Stackoverflow.com/users/13183",
"pm_score": 8,
"selected": true,
"text": "<p>Try the following regex string instead. Your test was probably done in a case-sensitive manner. I have added the lowercase ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java `String` flavor and pasted it into Java code, it does not work. The following class prints `false`:
```
public class Regex... | Try the following regex string instead. Your test was probably done in a case-sensitive manner. I have added the lowercase alphas as well as a proper string beginning placeholder.
```
String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
```
This works too:
```
String regex = "\... |
163,365 | <p>Let's say that for some reason you need to write a macro: <code>MACRO(X,Y)</code>. <strong>(Let's assume there's a good reason you can't use an inline function.)</strong> You want this macro to emulate a call to a function with no return value.</p>
<hr>
<h3>Example 1: This should work as expected.</h3>
<pre><co... | [
{
"answer_id": 163366,
"author": "Kip",
"author_id": 18511,
"author_profile": "https://Stackoverflow.com/users/18511",
"pm_score": 6,
"selected": false,
"text": "<p>There is a rather clever solution:</p>\n\n<pre><code>#define MACRO(X,Y) \\\ndo { ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | Let's say that for some reason you need to write a macro: `MACRO(X,Y)`. **(Let's assume there's a good reason you can't use an inline function.)** You want this macro to emulate a call to a function with no return value.
---
### Example 1: This should work as expected.
```
if (x > y)
MACRO(x, y);
do_something();
... | Macros should generally be avoided; prefer inline functions to them at all times. Any compiler worth its salt should be capable of inlining a small function as if it were a macro, and an inline function will respect namespaces and other scopes, as well as evaluating all the arguments once.
If it must be a macro, a whi... |
163,367 | <p>I get a mysql error:</p>
<p><strong>#update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine:</strong></p>
<p>When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem?</p>
<p>Below is the stacktrace. <... | [
{
"answer_id": 163422,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 1,
"selected": true,
"text": "<p>Maybe it's this bug: <a href=\"http://bugs.mysql.com/bug.php?id=10035\" rel=\"nofollow noreferrer\">#1030 - Go... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21596/"
] | I get a mysql error:
**#update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine:**
When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem?
Below is the stacktrace.
```
from /var/www/releases/200810021... | Maybe it's this bug: [#1030 - Got error 139 from storage engine](http://bugs.mysql.com/bug.php?id=10035), but it would help if you'd post the query which should come directly after the error message. |
163,382 | <p>I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please?</p>
<pre><code>public class Test {
public static void main(String args[]... | [
{
"answer_id": 163406,
"author": "Ken",
"author_id": 20621,
"author_profile": "https://Stackoverflow.com/users/20621",
"pm_score": 1,
"selected": false,
"text": "<p>Remove the conditional and the error is a little nicer...</p>\n\n<pre><code>public class Test {\n public static void mai... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6414/"
] | I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please?
```
public class Test {
public static void main(String args[]) {
Te... | The reason is that Test.class is of the type Class<Test>. You cannot assign a reference of type Class<Test> to a variable of type Class<T> as they are not the same thing. This, however, works:
```
Class<? extends Test> testType = type == null ? Test.class : type;
```
The wildcard allows both Class<T> and Class<Test>... |
163,389 | <p>I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why we don't want to execute them. I'm using Oracle's dbms_sql.parse to do this.</p>
<p>However,... | [
{
"answer_id": 163483,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>You should be able to prepare a SQL query to validate the syntax and get result set metadata. Preparing a query sho... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6479/"
] | I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why we don't want to execute them. I'm using Oracle's dbms\_sql.parse to do this.
However, I now ha... | You should be able to prepare a SQL query to validate the syntax and get result set metadata. Preparing a query should not execute it.
```
import java.sql.*;
. . .
Connection conn;
. . .
PreparedStatement ps = conn.prepareStatement("SELECT * FROM foo");
ResultSetMetadata rsmd = ps.getMetaData();
int numberOfColumns = ... |
163,407 | <p>Is there a way to use Enum values inside a JSP without using scriptlets.</p>
<p>e.g. </p>
<pre><code>package com.example;
public enum Direction {
ASC,
DESC
}
</code></pre>
<p>so in the JSP I want to do something like this</p>
<pre><code><c:if test="${foo.direction ==<% com.example.Direction.ASC %&... | [
{
"answer_id": 163431,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": 6,
"selected": true,
"text": "<p>You could implement the web-friendly text for a direction within the enum as a field:</p>\n\n<pre>\n<code>\n<%@ page i... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3332/"
] | Is there a way to use Enum values inside a JSP without using scriptlets.
e.g.
```
package com.example;
public enum Direction {
ASC,
DESC
}
```
so in the JSP I want to do something like this
```
<c:if test="${foo.direction ==<% com.example.Direction.ASC %>}">...
``` | You could implement the web-friendly text for a direction within the enum as a field:
```
<%@ page import="com.example.Direction" %>
...
<p>Direction is <%=foo.direction.getFriendlyName()%></p>
<% if (foo.direction == Direction.ASC) { %>
<p>That means you're going to heaven!</p>
<% } %>
```
but that mixes the view ... |
163,432 | <p>I am using Borland Builder C++. I have a memory leak and I know it must be because of this class I created, but I am not sure how to fix it. Please look at my code-- any ideas would be greatly appreciated!</p>
<p>Here's the .h file:</p>
<pre><code>#ifndef HeaderH
#define HeaderH
#include <vcl.h>
#include <... | [
{
"answer_id": 163438,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 2,
"selected": false,
"text": "<p>Your memory leak is in <code>main</code>; you are making a pointer with <code>new</code>, but not subsequently calling <... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23970/"
] | I am using Borland Builder C++. I have a memory leak and I know it must be because of this class I created, but I am not sure how to fix it. Please look at my code-- any ideas would be greatly appreciated!
Here's the .h file:
```
#ifndef HeaderH
#define HeaderH
#include <vcl.h>
#include <string>
using std::string;
cl... | I'm afraid there are a number of issues here.
For starters `char ImageCordsRep[1];` doesn't work ... a string is always null terminated, so when you do `strcpy(ImageCordsRep,"G");` you are overflowing the buffer.
It would also be good practice to terminate all those string buffers with a null in your constructor, so ... |
163,484 | <p>Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely.</p>
<p>Is there s a reg... | [
{
"answer_id": 163561,
"author": "Andrew Stein",
"author_id": 13029,
"author_profile": "https://Stackoverflow.com/users/13029",
"pm_score": 2,
"selected": true,
"text": "<p>From MSDN about the ASSERT macro:</p>\n\n<p>In an MFC ISAPI application, an assertion in debug mode will bring up a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5355/"
] | Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely.
Is there s a registry key ... | From MSDN about the ASSERT macro:
In an MFC ISAPI application, an assertion in debug mode will bring up a modal dialog box (ASSERT dialog boxes are now modal by default); this will interrupt or hang the execution. To suppress modal assertion dialogs, add the following lines to your project source file (projectname.cpp... |
163,507 | <p>Definition of variables in use:</p>
<pre><code>Guid fldProId = (Guid)ffdPro.GetProperty("FieldId");
string fldProValue = (string)ffdPro.GetProperty("FieldValue");
FormFieldDef fmProFldDef = new FormFieldDef();
fmProFldDef.Key = fldProId;
fmProFldDef.Retrieve();
string fldProName = (string)fmProFldDef.GetProperty("F... | [
{
"answer_id": 163519,
"author": "Danimal",
"author_id": 2757,
"author_profile": "https://Stackoverflow.com/users/2757",
"pm_score": 0,
"selected": false,
"text": "<p>Looks like fmProFldDef's FieldName property is screwy. Did you verify that it's getting the hTxtBox's client Id?</p>\n"
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24565/"
] | Definition of variables in use:
```
Guid fldProId = (Guid)ffdPro.GetProperty("FieldId");
string fldProValue = (string)ffdPro.GetProperty("FieldValue");
FormFieldDef fmProFldDef = new FormFieldDef();
fmProFldDef.Key = fldProId;
fmProFldDef.Retrieve();
string fldProName = (string)fmProFldDef.GetProperty("FieldName");
st... | Are you sure that findControl is returning a value?
Is hTxtBox.Text a property that does any computation on a set that could be throwing the NullReferenceException? |
163,531 | <p>I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?</p>
| [
{
"answer_id": 163706,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 0,
"selected": false,
"text": "<ul>\n<li><p>First find the correct .NET version folder. Use DirectorySearch/FileSearch to perform search.</p></li>\n<li><p>Us... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1865/"
] | I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX? | We use this:
First determine the .Net framework root directory from the registry:
```
<Property Id="FRAMEWORKROOT">
<RegistrySearch Id="FrameworkRootDir" Root="HKLM"
Key="SOFTWARE\Microsoft\.NETFramework"
Type="directory" Name="InstallRoot" />
</Property>
```
Then, inside the comp... |
163,535 | <p>In implementing my first significant script using jquery I needed to find a specific web-control on the page. Since I work with DotNetNuke, there is no guaranteeing the controls ClientID since the container control may change from site to site. I ended up using an attribute selector that looks for an ID that ends ... | [
{
"answer_id": 163559,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": false,
"text": "<p>Use a marker class on the control, and select that via jQuery.</p>\n"
},
{
"answer_id": 163566,
"author": "to... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4820/"
] | In implementing my first significant script using jquery I needed to find a specific web-control on the page. Since I work with DotNetNuke, there is no guaranteeing the controls ClientID since the container control may change from site to site. I ended up using an attribute selector that looks for an ID that ends with ... | ```
$("#<%= cboPanes.ClientID %>")
```
This will dynamically inject the DOM ID of the control. Of course, this means your JS has to be in an ASPX file, not in an external JS file. |
163,537 | <p>I'm trying to debug an MSBuild task, and I know there is some way to write to the MSBuild log from within a custom task but I forget how.</p>
| [
{
"answer_id": 163558,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": true,
"text": "<p>The base <a href=\"http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx\" rel=\"noreferrer\">... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | I'm trying to debug an MSBuild task, and I know there is some way to write to the MSBuild log from within a custom task but I forget how. | The base [Task](http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx) class has a `Log` property you can use:
```
Log.LogMessage("My message");
``` |
163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | [
{
"answer_id": 163556,
"author": "Daryl Spitzer",
"author_id": 4766,
"author_profile": "https://Stackoverflow.com/users/4766",
"pm_score": 6,
"selected": false,
"text": "<p>I figured out this workaround:</p>\n\n<pre><code>>>> p = subprocess.Popen(['grep','f'],stdout=subprocess.P... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | If I do the following:
```
import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
```
I get:
```
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/build/toolchain/mac32/pyth... | [`Popen.communicate()`](https://docs.python.org/3/library/subprocess.html?highlight=subprocess#subprocess.Popen.communicate) documentation:
>
> Note that if you want to send data to
> the process’s stdin, you need to
> create the Popen object with
> stdin=PIPE. Similarly, to get anything
> other than None in the resu... |
163,550 | <p>Is there a maximum number of characters that can be written to a file using a StreamWriter? Or is there a maximum number of characters that <code>WriteLine()</code> can output? I am trying to write some data to a file but all of the data does not seem to make it. This is the current state of my code:</p>
<pre><code... | [
{
"answer_id": 163585,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 6,
"selected": true,
"text": "<p>Are you calling StreamWriter.Close() or Flush()?</p>\n"
},
{
"answer_id": 163594,
"author": "user7116",
"a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2486/"
] | Is there a maximum number of characters that can be written to a file using a StreamWriter? Or is there a maximum number of characters that `WriteLine()` can output? I am trying to write some data to a file but all of the data does not seem to make it. This is the current state of my code:
```
StreamWriter sw = new St... | Are you calling StreamWriter.Close() or Flush()? |
163,563 | <p>I have an issue - </p>
<p>The javascript <code>Date("mm-dd-yyyy")</code> constructor doesn't work for FF. It works fine for IE.</p>
<ul>
<li>IE : <code>new Date("04-02-2008")</code> => <code>"Wed Apr 2 00:00:00 EDT 2008"</code></li>
<li>FF2 : <code>new Date("04-02-2008")</code> => <code>Invalid Date</code> </l... | [
{
"answer_id": 163584,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 7,
"selected": true,
"text": "<p>It is the <a href=\"http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date\" rel=\"noreferrer\">... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7617/"
] | I have an issue -
The javascript `Date("mm-dd-yyyy")` constructor doesn't work for FF. It works fine for IE.
* IE : `new Date("04-02-2008")` => `"Wed Apr 2 00:00:00 EDT 2008"`
* FF2 : `new Date("04-02-2008")` => `Invalid Date`
So lets try another constructor. Trying this constructor `Date("yyyy", "mm", "dd")`
* IE... | It is the [definition of the Date object](http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date) to use values 0-11 for the `month` field.
I believe that the constructor using a String is system-dependent (not to mention locale/timezone dependent) so you are probably better off using the co... |
163,569 | <p>I have a Flex application that calls a function which searches a large document collection. Depending on the search term, the user may want to stop the request from flex. </p>
<p>I’d like to not only stop the flex application from expecting the request, but also stop the CFC request. Is this possible? What’s the be... | [
{
"answer_id": 163790,
"author": "Peter Boughton",
"author_id": 9360,
"author_profile": "https://Stackoverflow.com/users/9360",
"pm_score": 0,
"selected": false,
"text": "<p>You can programmatically end requests with either <code><cfabort/></code> or <code><cfsetting requesttime... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24563/"
] | I have a Flex application that calls a function which searches a large document collection. Depending on the search term, the user may want to stop the request from flex.
I’d like to not only stop the flex application from expecting the request, but also stop the CFC request. Is this possible? What’s the best approac... | To add onto Ben Doom's answer, I'm including some example code of a way this can be accomplished. There are multiple approaches and ways of names, organizing and calling the code below, but hopefully it is helpful.
At some point during request start, store information about the process in shared scope and return an ID... |
163,591 | <p>In the GNOME Terminal, Bash does smart auto-completion. For example</p>
<pre><code>apt-get in<TAB>
</code></pre>
<p>becomes</p>
<pre><code>apt-get install
</code></pre>
<p>In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source <code>/etc/bash_completion</code>. The above exa... | [
{
"answer_id": 163754,
"author": "matli",
"author_id": 23896,
"author_profile": "https://Stackoverflow.com/users/23896",
"pm_score": 4,
"selected": false,
"text": "<p>I don't know the answer to this. But the reason that it doesn't work as you expect is probably because the completion in ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | In the GNOME Terminal, Bash does smart auto-completion. For example
```
apt-get in<TAB>
```
becomes
```
apt-get install
```
In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source `/etc/bash_completion`. The above example sticks as `in` or auto-completes with a filename in the curre... | I know this question is three years old, but it's something that I've also been interested in solving. A Web search directed me to a piece of elisp that makes Emacs use bash for completion in shell mode. It works for me, in any case.
Check it out at <https://github.com/szermatt/emacs-bash-completion> . |
163,604 | <p>I'm trying to select a random 10% sampling from a small table. I thought I'd just use the RAND() function and select those rows where the random number is less than 0.10:</p>
<pre><code>SELECT * FROM SomeTable
WHERE SomeColumn='SomeCondition' AND
RAND() < 0.10
</code></pre>
<p>But I soon discovered that ... | [
{
"answer_id": 163615,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p>If your table has a column (perhaps even the <strong>rowid</strong> column) that is numeric in the general sense, like integ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5987/"
] | I'm trying to select a random 10% sampling from a small table. I thought I'd just use the RAND() function and select those rows where the random number is less than 0.10:
```
SELECT * FROM SomeTable
WHERE SomeColumn='SomeCondition' AND
RAND() < 0.10
```
But I soon discovered that RAND() always returns the same... | This type of approach (shown by ΤΖΩΤΖΙΟΥ) will not guarantee a 10% sampling. It will only give you all rows where Rand() is evaluated to < .10 which will not be consistent.
Something like
```
select top 10 percent * from MyTable order by NEWID()
```
will do the trick.
**edit:** there is not really a good way to m... |
163,628 | <p>When placing email addresses on a webpage do you place them as text like this:</p>
<pre><code>joe.somebody@company.com
</code></pre>
<p>or use a clever trick to try and fool the email address harvester bots? For example:</p>
<p><strong>HTML Escape Characters:</strong></p>
<pre><code>&#106;&#111;&#101... | [
{
"answer_id": 163641,
"author": "tloach",
"author_id": 14092,
"author_profile": "https://Stackoverflow.com/users/14092",
"pm_score": 7,
"selected": true,
"text": "<p>I generally don't bother. I used to be on a mailing list that got several thousand spams every day. Our spam filter (sp... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | When placing email addresses on a webpage do you place them as text like this:
```
joe.somebody@company.com
```
or use a clever trick to try and fool the email address harvester bots? For example:
**HTML Escape Characters:**
```
joe.somebody@co... | I generally don't bother. I used to be on a mailing list that got several thousand spams every day. Our spam filter (spamassassin) let maybe 1 or 2 a day through. With filters this good, why make it difficult for legitimate people to contact you? |
163,662 | <p>Alright, I'm trying to read a comma delimited file and then put that into a ListView (or any grid, really). I have the delimiting part of the job taken care of, with the fields of the file being put into a multidimensional string array. The problem is trying to get it into the ListView.</p>
<p>It appears that the... | [
{
"answer_id": 163689,
"author": "Jeffrey L Whitledge",
"author_id": 10174,
"author_profile": "https://Stackoverflow.com/users/10174",
"pm_score": 2,
"selected": true,
"text": "<p>Just loop through each of the arrays in that you've created and create a new ListViewItem object (there is a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23875/"
] | Alright, I'm trying to read a comma delimited file and then put that into a ListView (or any grid, really). I have the delimiting part of the job taken care of, with the fields of the file being put into a multidimensional string array. The problem is trying to get it into the ListView.
It appears that there isn't a r... | Just loop through each of the arrays in that you've created and create a new ListViewItem object (there is a constructor that takes an array of strings, I believe). The pass the ListViewItem to the ListView.Items.Add() method. |
163,747 | <p>I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to <code>jni.h</code>. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and <code>g++</code> is available.</p>
<... | [
{
"answer_id": 164030,
"author": "Braden",
"author_id": 18144,
"author_profile": "https://Stackoverflow.com/users/18144",
"pm_score": 4,
"selected": true,
"text": "<p>Checking for headers is easy; just use <code>AC_CHECK_HEADER</code>. If it's in a weird place (i.e., one the compiler doe... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to `jni.h`. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and `g++` is available.
Alternatively, is there a way ... | Checking for headers is easy; just use `AC_CHECK_HEADER`. If it's in a weird place (i.e., one the compiler doesn't know about), it's entirely reasonable to expect users to set `CPPFLAGS`.
The hard part is actually locating `libjvm`. You typically don't want to link with this; but you may want to default to a location ... |
163,757 | <p>I am using boost::signal in a native C++ class, and I now I am writing a .NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as .NET events. When I try to use boost::bind to take the address of a member function of my managed class, I get compiler error 3374, saying I cannot take the address of a ... | [
{
"answer_id": 165362,
"author": "Brian Stewart",
"author_id": 3114,
"author_profile": "https://Stackoverflow.com/users/3114",
"pm_score": 2,
"selected": false,
"text": "<p>After googling some more, I finally found a <a href=\"http://mr-sharpoblunto.junkship.org/2007/11/mapping-boostsign... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] | I am using boost::signal in a native C++ class, and I now I am writing a .NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as .NET events. When I try to use boost::bind to take the address of a member function of my managed class, I get compiler error 3374, saying I cannot take the address of a mem... | While your answer works, it exposes some of your implementation to the world (Managed::OnSomeEvent). If you don't want people to be able to raise the OnChange event willy-nilly by invoking OnSomeEvent(), you can update your Managed class as follows (based on [this advice](http://msdn.microsoft.com/en-us/library/367eeye... |
163,760 | <p>I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help?</p>
<pre><code>at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 heig... | [
{
"answer_id": 163816,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 0,
"selected": false,
"text": "<p>Can you elaborate what you are trying to do here?\nIf you are trying to show a Form from a different thread than the UI thr... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4770/"
] | I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help?
```
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at System.... | The user has to be able to see multiple open accounts simultaneously, right? So you need multiple instances of a form?
Unless I'm misreading something, I don't think you need threads for this scenario, and I think you are just introducing yourself to a world of hurt (like these exceptions) as a result.
Assuming your ... |
163,761 | <p>I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this:</p>
<pre><code><object id="myPlayer" data="" type="audio/mpeg" pluginspage="http://www.apple.com/quicktime/download" width="0" height="0">
<param name="autoP... | [
{
"answer_id": 429916,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know the QuickTime API, but this might be worth a shot:</p>\n\n<pre><code>player.attributes.getNamedItem('data').va... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] | I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this:
```
<object id="myPlayer" data="" type="audio/mpeg" pluginspage="http://www.apple.com/quicktime/download" width="0" height="0">
<param name="autoPlay" value="false" />
... | Try giving the object element some width and height (1px by 1px) and make it visible within the viewport when you attempt to communicate with the plugin via JavaScript.
I've noticed that if the plugin area is not visible on screen it's unresponsive to JS commands.
This might explain why this isn't working for you in ... |
163,796 | <p>I have a lot of XML files and I'd like to generate a report from them. The report should provide information such as:</p>
<pre><code>root 100%
a*1 90%
b*1 80%
c*5 40%
</code></pre>
<p>meaning that all documents have a root element, 90% have one <strong>a</strong> element in the root, 80% have one <strong>b</st... | [
{
"answer_id": 164830,
"author": "JeniT",
"author_id": 6739,
"author_profile": "https://Stackoverflow.com/users/6739",
"pm_score": 4,
"selected": false,
"text": "<p>Here's an XSLT 2.0 method.</p>\n\n<p>Assuming that <code>$docs</code> contains a sequence of document nodes that you want t... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | I have a lot of XML files and I'd like to generate a report from them. The report should provide information such as:
```
root 100%
a*1 90%
b*1 80%
c*5 40%
```
meaning that all documents have a root element, 90% have one **a** element in the root, 80% have one **b** element in the root, 40% have 5 **c** elements... | Here's an XSLT 2.0 method.
Assuming that `$docs` contains a sequence of document nodes that you want to scan, you want to create one line for each element that appears in the documents. You can use `<xsl:for-each-group>` to do that:
```
<xsl:for-each-group select="$docs//*" group-by="name()">
<xsl:sort select="curr... |
163,803 | <p>I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the config file specified on the command line?</p>
<p>Edit:</p>
<p>It turns out that the... | [
{
"answer_id": 163815,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>A batch file that copies your desired configuration file to appname.exe.config and then runs the appname.exe.</p>\n"
},
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6819/"
] | I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the config file specified on the command line?
Edit:
It turns out that the correct way to lo... | So here is the code that actually allows me to actually access the appSettings section in a config file other than the default one.
```
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
configFile.ExeConfigFilename = Path.Combine(Environment.CurrentDirectory, "Alternate.config");
Configuration config... |
163,809 | <p>I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it.</p>
<p>Here's a quick example to make it clearer... this is what I have now:</p>
... | [
{
"answer_id": 163825,
"author": "changelog",
"author_id": 5646,
"author_profile": "https://Stackoverflow.com/users/5646",
"pm_score": 6,
"selected": true,
"text": "<p>Here is some code based on original code from <a href=\"https://www.strangerstudios.com/sandbox/pagination/diggstyle.php... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14981/"
] | I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it.
Here's a quick example to make it clearer... this is what I have now:
```
Pages: 1 ... | Here is some code based on original code from [this very old link](https://www.strangerstudios.com/sandbox/pagination/diggstyle.php). It uses markup compatible with Bootstrap's pagination component, and outputs page links like this:
```none
[1] 2 3 4 5 6 ... 100
1 [2] 3 4 5 6 ... 100
...
1 2 ... 14 15 [16] 17 18 ... 1... |
163,823 | <p>I have a <code>Person</code> model that has a foreign key relationship to <code>Book</code>, which has a number of fields, but I'm most concerned about <code>author</code> (a standard CharField).</p>
<p>With that being said, in my <code>PersonAdmin</code> model, I'd like to display <code>book.author</code> using <c... | [
{
"answer_id": 163968,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 5,
"selected": false,
"text": "<p>According to the documentation, you can only display the <code>__unicode__</code> representation of a ForeignKey:<... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I have a `Person` model that has a foreign key relationship to `Book`, which has a number of fields, but I'm most concerned about `author` (a standard CharField).
With that being said, in my `PersonAdmin` model, I'd like to display `book.author` using `list_display`:
```
class PersonAdmin(admin.ModelAdmin):
list_... | As another option, you can do look ups like:
```
class UserAdmin(admin.ModelAdmin):
list_display = (..., 'get_author')
def get_author(self, obj):
return obj.book.author
get_author.short_description = 'Author'
get_author.admin_order_field = 'book__author'
```
Since Django 3.2 you can use [`di... |
163,834 | <p>What's the most elegant templating (preferably in pure PHP!) solution you've seen?</p>
<p>Specifically i'm interested in handling:</p>
<ol>
<li>Detecting in a repeating block whether it's the first or last element</li>
<li>Easy handling of odd/even cases, like a zebra striped table, or similar</li>
<li>Other modul... | [
{
"answer_id": 163849,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 0,
"selected": false,
"text": "<p>I use Modulo like you did in your example all the time.</p>\n"
},
{
"answer_id": 163860,
"author... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20538/"
] | What's the most elegant templating (preferably in pure PHP!) solution you've seen?
Specifically i'm interested in handling:
1. Detecting in a repeating block whether it's the first or last element
2. Easy handling of odd/even cases, like a zebra striped table, or similar
3. Other modulos logic, where you'd do somethi... | You don't need to open the tags more than once. You can also make a function out of it if you do the same thing multiple times:
```
<?php
function makeul($items, $classes) {
$c = count($classes);
$out = "";
if (isset($items) && count($items) > 0) {
$out = "<ul>\n";
foreach ($items as $item) {
$out... |
163,887 | <p>Suppose I have a "tags" table with two columns: <strong>tagid</strong> and <strong>contentid</strong>. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 334, 338, and 342.</p>
<p>The "easy" way to do this ... | [
{
"answer_id": 163902,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 1,
"selected": false,
"text": "<p>The only alternative way i can think of is:</p>\n\n<pre><code>select a.contentid from tags a\ninner join tags b on a.... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16034/"
] | Suppose I have a "tags" table with two columns: **tagid** and **contentid**. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 334, 338, and 342.
The "easy" way to do this would be (*pseudocode*):
```
select c... | ```
SELECT contentID
FROM tags
WHERE tagID in (334, 338, 342)
GROUP BY contentID
HAVING COUNT(DISTINCT tagID) = 3
--In general
SELECT contentID
FROM tags
WHERE tagID in (...) --taglist
GROUP BY contentID
HAVING COUNT(DISTINCT tagID) = ... --tagcount
``` |
163,898 | <p>I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a single SDP file so that the viewing client could automatically re... | [
{
"answer_id": 171821,
"author": "Stu Thompson",
"author_id": 2961,
"author_profile": "https://Stackoverflow.com/users/2961",
"pm_score": 2,
"selected": false,
"text": "<p>I've gone over the RFC (<a href=\"http://www.faqs.org/rfcs/rfc2327.html\" rel=\"nofollow noreferrer\">RFC2327 - SDP:... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5065/"
] | I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a single SDP file so that the viewing client could automatically resiz... | The parameters in your two sdp examples are very close - the stream name and the sprop-parameter-sets differ. I assume you don't care about the stream name. If you need separate sprop-parameter-sets and the clients support the standard well you can use separate dynamic payload types for each resolution and have a singl... |
163,900 | <p>I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it.</p>
<p>Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party.</p>
<p>The problem is, FF3 and IE don't allow the ajax call, I g... | [
{
"answer_id": 163950,
"author": "Greg",
"author_id": 13009,
"author_profile": "https://Stackoverflow.com/users/13009",
"pm_score": -1,
"selected": false,
"text": "<p>If you have Python installed, a webserver to serve files can be as simple as </p>\n\n<pre><code>python -c “import SimpleH... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it.
Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party.
The problem is, FF3 and IE don't allow the ajax call, I get:
```
Access t... | In a similar situation, my solution was to use Mark Of The Web, which is a special HTML comment that IE recognizes. It places the page in a different security zone.
Reference: [MSDN](http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx) |
163,994 | <p>I have a very large table (8gb) with information about files, and i need to run a report against it that would would look something like this:</p>
<pre><code>(select * from fs_walk_scan where file_path like '\\\\server1\\groot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file... | [
{
"answer_id": 164007,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 2,
"selected": false,
"text": "<p>What kind of indexes do you have on that table? This index:</p>\n\n<p>CREATE INDEX fs_search_idx ON fs_walk_scan(f... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17785/"
] | I have a very large table (8gb) with information about files, and i need to run a report against it that would would look something like this:
```
(select * from fs_walk_scan where file_path like '\\\\server1\\groot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\... | What kind of indexes do you have on that table? This index:
CREATE INDEX fs\_search\_idx ON fs\_walk\_scan(file\_path, file\_size desc)
would speed this query up significantly... if you don't already have one like it.
Update:
You said there are already indexes on file\_path and file\_size... are they individual ind... |
163,998 | <p>Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for something like:</p>
<pre><code>ArrayList<Integer> setA ...
A... | [
{
"answer_id": 164033,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 3,
"selected": false,
"text": "<p>Are you looking for <a href=\"http://java.sun.com/javase/6/docs/api/java/util/Set.html\" rel=\"nofollow noreferrer\" tit... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19147/"
] | Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for something like:
```
ArrayList<Integer> setA ...
ArrayList<Integer> se... | Intersection is done with `Collection.retainAll`; subtraction with `Collection.removeAll`; union with `Collection.addAll`. In each case, as `Set` will act like a set and a `List` will act like a list.
As mutable objects, they operate in place. You'll need to explicitly copy if you want to retain the original mutable o... |
164,002 | <p>I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file.</p>
<p>The loop runs once and then ends because the EOF is reached (no errors). At t... | [
{
"answer_id": 164012,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 7,
"selected": true,
"text": "<p>perhaps it's a binary mode issue. Try opening the file with <code>\"r+b\"</code> as the mode.</p>\n\n<p><strong>EDIT<... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17871/"
] | I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file.
The loop runs once and then ends because the EOF is reached (no errors). At the end, by... | perhaps it's a binary mode issue. Try opening the file with `"r+b"` as the mode.
**EDIT**: as noted in a comment `"rb"` is likely a better match to your original intent since `"r+b"` will open it for read/write and `"rb"` is read-only. |
164,085 | <p>I need to execute a callback when an IFRAME has finished loading. I have no control over the content in the IFRAME, so I can't fire the callback from there.</p>
<p>This IFRAME is programmaticly created, and I need to pass its data as a variable in the callback, as well as destroy the iframe.</p>
<p>Any ideas?</p>
... | [
{
"answer_id": 164151,
"author": "roryf",
"author_id": 270,
"author_profile": "https://Stackoverflow.com/users/270",
"pm_score": 0,
"selected": false,
"text": "<p>I've had exactly the same problem in the past and the only way I found to fix it was to add the callback into the iframe page... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I need to execute a callback when an IFRAME has finished loading. I have no control over the content in the IFRAME, so I can't fire the callback from there.
This IFRAME is programmaticly created, and I need to pass its data as a variable in the callback, as well as destroy the iframe.
Any ideas?
**EDIT:**
Here is w... | First up, going by the function name *xssRequest* it sounds like you're trying cross site request - which if that's right, you're not going to be able to read the contents of the iframe.
On the other hand, if the iframe's URL is on your domain you can access the body, but I've found that if I use a timeout to remove t... |
164,093 | <p>in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes).</p>
<p>Theres a good way to make the serialization and de-serialization? </p>
| [
{
"answer_id": 164115,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "<p>If you create a char pointer that points to the beginning of the long array, when you increment through the char \"array\"... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18403/"
] | in a C program I have an long\* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes).
Theres a good way to make the serialization and de-serialization? | ```
long * longs;
// ...
int numChars = numLongs * sizeof(long);
char* longsAsChars = (char*) longs;
char* chars = malloc(numChars);
memcpy(chars, longsAsChars, numChars);
``` |
164,095 | <p>I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long.</p>
<p>It currently reads a recipe (see below) and prints ... | [
{
"answer_id": 164358,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "<p>Without looking into implementation details (or your github links), I'd try write a DSL like this:</p>\n\n<p>(stealing... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23909/"
] | I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long.
It currently reads a recipe (see below) and prints it back out.... | Without looking into implementation details (or your github links), I'd try write a DSL like this:
(stealing from here: <http://supercocktails.com/1310/Long-Island-Iced-Tea->)
```
describe "Long Island Iced Tea" do
serve_in 'Highball Glass'
ingredients do
half.ounce.of :vodka
half.ounce.of :tequila
h... |
164,102 | <p>For example, suppose I have a class:</p>
<pre><code>class Foo
{
public:
std::string& Name()
{
m_maybe_modified = true;
return m_name;
}
const std::string& Name() const
{
return m_name;
}
protected:
std::string m_name;
bool m_maybe_modified;
};
</code>... | [
{
"answer_id": 164130,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p>Two answers spring to mind:</p>\n<ol>\n<li><p>The non-const version is a closer match.</p>\n</li>\n<li><p>If it called the c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9876/"
] | For example, suppose I have a class:
```
class Foo
{
public:
std::string& Name()
{
m_maybe_modified = true;
return m_name;
}
const std::string& Name() const
{
return m_name;
}
protected:
std::string m_name;
bool m_maybe_modified;
};
```
And somewhere else in t... | Two answers spring to mind:
1. The non-const version is a closer match.
2. If it called the const overload for the non-const case, then under what circumstances would it *ever* call the non-const overload?
You can get it to use the other overload by casting `a` to a `const Foo *`.
**Edit:** From [C++ Annotations](ht... |
164,163 | <p>When implementing Quicksort, one of the things you have to do is to choose a pivot. But when I look at pseudocode like the one below, it is not clear how I should choose the pivot. First element of list? Something else?</p>
<pre><code> function quicksort(array)
var list less, greater
if length(array) ≤ 1 ... | [
{
"answer_id": 164177,
"author": "Kip",
"author_id": 18511,
"author_profile": "https://Stackoverflow.com/users/18511",
"pm_score": 8,
"selected": true,
"text": "<p>Choosing a random pivot minimizes the chance that you will encounter worst-case O(n<sup>2</sup>) performance (always choosin... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20032/"
] | When implementing Quicksort, one of the things you have to do is to choose a pivot. But when I look at pseudocode like the one below, it is not clear how I should choose the pivot. First element of list? Something else?
```
function quicksort(array)
var list less, greater
if length(array) ≤ 1
ret... | Choosing a random pivot minimizes the chance that you will encounter worst-case O(n2) performance (always choosing first or last would cause worst-case performance for nearly-sorted or nearly-reverse-sorted data). Choosing the middle element would also be acceptable in the majority of cases.
Also, if you are implement... |
164,167 | <p>Warning: this is the actual code generated from my system:</p>
<pre><code>;WITH RESULTS AS (
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, m.APPL_CD, m.ALBASE, 'CountFocusRecords' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
INNER JOIN MISProcess.SXProcessCatalog AS cat... | [
{
"answer_id": 164396,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 1,
"selected": false,
"text": "<p>Change to UNION ALL, since you'll never have dupes (the Measure column is hard coded to be different). UNION must f... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18255/"
] | Warning: this is the actual code generated from my system:
```
;WITH RESULTS AS (
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, m.APPL_CD, m.ALBASE, 'CountFocusRecords' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
INNER JOIN MISProcess.SXProcessCatalog AS cat WITH(NOLOCK)
... | Change to UNION ALL, since you'll never have dupes (the Measure column is hard coded to be different). UNION must first sort the rows, and then find dupes and eliminate.
My real guess is it's a parallelization issue. Try adding OPTION (MAXDOP 1) at the end. |
164,168 | <p>If I want to construct a std::string with a line like:</p>
<pre><code>std::string my_string("a\0b");
</code></pre>
<p>Where i want to have three characters in the resulting string (a, null, b), I only get one. What is the proper syntax?</p>
| [
{
"answer_id": 164185,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 4,
"selected": false,
"text": "<p>I have no idea <em>why</em> you'd want to do such a thing, but try this:</p>\n\n<pre><code>std::string my_string(\"a\\0b... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17958/"
] | If I want to construct a std::string with a line like:
```
std::string my_string("a\0b");
```
Where i want to have three characters in the resulting string (a, null, b), I only get one. What is the proper syntax? | ### Since C++14
we have been able to create [literal `std::string`](https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s)
```
#include <iostream>
#include <string>
int main()
{
using namespace std::string_literals;
std::string s = "pl-\0-op"s; // <- Notice the "s" at the end
... |
164,181 | <p>How can I fetch images from a server?</p>
<p>I've got this bit of code which allows me to draw some images on a canvas.</p>
<pre><code><html>
<head>
<script type="text/javascript">
function draw(){
var canvas = document.getElementById('canv');
var ctx = canvas.getConte... | [
{
"answer_id": 164191,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 6,
"selected": true,
"text": "<p>Use the built-in <a href=\"http://www.w3schools.com/htmldom/dom_obj_image.asp\" rel=\"noreferrer\">JavaScript Imag... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | How can I fetch images from a server?
I've got this bit of code which allows me to draw some images on a canvas.
```
<html>
<head>
<script type="text/javascript">
function draw(){
var canvas = document.getElementById('canv');
var ctx = canvas.getContext('2d');
for (i=0;i<document.... | Use the built-in [JavaScript Image object](http://www.w3schools.com/htmldom/dom_obj_image.asp).
Here is a very simple example of using the Image object:
```
myimage = new Image();
myimage.src = 'http://myserver/nextimage.cgi';
```
Here is a more appropriate mechanism for your scenario from the comments on this answ... |
164,194 | <p>The following code receives seg fault on line 2:</p>
<pre><code>char *str = "string";
str[0] = 'z'; // could be also written as *str = 'z'
printf("%s\n", str);
</code></pre>
<p>While this works perfectly well:</p>
<pre><code>char str[] = "string";
str[0] = 'z';
printf("%s\n", str);
</code></pre>
<p>Tested with ... | [
{
"answer_id": 164227,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<p>Because the type of <code>\"whatever\"</code> in the context of the 1st example is <code>const char *</code> (even if you a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24622/"
] | The following code receives seg fault on line 2:
```
char *str = "string";
str[0] = 'z'; // could be also written as *str = 'z'
printf("%s\n", str);
```
While this works perfectly well:
```
char str[] = "string";
str[0] = 'z';
printf("%s\n", str);
```
Tested with MSVC and GCC. | See the C FAQ, [Question 1.32](http://c-faq.com/decl/strlitinit.html)
>
> **Q**: What is the difference between these initializations?
>
> `char a[] = "string literal";`
>
> `char *p = "string literal";`
>
> My program crashes if I try to assign a new value to `p[i]`.
>
>
> **A**: A string literal (the fo... |
164,284 | <p>I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server.</p>
<p>Based on answers I've received I've tried the following code:</p>
<pre><code> static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 2... | [
{
"answer_id": 164299,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa384322(VS.85).aspx#Posting_data_to_the_\" rel=\"nofollow noreferre... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24628/"
] | I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server.
Based on answers I've received I've tried the following code:
```
static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 25";
static TCHAR frm... | Changing the form data and headers that I had above to the following solved the problem:
```
static TCHAR frmdata[] = "-----------------------------7d82751e2bc0858\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"file.txt\"\nContent-Type: text/plain\n\nfile contents here\n-------------------------... |
164,305 | <p>I'm using CodeSynthesis XSD C++/Tree Mapping utility to convert an existing xsd into c++ code we can populate the values in. This was we always make sure we follow the schema.</p>
<p>After doing the conversion, I'm trying to get it to work so I can test it. Problem is, I'm not used to doing this in c++ and it's m... | [
{
"answer_id": 164679,
"author": "Fry",
"author_id": 23553,
"author_profile": "https://Stackoverflow.com/users/23553",
"pm_score": 0,
"selected": false,
"text": "<p>Asked around the office, and it appears my problem wasn't creating the ABSTRACTNETWORKMODEL, but it was actually the ::xml_... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23553/"
] | I'm using CodeSynthesis XSD C++/Tree Mapping utility to convert an existing xsd into c++ code we can populate the values in. This was we always make sure we follow the schema.
After doing the conversion, I'm trying to get it to work so I can test it. Problem is, I'm not used to doing this in c++ and it's my first time... | I've been bitten by this before. If the line:
```
::xml_schema::time t();
```
is exactly as it appears in your code (that is, with the parens) then the problem is that you didn't actually instantiate an object like you think.
To instantiate an object you would use
```
::xml_schema::time t;
```
The first line, in... |
164,307 | <p>With the MacPorts version of ImageMagick 6.4.4 installed, I'm getting an error installing the RMagick gem.</p>
<pre><code>/opt/local/bin/ruby extconf.rb update rmagick
checking for Ruby version >= 1.8.2... yes
checking for /usr/bin/gcc-4.0... yes
checking for Magick-config... no
Can't install RMagick 2.7.0. Can'... | [
{
"answer_id": 164807,
"author": "Mike",
"author_id": 24316,
"author_profile": "https://Stackoverflow.com/users/24316",
"pm_score": 2,
"selected": false,
"text": "<p>The install script can't find Magick-config in your path. Did you use a non-standard install location when you installed ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11078/"
] | With the MacPorts version of ImageMagick 6.4.4 installed, I'm getting an error installing the RMagick gem.
```
/opt/local/bin/ruby extconf.rb update rmagick
checking for Ruby version >= 1.8.2... yes
checking for /usr/bin/gcc-4.0... yes
checking for Magick-config... no
Can't install RMagick 2.7.0. Can't find Magick-con... | I suggest using [Homebrew](https://brew.sh/) instead of Macports. After installing Homebrew, run:
```
brew install imagemagick
gem install rmagick
``` |
164,319 | <p>I learned something simple about SQL the other day:</p>
<pre><code>SELECT c FROM myTbl GROUP BY C
</code></pre>
<p>Has the same result as:</p>
<pre><code>SELECT DISTINCT C FROM myTbl
</code></pre>
<p>What I am curious of, is there anything different in the way an SQL engine processes the command, or are they tru... | [
{
"answer_id": 164323,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 3,
"selected": false,
"text": "<p>They have different semantics, even if they happen to have equivalent results on your particular data.</p>\n"
},
{
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5836/"
] | I learned something simple about SQL the other day:
```
SELECT c FROM myTbl GROUP BY C
```
Has the same result as:
```
SELECT DISTINCT C FROM myTbl
```
What I am curious of, is there anything different in the way an SQL engine processes the command, or are they truly the same thing?
I personally prefer the dist... | [MusiGenesis](https://stackoverflow.com/questions/164319/is-there-any-difference-between-group-by-and-distinct#164485)' response is functionally the correct one with regard to your question as stated; the SQL Server is smart enough to realize that if you are using "Group By" and not using any aggregate functions, then ... |
164,324 | <p>I need to get the Folder size and display the info on a report (SSRS). I need to do this for a number of Databases (loop!). These DB's are websites' backends.</p>
<p>Are any samples available for this? Does xp_filesize and the like the right solution?</p>
| [
{
"answer_id": 179648,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<p>Could you clarify who should do what in your scenario? Do you want SQL Server do get the info or do you want Reporting ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] | I need to get the Folder size and display the info on a report (SSRS). I need to do this for a number of Databases (loop!). These DB's are websites' backends.
Are any samples available for this? Does xp\_filesize and the like the right solution? | Looking at the question and Tomalak's response, and I'm assuming the reporting server will be able to reach the folders held in the DB:
Firstly set up the query to get you back the result-set of paths - I assume you'll have no trouble with this part. Next you'll need to add a custom code function to your report: <http... |
164,335 | <p>Any XPath like /NodeName/position() would give you the position of the Node w.r.t it's parent node.</p>
<p>There is no method on the XElement (Linq to XML) object that can get the position of the Element. Is there?</p>
| [
{
"answer_id": 164444,
"author": "Michael Damatov",
"author_id": 23372,
"author_profile": "https://Stackoverflow.com/users/23372",
"pm_score": 0,
"selected": false,
"text": "<pre><code>static int Position(this XNode node) {\n var position = 0;\n foreach(var n in node.Parent.Nodes()) {\... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] | Any XPath like /NodeName/position() would give you the position of the Node w.r.t it's parent node.
There is no method on the XElement (Linq to XML) object that can get the position of the Element. Is there? | Actually NodesBeforeSelf().Count doesn't work because it gets everything even of type XText
Question was about XElement object.
So I figured it's
```
int position = obj.ElementsBeforeSelf().Count();
```
that should be used,
Thanks to Bryant for the direction. |
164,342 | <p>I'm considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable. </p>
<p>Like this:</p>
<pre><code>public interface IRepository<T> : IQueryable<T>
{
T Save(T entity);
void Delete(T entity);
}
</code></pre>
<p>Or this:</p>
<pre><code>p... | [
{
"answer_id": 164380,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 5,
"selected": true,
"text": "<p>Depends on if you want a Has-A or an Is-A relationship.</p>\n\n<p>The first one is an Is-A relationship. The IRepository... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3759/"
] | I'm considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable.
Like this:
```
public interface IRepository<T> : IQueryable<T>
{
T Save(T entity);
void Delete(T entity);
}
```
Or this:
```
public interface IRepository<T>
{
T Save(T entity);
... | Depends on if you want a Has-A or an Is-A relationship.
The first one is an Is-A relationship. The IRepository interface is a IQueryable interface. The second is a has-a. The IRepository has an IQueryable interface. In the process of writing this, I actually like the second better then the first, simply because when u... |
164,344 | <p>How can I make my <code>std::fstream</code> object start reading a text file from the second line?</p>
| [
{
"answer_id": 164353,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 5,
"selected": false,
"text": "<p>Use getline() to read the first line, then begin reading the rest of the stream.</p>\n\n<pre><code>ifstream stream(\"file... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I make my `std::fstream` object start reading a text file from the second line? | Use getline() to read the first line, then begin reading the rest of the stream.
```
ifstream stream("filename.txt");
string dummyLine;
getline(stream, dummyLine);
// Begin reading your stream here
while (stream)
...
```
(Changed to std::getline (thanks dalle.myopenid.com)) |
164,356 | <p>For example, I'm writing a multi-threaded time-critical application that processes and streams audio in real-time. Interruptions in the audio are totally unacceptable. Does this mean I cannot use the STL because of the potential slow down when an exception is thrown? </p>
| [
{
"answer_id": 164377,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 5,
"selected": false,
"text": "<p>Generally, the only exceptions that STL containers will throw by themselves is an std::bad_alloc if new fails. The on... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13760/"
] | For example, I'm writing a multi-threaded time-critical application that processes and streams audio in real-time. Interruptions in the audio are totally unacceptable. Does this mean I cannot use the STL because of the potential slow down when an exception is thrown? | It's not clearly written in the previous answers, so:
Exceptions happen in C++
------------------------
Using the STL or not won't remove the RAII code that will free the objects's resources you allocated.
For example:
```
void doSomething()
{
MyString str ;
doSomethingElse() ;
}
```
In the code above, th... |
164,369 | <p>While I'm googling/reading for this answer I thought I would also ask here. </p>
<p>I have a class that is a wrapper for a SDK. The class accepts an ILoader object and uses the ILoader object to create an ISBAObject which is cast into an ISmallBusinessInstance object. I am simply trying to mock this behavior usin... | [
{
"answer_id": 164398,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>You need to use sbainst.Object, as sbinst isn't an instance of ISbaObjects - it's just the mock part.</p>\n"
},
{
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2916/"
] | While I'm googling/reading for this answer I thought I would also ask here.
I have a class that is a wrapper for a SDK. The class accepts an ILoader object and uses the ILoader object to create an ISBAObject which is cast into an ISmallBusinessInstance object. I am simply trying to mock this behavior using Moq.
```
... | You need to use sbainst.Object, as sbinst isn't an instance of ISbaObjects - it's just the mock part. |
164,395 | <p>I'm wondering if its possible to add new class data members at run-time in PHP?</p>
| [
{
"answer_id": 164416,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 2,
"selected": false,
"text": "<p>It is. You can add public members are run time with no additional code, and can affect protected/private members ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] | I'm wondering if its possible to add new class data members at run-time in PHP? | Yes.
```
$prop = 'newname';
$obj->$prop = 42;
```
will do the same thing as:
```
$obj->newname = 42;
```
Either one will add "newname" as a property in $obj if it does not yet exist. |
164,397 | <p>How can I print a message to the error console, preferably including a variable? </p>
<p>For example, something like:</p>
<pre><code>print('x=%d', x);
</code></pre>
| [
{
"answer_id": 164408,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 10,
"selected": true,
"text": "<p>Install <a href=\"http://en.wikipedia.org/wiki/Firebug_(software)\" rel=\"noreferrer\">Firebug</a> and then you can use <co... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | How can I print a message to the error console, preferably including a variable?
For example, something like:
```
print('x=%d', x);
``` | Install [Firebug](http://en.wikipedia.org/wiki/Firebug_(software)) and then you can use `console.log(...)` and `console.debug(...)`, etc. (see [the documentation](http://getfirebug.com/wiki/index.php/Console_Panel#Message_types) for more). |
164,400 | <p>I'm running SqlServer 2005 express edition on my laptop for development purposes. It seems that when I open a connection to the database, the setup time is REALLY slow. It can take up to 10 seconds to get a connection. I usually have multiple connections open at the same time (Profiler, Development environment, Quer... | [
{
"answer_id": 164445,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "<p>Are you sure the connection is the bottleneck? Is it your conn.Open() line that is taking 10 seconds? </p>\n"
},... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21155/"
] | I'm running SqlServer 2005 express edition on my laptop for development purposes. It seems that when I open a connection to the database, the setup time is REALLY slow. It can take up to 10 seconds to get a connection. I usually have multiple connections open at the same time (Profiler, Development environment, Query A... | I figured it out. The problem was I had multiple databases with AutoClose set to true. I shut it off in all my databases and the problem went away.
see [this article](http://www.sqlservercentral.com/articles/Administering/autoclosefordatabases/891/) for more info. |
164,414 | <p>I'm processing a file, line-by-line, and I'd like to do an inverse match. For instance, I want to match lines where there is a string of six letters, but only if these six letters are not '<em>Andrea</em>'. How should I do that?</p>
<p>I'm using <a href="https://en.wikipedia.org/wiki/RegexBuddy" rel="noreferrer">Re... | [
{
"answer_id": 164419,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 8,
"selected": true,
"text": "<pre><code>(?!Andrea).{6}\n</code></pre>\n<p>Assuming your regexp engine supports negative lookaheads...</p>\n<p>...or maybe yo... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21384/"
] | I'm processing a file, line-by-line, and I'd like to do an inverse match. For instance, I want to match lines where there is a string of six letters, but only if these six letters are not '*Andrea*'. How should I do that?
I'm using [RegexBuddy](https://en.wikipedia.org/wiki/RegexBuddy), but still having trouble. | ```
(?!Andrea).{6}
```
Assuming your regexp engine supports negative lookaheads...
...or maybe you'd prefer to use `[A-Za-z]{6}` in place of `.{6}`
Note that lookaheads and lookbehinds are generally not the right way to "inverse" a regular expression match. Regexps aren't really set up for doing negative matching; ... |