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 |
|---|---|---|---|---|---|---|
254,669 | <p>I've been working with some C# legacy code and I've been seeing a lot of @ symbols in front of variable names. What does this signify or do?</p>
<p>Currently I'm seeing it a lot in front of variables with common names that aren't reserved. E.g.:</p>
<pre><code>MyProcedure(@step.LoadInstanceId, @step.ResultCode, @s... | [
{
"answer_id": 254674,
"author": "ripper234",
"author_id": 11236,
"author_profile": "https://Stackoverflow.com/users/11236",
"pm_score": 9,
"selected": true,
"text": "<p>It's just a way to allow declaring reserved keywords as vars.</p>\n\n<pre><code>void Foo(int @string)\n</code></pre>\n... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7756/"
] | I've been working with some C# legacy code and I've been seeing a lot of @ symbols in front of variable names. What does this signify or do?
Currently I'm seeing it a lot in front of variables with common names that aren't reserved. E.g.:
```
MyProcedure(@step.LoadInstanceId, @step.ResultCode, @step.StatusCode);
```... | It's just a way to allow declaring reserved keywords as vars.
```
void Foo(int @string)
``` |
254,673 | <p>I have an abstract base class which acts as an interface.</p>
<p>I have two "sets" of derived classes, which implement half of the abstract class. ( one "set" defines the abstract virtual methods related to initialization, the other "set" defines those related to the actual "work". )</p>
<p>I then have derived cla... | [
{
"answer_id": 254696,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "<p>It can be done, although it gives most the shivers.</p>\n\n<p>You need to use \"virtual inheritance\", the syntax ... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29701/"
] | I have an abstract base class which acts as an interface.
I have two "sets" of derived classes, which implement half of the abstract class. ( one "set" defines the abstract virtual methods related to initialization, the other "set" defines those related to the actual "work". )
I then have derived classes which use mu... | It looks like you want to do virtual inheritance. Whether that turns out to actually be a good idea is another question, but here's how you do it:
```
class AbsBase {...};
class AbsInit: public virtual AbsBase {...};
class AbsWork: public virtual AbsBase {...};
class NotAbsTotal: public AbsInit, public AbsWork {...};... |
254,694 | <p>I see little functional difference between using a property</p>
<pre><code>public readonly property foo as string
get
return bar
end get
end property
</code></pre>
<p>or a function</p>
<pre><code>public function foo() as string
return bar
end function
</code></pre>
<p>Why would I want to use one form o... | [
{
"answer_id": 254700,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<p>It's purely a matter of appearance. Methods imply doing so action, while properties imply getting some data.</p>\... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736623/"
] | I see little functional difference between using a property
```
public readonly property foo as string
get
return bar
end get
end property
```
or a function
```
public function foo() as string
return bar
end function
```
Why would I want to use one form over the other?
Thanks! | I read an interesting article recently in Visual Studio Magazine that discussed the different between Methods and Properties.
Properties are supposed to return a value and the same value each time unless something else is called in between.
A Method on the other hand is typically expected to do something in the back... |
254,697 | <p>I'm running a PL/SQL block that is supposed to be calling a stored procedure who's output parameters are supposed to be populating variables in the PL/SQL block.</p>
<p>The procedure compiles, and the PL/SQL block runs successfully. But I'd like to check the values of the variables populated by the procedure. Is th... | [
{
"answer_id": 254727,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "<pre><code>dbms_output.put_line(varHere);\n</code></pre>\n"
},
{
"answer_id": 255169,
"author": "darreljn... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm running a PL/SQL block that is supposed to be calling a stored procedure who's output parameters are supposed to be populating variables in the PL/SQL block.
The procedure compiles, and the PL/SQL block runs successfully. But I'd like to check the values of the variables populated by the procedure. Is there a way ... | ```
dbms_output.put_line(varHere);
``` |
254,712 | <p>Can I somehow disable spell-checking on HTML textfields (as seen in e.g. Safari)?</p>
| [
{
"answer_id": 254716,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 10,
"selected": true,
"text": "<p><strong>Update</strong>: As suggested by a commenter (additional credit to <a href=\"https://stackoverflow.com/qu... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136/"
] | Can I somehow disable spell-checking on HTML textfields (as seen in e.g. Safari)? | **Update**: As suggested by a commenter (additional credit to [How can I disable the spell checker on text inputs on the iPhone](https://stackoverflow.com/questions/3416867/how-can-i-disable-the-spell-checker-on-text-inputs-on-the-iphone)), use this to handle all desktop and mobile browsers.
```
<tag autocomplete="off... |
254,726 | <p>I've been told that code such as:</p>
<pre><code>for (int i = 0; i < x.length(); i++) {
// blah
}
</code></pre>
<p>is actually O(n^2) because of the repeated calls to <code>x.length()</code>. Instead I should use:</p>
<pre><code>int l = x.length();
for (int i = 0; i < l; i++) {
// blah
}
</code></pr... | [
{
"answer_id": 254730,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 6,
"selected": false,
"text": "<p>No, the length of a java string is O(1) because java's string class stores the length as a field.</p>\n\n<p>The advice yo... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8913/"
] | I've been told that code such as:
```
for (int i = 0; i < x.length(); i++) {
// blah
}
```
is actually O(n^2) because of the repeated calls to `x.length()`. Instead I should use:
```
int l = x.length();
for (int i = 0; i < l; i++) {
// blah
}
```
Is this true? Is string length stored as a private integer ... | No, the length of a java string is O(1) because java's string class stores the length as a field.
The advice you've received is true of C, amongst other languages, but not java. C's strlen walks the char array looking for the end-of-string character. Joel's talked about it on the podcast, but in the context of C. |
254,732 | <p>Is it possible to determine whether my web site is being accessed as a trusted site? In <a href="https://stackoverflow.com/questions/251696/best-way-to-readset-ie-options">another question</a> we determined that, in general, it is not prudent to have visibility to client IE settings. Would this qualify as an excep... | [
{
"answer_id": 254817,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 0,
"selected": false,
"text": "<p>from my understanding this is not possible but you may have some luck testing for a more specific condition, suc... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26671/"
] | Is it possible to determine whether my web site is being accessed as a trusted site? In [another question](https://stackoverflow.com/questions/251696/best-way-to-readset-ie-options) we determined that, in general, it is not prudent to have visibility to client IE settings. Would this qualify as an exception?
The reaso... | Here's a test you could use:
```
function isTrustedIE(){
try{
var test=new ActiveXObject("Scripting.FileSystemObject");
}
catch(e){
return false;
}
return true;
}
```
This will, of course, fail if the user has disabled that particular object, even on a trusted site. |
254,737 | <p>In JSP I can reference a bean's property by using the tag
${object.property}</p>
<p>Is there some way to deal with properties that might not exist? I have a JSP page that needs to deal with different types. Example:</p>
<pre><code>public class Person {
public String getName()
}
public class Employee extends Pe... | [
{
"answer_id": 254769,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p>You could always have a type field.</p>\n\n<pre><code>public class Person {\n public String getType() { return \"Perso... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | In JSP I can reference a bean's property by using the tag
${object.property}
Is there some way to deal with properties that might not exist? I have a JSP page that needs to deal with different types. Example:
```
public class Person {
public String getName()
}
public class Employee extends Person {
public flo... | Just use the EL empty operator IF it was a scoped attribute, unfortunately you'll have to go with surrounding your expression using employee.salary with <c:catch>:
```
<c:catch var="err">
<c:out value="${employee.salary}"/>
</c:catch>
```
If you really need *instanceof*, you might consider a custom tag. |
254,765 | <p>How can I detect whether or not an input box is currently a jQuery UI autocomplete? There doesn't seem to be a native method for this, but I'm hoping there is something simple like this:</p>
<pre><code>if ($("#q").autocomplete)
{
//Do something
}
</code></pre>
<p>That conditional, however, seems to always retur... | [
{
"answer_id": 254786,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "<p>It's true because once you've included the autocomplete js, every $() object now has a autocomplete() method defin... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | How can I detect whether or not an input box is currently a jQuery UI autocomplete? There doesn't seem to be a native method for this, but I'm hoping there is something simple like this:
```
if ($("#q").autocomplete)
{
//Do something
}
```
That conditional, however, seems to always return true. | ```
if ($("#q").hasClass("ac_input")) {
// do something
}
```
**UPDATE**
The class name in the JQuery UI autocomplete widget is now 'ui-autocomplete-input' so that code would be:
```
if ($("#q").hasClass("ui-autocomplete-input")) {
// do something
}
``` |
254,784 | <p>I have two objects, let's call them <strong><code>Input</code></strong> and <strong><code>Output</code></strong></p>
<p><strong><code>Input</code></strong> has properties <em><code>Input_ID</code></em>, <em><code>Label</code></em>, and <em><code>Input_Amt</code></em><br>
<strong><code>Output</code></strong> has pro... | [
{
"answer_id": 254830,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>Which LINQ provider is this actually using? Are you actually talking to a database, or just working in-process? If yo... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1373/"
] | I have two objects, let's call them **`Input`** and **`Output`**
**`Input`** has properties *`Input_ID`*, *`Label`*, and *`Input_Amt`*
**`Output`** has properties *`Output_ID`* and *`Output_Amt`*
I want to perform the equivalent SQL statement in LINQ:
```
SELECT Label, Sum(Added_Amount) as Amount FROM
(SELECT... | Okay, now that I understand what's going on a bit better, the main problem is that you haven't got the equivalent of the ISNULL bit. Try this instead:
```
var InnerQuery = from i in input
join o in output
on i.Input_ID equals o.Output_ID into joined
from leftjoin in j... |
254,809 | <p>The following code fails at runtime…</p>
<pre>
Dim Id As Guid = CType(e.CommandArgument, Guid)
</pre>
<p>It throws this exception…</p>
<pre>
System.InvalidCastException was unhandled by user code
Specified cast is not valid
</pre>
<p>Why can't I cast <strong><em>e.CommandArgument</em></strong> as a... | [
{
"answer_id": 254826,
"author": "Jonathan S.",
"author_id": 2034,
"author_profile": "https://Stackoverflow.com/users/2034",
"pm_score": 3,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code>Dim DeleteId As Guid = New Guid(Convert.ToString(e.CommandArgument))\n</code></pre>\n\n<p>This ... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | The following code fails at runtime…
```
Dim Id As Guid = CType(e.CommandArgument, Guid)
```
It throws this exception…
```
System.InvalidCastException was unhandled by user code
Specified cast is not valid
```
Why can't I cast ***e.CommandArgument*** as a Guid? | Try:
```
Dim DeleteId As Guid = New Guid(Convert.ToString(e.CommandArgument))
```
This works...
```
Dim DeleteId As Guid = New Guid(DirectCast(e.CommandArgument, String))
``` |
254,811 | <p>My app crashes when I do the following in the applicationDidFinishLaunching event in the app delegate:</p>
<pre><code>_textures[mytex] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"a.png"]];
</code></pre>
<p>However when I replace <code>@"a.png"</code> with</p>
<pre><code>@"/Users/MyUserName/Desktop/M... | [
{
"answer_id": 254933,
"author": "carson",
"author_id": 25343,
"author_profile": "https://Stackoverflow.com/users/25343",
"pm_score": 1,
"selected": false,
"text": "<p>You need to make sure a.png is imported as a resource into xCode. If you have done that then referencing it as just \"a.... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | My app crashes when I do the following in the applicationDidFinishLaunching event in the app delegate:
```
_textures[mytex] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"a.png"]];
```
However when I replace `@"a.png"` with
```
@"/Users/MyUserName/Desktop/MyProjectFolder/a.png"
```
everything works fin... | `+[UIImage imageNamed:]` will look in your app bundle's resources to find the image. If you add an image to Xcode it will be default be added to the resource copy phase of your project. If you want to make sure it is being copied into your app bundle look at the list on the left side of your Xcode editor, under targets... |
254,821 | <p>I want to be able to load a serialized xml class to a Soap Envelope. I am starting so I am not filling the innards so it appears like:
<br /> </p>
<pre><code><Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/" />
</code></pre>
<p>I want it to appear like: <br/></p>
<pre><code><Envelope
x... | [
{
"answer_id": 254834,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": -1,
"selected": false,
"text": "<p>The two representations are equiavalent. Why do you need it to appear in the latter form?</p>\n"
},
{
"answer_id... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12924/"
] | I want to be able to load a serialized xml class to a Soap Envelope. I am starting so I am not filling the innards so it appears like:
```
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/" />
```
I want it to appear like:
```
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/" ></Envel... | The main issue here is that the `XmlSerializer` calls `WriteEndElement()` on the `XmlWriter` when it would write an end tag. This, however, generates the shorthand `<tag/>` form when there is no content. The `WriteFullEndElement()` writes the end tag separately.
You can inject your own `XmlTextWriter` into the middle ... |
254,823 | <p>I've got a form that's a few pages long. To traverse the form all I'm doing is showing and hiding container divs. The last page is a confirmation page before submitting. It takes the contents of the form and lays it out so the user can see what he/she just filled out. If they click on one of these it'll take them ba... | [
{
"answer_id": 254846,
"author": "Tim Howland",
"author_id": 4276,
"author_profile": "https://Stackoverflow.com/users/4276",
"pm_score": 2,
"selected": false,
"text": "<p>I'd start with an introduction to arrays: <a href=\"http://www.hunlock.com/blogs/Mastering_Javascript_Arrays\" rel=\"... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a form that's a few pages long. To traverse the form all I'm doing is showing and hiding container divs. The last page is a confirmation page before submitting. It takes the contents of the form and lays it out so the user can see what he/she just filled out. If they click on one of these it'll take them back ... | Without getting too complicated, you can make a function that handles the repetitive stuff. I haven't tested this, but you'll get the idea:
```
function valField(fieldName,navName) {
var output = '<a href="javascript://" onclick="$(\''+navName+'\').click();$(\'input#'+fieldName+'\').focus();" title="Click to edit"... |
254,844 | <p>I was reading an article on MSDN Magazine about using the <a href="http://msdn.microsoft.com/en-us/magazine/cc700332.aspx" rel="noreferrer">Enumerable class in LINQ</a> to generate a random array. The article uses VB.NET and I'm not immediately sure what the equivalent is in C#:</p>
<pre><code>Dim rnd As New System... | [
{
"answer_id": 254860,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<pre><code>Random rnd = new Random();\nIEnumerable<int> numbers = Enumerable.Range(1, 100).OrderBy(r => rnd.... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29762/"
] | I was reading an article on MSDN Magazine about using the [Enumerable class in LINQ](http://msdn.microsoft.com/en-us/magazine/cc700332.aspx) to generate a random array. The article uses VB.NET and I'm not immediately sure what the equivalent is in C#:
```
Dim rnd As New System.Random()
Dim numbers = Enumerable.Range(1... | The [Developer Fusion VB.Net to C# converter](http://www.developerfusion.com/tools/convert/vb-to-csharp/) says that the equivalent C# code is:
```
System.Random rnd = new System.Random();
IEnumerable<int> numbers = Enumerable.Range(1, 100).OrderBy(r => rnd.Next());
```
For future reference, they also have a [C# to V... |
254,849 | <p>I have an MSBuild project where within it I have a task that calls multiple projects where I set BuildInParallel = "true"</p>
<p>Example:</p>
<p></p>
<pre><code> <Message Text="MSBuild project list = @(ProjList)" />
<!-- Compile in parallel -->
<MSBuild Projects="@(ProjList)"
Targe... | [
{
"answer_id": 254860,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<pre><code>Random rnd = new Random();\nIEnumerable<int> numbers = Enumerable.Range(1, 100).OrderBy(r => rnd.... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] | I have an MSBuild project where within it I have a task that calls multiple projects where I set BuildInParallel = "true"
Example:
```
<Message Text="MSBuild project list = @(ProjList)" />
<!-- Compile in parallel -->
<MSBuild Projects="@(ProjList)"
Targets="Build"
Properties="Configurat... | The [Developer Fusion VB.Net to C# converter](http://www.developerfusion.com/tools/convert/vb-to-csharp/) says that the equivalent C# code is:
```
System.Random rnd = new System.Random();
IEnumerable<int> numbers = Enumerable.Range(1, 100).OrderBy(r => rnd.Next());
```
For future reference, they also have a [C# to V... |
254,859 | <p>I am creating an integration server for the first time, and although I have two projects in my cruisecontrol config file, only the first one seems to be executing. My config file is pasted below.</p>
<pre><code><cruisecontrol>
<project name="cc-config">
<triggers>
<int... | [
{
"answer_id": 254884,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 2,
"selected": false,
"text": "<ol>\n<li><p>Have you checked your CCNet build logs for any anomalies? (<em>Edit Answer: Yes, and there weren't any.</em... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26527/"
] | I am creating an integration server for the first time, and although I have two projects in my cruisecontrol config file, only the first one seems to be executing. My config file is pasted below.
```
<cruisecontrol>
<project name="cc-config">
<triggers>
<intervalTrigger seconds="60" />
... | 1. Have you checked your CCNet build logs for any anomalies? (*Edit Answer: Yes, and there weren't any.*)
2. Logging into the CCNet web server, does the second project show up as a valid project?
(*Edit Answer: No, it does not.*)
3. If so, can you do a force build on it? (*Edit Answer: No, because it doesn't show up.*)... |
254,864 | <p>So I know it's considered somewhat good practice to always include curly braces for if, for, etc even though they're optional if there is only one following statement, for the reason that it's easier to accidentally do something like:</p>
<pre><code>if(something == true)
DoSomething();
DoSomethingElse();
</... | [
{
"answer_id": 254866,
"author": "Nicholas Mancuso",
"author_id": 8945,
"author_profile": "https://Stackoverflow.com/users/8945",
"pm_score": 3,
"selected": false,
"text": "<p>Instead of:</p>\n\n<pre><code>if(something == true)\n{ DoSomething(); }\n</code></pre>\n\n<p>Do this:</p>\n\n<... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23822/"
] | So I know it's considered somewhat good practice to always include curly braces for if, for, etc even though they're optional if there is only one following statement, for the reason that it's easier to accidentally do something like:
```
if(something == true)
DoSomething();
DoSomethingElse();
```
when quick... | When I come across a one-line if statement, I usually skip the curlys and keep everything on the same line:
```
if (something == true) DoSomething();
```
It's quick, easy, and saves space. |
254,887 | <p>I am looking for a clear, complete example of programmatically deleting all documents from a specific document library, via the Sharepoint object model. The doclib does not contain folders. I am looking to delete the documents completely (ie I don't want them in the Recycle Bin).</p>
<p>I know of SPWeb.ProcessBat... | [
{
"answer_id": 254918,
"author": "Maxime Rouiller",
"author_id": 24975,
"author_profile": "https://Stackoverflow.com/users/24975",
"pm_score": 1,
"selected": false,
"text": "<p>You just have to go through all the files of your Document Library.</p>\n\n<pre><code>foreach(SPListItem item i... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5782/"
] | I am looking for a clear, complete example of programmatically deleting all documents from a specific document library, via the Sharepoint object model. The doclib does not contain folders. I am looking to delete the documents completely (ie I don't want them in the Recycle Bin).
I know of SPWeb.ProcessBatchData, but ... | I would persevere with the ProcessBatchData approach, maybe this will help:
>
> [Vincent Rothwell](http://blog.thekid.me.uk) has covered this
> best:
> <http://blog.thekid.me.uk/archive/2007/02/24/deleting-a-considerable-number-of-items-from-a-list-in-sharepoint.aspx>
>
>
>
Otherwise I'm not sure the other reco... |
254,895 | <p>How do I embed a tag within a <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url" rel="nofollow noreferrer" title="url templatetag">url templatetag</a> in a django template?</p>
<p>Django 1.0 , Python 2.5.2</p>
<p>In views.py</p>
<pre><code>def home_page_view(request):
NUP={"HOMEPAGE": ... | [
{
"answer_id": 254942,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 0,
"selected": false,
"text": "<p>That's seems way too dynamic. You're supposed to do</p>\n\n<pre><code>{% url named-url-pattern-string-for-my-home-page-... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11452/"
] | How do I embed a tag within a [url templatetag](http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url "url templatetag") in a django template?
Django 1.0 , Python 2.5.2
In views.py
```
def home_page_view(request):
NUP={"HOMEPAGE": "named-url-pattern-string-for-my-home-page-view"}
variables = R... | Maybe you could try passing the final URL to the template, instead?
Something like this:
```
from django.core.urlresolvers import reverse
def home_page_view(request):
NUP={"HOMEPAGE": reverse('named-url-pattern-string-for-my-home-page-view')}
variables = RequestContext(request, {'NUP':NUP})
return re... |
254,899 | <p>I am trying to get Silverlight to work with a quick sample application and am calling a rest service on a another computer. The server that has the rest service has a clientaccesspolicy.xml which looks like:</p>
<pre><code><access-policy>
<cross-domain-access>
<policy>
<... | [
{
"answer_id": 255014,
"author": "C. Dragon 76",
"author_id": 5682,
"author_profile": "https://Stackoverflow.com/users/5682",
"pm_score": 4,
"selected": true,
"text": "<p>If you haven't already done so, I'd first try changing the restUrl to something simpler like a static HTML page on th... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] | I am trying to get Silverlight to work with a quick sample application and am calling a rest service on a another computer. The server that has the rest service has a clientaccesspolicy.xml which looks like:
```
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*"... | If you haven't already done so, I'd first try changing the restUrl to something simpler like a static HTML page on the same server (or if need be on your own server) just to verify your main code works.
Assuming the security exception is specific to that REST URL (or site), you might take a look at the [URL Access Res... |
254,901 | <p>does anybody know how could I get the TWO most largest values from the third column on the following array?</p>
<pre><code>$ar = array(array(1, 1, 7.50, 'Hello'),
array(1, 2, 18.90, 'Hello'),
array(3, 5, 11.50, 'Hello'),
array(2, 4, 15.90, 'Hello'));
</code></pr... | [
{
"answer_id": 254920,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": true,
"text": "<p>If you're sure that the value (two) will never change, just iterate over the array and keep track of the two larges... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | does anybody know how could I get the TWO most largest values from the third column on the following array?
```
$ar = array(array(1, 1, 7.50, 'Hello'),
array(1, 2, 18.90, 'Hello'),
array(3, 5, 11.50, 'Hello'),
array(2, 4, 15.90, 'Hello'));
```
Output should be:
... | If you're sure that the value (two) will never change, just iterate over the array and keep track of the two largest numbers. If not, sort the arrays using [`usort`()](http://www.php.net/manual/en/function.usort.php) and providing an appropriate callback. Then take the first two values:
```
function cmp($a, $b) {
... |
254,912 | <p>Given that these two examples are equivalent, which do you think is preferrable?</p>
<p><strong>Without explicit modifier</strong></p>
<pre><code>public class MyClass
{
string name = "james";
public string Name {
get { return name; }
set { name = value; }
}
void SomeMethod() { ..... | [
{
"answer_id": 254922,
"author": "Nicholas Mancuso",
"author_id": 8945,
"author_profile": "https://Stackoverflow.com/users/8945",
"pm_score": 7,
"selected": true,
"text": "<p>I think explicity stating private helps in readability. It won't allow for a programmer to interpret its visibil... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4590/"
] | Given that these two examples are equivalent, which do you think is preferrable?
**Without explicit modifier**
```
public class MyClass
{
string name = "james";
public string Name {
get { return name; }
set { name = value; }
}
void SomeMethod() { ... }
}
```
**With explicit modif... | I think explicity stating private helps in readability. It won't allow for a programmer to interpret its visibility differently. |
254,929 | <p>I'm trying to figure out how to restrict access to a page unless the page is navigated to from a specific "gate" page. Essentially I want the page to be unaccessible unless you're coming from the page that comes before it in my sitemap. I'm not certain this is even possible. If possible, can you limit your suggestio... | [
{
"answer_id": 254939,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>If possible, can you limit your suggestions to using either html or javascript?</p>\n</blockquote>... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27171/"
] | I'm trying to figure out how to restrict access to a page unless the page is navigated to from a specific "gate" page. Essentially I want the page to be unaccessible unless you're coming from the page that comes before it in my sitemap. I'm not certain this is even possible. If possible, can you limit your suggestions ... | What if you encrypted a variable (like the current date) and placed that in the "gate" link. When you arrive at the new page, a script decrypts the variable and if it doesn't match or isn't even there, the script redirects to another page.
Something like:
```
<a href="restricted.php?pass=eERadWRWE3ad=">Go!</a>
```
... |
254,930 | <p>I'm currently working on an application which requires transmission of speech encoded to a specific audio format.</p>
<pre><code>System.Speech.AudioFormat.SpeechAudioFormatInfo synthFormat =
new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm,
... | [
{
"answer_id": 336940,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 1,
"selected": false,
"text": "<p>I have created some classes in my <a href=\"http://www.codeplex.com/naudio\" rel=\"nofollow noreferrer\">NAudio</a> li... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24695/"
] | I'm currently working on an application which requires transmission of speech encoded to a specific audio format.
```
System.Speech.AudioFormat.SpeechAudioFormatInfo synthFormat =
new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm,
... | It's entirely possible that the LH Michael and LH Michelle voices simply don't support 8000 Hz sample rates (because they inherently generate samples > 8000 Hz). SAPI allows engines to reject unsupported rates. |
254,969 | <p>I work in C#, and I've been pretty lax about using <code>using</code> blocks to declare objects that implement <code>IDisposable</code>, which you're apparently always supposed to do. However, I don't see an easy way of knowing when I'm slipping up. Visual Studio doesn't seem to indicate this in any way (am I just... | [
{
"answer_id": 254971,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": false,
"text": "<p>FxCop <em>might</em> help (although it didn't spot a test I just fired at it); but yes: you are meant to check. <c... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33219/"
] | I work in C#, and I've been pretty lax about using `using` blocks to declare objects that implement `IDisposable`, which you're apparently always supposed to do. However, I don't see an easy way of knowing when I'm slipping up. Visual Studio doesn't seem to indicate this in any way (am I just missing something?). Am I ... | FxCop *might* help (although it didn't spot a test I just fired at it); but yes: you are meant to check. `IDisposable` is simply such an important part of the system that you need to get into this habit. Using intellisense to look for `.D` is a good start (though not perfect).
However, it doesn't take long to familiar... |
254,976 | <p>I'm trying to create classes to read from my config file using ConfigurationSection and ConfigurationElementCollection but am having a hard time.</p>
<p>As an example of the config:</p>
<pre><code>
<PaymentMethodSettings>
<PaymentMethods>
<PaymentMethod name="blah blah" code="1"/>
<P... | [
{
"answer_id": 255012,
"author": "DOK",
"author_id": 27637,
"author_profile": "https://Stackoverflow.com/users/27637",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/2tw134k3.aspx\" rel=\"nofollow noreferrer\">This</a> should help you figu... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25951/"
] | I'm trying to create classes to read from my config file using ConfigurationSection and ConfigurationElementCollection but am having a hard time.
As an example of the config:
```
<PaymentMethodSettings>
<PaymentMethods>
<PaymentMethod name="blah blah" code="1"/>
<PaymentMethod name="blah blah" code="42"/>
... | The magic here is to use ConfigurationSection classes.
These classes just need to contain properties that match 1:1 with your configuration schema. You use attributes to let .NET know which properties match which elements.
So, you could create PaymentMethod and have it inherit from ConfigurationSection
And you would... |
254,979 | <p>I have 3 points (A, B and X) and a distance (d). I need to make a function that tests if point X is closer than distance d to any point on the line segment AB. </p>
<p>The question is firstly, is my solution correct and then to come up with a better (faster) solution.</p>
<p>My first pass is as follows</p>
<pre><... | [
{
"answer_id": 255024,
"author": "benjismith",
"author_id": 22979,
"author_profile": "https://Stackoverflow.com/users/22979",
"pm_score": 2,
"selected": false,
"text": "<p>Hmmmmmmm.... What's the hit-rate? How often does point \"X\" meet the proximity requirements?</p>\n\n<p>I think your... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I have 3 points (A, B and X) and a distance (d). I need to make a function that tests if point X is closer than distance d to any point on the line segment AB.
The question is firstly, is my solution correct and then to come up with a better (faster) solution.
My first pass is as follows
```
AX = X-A
BX = X-B
AB = ... | If your set of (A,B,d) in fixed, you can calculate a pair of matrices for each to translate the co-ordinate system, so that the line AB becomes the X axis, and the midpoint of AB is the origin.
I *think* this is a simple way to construct the matrices:
```
trans = - ((A + B) / 2) // translate midpoint of AB to ... |
254,980 | <p>As a follow-up to <a href="https://stackoverflow.com/questions/199518/how-to-programatically-add-mapped-network-passwords-winxp">this</a> question I am hoping someone can help with the <a href="http://msdn.microsoft.com/en-us/library/aa374794(VS.85).aspx" rel="nofollow noreferrer">CredEnumerate</a> API. </p>
<p>As... | [
{
"answer_id": 255073,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 4,
"selected": true,
"text": "<p>You need to dereference the pointer to the array to get the array, then for each item in the array you will need to derefe... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12842/"
] | As a follow-up to [this](https://stackoverflow.com/questions/199518/how-to-programatically-add-mapped-network-passwords-winxp) question I am hoping someone can help with the [CredEnumerate](http://msdn.microsoft.com/en-us/library/aa374794(VS.85).aspx) API.
As I understand from the documentation the PCREDENTIALS out p... | You need to dereference the pointer to the array to get the array, then for each item in the array you will need to dereference the item to get the `PCREDENTIALS` instance.
I found [this post with some example code](http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic33651.aspx) for perform... |
254,985 | <p>The company I work for has a large webapp written in C++ as an ISAPI extension (not a filter). We're currently enhancing our system to integrate with several 3rd party tools that have SOAP interfaces. Rather than roll our own, I think it would probably be best if we used some SOAP library. Ideally, it would be fr... | [
{
"answer_id": 255073,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 4,
"selected": true,
"text": "<p>You need to dereference the pointer to the array to get the array, then for each item in the array you will need to derefe... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10861/"
] | The company I work for has a large webapp written in C++ as an ISAPI extension (not a filter). We're currently enhancing our system to integrate with several 3rd party tools that have SOAP interfaces. Rather than roll our own, I think it would probably be best if we used some SOAP library. Ideally, it would be free and... | You need to dereference the pointer to the array to get the array, then for each item in the array you will need to dereference the item to get the `PCREDENTIALS` instance.
I found [this post with some example code](http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic33651.aspx) for perform... |
254,992 | <p>I've got some RadioButtons in my XAML...</p>
<pre><code><StackPanel>
<RadioButton Name="RadioButton1" GroupName="Buttons" Click="ButtonsChecked" IsChecked="True">One</RadioButton>
<RadioButton Name="RadioButton2" GroupName="Buttons" Click="ButtonsChecked">Two</RadioButton>
... | [
{
"answer_id": 255225,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 5,
"selected": true,
"text": "<p>In order for commands to work you need to set up bindings in either your xaml or code behind. These command bindings m... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I've got some RadioButtons in my XAML...
```
<StackPanel>
<RadioButton Name="RadioButton1" GroupName="Buttons" Click="ButtonsChecked" IsChecked="True">One</RadioButton>
<RadioButton Name="RadioButton2" GroupName="Buttons" Click="ButtonsChecked">Two</RadioButton>
<RadioButton Name="RadioButton3" GroupName="... | In order for commands to work you need to set up bindings in either your xaml or code behind. These command bindings must reference public static fields that have been previously declared.
Then in your buttons Command attribute you will then need to also reference these same commands.
```
<Window
x:Class="Radio... |
254,993 | <p>In one of my projects I need to build an ASP.NET page and some of the controls need to be created dynamically. These controls are added to the page by the code-behind class and they have some event-handlers added to them. Upon the PostBacks these event-handlers have a lot to do with what controls are then shown on t... | [
{
"answer_id": 255017,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>One thing I notice is that when you click a button you are invoking AddButtons() twice, once in the <code>Page_Load(... | 2008/10/31 | [
"https://Stackoverflow.com/questions/254993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3379/"
] | In one of my projects I need to build an ASP.NET page and some of the controls need to be created dynamically. These controls are added to the page by the code-behind class and they have some event-handlers added to them. Upon the PostBacks these event-handlers have a lot to do with what controls are then shown on the ... | I think that you have to provide the same ID for your buttons every time you add them like this for example (in first line of `AddButtonControl` method):
```
var button = new Button { Text = id , ID = id };
```
---
**EDIT** - My solution without using session:
```
public partial class _Default : Page
{
protect... |
255,006 | <p>Is it possible to automatically launch an application from a USB flash drive (bypassing windows prompt asking user what he wants to do)? on windows XP or vista.</p>
<p>I looked into "autorun.inf" and "open" entry seems to work only for CD drives for Windows XP SP2+ and Vista. Is it possible to launch program automa... | [
{
"answer_id": 255028,
"author": "BobC",
"author_id": 31167,
"author_profile": "https://Stackoverflow.com/users/31167",
"pm_score": 2,
"selected": false,
"text": "<p>I've had something set up on my USB keys for a while now. Using the autorun.inf file will work, depending on your system's... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19124/"
] | Is it possible to automatically launch an application from a USB flash drive (bypassing windows prompt asking user what he wants to do)? on windows XP or vista.
I looked into "autorun.inf" and "open" entry seems to work only for CD drives for Windows XP SP2+ and Vista. Is it possible to launch program automatically on... | First of all, some people choose to disable autorun for security reasons; but Windows computers up to Vista have it enabled. Edit: **Apparently the functionality was removed from Windows 7 onwards.**
Put a file named autorun.inf in the root of your USB flash drive. This is what's in mine:
```
[Autorun]
Open=PStart.ex... |
255,019 | <p>Is there any way to do the equivalent of the following in a JSP without using scriptlet?</p>
<pre><code><% response.setContentType("text/plain"); %>
</code></pre>
<p>I can't simply use</p>
<p>because I need to set the content-type in 2 places (each in a different branch of a ) and the JSP compiler will o... | [
{
"answer_id": 255023,
"author": "AlexJReid",
"author_id": 32320,
"author_profile": "https://Stackoverflow.com/users/32320",
"pm_score": 2,
"selected": false,
"text": "<pre><code><%@ page language=\"java\" contentType=\"text/plain\" %>\n</code></pre>\n\n<p>Edit:</p>\n\n<p>If you ne... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | Is there any way to do the equivalent of the following in a JSP without using scriptlet?
```
<% response.setContentType("text/plain"); %>
```
I can't simply use
because I need to set the content-type in 2 places (each in a different branch of a ) and the JSP compiler will only allow one such directive.
Also, I ca... | ```
<%@ page language="java" contentType="text/plain" %>
```
Edit:
If you need to set the MIME type conditionally, you could use
```
<%
if( branch condition ) {
response.setContentType("text/plain");
} else {
response.setContentType("text/html");
}
%>
```
Obviously the above is a scriptlet which goes again... |
255,035 | <p>How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way.</p>
| [
{
"answer_id": 255053,
"author": "kender",
"author_id": 4172,
"author_profile": "https://Stackoverflow.com/users/4172",
"pm_score": 7,
"selected": true,
"text": "<pre><code>import time, datetime\n\nd = datetime.datetime.now()\nprint time.mktime(d.timetuple())\n</code></pre>\n"
},
{
... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way. | ```
import time, datetime
d = datetime.datetime.now()
print time.mktime(d.timetuple())
``` |
255,056 | <p>I have a standard .NET windows service written in C#.</p>
<p>Can it install itself without using InstallUtil?
Should I use the service installer class? How should I use it?</p>
<p>I want to be able to call the following:</p>
<pre><code>MyService.exe -install
</code></pre>
<p>And it will have the same effect as c... | [
{
"answer_id": 255062,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 8,
"selected": true,
"text": "<p>Yes, that is fully possible (i.e. I do exactly this); you just need to reference the right dll (System.ServiceProce... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20257/"
] | I have a standard .NET windows service written in C#.
Can it install itself without using InstallUtil?
Should I use the service installer class? How should I use it?
I want to be able to call the following:
```
MyService.exe -install
```
And it will have the same effect as calling:
```
InstallUtil MyService.exe
... | Yes, that is fully possible (i.e. I do exactly this); you just need to reference the right dll (System.ServiceProcess.dll) and add an installer class...
[Here's an example:](http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/4d45e9ea5471cba4/4519371a77ed4a74)
```
[RunInstal... |
255,063 | <p>Would there a more elegant way of writing the following syntax? </p>
<pre><code> Thread t0 = new Thread(new ParameterizedThreadStart(doWork));
t0.Start('someVal');
t0.Join();
Thread t1 = new Thread(new ParameterizedThreadStart(doWork));
t1.Start('someDiffVal');
t1.Joi... | [
{
"answer_id": 255072,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Why would you start a thread and then join against it immediately?</p>\n\n<p>I'd normally do something like this:</p>\... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30649/"
] | Would there a more elegant way of writing the following syntax?
```
Thread t0 = new Thread(new ParameterizedThreadStart(doWork));
t0.Start('someVal');
t0.Join();
Thread t1 = new Thread(new ParameterizedThreadStart(doWork));
t1.Start('someDiffVal');
t1.Join();
```
Pre... | Why would you start a thread and then join against it immediately?
I'd normally do something like this:
```
List<Thread> threads = new List<Thread>();
foreach (string item in items)
{
string copy = item; // Important due to variable capture
ThreadStart ts = () => DoWork(copy); // Strongly typed :)
Thread... |
255,071 | <p>I've been tasked with implementing a Date/Time selector for several areas of our web project, and instructed to use a control that another developer created as part of it. The control I'm working on is supposed to allow the user to choose a date from a calendar, choose a format for the display of that date (from se... | [
{
"answer_id": 255072,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Why would you start a thread and then join against it immediately?</p>\n\n<p>I'd normally do something like this:</p>\... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23902/"
] | I've been tasked with implementing a Date/Time selector for several areas of our web project, and instructed to use a control that another developer created as part of it. The control I'm working on is supposed to allow the user to choose a date from a calendar, choose a format for the display of that date (from severa... | Why would you start a thread and then join against it immediately?
I'd normally do something like this:
```
List<Thread> threads = new List<Thread>();
foreach (string item in items)
{
string copy = item; // Important due to variable capture
ThreadStart ts = () => DoWork(copy); // Strongly typed :)
Thread... |
255,077 | <p>I have just installed VMWare Server 2.0 on a fresh Fedora Core 8 install. The ports for the web access console of VMWare are 8222 and 8333 (like the defaults).</p>
<p>When I try a remote http access to myserver:8222 it fails. But when I run</p>
<pre><code>/sbin/service iptables stop
</code></pre>
<p>access become... | [
{
"answer_id": 255331,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 3,
"selected": true,
"text": "<p>Your rules for VMware need to come before the REJECT entry; otherwise they'll never be reached.</p>\n\n<p>A good debug... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18858/"
] | I have just installed VMWare Server 2.0 on a fresh Fedora Core 8 install. The ports for the web access console of VMWare are 8222 and 8333 (like the defaults).
When I try a remote http access to myserver:8222 it fails. But when I run
```
/sbin/service iptables stop
```
access becomes possibles (although not very sa... | Your rules for VMware need to come before the REJECT entry; otherwise they'll never be reached.
A good debugging tool is to add a LOG just before your rules to verify:
```
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# Custom authorization for VMWare administration
-A RH-Firewall-1-I... |
255,078 | <p>What's the difference between a string and a symbol in Ruby and when should I use one over the other?</p>
| [
{
"answer_id": 255088,
"author": "websch01ar",
"author_id": 32567,
"author_profile": "https://Stackoverflow.com/users/32567",
"pm_score": -1,
"selected": false,
"text": "<p>A symbol is something you use to represent names and strings. You would want to use a symbol when you may have nee... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | What's the difference between a string and a symbol in Ruby and when should I use one over the other? | The main difference is that multiple symbols representing a single value are identical whereas this is not true with strings. For example:
```
irb(main):007:0> :test.object_id
=> 83618
irb(main):008:0> :test.object_id
=> 83618
irb(main):009:0> :test.object_id
=> 83618
```
Those are three references to the symbol `:t... |
255,081 | <p>I have a situation where another developer is including source files from a project that I maintain in a project that he maintains. The nature of the files is such that each source file registers a "command" in an interpretive environment so all you have to do is link in a new source file to register a new "command... | [
{
"answer_id": 255090,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 0,
"selected": false,
"text": "<p>Could you simply write a source file containing nothing but <code>#include</code> directives? I'm not sure if VS checks ... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19674/"
] | I have a situation where another developer is including source files from a project that I maintain in a project that he maintains. The nature of the files is such that each source file registers a "command" in an interpretive environment so all you have to do is link in a new source file to register a new "command". W... | There is no reason a source file can't be in multiple projects. Just add it as an 'existing item' in VS.
If you are using precompiled headers then both projects will need equivalent set ups for this to work.
You can also use a #pragma in a lib to force a symbol to be included when the linker would otherwise discard i... |
255,098 | <p>I am experimenting with calling delegate functions from a delegate array. I've been able to create the array of delegates, but how do I call the delegate?</p>
<pre><code>public delegate void pd();
public static class MyClass
{
static void p1()
{
//...
}
static void p2 ()
{
//... | [
{
"answer_id": 255107,
"author": "Romain Verdier",
"author_id": 4687,
"author_profile": "https://Stackoverflow.com/users/4687",
"pm_score": 3,
"selected": false,
"text": "<pre><code>public class MainClass\n{\n static void Main()\n {\n pd[0]();\n pd[1]();\n }\n}\n</... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7899/"
] | I am experimenting with calling delegate functions from a delegate array. I've been able to create the array of delegates, but how do I call the delegate?
```
public delegate void pd();
public static class MyClass
{
static void p1()
{
//...
}
static void p2 ()
{
//...
}
... | If they're all the same type, why not just combine them into a single multicast delegate?
```
static pd delegateInstance = new pd(MyClass.p1) + new pd(MyClass.p2) ...;
...
pd();
``` |
255,104 | <p>I'm working on a WinForms app and I have a user control in it. The buttons in the user control raise events up to the form to be handled by other code. One of the buttons starts some processses that will cause problems if they run simultaneously. I have logic in the code to manage the state so typically a user ca... | [
{
"answer_id": 255118,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": -1,
"selected": false,
"text": "<p>Disable the button after the user first clicks it and before starting the task. When task completes,... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10221/"
] | I'm working on a WinForms app and I have a user control in it. The buttons in the user control raise events up to the form to be handled by other code. One of the buttons starts some processses that will cause problems if they run simultaneously. I have logic in the code to manage the state so typically a user can't ru... | Make sure that your button disabling or any other locking that you do is the /first/ thing that you do in your event handler. I would be extremely surprised if you could queue up two click events before even the first instruction fires, but I suppose that's possible if you're on a very slow computer that's bogged down ... |
255,114 | <p>Let's make this very easy. What I want:</p>
<pre><code>@array = qw/one two one/;
my @duplicates = duplicate(@array);
print "@duplicates"; # This should now print 'one'.
</code></pre>
<p>How to print duplicate values of a array/hash?</p>
| [
{
"answer_id": 255144,
"author": "Dave",
"author_id": 32938,
"author_profile": "https://Stackoverflow.com/users/32938",
"pm_score": 0,
"selected": false,
"text": "<p>Use a dictionary, put the value in the key, and the count in the value.</p>\n\n<p>Ah, just noticed you've tagged as perl</... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33232/"
] | Let's make this very easy. What I want:
```
@array = qw/one two one/;
my @duplicates = duplicate(@array);
print "@duplicates"; # This should now print 'one'.
```
How to print duplicate values of a array/hash? | ```
sub duplicate {
my @args = @_;
my %items;
for my $element(@args) {
$items{$element}++;
}
return grep {$items{$_} > 1} keys %items;
}
``` |
255,133 | <p>I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when real... | [
{
"answer_id": 256007,
"author": "Ronnie Liew",
"author_id": 1987,
"author_profile": "https://Stackoverflow.com/users/1987",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked at this event:</p>\n\n<pre><code>flash.events.Event.MOUSE_LEAVE\n</code></pre>\n\n<p><br />\n<br />\n... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] | I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when really ... | Simple and foolproof:
```
button.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
button.addEventListener( MouseEvent.MOUSE_UP, buttonMouseUpHandler ); // *
function mouseDownHandler( event : MouseEvent ) : void {
trace( "onPress" );
// this will catch the event anywhere
event.target.stage.add... |
255,147 | <p>In python, if I say</p>
<pre><code>print 'h'
</code></pre>
<p>I get the letter h and a newline. If I say </p>
<pre><code>print 'h',
</code></pre>
<p>I get the letter h and no newline. If I say</p>
<pre><code>print 'h',
print 'm',
</code></pre>
<p>I get the letter h, a space, and the letter m. How can I prev... | [
{
"answer_id": 255154,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 9,
"selected": true,
"text": "<pre><code>import sys\n\nsys.stdout.write('h')\nsys.stdout.flush()\n\nsys.stdout.write('m')\nsys.stdout.flush()\n</code></... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4343/"
] | In python, if I say
```
print 'h'
```
I get the letter h and a newline. If I say
```
print 'h',
```
I get the letter h and no newline. If I say
```
print 'h',
print 'm',
```
I get the letter h, a space, and the letter m. How can I prevent Python from printing the space?
The print statements are different ite... | ```
import sys
sys.stdout.write('h')
sys.stdout.flush()
sys.stdout.write('m')
sys.stdout.flush()
```
You need to call [`sys.stdout.flush()`](https://docs.python.org/library/io.html#io.IOBase.flush) because otherwise it will hold the text in a buffer and you won't see it. |
255,153 | <p>how do i determine what a mysql db's charset is set to? in the cli?</p>
| [
{
"answer_id": 255163,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SHOW CREATE DATABASE db-name\n</code></pre>\n\n<p>Will show you the default character set for the database... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18285/"
] | how do i determine what a mysql db's charset is set to? in the cli? | ```
SHOW CREATE DATABASE db-name
```
Will show you the default character set for the database,
```
SHOW CREATE TABLE db-name.table-name
```
Will show you the character set for a specific table (along with a lot of other information). |
255,157 | <p>In the context of a Google App Engine Webapp framework application:</p>
<p>I want to changed the request verb of a request in the case a
parameter _method is provided, for example if a POST request comes in
with a parameter _method=PUT, I need to change the request to call the
put method of the handler. This is to ... | [
{
"answer_id": 255906,
"author": "Nick Johnson",
"author_id": 12030,
"author_profile": "https://Stackoverflow.com/users/12030",
"pm_score": 2,
"selected": false,
"text": "<p>Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the ori... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304/"
] | In the context of a Google App Engine Webapp framework application:
I want to changed the request verb of a request in the case a
parameter \_method is provided, for example if a POST request comes in
with a parameter \_method=PUT, I need to change the request to call the
put method of the handler. This is to cope wit... | Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the original handler as well.
Instead, you have a couple of options:
* You can subclass webapp.WSGIApplication and override **call** to select the method based on \_method when it exists.
* You can check for the... |
255,170 | <p>I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the <a href="http://code.google.com/p/wmd/" rel="noreferrer">WMD</a> one here in Stack Overflow) would be perfect.</p>
<p>However, <strong>they do need the ability to have images ri... | [
{
"answer_id": 255182,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 9,
"selected": true,
"text": "<p>You can embed HTML in Markdown, so you can do something like this:</p>\n\n<pre><code><img style=\"float: right;\" sr... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9913/"
] | I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the [WMD](http://code.google.com/p/wmd/) one here in Stack Overflow) would be perfect.
However, **they do need the ability to have images right-aligned in a given paragraph**.
I can't see ... | You can embed HTML in Markdown, so you can do something like this:
```
<img style="float: right;" src="whatever.jpg">
Continue markdown text...
``` |
255,189 | <p>If I have a type defined as a <strong>set of</strong> an enumerated type, it's easy to create an empty set with [], but how do I create a <em>full</em> set?</p>
<p>EDIT: Yeah, the obvious solution is to use a for loop. That's also a really bad solution if there's another way. Does anyone know of a way that'll wor... | [
{
"answer_id": 255321,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 3,
"selected": false,
"text": "<p>Per Barry's suggestion:</p>\n\n<pre><code>FillChar(VarSet, SizeOf(VarSet), $FF);\n</code></pre>\n"
},
{
"answer... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | If I have a type defined as a **set of** an enumerated type, it's easy to create an empty set with [], but how do I create a *full* set?
EDIT: Yeah, the obvious solution is to use a for loop. That's also a really bad solution if there's another way. Does anyone know of a way that'll work in constant time? | Low() and High() are "compiler magic" functions that can be evaluated at compile time.
This allows their use in constant declarations like the following:
```
var
MySet : TBorderIcons;
MySet2 : TBorderIcons;
const
AllIcons : TBorderIcons = [Low(TBorderIcon)..High(TBorderIcon)];
begin
MySet := [Low(TBorderIcon)... |
255,194 | <p>I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models:</p>
<pre><code>ClientContact {
static hasMany = [owners: Person]
static belongsTo = [Person]
}
Person {
static hasMany = [clientContacts: ClientContact]
}
</code></pre>
<p>When I try to retrieve all the <code>Clie... | [
{
"answer_id": 255295,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 0,
"selected": false,
"text": "<p>Two quick observations:</p>\n\n<ol>\n<li>The [Grails Documentation](<a href=\"http://grails.org/doc/1.0.x/guide/5.%20O... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21832/"
] | I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models:
```
ClientContact {
static hasMany = [owners: Person]
static belongsTo = [Person]
}
Person {
static hasMany = [clientContacts: ClientContact]
}
```
When I try to retrieve all the `ClientContacts` with a specific own... | I know this thread is very old, but I just encountered exactly the same problem today and the solution seems to be usage of aliases, so instead:
```
def query = {
owners {
eq("id", Long.parseLong(params.ownerId))
}
}
```
one can try:
```
def query = {
createAlias("owners", "o... |
255,202 | <p>When I type <code>git diff</code>, I want to view the output with my visual diff tool of choice (SourceGear "diffmerge" on Windows). How do I configure git to do this?</p>
| [
{
"answer_id": 255212,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 10,
"selected": true,
"text": "<p>Since Git1.6.3, you can use the <strong>git difftool script</strong>: see <a href=\"https://stackoverflow.com/questions/2552... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3891/"
] | When I type `git diff`, I want to view the output with my visual diff tool of choice (SourceGear "diffmerge" on Windows). How do I configure git to do this? | Since Git1.6.3, you can use the **git difftool script**: see [my answer below](https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/949242#949242).
---
May be this [article](https://web.archive.org/web/20170508180316/http://git.net:80/ml/version-control.msysgit/2008-06/msg... |
255,214 | <p>I keep seeing references to the visitor pattern in blogs but I've got to admit, I just don't get it. I read the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="noreferrer">wikipedia article for the pattern</a> and I understand its mechanics but I'm still confused as to when I'd use it.</p>
<p>As someon... | [
{
"answer_id": 255224,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 7,
"selected": false,
"text": "<p>The reason for your confusion is probably that the Visitor is a fatal misnomer. Many (prominent<sup>1</sup>!) prog... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I keep seeing references to the visitor pattern in blogs but I've got to admit, I just don't get it. I read the [wikipedia article for the pattern](http://en.wikipedia.org/wiki/Visitor_pattern) and I understand its mechanics but I'm still confused as to when I'd use it.
As someone who just recently really **got** the ... | I'm not very familiar with the Visitor pattern. Let's see if I got it right. Suppose you have a hierarchy of animals
```cpp
class Animal { };
class Dog: public Animal { };
class Cat: public Animal { };
```
(Suppose it is a complex hierarchy with a well-established interface.)
Now we want to add a new operation t... |
255,216 | <p>So far, I've only been passing javascript strings to my web methods, which get parsed, usually as Guids. but now i have a method that accepts an IList... on the client, i build this array of objects and then attempt to pass it like: </p>
<pre><code>$.ajax({
type: 'POST',
url: 'personalization.aspx/SetPersonaliz... | [
{
"answer_id": 255261,
"author": "Duncan",
"author_id": 25035,
"author_profile": "https://Stackoverflow.com/users/25035",
"pm_score": 2,
"selected": false,
"text": "<p>The data you are passing you are trying to pass it as a string already. If you want jQuery to transform it leave the wh... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6350/"
] | So far, I've only been passing javascript strings to my web methods, which get parsed, usually as Guids. but now i have a method that accepts an IList... on the client, i build this array of objects and then attempt to pass it like:
```
$.ajax({
type: 'POST',
url: 'personalization.aspx/SetPersonalization',
data... | >
> data: "{'backerEntries':" + backerEntries + "}",
>
>
>
..is the same as
```
data: "{'backerEntries':" + backerEntries.toString() + "}",
```
...which is pretty much useless. Use [Duncan](https://stackoverflow.com/questions/255216/why-doesnt-jquery-turn-my-array-into-a-json-string-before-sending-to-aspnet-we... |
255,278 | <p>What would be the best way to determine if an object equals number zero (0) or string.empty in C#?</p>
<p><b>EDIT:</b> The object can equal any built-in System.Value type or reference type.</p>
<p>Source Code:</p>
<pre><code>public void MyMethod(object input1, object input2)
{
bool result = false;
object ... | [
{
"answer_id": 255281,
"author": "x0n",
"author_id": 6920,
"author_profile": "https://Stackoverflow.com/users/6920",
"pm_score": 0,
"selected": false,
"text": "<p>Do you mean null or string.empty, if you're talking about strings?</p>\n\n<p>if (String.IsNullOrEmpty(obj as string)) { ... d... | 2008/10/31 | [
"https://Stackoverflow.com/questions/255278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | What would be the best way to determine if an object equals number zero (0) or string.empty in C#?
**EDIT:** The object can equal any built-in System.Value type or reference type.
Source Code:
```
public void MyMethod(object input1, object input2)
{
bool result = false;
object compare = new object();
if... | Using Jonathan Holland code sample with a minor modification, here is the solution that worked:
```
static bool IsZeroOrEmpty(object o1)
{
bool Passed = false;
object ZeroValue = 0;
if(o1 != null)
{
if(o1.GetType().IsValueType)
{
Passed = (o1 as System.ValueType).Equals(Con... |
255,302 | <p>Hoping some of you TinyXML++ people can help me out. Really, since you recomended to me before I think you owe me ;)</p>
<p>I have the following code:</p>
<pre><code> //ticpp::Iterator< ticpp::Element > child( "SetPiece" );
ticpp::Iterator< ticpp::Node > child("SetPiece");
GLuint lc_SPieces =... | [
{
"answer_id": 256996,
"author": "tabdamage",
"author_id": 28022,
"author_profile": "https://Stackoverflow.com/users/28022",
"pm_score": 1,
"selected": false,
"text": "<p>just poking in the dark, i don't know tinyxml, but it seems that a dynamic_cast went wrong. \nIf you dynamic_cast<... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23829/"
] | Hoping some of you TinyXML++ people can help me out. Really, since you recomended to me before I think you owe me ;)
I have the following code:
```
//ticpp::Iterator< ticpp::Element > child( "SetPiece" );
ticpp::Iterator< ticpp::Node > child("SetPiece");
GLuint lc_SPieces = 0;
for(child = child.begin( ... | just poking in the dark, i don't know tinyxml, but it seems that a dynamic\_cast went wrong.
If you dynamic\_cast<> a pointer, you get a NULL-pointer on failure. However, if you cast to a reference type, there is no concept of a NULL-reference, so the runtime throws this exception (or bad\_type). [MSDN on dynamic\_cas... |
255,312 | <p>Say i have this PHP code:</p>
<pre><code>$FooBar = "a string";
</code></pre>
<p>i then need a function like this:</p>
<pre><code>print_var_name($FooBar);
</code></pre>
<p>which prints:</p>
<pre><code>FooBar
</code></pre>
<p>Any Ideas how to achieve this? Is this even possible in PHP?</p>
| [
{
"answer_id": 255319,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": -1,
"selected": false,
"text": "<p>I really fail to see the use case... If you will type print_var_name($foobar) what's so hard (and different) abo... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | Say i have this PHP code:
```
$FooBar = "a string";
```
i then need a function like this:
```
print_var_name($FooBar);
```
which prints:
```
FooBar
```
Any Ideas how to achieve this? Is this even possible in PHP? | You could use [get\_defined\_vars()](http://php.net/get_defined_vars) to find the name of a variable that has the same value as the one you're trying to find the name of. Obviously this will not always work, since different variables often have the same values, but it's the only way I can think of to do this.
Edit: ge... |
255,317 | <p>I have an asp.net page with a button. This button generates and inserts a user control into the page, so many controls could exist on one page. I need to validate that a certain dynamically generated control inside the generated control exists. </p>
<p>So..Page has 0 to N Control1’s. Each Control 1 can have 0 to... | [
{
"answer_id": 255933,
"author": "tbreffni",
"author_id": 637,
"author_profile": "https://Stackoverflow.com/users/637",
"pm_score": 0,
"selected": false,
"text": "<p>One method you could try is creating and maintaining a simple xml structure that represents your custom control hierarchy.... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33253/"
] | I have an asp.net page with a button. This button generates and inserts a user control into the page, so many controls could exist on one page. I need to validate that a certain dynamically generated control inside the generated control exists.
So..Page has 0 to N Control1’s. Each Control 1 can have 0 to N Control2’s... | Hmm i like the Interface idea suggested by digiguru but i would use the interface on the container Control1 instead of the sub controls as it seems like the more logical place for the code to live. Heres my take on it:
```
public interface IValidatableControl
{
bool IsValidControl();
}
```
then implement thi... |
255,337 | <p>I want to read and write from serial using events/interrupts.
Currently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++?</p>
<p>This is my current code:</p>
<pre>
while(true)
... | [
{
"answer_id": 255933,
"author": "tbreffni",
"author_id": 637,
"author_profile": "https://Stackoverflow.com/users/637",
"pm_score": 0,
"selected": false,
"text": "<p>One method you could try is creating and maintaining a simple xml structure that represents your custom control hierarchy.... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] | I want to read and write from serial using events/interrupts.
Currently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++?
This is my current code:
```
while(true)
{
//re... | Hmm i like the Interface idea suggested by digiguru but i would use the interface on the container Control1 instead of the sub controls as it seems like the more logical place for the code to live. Heres my take on it:
```
public interface IValidatableControl
{
bool IsValidControl();
}
```
then implement thi... |
255,341 | <p>It's easy to get the value of a key from a .NET generic Dictionary:</p>
<pre><code>Dictionary<int, string> greek = new Dictionary<int, string>();
greek.Add(1, "Alpha");
greek.Add(2, "Beta");
string secondGreek = greek[2]; // Beta
</code></pre>
<p>But trying to get the keys given a value is not as stra... | [
{
"answer_id": 255348,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 2,
"selected": false,
"text": "<p>revised: okay to have some kind of find you would need something other than dictionary, since if you think about it dictio... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22437/"
] | It's easy to get the value of a key from a .NET generic Dictionary:
```
Dictionary<int, string> greek = new Dictionary<int, string>();
greek.Add(1, "Alpha");
greek.Add(2, "Beta");
string secondGreek = greek[2]; // Beta
```
But trying to get the keys given a value is not as straightforward because there could be mul... | Okay, here's the multiple bidirectional version:
```
using System;
using System.Collections.Generic;
using System.Text;
class BiDictionary<TFirst, TSecond>
{
IDictionary<TFirst, IList<TSecond>> firstToSecond = new Dictionary<TFirst, IList<TSecond>>();
IDictionary<TSecond, IList<TFirst>> secondToFirst = new Di... |
255,370 | <p>I am developing Eclipse plugins, and I need to be able to automate the building and execution of the test suite for each plugin. (Using Junit)</p>
<p>Test are working within Eclipse, and I can break the plugins into the actual plugin and a fragment plugin for unit testing as described <a href="http://dev.eclipse.o... | [
{
"answer_id": 255620,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 0,
"selected": false,
"text": "<p>We're using the PDE build scripts (see <a href=\"https://stackoverflow.com/questions/133234/building-eclipse-plugins-an... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3446/"
] | I am developing Eclipse plugins, and I need to be able to automate the building and execution of the test suite for each plugin. (Using Junit)
Test are working within Eclipse, and I can break the plugins into the actual plugin and a fragment plugin for unit testing as described [here](http://dev.eclipse.org/viewcvs/in... | I have just got JUnit testing working as part of the headless build for our RCP application.
I found this article - [Automating Eclipse PDE Unit Tests using Ant](http://www.eclipse.org/articles/article.php?file=Article-PDEJUnitAntAutomation/index.html) incredibly helpful. It provides code and approach to get you star... |
255,393 | <p>I'm trying to make a page in php that takes rows from a database, displays them, and then give the viewer a chance to upvote or downvote a specific entry. Here is a snippet:</p>
<pre><code>echo("<form action=\"vote.php\" method=\"post\"> \n");
echo("<INPUT type=\"hidden\" name=\"idnum\" value=\"".$row[0]."... | [
{
"answer_id": 255396,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>Your form is not closed properly. Use <code></form></code> instead of <code><form/></code>.</p>\n"
},
... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25680/"
] | I'm trying to make a page in php that takes rows from a database, displays them, and then give the viewer a chance to upvote or downvote a specific entry. Here is a snippet:
```
echo("<form action=\"vote.php\" method=\"post\"> \n");
echo("<INPUT type=\"hidden\" name=\"idnum\" value=\"".$row[0]."\">");
echo("<INPUT typ... | Your form tag isn't closed properly. You have `<form/>`, but it should be `</form>`.
This makes the entire page a form so it sends all the inputs. With a form that is closed properly though, it will only send the inputs within the form tags that the pressed button was in. |
255,400 | <p>This is a very complicated question concerning how to serialize data via a web service call, when the data is not-strongly typed. I'll try to lay it out as best possible.</p>
<p><strong>Sample Storage Object:</strong></p>
<pre><code>[Serializable]
public class StorageObject {
public string Name { get; set; }
... | [
{
"answer_id": 255411,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not sure this would solve your problem (it would in C#, but maybe not in PHP), but try using <code>Dictionary&l... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27472/"
] | This is a very complicated question concerning how to serialize data via a web service call, when the data is not-strongly typed. I'll try to lay it out as best possible.
**Sample Storage Object:**
```
[Serializable]
public class StorageObject {
public string Name { get; set; }
public string Birthday { get; set; ... | This is like dynamic properties for a object.
C# is not quite a dynamic language unlike javascript or maybe PHP can parse the object properties on the fly. The following two methods are what I can think of. The second one might fit into your requirements.
**The KISS Way**
The Keep It Simple Stupid way
```
public ... |
255,414 | <p>I'm trying to write a small script to change the current directory to my project directory:</p>
<pre><code>#!/bin/bash
cd /home/tree/projects/java
</code></pre>
<p>I saved this file as proj, added execute permission with <code>chmod</code>, and copied it to <code>/usr/bin</code>. When I call it by:
<code>proj</cod... | [
{
"answer_id": 255415,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 10,
"selected": true,
"text": "<p>Shell scripts are run inside a subshell, and each subshell has its own concept of what the current directory is. The <... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] | I'm trying to write a small script to change the current directory to my project directory:
```
#!/bin/bash
cd /home/tree/projects/java
```
I saved this file as proj, added execute permission with `chmod`, and copied it to `/usr/bin`. When I call it by:
`proj`, it does nothing. What am I doing wrong? | Shell scripts are run inside a subshell, and each subshell has its own concept of what the current directory is. The `cd` succeeds, but as soon as the subshell exits, you're back in the interactive shell and nothing ever changed there.
One way to get around this is to use an alias instead:
```
alias proj="cd /home/tr... |
255,422 | <p>I would like to create an HTML table with row colors changing based on position and content. But instead of alternating every row, I'd like to be able to group rows together, so that I can have some XML like this:</p>
<pre><code><itemlist>
<item group="0">Conent...blah blah</item>
<item ... | [
{
"answer_id": 255457,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 1,
"selected": false,
"text": "<p>The first two groups are simple as you can parse them based on their group number.</p>\n\n<p>To handle group 2, consider using ... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33263/"
] | I would like to create an HTML table with row colors changing based on position and content. But instead of alternating every row, I'd like to be able to group rows together, so that I can have some XML like this:
```
<itemlist>
<item group="0">Conent...blah blah</item>
<item group="0">Content...who cares</item>... | Here's an example of using "choose" to apply a different class value based on the group value. Something similar to this would work if you want to treat each group in a specific way. If your decision logic for handling group 2 is more complex, then you could place additional decision logic inside the "when" statement t... |
255,423 | <p>I seem to remember being able to print out (or locate) the specific switches that each -O<num> option turns on. Can you remind?</p>
<p>Thanks!</p>
| [
{
"answer_id": 255434,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 2,
"selected": false,
"text": "<p>You may also try the good ol' manual</p>\n\n<pre><code>$ man gcc\n</code></pre>\n\n<p>at the subsection \"O... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30636/"
] | I seem to remember being able to print out (or locate) the specific switches that each -O<num> option turns on. Can you remind?
Thanks! | The [list of new features on gcc 4.3](http://gcc.gnu.org/gcc-4.3/changes.html) shows a way to do it, via an extension to the `--help` command line option:
```
gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
```
Note, however ... |
255,429 | <p>I would like to know if it is possible to determine if a function parameter with a default value was passed in Python.
For example, how does dict.pop work?</p>
<pre><code>>>> {}.pop('test')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'pop(): dictionary is ... | [
{
"answer_id": 255433,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>You can do it like this:</p>\n\n<pre><code>def isdefarg(*args):\n if len(args) > 0:\n print len(args), \"... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24730/"
] | I would like to know if it is possible to determine if a function parameter with a default value was passed in Python.
For example, how does dict.pop work?
```
>>> {}.pop('test')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'pop(): dictionary is empty'
>>> {}.pop('test',None)
>>> ... | I guess you mean "keyword argument", when you say "named parameter". `dict.pop()` does not accept keyword argument, so this part of the question is moot.
```
>>> {}.pop('test', d=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: pop() takes no keyword arguments
```
That said, ... |
255,470 | <p>As the title describes, what are the different doctypes available and what do they mean? I notice that the layout looks a little different in IE7 when I switch from </p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
</code></pre>
<p>to</p>
<pre><code><!DOCTYPE html PUBLIC "-/... | [
{
"answer_id": 255473,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 2,
"selected": false,
"text": "<p>Here is the official explanation of the various DTD's from the W3C:</p>\n\n<p><a href=\"http://www.w3.org/QA/2002... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2849/"
] | As the title describes, what are the different doctypes available and what do they mean? I notice that the layout looks a little different in IE7 when I switch from
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
```
to
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://... | Traditionally, a **Doctype**, or **Document Type Declaration** associates the document with a **Document Type Definition**.
The **Document Type Definition** is a standard for a specific XML or SGML document. XML and SGML themselves doesn't have much of a schema or a very specific set of rules aside from how tags and a... |
255,516 | <p>I used the method</p>
<pre><code>$("#dvTheatres a").hover(function (){
$(this).css("text-decoration", "underline");
},function(){
$(this).css("text-decoration", "none");
}
);
</code></pre>
<p>Is there a more elegant method?(single line)</p>
| [
{
"answer_id": 255519,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": false,
"text": "<p>Why not just use CSS?</p>\n\n<pre><code>#dvTheatres a {\n text-decoration: none;\n}\n\n#dvTheatres a:hover {\n te... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17447/"
] | I used the method
```
$("#dvTheatres a").hover(function (){
$(this).css("text-decoration", "underline");
},function(){
$(this).css("text-decoration", "none");
}
);
```
Is there a more elegant method?(single line) | You might be having issues with other CSS rules overriding the one you want. Even if it is declared last in the file, other declarations might have more importance and hence your will be ignored. eg:
```
#myDiv .myClass a {
color: red;
}
#myDiv a {
color: blue;
}
```
Because the first rule is **more specific... |
255,517 | <p>I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL's <code>LIMIT</code> requires a limit as well as an offset. Is there any way to do this?</p>
| [
{
"answer_id": 271648,
"author": "Czimi",
"author_id": 3906,
"author_profile": "https://Stackoverflow.com/users/3906",
"pm_score": 5,
"selected": false,
"text": "<p>As you mentioned it LIMIT is required, so you need to use the biggest limit possible, which is 18446744073709551615 (maximu... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23335/"
] | I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL's `LIMIT` requires a limit as well as an offset. Is there any way to do this? | From the [MySQL Manual on LIMIT](http://dev.mysql.com/doc/refman/5.0/en/select.html#id4651990):
>
> To retrieve all rows from a certain
> offset up to the end of the result
> set, you can use some large number for
> the second parameter. This statement
> retrieves all rows from the 96th row
> to the last:
>
>
... |
255,527 | <p>Is there a practical algorithm that gives "multiplication chains"</p>
<p>To clarify, the goal is to produce a multiplication change of an <b>arbitrary and exact </b> length<br>
Multiplication chains of length 1 are trivial.</p>
<p>A "multiplication chain" would be defined as 2 numbers, {start} and {multiplier}, us... | [
{
"answer_id": 255537,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<p>Why wouldn't this satisfy the requirements?</p>\n\n<pre><code>start = constant;\nmultiplier = 1;\n</code></pre>\n\n<p>... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24404/"
] | Is there a practical algorithm that gives "multiplication chains"
To clarify, the goal is to produce a multiplication change of an **arbitrary and exact** length
Multiplication chains of length 1 are trivial.
A "multiplication chain" would be defined as 2 numbers, {start} and {multiplier}, used in code:
```
Giv... | Here is a method for computing the values for start and multiplier for the case when constant is odd:
1. Find such odd m (m = multiplier) that order of m modulo 2^D is at least count, meaning that smallest n such that m^n = 1 (mod 2^D) is at least count. I don't know any other way to find such m than to make a random ... |
255,553 | <p>I've heard that it's possible with extension methods, but I can't quite figure it out myself. I'd like to see a specific example if possible.</p>
<p>Thanks!</p>
| [
{
"answer_id": 255621,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": false,
"text": "<p>It really depends on what you mean by \"mixin\" - everyone seems to have a slightly different idea. The kind of mixin... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6408/"
] | I've heard that it's possible with extension methods, but I can't quite figure it out myself. I'd like to see a specific example if possible.
Thanks! | It really depends on what you mean by "mixin" - everyone seems to have a slightly different idea. The kind of mixin I'd *like* to see (but which isn't available in C#) is making implementation-through-composition simple:
```
public class Mixin : ISomeInterface
{
private SomeImplementation impl implements ISomeInte... |
255,571 | <p>I am having some trouble manipulating images using CodeIgniter 1.7. With the following code, the image is uploaded correctly. Alas, instead of a new image being made, and then modified; the existing image is modified. Any help?</p>
<pre><code>//Upload image first
$config['upload_path'] = './uploads/';
$config['all... | [
{
"answer_id": 255628,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is simple, you have a typo in the line:</p>\n\n<pre><code>$imagemanip['new_img'] = './uploads/'.$thumbnail;\n</code... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am having some trouble manipulating images using CodeIgniter 1.7. With the following code, the image is uploaded correctly. Alas, instead of a new image being made, and then modified; the existing image is modified. Any help?
```
//Upload image first
$config['upload_path'] = './uploads/';
$config['allowed_types'] = ... | The problem is simple, you have a typo in the line:
```
$imagemanip['new_img'] = './uploads/'.$thumbnail;
```
The the index should be "new\_image", not "new\_img", so the line becomes..
```
$imagemanip['new_image'] = './uploads/'.$thumbnail;
``` |
255,605 | <p>There are several application systems that pass messages to each other as part of their work process. Due to technical constraints revolving transactional integrity, the application data and message delivery are all committed into a single mainframe DB2 database. The messages are not directly passed to BizTalk serve... | [
{
"answer_id": 342897,
"author": "Christian Loris",
"author_id": 2574178,
"author_profile": "https://Stackoverflow.com/users/2574178",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest looking into envelope schemas to 'unwrap' the interior message from the outer message. I b... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2663/"
] | There are several application systems that pass messages to each other as part of their work process. Due to technical constraints revolving transactional integrity, the application data and message delivery are all committed into a single mainframe DB2 database. The messages are not directly passed to BizTalk server (... | Chris is correct - it seems it's only the inner part of the message you actually care about, the outer part is just an envelope.
As such I would suggest you create a disassembler which, in the receive pipeline, will strip out the envelope (you can keep it in it's entirety as a context property and/or extract some bits... |
255,612 | <p>I have a class that contains a dynamically allocated array, say</p>
<pre><code>class A
{
int* myArray;
A()
{
myArray = 0;
}
A(int size)
{
myArray = new int[size];
}
~A()
{
// Note that as per MikeB's helpful style critique, no need to check against 0.
... | [
{
"answer_id": 255625,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<ol>\n<li><p>Use array or common container for objects only if they have default and copy constructors. </p></li>\n<li><p>Stor... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] | I have a class that contains a dynamically allocated array, say
```
class A
{
int* myArray;
A()
{
myArray = 0;
}
A(int size)
{
myArray = new int[size];
}
~A()
{
// Note that as per MikeB's helpful style critique, no need to check against 0.
delete [] ... | For building containers you obviously want to use one of the standard containers (such as a std::vector). But this is a perfect example of the things you need to consider when your object contains RAW pointers.
If your object has a RAW pointer then you need to remember the rule of 3 (now the rule of 5 in C++11).
* Co... |
255,642 | <p>I have a database table named call with columns call_time, location, emergency_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection.</p>
<... | [
{
"answer_id": 255657,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 0,
"selected": false,
"text": "<p>This is a dirty way of doing this.</p>\n\n<pre><code>string select = \"SELECT call_time, location, emergency_type where cal... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I have a database table named call with columns call\_time, location, emergency\_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection.
I crea... | Well if you have to use emergency\_type as a string then instead of passing in bools you could send in a List containing the text representation of the emergency type. For example to adjust the above code you could change the method signature to
```
public static DataTable GetHistory(DateTime from, DateTime to, List<s... |
255,669 | <p>How do I enable assembly bind failure logging (Fusion) in .NET?</p>
| [
{
"answer_id": 255670,
"author": "user32736",
"author_id": 32736,
"author_profile": "https://Stackoverflow.com/users/32736",
"pm_score": 7,
"selected": false,
"text": "<p>Set the following registry value:</p>\n\n<p>[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Fusion!EnableLog] (DWORD) to 1<... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32736/"
] | How do I enable assembly bind failure logging (Fusion) in .NET? | Add the following values to
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion
Add:
DWORD ForceLog set value to 1
DWORD LogFailures set value to 1
DWORD LogResourceBinds set value to 1
DWORD EnableLog set value to 1
String LogPath set value to folder for logs (e.g. C:\FusionLog\)
```
Make sure you **include the backs... |
255,700 | <p>In my website, users have the possibility to store links.</p>
<p>During typing the internet address into the designated field I would like to display a suggest/autocomplete box similar to Google Suggest or the Chrome Omnibar.</p>
<p>Example:</p>
<p>User is typing as URL:</p>
<pre><code>http://www.sta
</code></pr... | [
{
"answer_id": 255705,
"author": "Pesto D",
"author_id": 21746,
"author_profile": "https://Stackoverflow.com/users/21746",
"pm_score": 4,
"selected": true,
"text": "<p>You could try with\n<a href=\"http://google.com/complete/search?output=toolbar&q=keyword\" rel=\"noreferrer\">http:/... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26763/"
] | In my website, users have the possibility to store links.
During typing the internet address into the designated field I would like to display a suggest/autocomplete box similar to Google Suggest or the Chrome Omnibar.
Example:
User is typing as URL:
```
http://www.sta
```
Suggestions which would be displayed:
`... | You could try with
<http://google.com/complete/search?output=toolbar&q=keyword>
and then parse the xml result. |
255,714 | <p>So I've got a Ruby method like this:</p>
<pre><code>def something(variable, &block)
....
end
</code></pre>
<p>And I want to call it like this:</p>
<pre><code>something 'hello' { do_it }
</code></pre>
<p>Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works:</p>
<pre>... | [
{
"answer_id": 255732,
"author": "seanbehan",
"author_id": 155970,
"author_profile": "https://Stackoverflow.com/users/155970",
"pm_score": 2,
"selected": false,
"text": "<p>If you want \"def something\" to to accept a block, you need to yield data to that block. For example: </p>\n\n<pre... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14873/"
] | So I've got a Ruby method like this:
```
def something(variable, &block)
....
end
```
And I want to call it like this:
```
something 'hello' { do_it }
```
Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works:
```
something 'hello' do
do_it
end
```
Except there I'm ki... | You need to parenthesize your argument:
```
something('hello') { do_it }
```
That should work. |
255,723 | <p>I'm looking to write a html sanitiser, and obviously to test/prove that it works properly, I need a set of XSS examples to pitch against it to see how it performs. Here's a <a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">nice example from Coding Horror</a></p>
<pre><code><img src... | [
{
"answer_id": 255739,
"author": "RealHowTo",
"author_id": 25122,
"author_profile": "https://Stackoverflow.com/users/25122",
"pm_score": 5,
"selected": true,
"text": "<p>Take a look at this XSS Cheat List : <a href=\"https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet\" rel=\"... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11905/"
] | I'm looking to write a html sanitiser, and obviously to test/prove that it works properly, I need a set of XSS examples to pitch against it to see how it performs. Here's a [nice example from Coding Horror](http://www.codinghorror.com/blog/archives/001167.html)
```
<img src=""http://www.a.com/a.jpg<script type=text/ja... | Take a look at this XSS Cheat List : <https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet> |
255,771 | <p>I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame.</p>
<p>Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data ... | [
{
"answer_id": 255778,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 0,
"selected": false,
"text": "<p>Normally you can use a single class or other datatype to transfer data. So the dialog is used to change the proper... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame.
Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data once the mo... | Since you are passing data once the user has closed the dialog (presumably on DialogResult.OK), you can easily do this without having a MainFrame reference.
So say you have a TextBox on your dialog, called userNameTextBox and a button that ends the dialog with the OK result. You can either make the userNameTextBox pub... |
255,797 | <p>In what areas of programming would I use state machines ? Why ? How could I implement one ?</p>
<p><strong>EDIT:</strong> please provide a practical example , if it's not too much to ask .</p>
| [
{
"answer_id": 255808,
"author": "Maxam",
"author_id": 15310,
"author_profile": "https://Stackoverflow.com/users/15310",
"pm_score": 3,
"selected": false,
"text": "<p>Most workflows can be implemented as state machines. For example, processing leave applications or orders.</p>\n\n<p>If y... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | In what areas of programming would I use state machines ? Why ? How could I implement one ?
**EDIT:** please provide a practical example , if it's not too much to ask . | In what areas of programming would I use a state machine?
---------------------------------------------------------
Use a state machine to represent a (real or logical) object that can exist in a limited number of conditions ("*states*") and progresses from one state to the next according to a fixed set of rules.
Why... |
255,800 | <p>I'm making a program which the user build directories (not in windows, in my app) and in these folders there are subfolders and so on; every folder must contain either folders or documents. What is the best data structure to use? Notice that the user may select a subfolder and search for documents in it and in its s... | [
{
"answer_id": 255828,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 3,
"selected": false,
"text": "<p>I can think of a few ways you could structure this, but nothing would beat the obvious:</p>\n\n<p><strong>Use the ac... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29276/"
] | I'm making a program which the user build directories (not in windows, in my app) and in these folders there are subfolders and so on; every folder must contain either folders or documents. What is the best data structure to use? Notice that the user may select a subfolder and search for documents in it and in its subf... | This is what I do:
Every record in the database has two fields: ID and ParentID. IDs are 4-5 characters (Base36, a-z:0-9 or something similar). Parent IDs are a concatenation of the parent's complete structure...
So...
This structure:
```
Root
Folder1
Folder2
Folder3
Folder4
Folder5
Fo... |
255,815 | <p>I have the following line:</p>
<pre><code>"14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;)"
</code></pre>
<p>I parse this by using a simple regexp:</p>
<pre><code>if($line =~ /(\d+:\d+)\ssay;(.*);(.*);(.*);(.*)/) {
my($ts, $hash, $pid, $handle, $quote) = ($1, $2, $3, $4, $5);
}
</code></pre>
<p>Bu... | [
{
"answer_id": 255827,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>Try making the first 3 <code>(.*)</code> ungreedy <code>(.*?)</code></p>\n"
},
{
"answer_id": 255832,
"author"... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33232/"
] | I have the following line:
```
"14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;)"
```
I parse this by using a simple regexp:
```
if($line =~ /(\d+:\d+)\ssay;(.*);(.*);(.*);(.*)/) {
my($ts, $hash, $pid, $handle, $quote) = ($1, $2, $3, $4, $5);
}
```
But the ; at the end messes things up and I don't k... | The greedy operator tries to grab as much stuff as it can and still match the string. What's happening is the first one (after "say") grabs "0ed673079715c343281355c2a1fde843;2", the second one takes "laka", the third finds "hello " and the fourth matches the parenthesis.
What you need to do is make all but the last on... |
255,845 | <p>I have some event handler on a boundary class that manages a persistence mechanism for a given generic transaction:</p>
<pre><code>void MyBoundaryClass::MyEventHandler(...)
{
//retrieve stuff from the UI
//...
//declare and initialize trasaction to persist
SimpleTransaction myTransaction(.../*pass down stuf... | [
{
"answer_id": 255896,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "<p>Considering that:</p>\n\n<ul>\n<li>the <a href=\"https://stackoverflow.com/questions/99688/private-vs-public-members-in-pract... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | I have some event handler on a boundary class that manages a persistence mechanism for a given generic transaction:
```
void MyBoundaryClass::MyEventHandler(...)
{
//retrieve stuff from the UI
//...
//declare and initialize trasaction to persist
SimpleTransaction myTransaction(.../*pass down stuff*/);
//do s... | Considering that:
* the [concept of encapsulation](https://stackoverflow.com/questions/99688/private-vs-public-members-in-practice-how-important-is-encapsulation#100035) is about defining a container, and
* object-oriented design is based on the concept of message passing (invocation of methods)
I would argue that th... |
255,846 | <p>I'm having a lot of issues with NSDate objects being prematurely deallocated. I suspect that the issues may be related to the way that I deal with the objects returned from NSDate convenience methods. I <em>think</em> that my showDate property declaration in the JKShow class should be "retain", but changing it to as... | [
{
"answer_id": 255875,
"author": "philsquared",
"author_id": 32136,
"author_profile": "https://Stackoverflow.com/users/32136",
"pm_score": 2,
"selected": false,
"text": "<p>The date returned from dateFromComponents should be in the autorelease pool, so you are correct that your showDate ... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28422/"
] | I'm having a lot of issues with NSDate objects being prematurely deallocated. I suspect that the issues may be related to the way that I deal with the objects returned from NSDate convenience methods. I *think* that my showDate property declaration in the JKShow class should be "retain", but changing it to assign or co... | I figured it out, thanks for all your help, but the problem was outside of the code I posted here. I was not retaining the `NSDate` I created in my init method. Unfortunatly the crash didn't occur until after I had created the two new `NSDate` objects, so I was totally barking up the wrong tree. |
255,857 | <p>I am trying to insert an image (jpg) in to a word document and the Selection.InlineShapes.AddPicture does not seem to be supported by win32old or I am doing something wrong. Has anyone had any luck inserting images. </p>
| [
{
"answer_id": 258389,
"author": "Mike Woodhouse",
"author_id": 1060,
"author_profile": "https://Stackoverflow.com/users/1060",
"pm_score": 1,
"selected": false,
"text": "<p>Running on WinXP, Ruby 1.8.6, Word 2002/XP SP3, I recorded macros and translated them, as far as I could understan... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to insert an image (jpg) in to a word document and the Selection.InlineShapes.AddPicture does not seem to be supported by win32old or I am doing something wrong. Has anyone had any luck inserting images. | You can do this by calling the Document.InlineShapes.AddPicture() method.
The following example inserts an image into the active document, before the second sentence.
```
require 'win32ole'
word = WIN32OLE.connect('Word.Application')
doc = word.ActiveDocument
image = 'C:\MyImage.jpg'
range = doc... |
255,862 | <p>Netbeans is great but there's no way to wrap text in it (or hopefully I haven't found it yet). Is there any way to do this, and if not, is there any similarly good IDE for Java with this functionality (hopefully free as well).</p>
| [
{
"answer_id": 527471,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Except Eclipse does not support word wrap either, and they even don't have set up a target for this. Just like Netbeans, th... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Netbeans is great but there's no way to wrap text in it (or hopefully I haven't found it yet). Is there any way to do this, and if not, is there any similarly good IDE for Java with this functionality (hopefully free as well). | You can use word wrap in Netbeans.
Add the following to netbeans.conf (netbeans\_installation\_path/etc/netbeans.conf, by default /etc/netbeans.conf under linux):
```
-J-Dorg.netbeans.editor.linewrap=true
```
to the sixth line so it looks like this:
```
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:... |
255,876 | <p>I want to make an MVC route for a list of news, which can be served in several formats.</p>
<ul>
<li>news -> (X)HTML</li>
<li>news.rss -> RSS</li>
<li>news.atom -> ATOM</li>
</ul>
<p>Is it possible to do this (the more general "optional extension" situation crops up in several places in my planned design) with one... | [
{
"answer_id": 255880,
"author": "Doug McClean",
"author_id": 11173,
"author_profile": "https://Stackoverflow.com/users/11173",
"pm_score": 5,
"selected": true,
"text": "<p>I made a method to support adding pairs like this as follows:</p>\n\n<pre><code>public static void MapRouteWithOpti... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11173/"
] | I want to make an MVC route for a list of news, which can be served in several formats.
* news -> (X)HTML
* news.rss -> RSS
* news.atom -> ATOM
Is it possible to do this (the more general "optional extension" situation crops up in several places in my planned design) with one route? Or do I need to make two routes li... | I made a method to support adding pairs like this as follows:
```
public static void MapRouteWithOptionalFormat(this RouteCollection routes,
string name,
string url,
object defaults... |
255,879 | <p>I need some help with WPF binding syntax:</p>
<pre><code>public class ApplicationPresenter
{
public ObservableCollection<Quotes> PriceList {get;}
}
public class WebSitePricesView
{
private IApplicationPresenter presenter
{
get { return (ApplicationPresenter)DataContext; }
}
// p... | [
{
"answer_id": 256249,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure what your problem is, the bindings (apart from the missing end quotes) appear to be fine. The following code... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30046/"
] | I need some help with WPF binding syntax:
```
public class ApplicationPresenter
{
public ObservableCollection<Quotes> PriceList {get;}
}
public class WebSitePricesView
{
private IApplicationPresenter presenter
{
get { return (ApplicationPresenter)DataContext; }
}
// public ObservableColle... | Not sure what your problem is, the bindings (apart from the missing end quotes) appear to be fine. The following code works fine for me.
```
public class Quotes
{
public string Description { get; set; }
public decimal Value { get; set; }
}
public class ApplicationPresenter
{
public ApplicationPresenter()
... |
255,898 | <p>I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of <code>$1</code> easily:</p>
<pre><code>foo $1 args -o $1.ext
</code></pre>
<p>I want to be able to pass multiple input names to the script. What's the right way to do it? </p>
<p>And, of course, I want to handle fi... | [
{
"answer_id": 255913,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 12,
"selected": true,
"text": "<p>Use <code>\"$@\"</code> to represent all the arguments:</p>\n\n<pre><code>for var in \"$@\"\ndo\n echo \"$var\... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12874/"
] | I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of `$1` easily:
```
foo $1 args -o $1.ext
```
I want to be able to pass multiple input names to the script. What's the right way to do it?
And, of course, I want to handle filenames with spaces in them. | Use `"$@"` to represent all the arguments:
```
for var in "$@"
do
echo "$var"
done
```
This will iterate over each argument and print it out on a separate line. $@ behaves like $\* except that when quoted the arguments are broken up properly if there are spaces in them:
```
sh test.sh 1 2 '3 4'
1
2
3 4
``` |
255,907 | <p>In Visual Studio 2008 in a C# WinForms project, there is a button on a form. In the properties view, the property "Font" is set to "Arial Unicode MS".</p>
<p>What do I need to put into the property "Text", so I get the unicode character \u0D15 displayed on the button?</p>
<p>When I put \u0D15 into the "Text" prope... | [
{
"answer_id": 255914,
"author": "axk",
"author_id": 578,
"author_profile": "https://Stackoverflow.com/users/578",
"pm_score": 0,
"selected": false,
"text": "<p>One possible way is to run \"charmap\" and copypaste from there or copypaste it from elsewhere.</p>\n"
},
{
"answer_id"... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33311/"
] | In Visual Studio 2008 in a C# WinForms project, there is a button on a form. In the properties view, the property "Font" is set to "Arial Unicode MS".
What do I need to put into the property "Text", so I get the unicode character \u0D15 displayed on the button?
When I put \u0D15 into the "Text" property, the button d... | You don't have to escape your unicode characters in strings as C# is inherently unicode. Just put your unicode characters as they are into the string. For example:
```
button1.Text = "日本";
``` |
255,916 | <p>I use BIRT since early days and still have riddles regarding PDF emitter. </p>
<p><strong>Short story</strong>:
Can I configure fontsConfig.xml to load fonts from relative path or from jars?</p>
<p><strong>Long story:</strong>
We are using both FOP and BIRT for generating PDF in our web application. It would be ni... | [
{
"answer_id": 21705054,
"author": "hvb",
"author_id": 2814025,
"author_profile": "https://Stackoverflow.com/users/2814025",
"pm_score": 3,
"selected": true,
"text": "<p>With some BIRT versions, you can use a SystemProperty \"birt.font.dirs\". This overrides the fontsConfig.xml.</p>\n\n<... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19347/"
] | I use BIRT since early days and still have riddles regarding PDF emitter.
**Short story**:
Can I configure fontsConfig.xml to load fonts from relative path or from jars?
**Long story:**
We are using both FOP and BIRT for generating PDF in our web application. It would be nice to share fonts between libraries. Unfort... | With some BIRT versions, you can use a SystemProperty "birt.font.dirs". This overrides the fontsConfig.xml.
Well, this once worked, but obviously it was removed from the BIRT source code later.
Now you can call something like
```java
EngineConfig engineConfig = new EngineConfig();
URL fontsConfigurationURL = new URL... |
255,941 | <p>Is there anything out there freeware or commercial that can facilitate analysis of memory usage by a PHP application? I know xdebug can produce trace files that shows memory usage by function call but without a graphical tool the data is hard to interpret. </p>
<p>Ideally I would like to be able to view not only t... | [
{
"answer_id": 255973,
"author": "Marius Or.",
"author_id": 33314,
"author_profile": "https://Stackoverflow.com/users/33314",
"pm_score": 0,
"selected": false,
"text": "<p>A graphical tool for xdebug output is <a href=\"http://kcachegrind.sourceforge.net/\" rel=\"nofollow noreferrer\">KC... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2043539/"
] | Is there anything out there freeware or commercial that can facilitate analysis of memory usage by a PHP application? I know xdebug can produce trace files that shows memory usage by function call but without a graphical tool the data is hard to interpret.
Ideally I would like to be able to view not only total memory... | As you probably know, Xdebug dropped the memory profiling support since the 2.\* version. Please search for the "removed functions" string here: <http://www.xdebug.org/updates.php>
>
> **Removed functions**
>
>
> Removed support for Memory profiling as that didn't work properly.
>
>
>
So I've tried another tool... |
255,942 | <p>I'm using Castle ActiveRecord for persistence, and I'm trying to write a base class for my persistence tests which will do the following:</p>
<ul>
<li>Open a transaction for each test case and roll it back at the end of the test case, so that I get a clean DB for each test case without me having to rebuild the sche... | [
{
"answer_id": 258313,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 1,
"selected": false,
"text": "<p>Not too sure about ActiveRecord, but in NHibernate a transaction belongs to a session, not the otherway round.</p>\n... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12006/"
] | I'm using Castle ActiveRecord for persistence, and I'm trying to write a base class for my persistence tests which will do the following:
* Open a transaction for each test case and roll it back at the end of the test case, so that I get a clean DB for each test case without me having to rebuild the schema for each te... | Not too sure about ActiveRecord, but in NHibernate a transaction belongs to a session, not the otherway round.
If you've used ADO.Net a lot, this will make more sense, as to create an `IDbTransaction` you need to use the connection. ActiveRecord's `TransactionScope` (and NHibnerate's `ITransaction`) essentially wrap a... |
255,955 | <p>Returning to WinForms in VS2008 after a long time.. Tinkering with a OOD problem in VS2008 Express Edition.</p>
<p>I need some controls to be "display only" widgets. The user should not be able to change the value of these controls... the widgets are updated by a periodic update tick event. I vaguely remember there... | [
{
"answer_id": 255965,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 5,
"selected": true,
"text": "<p>For some typical winforms controls:</p>\n\n<p><a href=\"http://jquiz.wordpress.com/2007/05/29/c-winforms-readonly-con... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | Returning to WinForms in VS2008 after a long time.. Tinkering with a OOD problem in VS2008 Express Edition.
I need some controls to be "display only" widgets. The user should not be able to change the value of these controls... the widgets are updated by a periodic update tick event. I vaguely remember there being a R... | For some typical winforms controls:
<http://jquiz.wordpress.com/2007/05/29/c-winforms-readonly-controls/>
This is also a good tip to preserve the appearance:
```
Color clr = textBox1.BackColor;
textBox1.ReadOnly = true;
textBox1.BackColor = clr;
``` |
255,969 | <p>I'm struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby's framework, I must instead write: </p>
<pre><code>class MyTest < Test::Unit::TestCase
def setup
end
def test_1
end
def test_1
end
end
</code></pre>
<p>But setup and teardown r... | [
{
"answer_id": 256063,
"author": "Rômulo Ceccon",
"author_id": 23193,
"author_profile": "https://Stackoverflow.com/users/23193",
"pm_score": 3,
"selected": false,
"text": "<p>That's how it's supposed to work!</p>\n\n<p>Each test should be completely isolated from the rest, so the <code>s... | 2008/11/01 | [
"https://Stackoverflow.com/questions/255969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8913/"
] | I'm struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby's framework, I must instead write:
```
class MyTest < Test::Unit::TestCase
def setup
end
def test_1
end
def test_1
end
end
```
But setup and teardown run for every invocation of a tes... | As mentioned in Hal Fulton's book "The Ruby Way".
He overrides the self.suite method of Test::Unit which allows the test cases in a class to run as a suite.
```
def self.suite
mysuite = super
def mysuite.run(*args)
MyTest.startup()
super
MyTest.shutdown()
end
mysuite
end
```
Here i... |
256,021 | <p>I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also... | [
{
"answer_id": 256028,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You would have to write the web page in Python. There are many Python web frameworks out there (e.g. Django) that are easy ... | 2008/11/01 | [
"https://Stackoverflow.com/questions/256021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30105/"
] | I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also crea... | Well I finally found an answer that achieved what I wanted-I did not want to learn a new language-Python is hard enough given my lack or experience
```
def OnDelete(self, event):
assert self.current, "invalid delete operation"
try:
os.remove(os.path.join(self.cwd, self.current))
``` |
256,027 | <p>I am developing an application which will be connected to Access database at the beginning and the plan is to switch to MS SQL or SQL Express in the near future. The datatables structures are same for both types of databases and I am trying to avoid duplicating the code and trying to find the way to minimize the cod... | [
{
"answer_id": 256028,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You would have to write the web page in Python. There are many Python web frameworks out there (e.g. Django) that are easy ... | 2008/11/01 | [
"https://Stackoverflow.com/questions/256027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I am developing an application which will be connected to Access database at the beginning and the plan is to switch to MS SQL or SQL Express in the near future. The datatables structures are same for both types of databases and I am trying to avoid duplicating the code and trying to find the way to minimize the code.
... | Well I finally found an answer that achieved what I wanted-I did not want to learn a new language-Python is hard enough given my lack or experience
```
def OnDelete(self, event):
assert self.current, "invalid delete operation"
try:
os.remove(os.path.join(self.cwd, self.current))
``` |
256,038 | <p>I'm using a <code>std::map</code> (VC++ implementation) and it's a little slow for lookups via the map's find method. </p>
<p>The key type is <code>std::string</code>.</p>
<p>Can I increase the performance of this <code>std::map</code> lookup via a custom key compare override for the map? For example, maybe <code>... | [
{
"answer_id": 256044,
"author": "lacker",
"author_id": 2652,
"author_profile": "https://Stackoverflow.com/users/2652",
"pm_score": 3,
"selected": false,
"text": "<p>The first thing is to try using a hash_map if that's possible - you are right that the standard string compare doesn't fir... | 2008/11/01 | [
"https://Stackoverflow.com/questions/256038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | I'm using a `std::map` (VC++ implementation) and it's a little slow for lookups via the map's find method.
The key type is `std::string`.
Can I increase the performance of this `std::map` lookup via a custom key compare override for the map? For example, maybe `std::string` < compare doesn't take into consideration ... | First, turn off all the profiling and DEBUG switches. These can slow down STL immensely.
If that's not it, part of the problem may be that your strings are identical for the first 80-90% of the string. This isn't bad for map, necessarily, but it is for string comparisons. If this is the case, your search can take much... |