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 |
|---|---|---|---|---|---|---|
367,104 | <p>In java <1.5, constants would be implemented like this</p>
<pre><code>public class MyClass {
public static int VERTICAL = 0;
public static int HORIZONTAL = 1;
private int orientation;
public MyClass(int orientation) {
this.orientation = orientation;
}
...
</code></pre>
<p>and you w... | [
{
"answer_id": 367105,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 2,
"selected": false,
"text": "<p>Did you know you can import Orientation and say </p>\n\n<pre><code>MyClass myClass = new MyClass(Orientation.VERTICAL... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26334/"
] | In java <1.5, constants would be implemented like this
```
public class MyClass {
public static int VERTICAL = 0;
public static int HORIZONTAL = 1;
private int orientation;
public MyClass(int orientation) {
this.orientation = orientation;
}
...
```
and you would use it like this:
```
M... | Don't know about Java, but in .NET the good practice is to put enums in parallel to the class that uses them, even if it is used by one class alone. That is, you would write:
```
namespace Whatever
{
enum MyEnum
{
}
class MyClass
{
}
}
```
Thus, you can use:
```
MyClass c = new MyClass(MyEnu... |
367,130 | <p>I want create a Playlist control. I have a lot of information to display into a TStringList. I want to assign a record to TStringGrid.Objects instead of an object because so many objects may take a while to create/destroy. It also take a lot of RAM.</p>
<p>A record will be much faster and slim.
How can I do that?<... | [
{
"answer_id": 367147,
"author": "Cesar Romero",
"author_id": 36875,
"author_profile": "https://Stackoverflow.com/users/36875",
"pm_score": 1,
"selected": false,
"text": "<p>you can using the record Pointer.</p>\n\n<pre><code>List.AddObject(MyRecord.FullName, @MyRecord);\n</code></pre>\n... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want create a Playlist control. I have a lot of information to display into a TStringList. I want to assign a record to TStringGrid.Objects instead of an object because so many objects may take a while to create/destroy. It also take a lot of RAM.
A record will be much faster and slim.
How can I do that?
```
TYPE
... | You can use a TList to a Pointer of your record.
Eg:
```
Type
PMyrec = ^AMyRec;
```
usage
```
var
MyRec : PMyRec;
new(MyRec);
MyRec^.Fullname := 'test';
MyRec^.RelativePath := false;
```
etc
{ MyList is a List you have create elsewhere }
```
MyList.Add(MyRec);
```
You'll have to handle disposing of it... |
367,141 | <p>Using Win32-specific APIs, is there an easy way to start an external application to open a file simply by passing in the path/name of the file?</p>
<p>For example, say I have a file called C:\tmp\image.jpg. Is there a single API that I can call to tell Windows to open the application associated with .jpg files? W... | [
{
"answer_id": 367144,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx\" rel=\"nofollow noreferrer\">ShellExecute</a... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13022/"
] | Using Win32-specific APIs, is there an easy way to start an external application to open a file simply by passing in the path/name of the file?
For example, say I have a file called C:\tmp\image.jpg. Is there a single API that I can call to tell Windows to open the application associated with .jpg files? Without havin... | [ShellExecute](http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx)
>
> Performs an operation on a specified file.
>
>
> ### Syntax
>
>
> C++
>
>
>
> ```
> HINSTANCE ShellExecute(
> _In_opt_ HWND hwnd,
> _In_opt_ LPCTSTR lpOperation,
> _In_ LPCTSTR lpFile,
> _In_opt_ LPCTSTR lpParameter... |
367,155 | <p>I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.</p>
<p>For instance:</p>
<pre><code>>>> c = "help, me"
>>> print c.split()
['help,', 'me']
</code></pre>
<p>What I really want the list to look like is:</p>
<pre><code>['help', ... | [
{
"answer_id": 367160,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried using a regex?</p>\n\n<p><a href=\"http://docs.python.org/library/re.html#re-syntax\" rel=\"nofoll... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40429/"
] | I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.
For instance:
```
>>> c = "help, me"
>>> print c.split()
['help,', 'me']
```
What I really want the list to look like is:
```
['help', ',', 'me']
```
So, I want the string split at whitespace wit... | This is more or less the way to do it:
```
>>> import re
>>> re.findall(r"[\w']+|[.,!?;]", "Hello, I'm a string!")
['Hello', ',', "I'm", 'a', 'string', '!']
```
The trick is, not to think about where to split the string, but what to include in the tokens.
Caveats:
* The underscore (\_) is considered an inner-word ... |
367,178 | <p>I think the answer to this question is so obivous that noone has bothered writing about this, but its late and I really can't get my head around this.</p>
<p>I've been reading into IoC containers (Windsor in this case) and I'm missing how you talk to the container from the various parts of your code.</p>
<p>I get ... | [
{
"answer_id": 367190,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 0,
"selected": false,
"text": "<p>I'm using an implementation of this interface:</p>\n\n<pre><code>public interface IResolver\n{\n object Resolve(Type t... | 2008/12/14 | [
"https://Stackoverflow.com/questions/367178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28543/"
] | I think the answer to this question is so obivous that noone has bothered writing about this, but its late and I really can't get my head around this.
I've been reading into IoC containers (Windsor in this case) and I'm missing how you talk to the container from the various parts of your code.
I get DI, I've been doi... | 99% of the cases it's one container instance per app. Normally you initialize it in Application\_Start (for a web app), [like this](https://github.com/castleproject/Castle.MonoRail-READONLY/blob/45ac205867396b1b7ad287a872e5b20afd0af837/src/TempWeb/Global.asax.cs).
After that, it's really up to the consumer of the cont... |
367,192 | <p>I know java and would normally put in getter/setter methods. I am interested in doing it in C# with the following code, but it throws a StackOverflow exception. What am I doing wrong?</p>
<p>Calling Code</p>
<pre><code>c.firstName = "a";
</code></pre>
<p>Property Code </p>
<pre><code>public String firstName;
{
... | [
{
"answer_id": 367195,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 8,
"selected": true,
"text": "<p>It's because you're recursively calling the property - in the <code>set</code> you are setting the property again, wh... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/673/"
] | I know java and would normally put in getter/setter methods. I am interested in doing it in C# with the following code, but it throws a StackOverflow exception. What am I doing wrong?
Calling Code
```
c.firstName = "a";
```
Property Code
```
public String firstName;
{
get
{
return firstName;
}... | It's because you're recursively calling the property - in the `set` you are setting the property again, which continues *ad infinitum* until you blow the stack.
You need a private backing field to hold the value, e.g.
```
private string firstName;
public string FirstName
{
get
{
return this.firstName... |
367,201 | <p>I need to intercept the console output stream(s) in order to capture it for a log but still pass things through to the original stream so the application works properly. This obviously means storing the original <code>Console.Out</code> TextWriter before changing it with <code>Console.SetOut(new MyTextWriterClass(o... | [
{
"answer_id": 367428,
"author": "devstuff",
"author_id": 41321,
"author_profile": "https://Stackoverflow.com/users/41321",
"pm_score": 0,
"selected": false,
"text": "<p>If you can do this early in <code>Main()</code> you'll have a much better chance of avoiding any race conditions, espe... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/181460/"
] | I need to intercept the console output stream(s) in order to capture it for a log but still pass things through to the original stream so the application works properly. This obviously means storing the original `Console.Out` TextWriter before changing it with `Console.SetOut(new MyTextWriterClass(originalOut))`.
I as... | If you look at the implementation for SetOut it looks thread safe to me:
```
[HostProtection(SecurityAction.LinkDemand, UI=true)]
public static void SetOut(TextWriter newOut)
{
if (newOut == null)
{
throw new ArgumentNullException("newOut");
}
new SecurityPermission(SecurityPermissionFlag.Unman... |
367,213 | <p>Is there a way to find the HTML element on the page that a Silverlight control is hosted in from within Silverlight?</p>
| [
{
"answer_id": 367427,
"author": "msingleton",
"author_id": 46184,
"author_profile": "https://Stackoverflow.com/users/46184",
"pm_score": 0,
"selected": false,
"text": "<p>Use firefox and install <a href=\"https://addons.mozilla.org/en-US/firefox/addon/1843\" rel=\"nofollow noreferrer\">... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11829/"
] | Is there a way to find the HTML element on the page that a Silverlight control is hosted in from within Silverlight? | Use this:
```
System.Windows.Browser.HtmlElement plugin = System.Windows.Browser.HtmlPage.Plugin;
``` |
367,214 | <p>Consider two web pages with the following in their body respectively:</p>
<pre><code><body>
<script>
document.writeln('<textarea></textarea>')
</script>
</body>
</code></pre>
<p>and</p>
<pre><code><body>
<script>
var t = document.createElement('textarea');
document.... | [
{
"answer_id": 367358,
"author": "Chase Seibert",
"author_id": 7679,
"author_profile": "https://Stackoverflow.com/users/7679",
"pm_score": 4,
"selected": true,
"text": "<p>I believe the document.write version actually blows away an existing content on the page. Ie, the body and script ta... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4958/"
] | Consider two web pages with the following in their body respectively:
```
<body>
<script>
document.writeln('<textarea></textarea>')
</script>
</body>
```
and
```
<body>
<script>
var t = document.createElement('textarea');
document.body.appendChild(t);
</script>
</body>
```
(think of them as part of something larg... | I believe the document.write version actually blows away an existing content on the page. Ie, the body and script tags will no longer be there. That is why people usually use appendChild.
Keeping the text or not is very browser specific. I wouldn't bet that Firefox would not change it's behavior on that in a future ve... |
367,225 | <p>I found this in an error log and am trying to work out how it's possible. It's not every day that a NullReferenceException turns up deep within the .net base classes!</p>
<pre><code>1) Exception Information
*********************************************
Exception Type: System.NullReferenceException
Message: Object r... | [
{
"answer_id": 367237,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<p>I'm guessing that disposing the dataset invalidates the table that it contains!</p>\n\n<p>BTW you don't need the d... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8479/"
] | I found this in an error log and am trying to work out how it's possible. It's not every day that a NullReferenceException turns up deep within the .net base classes!
```
1) Exception Information
*********************************************
Exception Type: System.NullReferenceException
Message: Object reference not s... | >
> Could a multi-thread scenario cause this exception
>
>
>
Instance methods of ADO.NET classes (e.g. SqlCommand) are generally not thread-safe.
So if you are using such instances from multiple threads, you can expect problems such as the one you describe. |
367,262 | <p>I need to make some commits using Git but I would like the timestamp in git-log to be in the future.</p>
<p>How can I do a commit in git that causes a future timestamp to register in the git-log?</p>
| [
{
"answer_id": 367419,
"author": "msingleton",
"author_id": 46184,
"author_profile": "https://Stackoverflow.com/users/46184",
"pm_score": -1,
"selected": false,
"text": "<p>May I ask why you would want to do this? </p>\n\n<p>If you don't want to change your clock, I would suggest creatin... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to make some commits using Git but I would like the timestamp in git-log to be in the future.
How can I do a commit in git that causes a future timestamp to register in the git-log? | You should wait a bit.
Or you can do this:
```
/tmp/x 604% env GIT_AUTHOR_DATE='Wed Dec 19 15:14:05 2029 -0800' git commit -m 'future!'
[master]: created 6348548: "Future!"
1 files changed, 1 insertions(+), 0 deletions(-)
/tmp/x 605% git log
Author: Dustin Sallings <dustin@spy.net>
Date: Wed Dec 19 15:14:05 202... |
367,276 | <p>I seem to not understand two OOP concepts very well. Could you explain what <strong>abstraction</strong> and <strong>polymorphism</strong> are, preferably with real examples and code?</p>
<p>Thank you.</p>
| [
{
"answer_id": 367284,
"author": "orion3",
"author_id": 34134,
"author_profile": "https://Stackoverflow.com/users/34134",
"pm_score": -1,
"selected": false,
"text": "<p>very easy.</p>\n\n<ol>\n<li><p>Abstraction is abstraction. Class 'Student' is an abstraction of a real student.</p></li... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1602746/"
] | I seem to not understand two OOP concepts very well. Could you explain what **abstraction** and **polymorphism** are, preferably with real examples and code?
Thank you. | Abstraction
-----------
Imagine a fraction class:
```
class fraction:
int denominator
int numerator
```
Now two objects of that:
```
fraction(obj1): denominator=-1 numerator=-1
fraction(obj2): denominator=1 numerator=1
```
Both objects have the value 1: `(1/1) == (-1)/(-1)`. You wouldn't expect they beh... |
367,282 | <p>I have a content management application in the root of my website, and I'm trying to use a different app (a billing application) under a sub-folder. Unfortunately, the web.config of the root site is interfering with the sub-app.</p>
<p>Is there a way to just disable web.config inheritance for a sub-folder?</p>
<p>... | [
{
"answer_id": 367372,
"author": "devstuff",
"author_id": 41321,
"author_profile": "https://Stackoverflow.com/users/41321",
"pm_score": 3,
"selected": false,
"text": "<p>I would explicitly define all of the settings required - never assume that any setting is still set to the default val... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23276/"
] | I have a content management application in the root of my website, and I'm trying to use a different app (a billing application) under a sub-folder. Unfortunately, the web.config of the root site is interfering with the sub-app.
Is there a way to just disable web.config inheritance for a sub-folder?
**Update:**
As li... | There is an attribute that you can use in the root web.config file to cause it not to have its contents become inherited by child applications.
inheritInChildApplications
[Blog about inheritInChildApplications](http://www.kowitz.net/archive/2007/05/16/stopping-asp.net-web.config-inheritance.aspx)
[MSDN article on AS... |
367,308 | <p>I'm working on a project where there is a lot of external service messaging. A good way to describe it in only a slightly "hyperbolas" way would be an application where the system has to send messages to the Flicker API, the Facebook API, and the Netflix API.</p>
<p>To support disconnected scenarios, logging concer... | [
{
"answer_id": 367451,
"author": "Hamish Smith",
"author_id": 15572,
"author_profile": "https://Stackoverflow.com/users/15572",
"pm_score": 2,
"selected": false,
"text": "<p>I think you may need to clarify your question. \nI'm unclear as to whether you are talking about using test double... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] | I'm working on a project where there is a lot of external service messaging. A good way to describe it in only a slightly "hyperbolas" way would be an application where the system has to send messages to the Flicker API, the Facebook API, and the Netflix API.
To support disconnected scenarios, logging concerns, develo... | There is a design pattern called Null Object. A null object is an object that implements a Interface, so it could be used in an scenario like yours.
The important thing about the Null Object is that DON'T return null in places where that could break the system.
The purpose of the Null Object is to have a void and s... |
367,310 | <p>I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting... | [
{
"answer_id": 367312,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 0,
"selected": false,
"text": "<p>Surely it would depend on whether you have a reasonable expectation of memory becoming available in the 100 (millise... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | There are a few different ways to attack this - note that the tool instructions will vary a bit, based on what version of Windows CE / Windows Mobile you are using.
Some questions to answer:
**1. Is your application leaking memory, leading to this low memory condition?**
**2. Does your application simply use too mu... |
367,325 | <p>Here is an interesting piece of code that my fellow team members were just having a slightly heated discussion about...</p>
<pre><code> Dim fred As Integer
If True Then fred = 5 : fred = 3 : fred = 6 Else fred = 4 : fred = 2 : fred = 1
</code></pre>
<p>After executing the above code snippet, what is the value ... | [
{
"answer_id": 367342,
"author": "user21826",
"author_id": 21826,
"author_profile": "https://Stackoverflow.com/users/21826",
"pm_score": 0,
"selected": false,
"text": "<p>Just a guess</p>\n\n<p>fred = 6 because you can have multiple statements on the same line separated by a colon.</p>\n... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19377/"
] | Here is an interesting piece of code that my fellow team members were just having a slightly heated discussion about...
```
Dim fred As Integer
If True Then fred = 5 : fred = 3 : fred = 6 Else fred = 4 : fred = 2 : fred = 1
```
After executing the above code snippet, what is the value of *fred*?
Try not to che... | I'm assuming you mean VB.Net.
According to the grammar in the VB Language spec, which you can read here:
<http://www.microsoft.com/Downloads/thankyou.aspx?familyId=39de1dd0-f775-40bf-a191-09f5a95ef500&displayLang=en>
The result should be "6".
This is because the grammar for a "line if statement" is:
```
If Boolea... |
367,328 | <p>I received a dump file of a SVN repository that I'm moving to my server. Let's call it myserver.com/svn. The load statement prints out a long list of files loaded and reports no error. However, once I try to access the repository for checkout, or relocate my existing checkout, I'm told:</p>
<pre><code>Repository... | [
{
"answer_id": 367351,
"author": "BenB",
"author_id": 11703,
"author_profile": "https://Stackoverflow.com/users/11703",
"pm_score": 0,
"selected": false,
"text": "<p>I think someone has added a hook script to inform you that your repository is now at another URL.</p>\n\n<p>If this was no... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28565/"
] | I received a dump file of a SVN repository that I'm moving to my server. Let's call it myserver.com/svn. The load statement prints out a long list of files loaded and reports no error. However, once I try to access the repository for checkout, or relocate my existing checkout, I'm told:
```
Repository moved temporaril... | subversion generates a UUID (Universally Unique ID) whenever it creates a repository. I believe that in order to use the UUID from your original repo you need to ad "--force-uuid" to your svnadmin load command.
<http://svnbook.red-bean.com/en/1.5/svn.ref.svnadmin.c.load.html> |
367,343 | <p>I have the following code:</p>
<pre><code>abstract class AbstractParent {
function __construct($param) { print_r($param); }
public static function test() { return new self(1234); }
}
class SpecificClass extends AbstractParent {}
</code></pre>
<p>When I invoke <code>SpecificClass::test()</code>, I am getting an ... | [
{
"answer_id": 367350,
"author": "dave mankoff",
"author_id": 10093,
"author_profile": "https://Stackoverflow.com/users/10093",
"pm_score": 2,
"selected": false,
"text": "<p>You can do it in PHP 5.3, which is still in alpha. What you're looking for is called Late-Static-Binding. You want... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45652/"
] | I have the following code:
```
abstract class AbstractParent {
function __construct($param) { print_r($param); }
public static function test() { return new self(1234); }
}
class SpecificClass extends AbstractParent {}
```
When I invoke `SpecificClass::test()`, I am getting an error:
```
Fatal error: Cannot insta... | You can do it in PHP 5.3, which is still in alpha. What you're looking for is called Late-Static-Binding. You want the parent class to refer to the child class in a static method. You can't do it yet, but it's coming...
Edit: You can find more info here - <http://www.php.net/manual/en/language.oop5.late-static-binding... |
367,349 | <p>How do you submit from a dropdownlist "onchange" event from inside of an ajax form?</p>
<p>According to the following question: <a href="https://stackoverflow.com/questions/364505/how-do-you-submit-a-dropdownlist-in-aspnet-mvc">How do you submit a dropdownlist in asp.net mvc</a>, from inside of an Html.BeginFrom yo... | [
{
"answer_id": 367401,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 2,
"selected": false,
"text": "<p>What you can try to do it this (jQuery required):</p>\n\n<pre><code>$(\"#yourDropdown\").change(function() {\n var f = $... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you submit from a dropdownlist "onchange" event from inside of an ajax form?
According to the following question: [How do you submit a dropdownlist in asp.net mvc](https://stackoverflow.com/questions/364505/how-do-you-submit-a-dropdownlist-in-aspnet-mvc), from inside of an Html.BeginFrom you can set onchange="t... | OK, nearly 2 years later, you probably don't care anymore. Who knows: Maybe others (such as me ;-) do.
So here's the (extremely simple) solution:
In your `Html.DropDownList(...)` call, change
```
new { onchange = "this.form.submit()" }
```
to
```
new { onchange = "this.form.onsubmit()" }
```
Can you spot the d... |
367,368 | <p>Is it possible to set a symbol for conditional compilation by setting up properties in an Xcode project?</p>
<p>My aim is to to create a symbol that is available to all files, without having to use import/include, so that a set of common classes can have a special behavior in some projects. Like the following, but ... | [
{
"answer_id": 367430,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 8,
"selected": true,
"text": "<p>Go to your Target or Project settings, click the Gear icon at the bottom left, and select \"Add User-Defined Setting\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] | Is it possible to set a symbol for conditional compilation by setting up properties in an Xcode project?
My aim is to to create a symbol that is available to all files, without having to use import/include, so that a set of common classes can have a special behavior in some projects. Like the following, but with my ow... | Go to your Target or Project settings, click the Gear icon at the bottom left, and select "Add User-Defined Setting". The new setting name should be `GCC_PREPROCESSOR_DEFINITIONS`, and you can type your definitions in the right-hand field.
Per Steph's comments, the full syntax is:
```
constant_1=VALUE constant_2=VALU... |
367,377 | <p>Suppose you have a software package. You want to make it a gem, because gems are the de facto standard way to distribute anything in the Ruby world. Gems are great -- for libraries. But for real applications, the Rubygems system seems lacking. Only "recently" did they introduce a way to mark executables to be pl... | [
{
"answer_id": 367430,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 8,
"selected": true,
"text": "<p>Go to your Target or Project settings, click the Gear icon at the bottom left, and select \"Add User-Defined Setting\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28558/"
] | Suppose you have a software package. You want to make it a gem, because gems are the de facto standard way to distribute anything in the Ruby world. Gems are great -- for libraries. But for real applications, the Rubygems system seems lacking. Only "recently" did they introduce a way to mark executables to be placed in... | Go to your Target or Project settings, click the Gear icon at the bottom left, and select "Add User-Defined Setting". The new setting name should be `GCC_PREPROCESSOR_DEFINITIONS`, and you can type your definitions in the right-hand field.
Per Steph's comments, the full syntax is:
```
constant_1=VALUE constant_2=VALU... |
367,378 | <p>I'm creating my own dictionary and I am having trouble implementing the <a href="http://msdn.microsoft.com/en-us/library/ms132143(VS.85).aspx" rel="noreferrer">TryGetValue</a> function. When the key isn't found, I don't have anything to assign to the out parameter, so I leave it as is. This results in the followin... | [
{
"answer_id": 367380,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 3,
"selected": false,
"text": "<pre><code>return default(int);\n\nreturn default(bool);\n\nreturn default(MyObject);\n</code></pre>\n\n<p>so in your case y... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4891/"
] | I'm creating my own dictionary and I am having trouble implementing the [TryGetValue](http://msdn.microsoft.com/en-us/library/ms132143(VS.85).aspx) function. When the key isn't found, I don't have anything to assign to the out parameter, so I leave it as is. This results in the following error: "The out parameter 'valu... | You are looking for the [`default`](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/default-value-expressions) keyword.
For example, in the example you gave, you want something like:
```
class MyEmptyDictionary<K, V> : IDictionary<K, V>
{
bool IDictionary<K, V>.T... |
367,379 | <p>This issue is driving me mad.</p>
<p>I have several tables defined, and CRUD stored procs for those tables. I have wired up the stored procs to the tables in Visual Studio using the dbml mapper. </p>
<p>All work fine, except for one table. The insert stored proc is not being hit for my history table.</p>
<p>The i... | [
{
"answer_id": 367478,
"author": "tdavisjr",
"author_id": 32586,
"author_profile": "https://Stackoverflow.com/users/32586",
"pm_score": 0,
"selected": false,
"text": "<p>Did you manually wired up your sproc to your table in the .dbml file? If you select a table a in the property grid yo... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29830/"
] | This issue is driving me mad.
I have several tables defined, and CRUD stored procs for those tables. I have wired up the stored procs to the tables in Visual Studio using the dbml mapper.
All work fine, except for one table. The insert stored proc is not being hit for my history table.
The insert property in the ta... | Ok, this is unbelievable but... the app already had a page called history.aspx. VB defaulted to the history class for that page, rather than the db.History class used by LinQ.
Once I renamed history.aspx, everything worked! :) |
367,400 | <p>Lately I've been seeing a lot of talk regarding PHP's lack of late static binding until 5.3. </p>
<p>From what I've read proper implementations of stuff like ActiveRecord are not possible until the language has this feature.</p>
<p>So, I'm curious about:</p>
<ul>
<li>Which languages do support it,
specifically th... | [
{
"answer_id": 367410,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": "<p>I completely misunderstood the what late static binding is. Here's what <a href=\"http://en.wikipedia.org/wiki/Nam... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41111/"
] | Lately I've been seeing a lot of talk regarding PHP's lack of late static binding until 5.3.
From what I've read proper implementations of stuff like ActiveRecord are not possible until the language has this feature.
So, I'm curious about:
* Which languages do support it,
specifically those commonly
associated with... | If you want a work around, that admittedly is a little time consuming, yet will be easily removed when php 5.3 becomes available and mainstreamed, you can try the following code.
```
class Specific_Model extends Model{
public static function GetAll($options = null){
parent::GetAll($options, get_class());... |
367,426 | <p>This is a total newbie question, so thanks in advance. I'm trying to get my head around the difference between divs and spans, and when and how to use them.</p>
<p>Say for instance, I want to have an image left justified, and I want the text to flow around the image on the right, while maintaining justification. If... | [
{
"answer_id": 367434,
"author": "Elle H",
"author_id": 23666,
"author_profile": "https://Stackoverflow.com/users/23666",
"pm_score": 2,
"selected": false,
"text": "<p>Block level means basically that it starts on its own line by default, whereas inline sits beside other elements.</p>\n\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39781/"
] | This is a total newbie question, so thanks in advance. I'm trying to get my head around the difference between divs and spans, and when and how to use them.
Say for instance, I want to have an image left justified, and I want the text to flow around the image on the right, while maintaining justification. If the text ... | A SPAN tag is not intended to be a container for other tags. This is especially useful when combined with classes.
Use divs for defining sections of a page, and spans to enclose and style text or classes of text.
<http://www.learnwebdesignonline.com/htmlcourse/span-div.htm> shows a good example of how they are used.... |
367,440 | <p>I want to create an associative array:</p>
<pre><code>var aa = {} // Equivalent to Object(), new Object(), etc...
</code></pre>
<p>And I want to be sure that any key I access is going to be a number:</p>
<pre><code>aa['hey'] = 4.3;
aa['btar'] = 43.1;
</code></pre>
<p>I know JavaScript doesn't have typing, so I can't... | [
{
"answer_id": 367453,
"author": "Moss Collum",
"author_id": 13210,
"author_profile": "https://Stackoverflow.com/users/13210",
"pm_score": 2,
"selected": false,
"text": "<p>One possibility would be to use hasOwnProperty to check that the key is something you explicitly added to the array... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | I want to create an associative array:
```
var aa = {} // Equivalent to Object(), new Object(), etc...
```
And I want to be sure that any key I access is going to be a number:
```
aa['hey'] = 4.3;
aa['btar'] = 43.1;
```
I know JavaScript doesn't have typing, so I can't automatically check this, but I can ensure i... | This may work for you:
```
function getValue(id){
return (!isNaN(aa[id])) ? aa[id] : undefined;
}
```
Alternatively, I recommend this generic solution:
```
function getValue(hash,key) {
return Object.prototype.hasOwnProperty.call(hash,key) ? hash[key] : undefined;
}
```
Note the following: The key will inte... |
367,442 | <p>I've been trying to use Zsh within my emacs session, without emacs remapping all the Zsh keys. I found ansi-term works pretty well for this but, I'm still having some problems. I was getting lots of junk characters outputted with, I was able to fix it with:</p>
<pre><code>## Setup proper term information for emacs ... | [
{
"answer_id": 367456,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Hmmm. I don't think I've ever seen any fancy editing work out well within ansi-term, although I haven't tried i... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been trying to use Zsh within my emacs session, without emacs remapping all the Zsh keys. I found ansi-term works pretty well for this but, I'm still having some problems. I was getting lots of junk characters outputted with, I was able to fix it with:
```
## Setup proper term information for emacs ansi-term mode... | Try [MultiTerm](http://www.emacswiki.org/emacs/MultiTerm).
Its the only Emacs terminal mode that seems to play nice with zsh. It allows you to easily set which commands you want captured by emacs and which you want routed to the terminal. The default settings have been good enough for me so far though.
Also, add the ... |
367,444 | <p>I need to show an object in PropertyGrid with the following requirements: the object and its sub object must be read-only, able to activate PropertyGrid's CollectionEditors.</p>
<p>I found a sample that's closely match to what I need but there's an unexpected behaviour I couldn't figure out. I have more than one Pr... | [
{
"answer_id": 367456,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Hmmm. I don't think I've ever seen any fancy editing work out well within ansi-term, although I haven't tried i... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to show an object in PropertyGrid with the following requirements: the object and its sub object must be read-only, able to activate PropertyGrid's CollectionEditors.
I found a sample that's closely match to what I need but there's an unexpected behaviour I couldn't figure out. I have more than one PropertyGrid... | Try [MultiTerm](http://www.emacswiki.org/emacs/MultiTerm).
Its the only Emacs terminal mode that seems to play nice with zsh. It allows you to easily set which commands you want captured by emacs and which you want routed to the terminal. The default settings have been good enough for me so far though.
Also, add the ... |
367,448 | <p>I'm using the following code within a VB 6.0 application to allow give the application a system tray icon:</p>
<pre><code>Option Explicit
'user defined type required by Shell_NotifyIcon API call
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Lon... | [
{
"answer_id": 367463,
"author": "JFV",
"author_id": 1391,
"author_profile": "https://Stackoverflow.com/users/1391",
"pm_score": 4,
"selected": true,
"text": "<p>This is what I use when I am closing my programs for the Query_Unload:</p>\n\n<pre><code>Private Sub Form_QueryUnload(Cancel A... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46249/"
] | I'm using the following code within a VB 6.0 application to allow give the application a system tray icon:
```
Option Explicit
'user defined type required by Shell_NotifyIcon API call
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As ... | This is what I use when I am closing my programs for the Query\_Unload:
```
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case 1, 2, 3 'If the program is being terminated by Code, Windows shutting down, or Task Manager
Cancel = False 'Allow the pr... |
367,457 | <p>I have a list of objects implementing an interface, and a list of that interface:</p>
<pre><code>public interface IAM
{
int ID { get; set; }
void Save();
}
public class concreteIAM : IAM
{
public int ID { get; set; }
internal void Save(){
//save the object
}
//other staff for this ... | [
{
"answer_id": 367464,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 3,
"selected": false,
"text": "<p>I don't think you should be using an interface here. Maybe you should be using an abstract base, something like:</p>\n<p... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a list of objects implementing an interface, and a list of that interface:
```
public interface IAM
{
int ID { get; set; }
void Save();
}
public class concreteIAM : IAM
{
public int ID { get; set; }
internal void Save(){
//save the object
}
//other staff for this particular cla... | I think you don't understand what an interface is for. Interface is a **contract**. It specifies that an object behaves in a certain way. If an object implements an interface, it means that you can rely on it that it has all the interface's methods implemented.
Now, consider what would happen if there was an interface... |
367,461 | <p>I've factored out common attributes from two classes into an abstract base class, however I have another model that needs to reference either one of those classes. It's not possible to reference an ABC as it doesn't actually have a database table.</p>
<p>The following example should illustrate my problem:</p>
<pre... | [
{
"answer_id": 367479,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 3,
"selected": false,
"text": "<p>My gut would be to suggest removing the abstract modifier on the base class. You'll get the same model structure, ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10583/"
] | I've factored out common attributes from two classes into an abstract base class, however I have another model that needs to reference either one of those classes. It's not possible to reference an ABC as it doesn't actually have a database table.
The following example should illustrate my problem:
```
class Answer(m... | A [generic relation](https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations) seems to be the solution. But it will complicate things even further.
It seems to me; your model structure is already more complex than necessary. I would simply merge all three `Answer` models into one. This way:
... |
367,471 | <p>In the clocks application, the timer screen shows a picker (probably a <code>UIPicker</code> in <code>UIDatePickerModeCountDownTimer</code> mode) with some text in the selection bar ("hours" and "mins" in this case).</p>
<p>(edit) Note that these labels are <strong>fixed</strong>: They don't move when the picker wh... | [
{
"answer_id": 367763,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": 2,
"selected": false,
"text": "<p>There are 2 things you can do:</p>\n\n<p>If each row and component in row is a simple text, than you can simply use the ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42690/"
] | In the clocks application, the timer screen shows a picker (probably a `UIPicker` in `UIDatePickerModeCountDownTimer` mode) with some text in the selection bar ("hours" and "mins" in this case).
(edit) Note that these labels are **fixed**: They don't move when the picker wheel is rolling.
Is there a way to show such ... | Create your picker, create a label with a shadow, and push it to a picker's subview below the selectionIndicator view.
It would look something like this
```
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(135, 93, 80, 30)] autorelease];
label.text = @"Label";
label.font = [UIFont boldSystemFontOfSize:20... |
367,494 | <p>I'm attempting to map a set of key presses to a set of commands. Because I process the commands from several places, I'd like to set up a layer of abstraction between the keys and the commands so that if I change the underlying key mappings, I don't have to change very much code. My current attempt looks like this... | [
{
"answer_id": 367521,
"author": "fasih.rana",
"author_id": 46024,
"author_profile": "https://Stackoverflow.com/users/46024",
"pm_score": 0,
"selected": false,
"text": "<p>Is there a comparison operator defined for the \"LogicalMappings\"? If not then that is the error.</p>\n"
},
{
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19491/"
] | I'm attempting to map a set of key presses to a set of commands. Because I process the commands from several places, I'd like to set up a layer of abstraction between the keys and the commands so that if I change the underlying key mappings, I don't have to change very much code. My current attempt looks like this:
``... | Array references aren't "constant enough", regardless.
You just need to do the mapping slightly differently. You want the same action to occur when the logical key is pressed, so use the logical key codes in the `case` clauses of the `switch` statement. Then map the actual key code to the logical code, possibly in the... |
367,518 | <p>This should be straight forward for a guru. I don't have any code really written out, just a couple of controllers and a custom UIView. All connected through nibs. The app loads without crashing, yet I can't see my NSLog() hit from my custom UIView.</p>
<p>My application delegate has default template code which cal... | [
{
"answer_id": 367668,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": 4,
"selected": true,
"text": "<p>First of all, when a view is dehydrated from nib file, instead of <code>initWithFrame</code>, <code>initWithCoder</code> ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | This should be straight forward for a guru. I don't have any code really written out, just a couple of controllers and a custom UIView. All connected through nibs. The app loads without crashing, yet I can't see my NSLog() hit from my custom UIView.
My application delegate has default template code which calls for a c... | First of all, when a view is dehydrated from nib file, instead of `initWithFrame`, `initWithCoder` is invoked. So you need to implement your initialization in `initWithCoder` as well. (It may be a good idea to keep the `initWithFrame` initialization as well, if you anticipate programmatically creating your TabView inst... |
367,523 | <p>I would like to ensure that I only subscribe once in a particular class for an event on an instance.</p>
<p>For example I would like to be able to do the following:</p>
<pre><code>if (*not already subscribed*)
{
member.Event += new MemeberClass.Delegate(handler);
}
</code></pre>
<p>How would I go about implem... | [
{
"answer_id": 367541,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 2,
"selected": false,
"text": "<p>You would either need to store a separate flag indicating whether or not you'd subscribed or, if you have control... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40444/"
] | I would like to ensure that I only subscribe once in a particular class for an event on an instance.
For example I would like to be able to do the following:
```
if (*not already subscribed*)
{
member.Event += new MemeberClass.Delegate(handler);
}
```
How would I go about implementing such a guard? | If you are talking about an event on a class that you have access to the source for then you could place the guard in the event definition.
```
private bool _eventHasSubscribers = false;
private EventHandler<MyDelegateType> _myEvent;
public event EventHandler<MyDelegateType> MyEvent
{
add
{
if (_myEvent ... |
367,545 | <p>Is there an equivalent of <a href="http://www.php.net/manual/en/function.get-defined-functions.php" rel="noreferrer"><code>get_defined_functions()</code></a> which only shows the functions of a given object?</p>
<p>Example usage and output:</p>
<pre><code>class A {
function foo() { }
function bar() { }
}
c... | [
{
"answer_id": 367546,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 4,
"selected": false,
"text": "<p>Ah I found it:</p>\n\n<p><a href=\"http://www.php.net/manual/en/function.get-class-methods.php\" rel=\"noreferrer\"><code>g... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Is there an equivalent of [`get_defined_functions()`](http://www.php.net/manual/en/function.get-defined-functions.php) which only shows the functions of a given object?
Example usage and output:
```
class A {
function foo() { }
function bar() { }
}
class B extends A {
function foobar() { }
}
$b = new B();... | Ah I found it:
[`get_class_methods()`](http://www.php.net/manual/en/function.get-class-methods.php) |
367,560 | <p>I'm interested in how much up front validation people do in the Python they write.</p>
<p>Here are a few examples of simple functions:</p>
<pre><code>def factorial(num):
"""Computes the factorial of num."""
def isPalindrome(inputStr):
"""Tests to see if inputStr is the same backwards and forwards."""
def... | [
{
"answer_id": 367568,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 2,
"selected": false,
"text": "<p>I basically try to convert the variable to what it should be and pass up or throw the appropriate exception if th... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I'm interested in how much up front validation people do in the Python they write.
Here are a few examples of simple functions:
```
def factorial(num):
"""Computes the factorial of num."""
def isPalindrome(inputStr):
"""Tests to see if inputStr is the same backwards and forwards."""
def sum(nums):
"""Sa... | For calculations like sum, factorial etc, pythons built-in type checks will do fine. The calculations will end upp calling **add**, **mul** etc for the types, and if they break, they will throw the correct exception anyway. By enforcing your own checks, you may invalidate otherwise working input. |
367,565 | <p>How can I build a numpy array out of a generator object?</p>
<p>Let me illustrate the problem:</p>
<pre><code>>>> import numpy
>>> def gimme():
... for x in xrange(10):
... yield x
...
>>> gimme()
<generator object at 0x28a1758>
>>> list(gimme())
[0, 1, 2, 3, 4, 5, 6... | [
{
"answer_id": 367599,
"author": "shsmurfy",
"author_id": 2188962,
"author_profile": "https://Stackoverflow.com/users/2188962",
"pm_score": 8,
"selected": true,
"text": "<p>Numpy arrays require their length to be set explicitly at creation time, unlike python lists. This is necessary so ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] | How can I build a numpy array out of a generator object?
Let me illustrate the problem:
```
>>> import numpy
>>> def gimme():
... for x in xrange(10):
... yield x
...
>>> gimme()
<generator object at 0x28a1758>
>>> list(gimme())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> numpy.array(xrange(10))
array([0, 1, 2, 3, 4, 5,... | Numpy arrays require their length to be set explicitly at creation time, unlike python lists. This is necessary so that space for each item can be consecutively allocated in memory. Consecutive allocation is the key feature of numpy arrays: this combined with native code implementation let operations on them execute mu... |
367,571 | <p>I have written a simple <a href="http://en.wikipedia.org/wiki/Brainfuck" rel="noreferrer">brainfuck</a> interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number o... | [
{
"answer_id": 367574,
"author": "dancavallaro",
"author_id": 42891,
"author_profile": "https://Stackoverflow.com/users/42891",
"pm_score": 6,
"selected": false,
"text": "<p>Alan Turing would like to have a word with you.</p>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Halting_problem\"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8127/"
] | I have written a simple [brainfuck](http://en.wikipedia.org/wiki/Brainfuck) interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets ... | When I used linear genetic programming, I just used an upper bound for the number of instructions a single program was allowed to do in its lifetime. I think that this is sensible in two ways: I cannot really solve the halting problem anyway, and programs that take too long to compute are not worthy of getting more tim... |
367,577 | <p>When you have code like the following: </p>
<pre><code>static T GenericConstruct<T>() where T : new()
{
return new T();
}
</code></pre>
<p>The C# compiler insists on emitting a call to Activator.CreateInstance, which is considerably slower than a native constructor. </p>
<p>I have the following workarou... | [
{
"answer_id": 367643,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>I <em>suspect</em> it's a JITting problem. Currently, the JIT reuses the same generated code for all reference type a... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46267/"
] | When you have code like the following:
```
static T GenericConstruct<T>() where T : new()
{
return new T();
}
```
The C# compiler insists on emitting a call to Activator.CreateInstance, which is considerably slower than a native constructor.
I have the following workaround:
```
public static class Parameterl... | I *suspect* it's a JITting problem. Currently, the JIT reuses the same generated code for all reference type arguments - so a `List<string>`'s vtable points to the same machine code as that of `List<Stream>`. That wouldn't work if each `new T()` call had to be resolved in the JITted code.
Just a guess, but it makes a ... |
367,586 | <p>I need to generate random text strings of a particular format. Would like some ideas so that I can code it up in Python. The format is <8 digit number><15 character string>. </p>
| [
{
"answer_id": 367594,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "<p>See an example - <a href=\"http://code.activestate.com/recipes/59873/\" rel=\"noreferrer\">Recipe 59873: Random Password Ge... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] | I need to generate random text strings of a particular format. Would like some ideas so that I can code it up in Python. The format is <8 digit number><15 character string>. | ```
#!/usr/bin/python
import random
import string
digits = "".join( [random.choice(string.digits) for i in xrange(8)] )
chars = "".join( [random.choice(string.letters) for i in xrange(15)] )
print digits + chars
```
EDIT: liked the idea of using random.choice better than randint() so I've updated the code to reflec... |
367,617 | <p>In another <a href="https://stackoverflow.com/questions/89193/does-linq-to-sql-support-composable-queries">posting: Does Linq-To-Sql support composable queries</a> there was discussion on how to compose/concat where clauses dynamically. This appears to be done with an "AND" (i.e. the first where clause and the seco... | [
{
"answer_id": 367912,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 4,
"selected": true,
"text": "<p>Is what you want as simple as:</p>\n\n<pre><code>var people = from p in Person\n where p.age < 18 || ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] | In another [posting: Does Linq-To-Sql support composable queries](https://stackoverflow.com/questions/89193/does-linq-to-sql-support-composable-queries) there was discussion on how to compose/concat where clauses dynamically. This appears to be done with an "AND" (i.e. the first where clause and the second where clause... | Is what you want as simple as:
```
var people = from p in Person
where p.age < 18 || p.firstName == "Daniel"
select p;
```
or have you just given a simple example?
In which case you can use:
```
var under18 = from p in Person
where p.age < 18
select p;
var dan... |
367,623 | <p>We are invoking Asp.Net ajax web service from the client side. So the JavaScript functions have calls like:</p>
<p>// The function to alter the server side state object and set the selected node for the case tree.</p>
<pre><code>function JSMethod(caseId, url)
{
Sample.XYZ.Method(param1, param2, OnMethodRetur... | [
{
"answer_id": 368720,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 1,
"selected": true,
"text": "<p>You have a callback method (OnMethodReturn) specified in the WebMethod call, but not an error handler method. You need to c... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46279/"
] | We are invoking Asp.Net ajax web service from the client side. So the JavaScript functions have calls like:
// The function to alter the server side state object and set the selected node for the case tree.
```
function JSMethod(caseId, url)
{
Sample.XYZ.Method(param1, param2, OnMethodReturn);
}
function OnM... | You have a callback method (OnMethodReturn) specified in the WebMethod call, but not an error handler method. You need to create one and pass it into as you do the callback method. Then you can handle your failed WebMethod calls in there. |
367,626 | <p>In the Java snippet:</p>
<pre><code>SyndFeedInput fr = new SyndFeedInput();
SyndFeed sf = fr.build(new XmlReader(myInputStream));
List<SyndEntry> entries = sf.getEntries();
</code></pre>
<p>the last line generates the warning </p>
<p>"The expression of type <code>List</code> needs unchecked conversion to co... | [
{
"answer_id": 367632,
"author": "Alex B",
"author_id": 6180,
"author_profile": "https://Stackoverflow.com/users/6180",
"pm_score": 3,
"selected": false,
"text": "<p>Did you write the <code>SyndFeed</code>?</p>\n\n<p>Does <code>sf.getEntries</code> return List or <code>List<SyndEntry&... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46277/"
] | In the Java snippet:
```
SyndFeedInput fr = new SyndFeedInput();
SyndFeed sf = fr.build(new XmlReader(myInputStream));
List<SyndEntry> entries = sf.getEntries();
```
the last line generates the warning
"The expression of type `List` needs unchecked conversion to conform to `List<SyndEntry>`"
What's an appropriate... | Since `getEntries` returns a raw `List`, it could hold anything.
The warning-free approach is to create a new `List<SyndEntry>`, then cast each element of the `sf.getEntries()` result to `SyndEntry` before adding it to your new list. `Collections.checkedList` does *not* do this checking for you—although it would have ... |
367,633 | <p>What are all the common undefined behaviours that a C++ programmer should know about?</p>
<p>Say, like:</p>
<pre><code>a[i] = i++;
</code></pre>
<p></p>
| [
{
"answer_id": 367650,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": false,
"text": "<p>The only type for which C++ guarantees a size is <code>char</code>. And the size is 1. The size of all other types is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | What are all the common undefined behaviours that a C++ programmer should know about?
Say, like:
```
a[i] = i++;
``` | ### Pointer
* Dereferencing a `NULL` pointer
* Dereferencing a pointer returned by a "new" allocation of size zero
* Using pointers to objects whose lifetime has ended (for instance, stack allocated objects or deleted objects)
* Dereferencing a pointer that has not yet been definitely initialized
* Performing pointer ... |
367,656 | <p>Currently I am working very basic game using the C++ environment. The game used to be a school project but now that I am done with that programming class, I wanted to expand my skills and put some more flourish on this old assignment.</p>
<p>I have already made a lot of changes that I am pleased with. I have centra... | [
{
"answer_id": 367670,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 0,
"selected": false,
"text": "<p>One thing that looks wrong is that the second parameter to substr should be the number of chars to copy, not the positi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36254/"
] | Currently I am working very basic game using the C++ environment. The game used to be a school project but now that I am done with that programming class, I wanted to expand my skills and put some more flourish on this old assignment.
I have already made a lot of changes that I am pleased with. I have centralized all ... | In all honeasty, you're probably approaching this from the wrong end.
Your item class should have a string "bow", in a private member. The function Item::GetFilePath would then (at runtime) do "..\DATA\Images\" + this->name + ".png".
The fundamental property of the "bow" item object isn't the filename bow.png, but th... |
367,684 | <p>I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal ... | [
{
"answer_id": 367769,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 0,
"selected": false,
"text": "<p>If you read the snippet you link to you can understand that the simplest and way to get the \"normal\" values is just acce... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37181/"
] | I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal forma... | You must first create an array of the correct type, then pass it to glReadPixels:
```
a = (GLuint * 1)(0)
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_INT, a)
```
To test this, insert the following in the Pyglet "opengl.py" example:
```
@window.event
def on_mouse_press(x, y, button, modifiers):
a = (GLuint * 1)... |
367,695 | <p>I need to get substed drive letter in Perl. Could anyone kindly help me?
$ENV{SYSTEMDRIVE} does not work; it gives me real logical drive letter, not the substed one.</p>
| [
{
"answer_id": 367701,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "<p>Are you looking for <a href=\"http://search.cpan.org/dist/Win32-FileOp\" rel=\"nofollow noreferrer\">Win32::Fil... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46289/"
] | I need to get substed drive letter in Perl. Could anyone kindly help me?
$ENV{SYSTEMDRIVE} does not work; it gives me real logical drive letter, not the substed one. | ```
perl -e 'use Cwd; print( substr(getcwd(),10,1 )) ' # prints 10th char.
``` |
367,706 | <p>What is a good way of parsing command line arguments in Java?</p>
| [
{
"answer_id": 367714,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 10,
"selected": true,
"text": "<p>Check these out:</p>\n<ul>\n<li><a href=\"http://commons.apache.org/cli/\" rel=\"noreferrer\">http://commons.apac... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] | What is a good way of parsing command line arguments in Java? | Check these out:
* <http://commons.apache.org/cli/>
* <http://www.martiansoftware.com/jsap/>
Or roll your own:
* <http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html>
---
**For instance,** this is how you use [`commons-cli`](https://mvnrepository.com/artifact/commons-cli/commons-cli/1.3.1) to parse 2 s... |
367,709 | <p>I would like to execute the jQuery $(document).ready() in a drupal site. While i know that i can just stick it in the index page , this is really messy and a hack. </p>
<p>What i want to know is where is the correct location to put this, it would also need to be theme specific as i dont want all themes to use it.</... | [
{
"answer_id": 367729,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<p>Not a Drupal specialist, but this <a href=\"http://raincitystudios.com/blogs-and-pods/katherine-bailey/the-lowdown-jquery-dr... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42069/"
] | I would like to execute the jQuery $(document).ready() in a drupal site. While i know that i can just stick it in the index page , this is really messy and a hack.
What i want to know is where is the correct location to put this, it would also need to be theme specific as i dont want all themes to use it.
Thanks in ... | VonC adequately answered the "how" part of the question, so I'll focus on the "where" part.
If the script is theme-specific, then the natural place to put the script file is in your theme. The problem is that by the time Drupal gets to the theme, the `$scripts` variable has already been "rendered" (in Drupal parlance)... |
367,726 | <p>How can two classes in separate projects communicate between one another?</p>
<p>If ClassA references ClassB I can access methods of ClassB in ClassA... How can I make use of Interfaces to access methods of ClassA in ClassB?</p>
<p>Indeed do the classes even need to be linked if I make use of Interfaces?</p>
<p>C... | [
{
"answer_id": 367746,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 2,
"selected": false,
"text": "<p>I assume you mean assemblies, not classes.</p>\n\n<p>You have two options, either you use System.Reflection namespace (... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can two classes in separate projects communicate between one another?
If ClassA references ClassB I can access methods of ClassB in ClassA... How can I make use of Interfaces to access methods of ClassA in ClassB?
Indeed do the classes even need to be linked if I make use of Interfaces?
Can someone please provid... | I assume you mean assemblies, not classes.
You have two options, either you use System.Reflection namespace (dirty way) and then you don't even need to have any interfaces, just invoke methods via reflection.
```
System.Reflection.Assembly.LoadFile("MyProject.dll").GetType("MyProject.TestClass").GetMethod("TestMethod... |
367,730 | <p>How can I change an attribute of an element in an XML file, using C#?</p>
| [
{
"answer_id": 367772,
"author": "alexmac",
"author_id": 23066,
"author_profile": "https://Stackoverflow.com/users/23066",
"pm_score": 6,
"selected": false,
"text": "<p>Using LINQ to xml if you are using framework 3.5:</p>\n\n<pre><code>using System.Xml.Linq;\n\nXDocument xmlFile = XDocu... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I change an attribute of an element in an XML file, using C#? | Using LINQ to xml if you are using framework 3.5:
```
using System.Xml.Linq;
XDocument xmlFile = XDocument.Load("books.xml");
var query = from c in xmlFile.Elements("catalog").Elements("book")
select c;
foreach (XElement book in query)
{
book.Attribute("attr1").Value = "MyNewValue";
}
xmlFile... |
367,739 | <p>I have a Product Class which has a one to many relationship to a Price class.
So a product can have multiple prices.</p>
<p>I need to query the db to get me 10 products which have Price.amount < $2. In this case its to populate a UI with 10 items in a page.
so i writ the following code:</p>
<pre><code>ICriteria... | [
{
"answer_id": 367753,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": 0,
"selected": false,
"text": "<p>That would be up to the SQL to decide, depending on what happens in the methods that gets the list you need to cha... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a Product Class which has a one to many relationship to a Price class.
So a product can have multiple prices.
I need to query the db to get me 10 products which have Price.amount < $2. In this case its to populate a UI with 10 items in a page.
so i writ the following code:
```
ICriteria criteria = session.Crea... | That would be up to the SQL to decide, depending on what happens in the methods that gets the list you need to change the SQL so that it behaves as you like.
But being Distinct, you shouldnt get any duplicates. |
367,751 | <p>I want to create a dmg file for my Mac project. Can someone please tell me how to do this? This being my first Mac project, I do not have any idea how to proceed. I also want to give the user an option of running the app on start-up. How do I do this?</p>
<p>Thanks.</p>
<p>P.S. I also want to add a custom license ... | [
{
"answer_id": 367826,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 5,
"selected": false,
"text": "<p>To do this manually:</p>\n\n<p><strong>Method 1:</strong></p>\n\n<ul>\n<li>Make a folder with the files your DMG will contain.<... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | I want to create a dmg file for my Mac project. Can someone please tell me how to do this? This being my first Mac project, I do not have any idea how to proceed. I also want to give the user an option of running the app on start-up. How do I do this?
Thanks.
P.S. I also want to add a custom license agreement. | To do this manually:
**Method 1:**
* Make a folder with the files your DMG will contain.
[](https://i.stack.imgur.com/sOBin.png)
* Open Disk Utility (It's in `/Applications/Utilities/`)
[\n{\n return function()\n ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8372/"
] | Trying to add an onclick handler to my tabs, and can't seem to get the DOM selection right. Can you guys help?
```
<div id="tabstrip">
<ul>
<li id="a" class="selected"><a href="#">A</a></li>
<li id="b"><a href="#">B</a></li>
<li id="b"><a href="#">C</a></li>
</ul>
</div>
function initTab... | Seems like your closure is wrong.
Try
```
as[j].onclick = function(items, i)
{
return function()
{
changeTab(items[i].id);
return false;
};
}(items, i);
```
If it works then the question is a dupe of [jQuery Closures, Loops and Events](https://stackoverflow.com/questions/359467/jquery-cl... |
367,761 | <h2>Original title: How can I prevent loading a native dll from a .NET app?</h2>
<p><strong>Background:</strong></p>
<p>My C# application includes a plugin framework and generic plugin loader.</p>
<p>The plugin loader enumerates the application directory in order to identify plugin dlls (essentially it searches for ... | [
{
"answer_id": 367770,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 0,
"selected": false,
"text": "<p>You could always wrap the DLL loading with a try/except block...</p>\n"
},
{
"answer_id": 367785,
"author": "I... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46296/"
] | Original title: How can I prevent loading a native dll from a .NET app?
-----------------------------------------------------------------------
**Background:**
My C# application includes a plugin framework and generic plugin loader.
The plugin loader enumerates the application directory in order to identify plugin d... | Answer quoted by lubos hasko is good but it doesn't work for 64-bit assemblies. Here's a corrected version (inspired by <http://apichange.codeplex.com/SourceControl/changeset/view/76c98b8c7311#ApiChange.Api/src/Introspection/CorFlagsReader.cs>)
```
public static bool IsManagedAssembly(string fileName)
{
using (St... |
367,768 | <p>Given a function:</p>
<pre><code>function x(arg) { return 30; }
</code></pre>
<p>You can call it two ways:</p>
<pre><code>result = x(4);
result = new x(4);
</code></pre>
<p>The first returns 30, the second returns an object.</p>
<p>How can you detect which way the function was called <strong>inside the function... | [
{
"answer_id": 367794,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 6,
"selected": false,
"text": "<p>1) You can check <code>this.constructor</code>:</p>\n\n<pre><code>function x(y)\n{\n if (this.constructor == x)\n ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | Given a function:
```
function x(arg) { return 30; }
```
You can call it two ways:
```
result = x(4);
result = new x(4);
```
The first returns 30, the second returns an object.
How can you detect which way the function was called **inside the function itself**?
Whatever your solution is, it must work with the f... | **NOTE: This is now possible in ES2015 and later. See [Daniel Weiner's answer](https://stackoverflow.com/a/31060154/96100).**
I don't think what you want is possible [prior to ES2015]. There simply isn't enough information available within the function to make a reliable inference.
Looking at the ECMAScript 3rd editi... |
367,781 | <p>I have a java me application and now I want to place that application at the server. I want to write the download page with servlet. I mean when the user keys in the servlet url and hit to that servlet, my jad file will send to the phone(user no need to click to download button or link.After page loading, the servle... | [
{
"answer_id": 367801,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 0,
"selected": false,
"text": "<p>i guess the problem lies in the contents of jad file - path to jar file must be invalid.</p>\n\n<p>besides, handsets fre... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a java me application and now I want to place that application at the server. I want to write the download page with servlet. I mean when the user keys in the servlet url and hit to that servlet, my jad file will send to the phone(user no need to click to download button or link.After page loading, the servlet w... | you should add variety of other lines that usually come in jad file ;)
in this example below jad and jar files are in the same directory. if they are not in the same dir, you should provide MIDlet-Jar-URL: either with relative path to the jad file or an absolute path to your jar file. I mean this has to be full url - ... |
367,786 | <p>It looks like if I load dynamic content using <code>$.get()</code>, the result is cached in browser.</p>
<p>Adding some random string in QueryString seems to solve this issue (I use <code>new Date().toString()</code>), but this feels like a hack. </p>
<p>Is there any other way to achieve this?
Or, if unique string... | [
{
"answer_id": 367796,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 5,
"selected": false,
"text": "<p>another way is to provide no cache headers from serverside in the code that generates the response to ajax call:</p>\n\n... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10629/"
] | It looks like if I load dynamic content using `$.get()`, the result is cached in browser.
Adding some random string in QueryString seems to solve this issue (I use `new Date().toString()`), but this feels like a hack.
Is there any other way to achieve this?
Or, if unique string is the only way to achieve this, any s... | I use `new Date().getTime()`, which will avoid collisions unless you have multiple requests happening within the same millisecond:
```
$.get('/getdata?_=' + new Date().getTime(), function(data) {
console.log(data);
});
```
**Edit:** This answer is several years old. It still works (hence I haven't deleted it), ... |
367,797 | <p>I am using <code>Path.Combine</code>, and one of the strings contain a Unicode characters. I get <code>{System.ArgumentException} exception; illegal characters in path</code>.</p>
<p>According to <a href="http://msdn.microsoft.com/en-us/library/aa365247.aspx" rel="nofollow noreferrer">MSDN</a> filepath/name can have... | [
{
"answer_id": 367816,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<p>You may have <a href=\"http://www.mail-archive.com/nant-developers@lists.sourceforge.net/msg05235.html\" rel=\"nofollow nore... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] | I am using `Path.Combine`, and one of the strings contain a Unicode characters. I get `{System.ArgumentException} exception; illegal characters in path`.
According to [MSDN](http://msdn.microsoft.com/en-us/library/aa365247.aspx) filepath/name can have unicode characters. Why do I get this exception?
### Edit:
Here i... | I figured out the problem. The second string contains a "tab" character in it causing the exception. (that didn't showed up when I pasted the string here)
Thanks everyone and sorry for the confusion. |
367,817 | <p>I want to achieve the following:</p>
<pre><code>ID | Counter
------------
0 | 343
1 | 8344
</code></pre>
<p>Now say that I want to update counter for ID 1,,, what is the easiest way to do it? Do I use sequences? do I simply read the value and update? Is there any special type for it?</p>
<p>I was thinking about... | [
{
"answer_id": 367843,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "<p>It <em>sounds</em> like what you need is to create a <strong>view</strong> exactly along the lines of:</p>\n\n<p><code... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46303/"
] | I want to achieve the following:
```
ID | Counter
------------
0 | 343
1 | 8344
```
Now say that I want to update counter for ID 1,,, what is the easiest way to do it? Do I use sequences? do I simply read the value and update? Is there any special type for it?
I was thinking about using sequence but then I have t... | UPDATE Table
SET Counter=Counter+1
WHERE ID=:ID;
(where 'Table' is of course the table with the counter, and the parameter ':ID' is the id of the counter)
Sequences are mainly used for auto-generating ID values sequentially and can have gaps. The update statement above is atomic, as update is an atomic action. Howeve... |
367,819 | <p>In the external code that I am using there is enum: </p>
<pre><code>enum En {VALUE_A, VALUE_B, VALUE_C};
</code></pre>
<p>In another external code that I am using there are 3 #define directives: </p>
<pre><code>#define ValA 5
#define ValB 6
#define ValC 7
</code></pre>
<p>Many times I have int X which is equal t... | [
{
"answer_id": 367834,
"author": "Patrick",
"author_id": 38892,
"author_profile": "https://Stackoverflow.com/users/38892",
"pm_score": 1,
"selected": false,
"text": "<p>Have functions and then overload the library functions?</p>\n\n<pre><code>//libFunc( enum a );\n\nlibFuncOverload( defi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] | In the external code that I am using there is enum:
```
enum En {VALUE_A, VALUE_B, VALUE_C};
```
In another external code that I am using there are 3 #define directives:
```
#define ValA 5
#define ValB 6
#define ValC 7
```
Many times I have int X which is equal to ValA or ValB or ValC, and I have to cast it to ... | Since you can't just cast here, I would use a free function, and if there are likely to be other enums that also need converting, try to make it look a little bit like the builtin casts:
```
template<typename T>
T my_enum_convert(int);
template<>
En my_enum_convert<En>(int in) {
switch(in) {
case ValA: re... |
367,823 | <p>Can anyone tell me how to write a nested SQL query like </p>
<p>SELECT * FROM X WHERE X.ID IN (SELECT Y.XID FROM Y WHERE .....)</p>
<p>in LINQ?</p>
| [
{
"answer_id": 367829,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>You could try:</p>\n\n<pre><code>var yIds = from y in dataContext.Y\n where ...\n select y.XId;\n\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] | Can anyone tell me how to write a nested SQL query like
SELECT \* FROM X WHERE X.ID IN (SELECT Y.XID FROM Y WHERE .....)
in LINQ? | You could try:
```
var yIds = from y in dataContext.Y
where ...
select y.XId;
var query = from x in dataContext.X
where yIds.Contains(x.Id)
select x;
```
I don't know whether it will work though - any reason why you don't want to just do a join instead? For instance:
`... |
367,846 | <p>I'm currently using the ModelStateDictionary in asp.net mvc to hold validation errors and pass then back to the user. Being able to check if the whole model is valid with ModelState.IsValid is particularly. However, a current application I'm working on has a need to be able to report warnings. These aren't as critic... | [
{
"answer_id": 368155,
"author": "Mike Scott",
"author_id": 43649,
"author_profile": "https://Stackoverflow.com/users/43649",
"pm_score": 2,
"selected": false,
"text": "<p>Why not simply add a list of warnings, or a dictionary, to the ViewData and then display them in your view?</p>\n\n<... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35047/"
] | I'm currently using the ModelStateDictionary in asp.net mvc to hold validation errors and pass then back to the user. Being able to check if the whole model is valid with ModelState.IsValid is particularly. However, a current application I'm working on has a need to be able to report warnings. These aren't as critical ... | So the route that I was headed down before turned out to be a bad idea, there just isn't enough access in the framework to get at the bits that you need. At least not without reinventing the wheel a few times.
I decided to head down the route of extending the ModelState class to add a warnings collection to it:
```
p... |
367,847 | <p>There is a div that has inner content, a div with a border that's inside a div. Somehow, this div is expanded to encompass the next div. It blows my mind.</p>
<pre><code><div style="background: yellow;">
<div>
<div style="border: 1px solid black; background: green">green background</div... | [
{
"answer_id": 367849,
"author": "Sam",
"author_id": 43005,
"author_profile": "https://Stackoverflow.com/users/43005",
"pm_score": 0,
"selected": false,
"text": "<p>One solution is to put \"position: relative\" everywhere, but this breaks other things in my page.</p>\n"
},
{
"ans... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] | There is a div that has inner content, a div with a border that's inside a div. Somehow, this div is expanded to encompass the next div. It blows my mind.
```
<div style="background: yellow;">
<div>
<div style="border: 1px solid black; background: green">green background</div>
</div>
</div>
<div style="margin-... | You need to "give layout" to the first div. You better do this using IE6 targeted styles:
```
<style>
* html .haslayout {
display:inline-block;
}
</style>
...
<div style="background: yellow;" class="haslayout">
```
This is a known IE6 issue with the hasLayout attribute. Read more on it here - <http://... |
367,853 | <p>Below is my stored procedure. I want use stored procedure select all row of date from tbl_member and insert 2 table. But it's not work. Some one can help me?</p>
<pre><code>Create PROCEDURE sp_test
AS
BEGIN
SET NOCOUNT ON;
Declare @A Varchar(255), @B Varchar(255), @C Varchar(255), @D int
Declare Table... | [
{
"answer_id": 367875,
"author": "Pete OHanlon",
"author_id": 43635,
"author_profile": "https://Stackoverflow.com/users/43635",
"pm_score": 4,
"selected": true,
"text": "<p>The first thing I can see here is that you are using a cursor when you don't need to. You can rewrite the first que... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44260/"
] | Below is my stored procedure. I want use stored procedure select all row of date from tbl\_member and insert 2 table. But it's not work. Some one can help me?
```
Create PROCEDURE sp_test
AS
BEGIN
SET NOCOUNT ON;
Declare @A Varchar(255), @B Varchar(255), @C Varchar(255), @D int
Declare Table_Cursor Curso... | The first thing I can see here is that you are using a cursor when you don't need to. You can rewrite the first query as:
```
INSERT INTO NewMember(A, B, C, D)
SELECT A, B, C, D
FROM tbl_member
```
Then, I would have an INSERT trigger against NewMember that inserted the identity column.
```
create trigger myInsertT... |
367,859 | <p>Does any one know of a control that i can use with a ASP.Net gridview that provides the functionality of the ASP.Net Ajax Control PagingBulletedList. I want to provide the users with a easier way to access the data in the grid.</p>
<p>It should ideally work in the same way paging for the grid works except that it s... | [
{
"answer_id": 380065,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>DataGrid has its own set of data sorting that you can tap, for example, you can page a GridView by adding 'AllowPaging=\"tr... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42069/"
] | Does any one know of a control that i can use with a ASP.Net gridview that provides the functionality of the ASP.Net Ajax Control PagingBulletedList. I want to provide the users with a easier way to access the data in the grid.
It should ideally work in the same way paging for the grid works except that it should show... | Unfortunatly there is nothing already buildt for this. To build your own you will have to create your own [PagerTemplate](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagertemplate.aspx).
There is something similiar with code in it in this [tutorial](http://www.highoncoding.com/Articles/2... |
367,862 | <p>I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir.</p>
<p>The problem is that I can't get the hang of the regexp "mind model" :)</p>
<p>This is the regexp that I came up with to select the files that I would like to exclude </p>
<p>((ABC|XYZ))+\w*Test.xml... | [
{
"answer_id": 367868,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 3,
"selected": false,
"text": "<p>This stuff is easier, faster and more readable without regexes.</p>\n\n<pre><code>if (str.endsWith(\"Test.xml\") &... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38973/"
] | I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir.
The problem is that I can't get the hang of the regexp "mind model" :)
This is the regexp that I came up with to select the files that I would like to exclude
((ABC|XYZ))+\w\*Test.xml
What I would like to ... | >
> What I would like to do is to select
> all the files that end with `Test.xml`
> but do not start with `ABC` or `XYZ`.
>
>
>
Either you match all your files with this regex:
```
^(?:(?:...)(?<!ABC|XYZ).*?)?Test\.xml$
```
or you do the opposite, and take every file that does *not* match:
```
^(?:ABC|XYZ)... |
367,863 | <p>I've got the following two tables (in MySQL):</p>
<pre><code>Phone_book
+----+------+--------------+
| id | name | phone_number |
+----+------+--------------+
| 1 | John | 111111111111 |
+----+------+--------------+
| 2 | Jane | 222222222222 |
+----+------+--------------+
Call
+----+------+--------------+
| id | ... | [
{
"answer_id": 367865,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 10,
"selected": true,
"text": "<p>There's several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] | I've got the following two tables (in MySQL):
```
Phone_book
+----+------+--------------+
| id | name | phone_number |
+----+------+--------------+
| 1 | John | 111111111111 |
+----+------+--------------+
| 2 | Jane | 222222222222 |
+----+------+--------------+
Call
+----+------+--------------+
| id | date | phone_... | There's several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and the relative size of your two tables:
This is the shortest statement, and may be quickest if your phone book is very short:
```
SELECT *
FROM Call
WHERE phone_number NOT IN (SELECT phone_num... |
367,870 | <p>If someone logs on to my application this user contains a dictionary with certain permissions.</p>
<pre><code>ex: module.view.workspace = true
module.view.reporting = false
...
</code></pre>
<p>Then we know to what parts of the application the user has access.
What I want to know is how we can apply these ... | [
{
"answer_id": 367865,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 10,
"selected": true,
"text": "<p>There's several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29964/"
] | If someone logs on to my application this user contains a dictionary with certain permissions.
```
ex: module.view.workspace = true
module.view.reporting = false
...
```
Then we know to what parts of the application the user has access.
What I want to know is how we can apply these permissions on the view.
W... | There's several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and the relative size of your two tables:
This is the shortest statement, and may be quickest if your phone book is very short:
```
SELECT *
FROM Call
WHERE phone_number NOT IN (SELECT phone_num... |
367,905 | <p>All the generated webservice-stubs from our backend have an equals-method similar to this one:</p>
<pre><code>private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof PropertyData)) return false;
PropertyData other = (PropertyData) obj;
... | [
{
"answer_id": 367911,
"author": "David Santamaria",
"author_id": 24097,
"author_profile": "https://Stackoverflow.com/users/24097",
"pm_score": -1,
"selected": false,
"text": "<p>The __equalsCal behave as a Cache for the last call to Equals. So, if two calls in the same instance to equal... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870/"
] | All the generated webservice-stubs from our backend have an equals-method similar to this one:
```
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof PropertyData)) return false;
PropertyData other = (PropertyData) obj;
if (obj == n... | I suspect it's trying to stop recursion - if something has itself as its key, you don't want it to recurse forever.
However, at that point it uses reference equality for the test, which is possibly not desirable.
What's generating this code? Is it a home-grown system, or a public one? If it's home-grown, is the devel... |
367,907 | <p>I'm trying to follow the directions from this page:<br>
<a href="http://www.opengl.org/resources/faq/technical/color.htm" rel="nofollow noreferrer">http://www.opengl.org/resources/faq/technical/color.htm</a><br>
regarding rendering primitives with a unique color</p>
<p>I've checked the number of bits for every colo... | [
{
"answer_id": 367921,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 1,
"selected": false,
"text": "<p>Have you done this, too?</p>\n\n<pre><code>In either event, you'll need to ensure that any state that could\naffect t... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] | I'm trying to follow the directions from this page:
<http://www.opengl.org/resources/faq/technical/color.htm>
regarding rendering primitives with a unique color
I've checked the number of bits for every color and the result was 8 for each.
When calling:
```
glColor3ui(0x80000000, 0, 0xFF000000);
```
and r... | It turns out that the FAQ has a mistake.
The [documentation of glColor](http://www.opengl.org/sdk/docs/man/xhtml/glColor.xml)
states that: "Unsigned integer color components, when specified, are linearly mapped to floating-point values such that the **largest representable value** maps to 1.0 (full intensity), and 0 ... |
367,926 | <p>I'm trying to use a dll, namely libcurl, with my program, but, it's not linking. Libcurl comes with .h files that I can include (takes care of dllimport), but then I guess I must specify which dll to actually use when linking somehow... How do I do that? I'm compiling with Borland C++ builder, but I really want to k... | [
{
"answer_id": 367944,
"author": "Timo Geusch",
"author_id": 29068,
"author_profile": "https://Stackoverflow.com/users/29068",
"pm_score": 1,
"selected": false,
"text": "<p>Normally, if you are linking against a Windows DLL, you'll need to pass the name of either the DLL or the import li... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2079/"
] | I'm trying to use a dll, namely libcurl, with my program, but, it's not linking. Libcurl comes with .h files that I can include (takes care of dllimport), but then I guess I must specify which dll to actually use when linking somehow... How do I do that? I'm compiling with Borland C++ builder, but I really want to know... | As mentioned, you will need the static .lib file that goes with the .dll which you run
through implib and add the result lib file to your project.
If you have done that then:
* You may need to use the stdcall calling convention.
You didn't mention which version of Builder you are using, but
it is usually under Projec... |
367,934 | <p>Having read an existing post on <a href="https://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file">stackoverflow</a> and done some reading around on the net. I thought it was time to post my question before I lost too much hair!</p>
<p>I have the following code within a batch file which I double cli... | [
{
"answer_id": 368076,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "<p>Your immediate problem is that you're setting the variable to the value < \"Two\"> which you can see here:</p>\n\n... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40593/"
] | Having read an existing post on [stackoverflow](https://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file) and done some reading around on the net. I thought it was time to post my question before I lost too much hair!
I have the following code within a batch file which I double click to run, under Wind... | Your immediate problem is that you're setting the variable to the value < "Two"> which you can see here:
```
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
::Observe variable is not defined
SET test
::Define initial value
SET test = "Two"
::Observe initial value is set
SET test
echo %test%
echo..%test %.
::Verify if t... |
367,940 | <p>I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff.</p>
<p>I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or wha... | [
{
"answer_id": 367943,
"author": "Mario Ortegón",
"author_id": 2309,
"author_profile": "https://Stackoverflow.com/users/2309",
"pm_score": 0,
"selected": false,
"text": "<p>I would create a List to store the text fields, and then you can get them back by index. Then you can have as many... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] | I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff.
I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or whatever.
I ... | Use an appropriate LayoutManager (e.g. GridLayout) to create and add your textfields.
```
for (i = 0; i < numberOfTextFields; i++) {
JTextField textField = new JTextField();
container.add(textField);
/* also store textField somewhere else. */
}
``` |
367,947 | <p>What is the c# equivalent of the following c++:</p>
<pre><code>srand((unsigned)(time(NULL)));
weight=(double)(rand())/(RAND_MAX/2) - 1;
</code></pre>
| [
{
"answer_id": 367953,
"author": "Frans Bouma",
"author_id": 44991,
"author_profile": "https://Stackoverflow.com/users/44991",
"pm_score": 2,
"selected": false,
"text": "<p>To do random value generation in .NET, you should use the Random class. to seed it with a time value, use:\nRandom ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the c# equivalent of the following c++:
```
srand((unsigned)(time(NULL)));
weight=(double)(rand())/(RAND_MAX/2) - 1;
``` | To do random value generation in .NET, you should use the Random class. to seed it with a time value, use:
Random rand = new Random((int)DateTime.Now.Ticks);
For further specifics, it's best to check out the docs about the Random class in the MSDN, e.g. which methods are available. |
367,966 | <p>For testing purposes I'm planning to put together a little app that will listen for a particular event coming from an application and interact with it at that point. </p>
<p>Given that we're at a point in the testing process where changing the application code is out of the question, the ideal from my point of view... | [
{
"answer_id": 368028,
"author": "Arnout",
"author_id": 3496,
"author_profile": "https://Stackoverflow.com/users/3496",
"pm_score": 1,
"selected": false,
"text": "<p>Is the application that you want to trace using standard <code>System.Diagnostics</code>-based tracing? In that case you c... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15394/"
] | For testing purposes I'm planning to put together a little app that will listen for a particular event coming from an application and interact with it at that point.
Given that we're at a point in the testing process where changing the application code is out of the question, the ideal from my point of view would be ... | The way I found to do it used the [Mdbg tools](http://blogs.msdn.com/jmstall/archive/2005/11/08/mdbg_linkfest.aspx) from Microsoft to give me access from the runtime to the core debugging information. The basic shape of the code I'm using looks like this:
```
MDbgEngine mg;
MDbgProcess mgProcess;
try
{
mg =... |
368,001 | <p>I have a .NET assembly which I have exposed to COM via a tlb file, and an installer which registers the tlb. I have manually checked that the installer works correctly and that COM clients can access the library. So far, so good...</p>
<p>However, I am trying to put together some automated system tests which check ... | [
{
"answer_id": 368019,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": -1,
"selected": false,
"text": "<p>Using <a href=\"http://msdn.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx\" rel=\"nofollow noreferrer\">tlbi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32413/"
] | I have a .NET assembly which I have exposed to COM via a tlb file, and an installer which registers the tlb. I have manually checked that the installer works correctly and that COM clients can access the library. So far, so good...
However, I am trying to put together some automated system tests which check that the i... | The Closest I've gotten to a solution is something like the following:
```
using System;
class ComClass
{
public bool CallFunction(arg1, arg2)
{
Type ComType;
object ComObject;
ComType = Type.GetTypeFromProgID("Registered.ComClass");
// Create an instance of your COM Registered... |
368,003 | <p>I have a single spool mbox file that was created with evolution, containing a selection of emails that I wish to print. My problem is that the emails are not placed into the mbox file chronologically. I would like to know the best way to place order the files from first to last using bash, perl or python. I would li... | [
{
"answer_id": 368013,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": -1,
"selected": false,
"text": "<p>What's the point in rewriting the mbox whereas you can reorder the mails in memory when loading up the mailbox? Which ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I have a single spool mbox file that was created with evolution, containing a selection of emails that I wish to print. My problem is that the emails are not placed into the mbox file chronologically. I would like to know the best way to place order the files from first to last using bash, perl or python. I would like ... | This is how you could do it in python:
```
#!/usr/bin/python2.5
from email.utils import parsedate
import mailbox
def extract_date(email):
date = email.get('Date')
return parsedate(date)
the_mailbox = mailbox.mbox('/path/to/mbox')
sorted_mails = sorted(the_mailbox, key=extract_date)
the_mailbox.update(enumera... |
368,006 | <p>I want my background worker to add items to a list box, it appears to do so when debugging but the listbox doesn't show the values. I suspect this is something to do with adding items whilst inside the background worker thread, do I need to add these to an array and then populate the list box from the array during <... | [
{
"answer_id": 368009,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 1,
"selected": false,
"text": "<p>You can add them while on a background thread via:</p>\n\n<pre><code>Form.Invoke\n</code></pre>\n\n<p>or </p>\n\n<pre... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want my background worker to add items to a list box, it appears to do so when debugging but the listbox doesn't show the values. I suspect this is something to do with adding items whilst inside the background worker thread, do I need to add these to an array and then populate the list box from the array during `bac... | You can use Invoke like this:
```
private void AddToListBox(object oo)
{
Invoke(new MethodInvoker(
delegate { listBox.Items.Add(oo); }
));
}
``` |
368,018 | <p>I'm trying to replace every multiline import inside a Python source file.. So, the source goes like</p>
<pre><code>from XXX import (
AAA,
BBB,
)
from YYY import (
CCC,
DDD,
EEE,
...
)
...other instructions...
</code></pre>
<p>and I'd like to get something like</p>
<pre><code>from XXX import AAA,... | [
{
"answer_id": 368037,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": true,
"text": "<p>Ummm... what's wrong with Python?</p>\n\n<pre><code>lineIter= iter(aFile)\nfor aLine in lineIter:\n if aLine.startswit... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3497/"
] | I'm trying to replace every multiline import inside a Python source file.. So, the source goes like
```
from XXX import (
AAA,
BBB,
)
from YYY import (
CCC,
DDD,
EEE,
...
)
...other instructions...
```
and I'd like to get something like
```
from XXX import AAA, BBB
from YYY import CCC, DDD, EEE, .... | Ummm... what's wrong with Python?
```
lineIter= iter(aFile)
for aLine in lineIter:
if aLine.startswith("import"):
if aLine.endswith("("):
for aModule in lineIter:
if aModule.endwith(")"):
break
print "import", aModule.strip()
else:
... |
368,021 | <p>When my app is run in the iPhone simulator, the delegate method</p>
<pre><code>- (void)applicationWillTerminate:(UIApplication *)application
</code></pre>
<p>is only called the first time I hit the iPhone simulator's home button.</p>
<p>After the home button is pressed and the app is launched again, hitting the h... | [
{
"answer_id": 368064,
"author": "Lily Ballard",
"author_id": 582,
"author_profile": "https://Stackoverflow.com/users/582",
"pm_score": 6,
"selected": true,
"text": "<p>I suspect that it is being called, but that you are getting confused because after you hit the Home button in the Simul... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26088/"
] | When my app is run in the iPhone simulator, the delegate method
```
- (void)applicationWillTerminate:(UIApplication *)application
```
is only called the first time I hit the iPhone simulator's home button.
After the home button is pressed and the app is launched again, hitting the home button does not call the dele... | I suspect that it is being called, but that you are getting confused because after you hit the Home button in the Simulator, you've ended the current session in Xcode. You probably have an `NSLog` in your `applicationWillTerminate:` method, yes? Once you hit the Home button, `NSLog`s no longer show up in Xcode's run co... |
368,039 | <p>I seem to have an app on my Dev server that has lots of open connections (they should be there, but some bad data layer was used to open them, that forgot to close them). I just want them closed so I can keep other apps running on the server. How can I force all the connections to close?</p>
| [
{
"answer_id": 368047,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 2,
"selected": false,
"text": "<p>Other than killing your connections manually, you can</p>\n\n<ul>\n<li>Dispose of the connections. That is, retriev... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5055/"
] | I seem to have an app on my Dev server that has lots of open connections (they should be there, but some bad data layer was used to open them, that forgot to close them). I just want them closed so I can keep other apps running on the server. How can I force all the connections to close? | Use the following script to kill inactive sessions from a specific host / login. You could use it from a scheduled job, of course your priority should be to fix your app tier.
```
SET NOCOUNT ON;
DECLARE @host VARCHAR(50), @login NVARCHAR(128);
SET @host = 'fooHost'; --NULL to kill sessions from all hosts.
SET @log... |
368,041 | <p>I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.</p>
<p>Does anyone have a clue?</p>
| [
{
"answer_id": 368044,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 0,
"selected": false,
"text": "<p>You can use a counter that prints a different character from a given set (like \"\\|/-\") and you change the character a... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44532/"
] | I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.
Does anyone have a clue? | This can actually be done quite easily with pure native commands, you just have to know how to use the more tricky of them. No use of external tools like VBScript or nasty side effects like clearing the screen are necessary.
What you're looking for is the equivalent of the bash "`echo -n`" command which outputs a line... |
368,049 | <p>I'd like to insert a new field with a Default value using Visual C++ Code.
I have wrote this:</p>
<pre><code>CADODatabase pDB;
String strConnessione = _T("Provider=Microsoft.Jet.OLEDB.4.0;""Data Source=");
strConnessione = strConnessione + "MioDatabase.mdb";
pDB.SetConnectionString(strConnessione);
pDB.Open();
que... | [
{
"answer_id": 368572,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 2,
"selected": false,
"text": "<p>In JET-SQL language you have to be more specific with the syntax and add the 'COLUMN' word in the 'ALTER TABL... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to insert a new field with a Default value using Visual C++ Code.
I have wrote this:
```
CADODatabase pDB;
String strConnessione = _T("Provider=Microsoft.Jet.OLEDB.4.0;""Data Source=");
strConnessione = strConnessione + "MioDatabase.mdb";
pDB.SetConnectionString(strConnessione);
pDB.Open();
query.Format("ALT... | In JET-SQL language you have to be more specific with the syntax and add the 'COLUMN' word in the 'ALTER TABLE' sentence. Exemple:
```
strSql = "ALTER TABLE MyTable ADD COLUMN MyField DECIMAL (28,3);"
strSql = "ALTER TABLE MyTable ADD COLUMN MyText TEXT(3);"
```
According to the Help, you can define a default value ... |
368,057 | <p>Say I have a package "mylibrary".</p>
<p>I want to make "mylibrary.config" available for import, either as a dynamically created module, or a module imported from an entirely different place that would then basically be "mounted" inside the "mylibrary" namespace.</p>
<p>I.e., I do:</p>
<pre><code>import sys, type... | [
{
"answer_id": 368178,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 5,
"selected": true,
"text": "<p>You need to monkey-patch the module not only into sys.modules, but also into its parent module:</p>\n\n<pre><cod... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15677/"
] | Say I have a package "mylibrary".
I want to make "mylibrary.config" available for import, either as a dynamically created module, or a module imported from an entirely different place that would then basically be "mounted" inside the "mylibrary" namespace.
I.e., I do:
```
import sys, types
sys.modules['mylibrary.con... | You need to monkey-patch the module not only into sys.modules, but also into its parent module:
```
>>> import sys,types,xml
>>> xml.config = sys.modules['xml.config'] = types.ModuleType('xml.config')
>>> import xml.config
>>> from xml import config
>>> from xml import config as x
>>> x
<module 'xml.config' (built-in)... |
368,074 | <p>I have a problem in integrating PHP and JQuery:</p>
<p>My main file is <code>MyFile.html</code> and the AJAX call file is <code>ajax.php</code>.</p>
<p>The <code>ajax.php</code> function returns links to <code>myFile.html</code> as </p>
<p><code><a href Link.php?action=Function ></a></code> (i.e <cod... | [
{
"answer_id": 368113,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>You're missing the <code>=</code> and quotes:</p>\n\n<pre><code><a href Link.php?action=Function >\n</code></pre>\n\... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I have a problem in integrating PHP and JQuery:
My main file is `MyFile.html` and the AJAX call file is `ajax.php`.
The `ajax.php` function returns links to `myFile.html` as
`<a href Link.php?action=Function ></a>` (i.e `echo " <a href Link.php?action=Delete";`)
When I click the returned link from `MyFile.html` it... | It sounds like you are trying to simply set the contents of an HTML element to the result of executing a PHP script. Here is a sample PHP script that will just print an HTML link depending on what parameter you pass it in the 'foo' parameter.
```
<?
// Get the parameter "foo" from the URL string.
$action = $_GET['... |
368,094 | <p>In Java, what are the performance and resource implications of using</p>
<pre><code>System.currentTimeMillis()
</code></pre>
<p>vs. </p>
<pre><code>new Date()
</code></pre>
<p>vs. </p>
<pre><code>Calendar.getInstance().getTime()
</code></pre>
<p>As I understand it, <code>System.currentTimeMillis()</code> is ... | [
{
"answer_id": 368100,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 4,
"selected": false,
"text": "<p>I prefer using the value returned by <code>System.currentTimeMillis()</code> for all kinds of calculations and only use <... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15452/"
] | In Java, what are the performance and resource implications of using
```
System.currentTimeMillis()
```
vs.
```
new Date()
```
vs.
```
Calendar.getInstance().getTime()
```
As I understand it, `System.currentTimeMillis()` is the most efficient. However, in most applications, that long value would need to be... | `System.currentTimeMillis()` is obviously the most **efficient** since it does not even create an object, but `new Date()` is really just a thin wrapper about a long, so it is not far behind. `Calendar`, on the other hand, is relatively slow and very complex, since it has to deal with the considerably complexity and al... |
368,114 | <p>I have an HTML form with two buttons as follows:</p>
<pre><code><input type="submit" name="confirm" value="Yes, Delete" />
<button name="confirm" type="button" onclick="history.back()" value="No, Go Back">No, Go Back</button>
</code></pre>
<p>Now, when I click on either in Firefox, the behavior ... | [
{
"answer_id": 368127,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "<p>Because the control with the name “confirm” has the value “No, Go Back”.</p>\n"
},
{
"answer_id": 368132,
"au... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3831/"
] | I have an HTML form with two buttons as follows:
```
<input type="submit" name="confirm" value="Yes, Delete" />
<button name="confirm" type="button" onclick="history.back()" value="No, Go Back">No, Go Back</button>
```
Now, when I click on either in Firefox, the behavior is as expected. If I click the submit button... | Firefox, Safari, Chrome, Opera ***all play*** the "***first match wins***" game, but IE plays the "*last match wins*" game.
([see bug/feature report here](http://webbugtrack.blogspot.com/2008/06/bug-or-feature-round-three.html))
In general, I would name the buttons differently unless they are part of a radio/checkbox... |
368,143 | <p>I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic.</p>
<p>Is it possible (and if yes, a good design) to have routes like so:
.../Organization/10/User/5/Edit
.../Organization/10/User/List</p>
<p>In other words; can the urls mirror your domain model?</p>
| [
{
"answer_id": 368243,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 1,
"selected": false,
"text": "<p>Possible, yes, with a route something like:</p>\n\n<pre><code>\"~/Organization/{orgId}/{Controller}/{id}/{action}\"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46343/"
] | I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic.
Is it possible (and if yes, a good design) to have routes like so:
.../Organization/10/User/5/Edit
.../Organization/10/User/List
In other words; can the urls mirror your domain model? | Possible, yes, with a route something like:
```
"~/Organization/{orgId}/{Controller}/{id}/{action}"
```
Whether it is a good design or not I couldn't say for sure, only that it seems rather complicated to me.
If you have multiple User tables, one for each company, it might make some sense. |
368,154 | <p>I'm creating a installer for a c# windows project using VS 2008. I'm trying to write a custom action that copies a settings file from the source directory of the MSI file stored on a file server (e.g. \server\fileshare\myappinstaller\mysetting.xml) to the target directory on the computer on which my application is b... | [
{
"answer_id": 368248,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 2,
"selected": false,
"text": "<p>I would recommend you to add the XML file to the installer as one of the components to be installed. That would be... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/254/"
] | I'm creating a installer for a c# windows project using VS 2008. I'm trying to write a custom action that copies a settings file from the source directory of the MSI file stored on a file server (e.g. \server\fileshare\myappinstaller\mysetting.xml) to the target directory on the computer on which my application is been... | I have solved this by adding
>
> /InstallerPath="[OriginalDatabase]"
>
>
>
to the CustomActionData of the Custom Action (in the Tab Custom Actions of the Setup Project) and reading the value with this code in the Custom Action:
```
Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictiona... |
368,156 | <p>How can I apply an Interface to a form class</p>
<pre><code>partial class Form1 : Form, InterfaceA
</code></pre>
<p>Is this correct?</p>
<p>Basically I would like to implement an Interface on a form.
How To ....</p>
| [
{
"answer_id": 368161,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 3,
"selected": false,
"text": "<p>A Form is just a class (that subclasses System.Windows.Forms.Form), so yes - standard syntax is fine, as you have it... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I apply an Interface to a form class
```
partial class Form1 : Form, InterfaceA
```
Is this correct?
Basically I would like to implement an Interface on a form.
How To .... | A Form is just a class (that subclasses System.Windows.Forms.Form), so yes - standard syntax is fine, as you have it.
Edit: As to your partial class part of the question, no, you need only declare that you implement the interface once. From MSDN...
>
> If any of the parts are declared abstract, then the entire type ... |
368,160 | <p>I have a dataset in a worksheet that can be different every time. I am creating a pivottable from that data, but it is possible that one of the PivotItems is not there. For example:</p>
<pre><code>.PivotItems("Administratie").Visible = False
</code></pre>
<p>If that specific value is not in my dataset, the VBA scr... | [
{
"answer_id": 368211,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 0,
"selected": false,
"text": "<p>Try something like this:</p>\n\n<pre><code>Public Function Test()\n On Error GoTo Test_EH\n\n Dim pvtField As ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42389/"
] | I have a dataset in a worksheet that can be different every time. I am creating a pivottable from that data, but it is possible that one of the PivotItems is not there. For example:
```
.PivotItems("Administratie").Visible = False
```
If that specific value is not in my dataset, the VBA script fails, saying that it ... | I've got it! :D
```
Dim Table As PivotTable
Dim FoundCell As Object
Dim All As Range
Dim PvI As PivotItem
Set All = Worksheets("Analyse").Range("A7:AZ10000")
Set Table = Worksheets("Analyse").PivotTables("tablename")
For Each PvI In Table.PivotFields("fieldname").PivotItems
Set FoundCell = All.Fin... |
368,169 | <p>I have some code that prints out databse values into a repeater control on an asp.net page. However, some of the values returned are null/blank - and this makes the result look ugly when there are blank spaces. </p>
<p>How do you do conditional logic in asp.net controls i.e. print out a value if one exists, else ... | [
{
"answer_id": 368225,
"author": "Matt Woodward",
"author_id": 40593,
"author_profile": "https://Stackoverflow.com/users/40593",
"pm_score": 4,
"selected": true,
"text": "<p>It's going to be a pretty subjective one this as it completely depends on where and how you like to handle null / ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] | I have some code that prints out databse values into a repeater control on an asp.net page. However, some of the values returned are null/blank - and this makes the result look ugly when there are blank spaces.
How do you do conditional logic in asp.net controls i.e. print out a value if one exists, else just go to n... | It's going to be a pretty subjective one this as it completely depends on where and how you like to handle null / blank values, and indeed which one of those two you are dealing with.
For example, some like to handle nulls at the database level, some like to code default values in the business logic layer and others l... |
368,170 | <p>I'm trying to write some code to find a specific XmlNode object based on the URL in the XML sitemap but can't get it to find anything.</p>
<p>The sitemap is the standard ASP.net sitemap and contains:</p>
<pre><code><siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views">
--- Child Items ---
</siteMapNo... | [
{
"answer_id": 368174,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>Try adding \"//\" to the start of your XPath query so it will match <em>any</em> siteMapNode element with the right u... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33721/"
] | I'm trying to write some code to find a specific XmlNode object based on the URL in the XML sitemap but can't get it to find anything.
The sitemap is the standard ASP.net sitemap and contains:
```
<siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views">
--- Child Items ---
</siteMapNode>
```
The code I'm using t... | The site map has a default name space, but you do not refer to it.
```
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views">
<!-- Child Items -->
</siteMapNode>
</siteMap>
```
So, you should use this:
```
XmlNamespaceManager nsmgr... |
368,184 | <p>I found some code in a project which looks like that : </p>
<pre><code>int main(int argc, char *argv[])
{
// some stuff
try {
theApp.Run();
} catch (std::exception& exc) {
cerr << exc.what() << std::endl;
exit(EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
</code></pre>
<p>I don't understan... | [
{
"answer_id": 368187,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you say that the exception would be printed? This is not the typical behavior of the C++ runtime. At bes... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20986/"
] | I found some code in a project which looks like that :
```
int main(int argc, char *argv[])
{
// some stuff
try {
theApp.Run();
} catch (std::exception& exc) {
cerr << exc.what() << std::endl;
exit(EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
```
I don't understand why the exceptions are being catched. If... | If an exception is uncaught, then the standard does not define whether the stack is unwound. So on some platforms destructors will be called, and on others the program will terminate immediately. Catching at the top level ensures that destructors are always called.
So, if you aren't running under the debugger, it's pr... |
368,192 | <p>I have this little function</p>
<pre><code>function makewindows(){
child1 = window.open ("about:blank");
child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
child1.document.close();
}
</code></pre>
<p>Which whatever I try, simply outputs the php code as ... | [
{
"answer_id": 368207,
"author": "Sydius",
"author_id": 43496,
"author_profile": "https://Stackoverflow.com/users/43496",
"pm_score": 1,
"selected": false,
"text": "<p>This code must be in a file that is parsed by PHP before being sent to the browser. Make sure it has a \".php\" extensi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I have this little function
```
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
child1.document.close();
}
```
Which whatever I try, simply outputs the php code as the html source, and not the res... | I assume you still have it in a file that is parsed by PHP, like the others already have said. Then it is probably something above this code snippet that confuses the php-parser so it don't recognize the php-tag.
To test that, try to output something else before this function, maybe just a comment or something.
Also... |
368,194 | <p>I'm using <a href="https://tablelayout.dev.java.net/" rel="nofollow noreferrer">TableLayout</a> for my swing GUI. Initially only some basic labels, buttons and text fields where required which I could later on access by:</p>
<pre><code>public Component getComponent(String componentName) {
return getComponent(co... | [
{
"answer_id": 368207,
"author": "Sydius",
"author_id": 43496,
"author_profile": "https://Stackoverflow.com/users/43496",
"pm_score": 1,
"selected": false,
"text": "<p>This code must be in a file that is parsed by PHP before being sent to the browser. Make sure it has a \".php\" extensi... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33429/"
] | I'm using [TableLayout](https://tablelayout.dev.java.net/) for my swing GUI. Initially only some basic labels, buttons and text fields where required which I could later on access by:
```
public Component getComponent(String componentName) {
return getComponent(componentName, this.frame.getContentPane());
}
priva... | I assume you still have it in a file that is parsed by PHP, like the others already have said. Then it is probably something above this code snippet that confuses the php-parser so it don't recognize the php-tag.
To test that, try to output something else before this function, maybe just a comment or something.
Also... |
368,200 | <p>Simple question. How do you disable the text selection of DocumentViewer in WPF? This is the feature where an XPS document is displayed by the viewer and then text can be highlighted via mouse. The highlighted text can also be copied but I have already disabled this. I just don't know how to disable the highlighting... | [
{
"answer_id": 402453,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>you may use IsFocusable=false. But search box will be disabled too...</p>\n"
},
{
"answer_id": 415155,
"author"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Simple question. How do you disable the text selection of DocumentViewer in WPF? This is the feature where an XPS document is displayed by the viewer and then text can be highlighted via mouse. The highlighted text can also be copied but I have already disabled this. I just don't know how to disable the highlighting.
... | We have solved this by overriding the ControlTemplate of the ScrollViewer embedded in the DocumentViewer control. Insert the Style below in "Window.Resources":
```
<Style TargetType="{x:Type ScrollViewer}" x:Key="CustomScrollPresenter">
<Setter Property="Template">
<Setter.Value>
<ControlTempl... |
368,215 | <p>Considering the following table</p>
<p>I have a large table from which I can query to get the following table</p>
<pre><code>type no of times type occurs
101 450
102 562
103 245
111 25
112 28
113 21
</code></pre>
<p>Now suppose I wanted to ge... | [
{
"answer_id": 402453,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>you may use IsFocusable=false. But search box will be disabled too...</p>\n"
},
{
"answer_id": 415155,
"author"... | 2008/12/15 | [
"https://Stackoverflow.com/questions/368215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] | Considering the following table
I have a large table from which I can query to get the following table
```
type no of times type occurs
101 450
102 562
103 245
111 25
112 28
113 21
```
Now suppose I wanted to get a table which shows me the sum ... | We have solved this by overriding the ControlTemplate of the ScrollViewer embedded in the DocumentViewer control. Insert the Style below in "Window.Resources":
```
<Style TargetType="{x:Type ScrollViewer}" x:Key="CustomScrollPresenter">
<Setter Property="Template">
<Setter.Value>
<ControlTempl... |