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 |
|---|---|---|---|---|---|---|
553,682 | <p>I am looking for the definition of when I am allowed to do forward declaration of a class in another class's header file:</p>
<p>Am I allowed to do it for a base class, for a class held as a member, for a class passed to member function by reference, etc. ?</p>
| [
{
"answer_id": 553692,
"author": "dirkgently",
"author_id": 66692,
"author_profile": "https://Stackoverflow.com/users/66692",
"pm_score": 2,
"selected": false,
"text": "<p>As long as you don't need the definition (think pointers and references) you can get away with forward declarations.... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] | I am looking for the definition of when I am allowed to do forward declaration of a class in another class's header file:
Am I allowed to do it for a base class, for a class held as a member, for a class passed to member function by reference, etc. ? | Put yourself in the compiler's position: when you forward declare a type, all the compiler knows is that this type exists; it knows nothing about its size, members, or methods. This is why it's called an *incomplete type*. Therefore, you cannot use the type to declare a member, or a base class, since the compiler would... |
553,708 | <p>The static analysis tool we use is flagging C code similar to the following as a critical buffer overflow.</p>
<pre><code>#define size 64
char buf [size + 1] = "";
memset (buf, 0, size + 1);
</code></pre>
<p>The tool's error message is: <strong>Buffer Overflow</strong> (Array Index Out of Bounds): The array 'bu... | [
{
"answer_id": 553720,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 4,
"selected": false,
"text": "<p>Aside from the fact that char buf[size+1] won't compile because size is a runtime value, assuming you could build buf... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17035/"
] | The static analysis tool we use is flagging C code similar to the following as a critical buffer overflow.
```
#define size 64
char buf [size + 1] = "";
memset (buf, 0, size + 1);
```
The tool's error message is: **Buffer Overflow** (Array Index Out of Bounds): The array 'buf' size is 1. Array 'buf' may use the 0..... | Assigning "" to buf[size+1] does not reset the size of buf, but it is pointless, because it is duplicating a small portion of what the subsequent memset does (and it confuses your static analysis tool - you might want to file a bug report against it). |
553,749 | <p>I'm building a Spring MVC web application with Tiles/JSP as the view technology.
Previously I stored the paths to common images in class Common:</p>
<pre><code> public final static String IMG_BREADCRUMBS_NEXT = "/shared/images/famfam/bullet_arrow_right.png";
</code></pre>
<p>Then I would use this class in jsp to g... | [
{
"answer_id": 553806,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 1,
"selected": false,
"text": "<p>Use a configuration bean in application scope, so you can write something like</p>\n\n<pre><code><img src=\"${con... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15114/"
] | I'm building a Spring MVC web application with Tiles/JSP as the view technology.
Previously I stored the paths to common images in class Common:
```
public final static String IMG_BREADCRUMBS_NEXT = "/shared/images/famfam/bullet_arrow_right.png";
```
Then I would use this class in jsp to get the image src like
```... | In the end I used Spring's theme support to achieve what I wanted.
In my view code I use the `<spring:theme code=""/>` tag to get the path to image file:
```
<img src="<spring:theme code="theme.images.actions.edit.link"/>" />
```
This tag behaves like any `<fmt:message>` or `<spring:message>` tag, but it has its ow... |
553,751 | <p>To check if a column is auto incremented i can do the following</p>
<pre><code>Connection con = ...
DatabaseMetaData meta = con.getMetaData();
ResultSet metaCols = meta.getColumns(catalog, schema, table, "%");
while ( metaCols.next() )
String value = rs.getString("IS_AUTOINCREMENT")
...
</code></p... | [
{
"answer_id": 553895,
"author": "Vincent",
"author_id": 66697,
"author_profile": "https://Stackoverflow.com/users/66697",
"pm_score": 2,
"selected": false,
"text": "<p>Sybase uses 'identity' columns rather than 'default autoincrement' which is why I believe you are getting this message.... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49786/"
] | To check if a column is auto incremented i can do the following
```
Connection con = ...
DatabaseMetaData meta = con.getMetaData();
ResultSet metaCols = meta.getColumns(catalog, schema, table, "%");
while ( metaCols.next() )
String value = rs.getString("IS_AUTOINCREMENT")
...
```
works fine except ... | sp\_help delivers all the information I need.
This SP returns several ResultSets.
The third ResultSet contains the information I need.
```
Statement stmt = con.createStatement();
stmt.executeQuery("sp_help " + table);
stmt.getMoreResults();
stmt.getMoreResults();
ResultSet rs = stmt.getResultSet();
//...
while( rs.nex... |
553,758 | <p>I am having trouble escaping special characters in as3.</p>
<pre><code>trace( escape("who are ü?") );
</code></pre>
<p>returns who%20are%20%uFFFD%3F</p>
<p>or </p>
<pre><code>trace( encodeURIComponent("who are ü?") );
</code></pre>
<p>returns who%20are%20%EF%BF%BD%3F</p>
<p>while in javascript this</p>
<pre><... | [
{
"answer_id": 553894,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 4,
"selected": true,
"text": "<p>Looks like AS is escaping the string as UTF-16, while the Javascript example is escaping as UTF-8. <a href=\"https://de... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62255/"
] | I am having trouble escaping special characters in as3.
```
trace( escape("who are ü?") );
```
returns who%20are%20%uFFFD%3F
or
```
trace( encodeURIComponent("who are ü?") );
```
returns who%20are%20%EF%BF%BD%3F
while in javascript this
```
alert( encodeURIComponent("who are ü?") );
```
returns who%20are%20... | Looks like AS is escaping the string as UTF-16, while the Javascript example is escaping as UTF-8. [`escape`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#escape_and_unescape_functions%28Obsoleted_above_JavaScript_1.5%29) doesn't define how to deal with non-ascii characters, and so it's been ... |
553,762 | <p>Visual Studio seems to complain when I pass a string into an exception parameter.</p>
<pre><code>if (str1 == null || str2 == null)
{
throw new ArgumentNullException("lmkl");
}
</code></pre>
<p>Visual Studio says that it cannot resolve symbol <code>"lmkl"</code>.</p>
<p>If I have a string variable (eg above <c... | [
{
"answer_id": 553779,
"author": "Richard Ev",
"author_id": 39709,
"author_profile": "https://Stackoverflow.com/users/39709",
"pm_score": 4,
"selected": true,
"text": "<p>The documentation for the overloaded constructor for <code>ArgumentNullException</code> that takes a single string pa... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | Visual Studio seems to complain when I pass a string into an exception parameter.
```
if (str1 == null || str2 == null)
{
throw new ArgumentNullException("lmkl");
}
```
Visual Studio says that it cannot resolve symbol `"lmkl"`.
If I have a string variable (eg above `throw new... string s = "test";`) and include... | The documentation for the overloaded constructor for `ArgumentNullException` that takes a single string parameter states that this argument should be:
```
The name of the parameter that caused the exception.
```
At the moment, if your code throws an exception you won't know which argument was null.
Recommend rewriti... |
553,766 | <p>I'm trying to do make the following selection:</p>
<pre><code>$(".program", row)
</code></pre>
<p>Where "row" is a jQuery object containing two table rows. One of the tr's has the class 'program". This selector doesn't seem to find it. However the following works: </p>
<pre><code>$(".title", row)
</code></pre>
... | [
{
"answer_id": 553811,
"author": "Salty",
"author_id": 50548,
"author_profile": "https://Stackoverflow.com/users/50548",
"pm_score": -1,
"selected": false,
"text": "<p>You most certainly are able to match the top level elements. Could we see the source you're using? Your code should be w... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44683/"
] | I'm trying to do make the following selection:
```
$(".program", row)
```
Where "row" is a jQuery object containing two table rows. One of the tr's has the class 'program". This selector doesn't seem to find it. However the following works:
```
$(".title", row)
```
where div.title is a descendant of tr.program. ... | It looks like you're trying to select elements out of the ones you already have selected (residing in the jQuery object).
Context, as far as jQuery is concerned, is like specifying a parent - the context is a node somewhere ABOVE what you're looking for in the DOM tree. The context is where jQuery will look for the se... |
553,767 | <p>I'm trying to have SEO friendly URLs for my wordpress blog, while still having the flexibility to change a post's title at will.</p>
<p>My permalink structure would be like this:</p>
<blockquote>
<p>%post_id%/%postname%</p>
</blockquote>
<p>However, I'd like wordpress to just consider the %post_id% from the URL... | [
{
"answer_id": 553821,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 2,
"selected": false,
"text": "<p>You could try the following rule:</p>\n\n<pre><code>RewriteRule ^(\\d+)(/[^/]*)?$ index.php?id=$1 [L,QSA]\n</code></pre>\... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/810/"
] | I'm trying to have SEO friendly URLs for my wordpress blog, while still having the flexibility to change a post's title at will.
My permalink structure would be like this:
>
> %post\_id%/%postname%
>
>
>
However, I'd like wordpress to just consider the %post\_id% from the URL when looking for the appropriate pos... | My response does not directly answer your question, but I think I have some points worth noting.
>
> I'm trying to have SEO friendly URLs
> for my wordpress blog, while still
> having the flexibility to change a
> post's title at will.
>
>
>
I'm not immediately seeing the benefit of your pursuit.
The obvious ... |
553,784 | <p>I'm using a <strong>Builder</strong> pattern in Python to separate a bunch of different configuration possibilities. Basically, I have a bunch of classes that are named <code>ID...</code> (e.g. <code>ID12345</code>). These all inherit from the base Builder class. In my script, I need to instantiate an instance for e... | [
{
"answer_id": 554034,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 0,
"selected": false,
"text": "<p>There's some stuff missing from your question, so I'm forced to guess at the omitted stuff. Feel free to edit your ques... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53007/"
] | I'm using a **Builder** pattern in Python to separate a bunch of different configuration possibilities. Basically, I have a bunch of classes that are named `ID...` (e.g. `ID12345`). These all inherit from the base Builder class. In my script, I need to instantiate an instance for each class (about 50) every time this a... | Not sure this is what you want but it seems like a more Pythonic way to instantiate a bunch of classes listed in a string:
```
class idClasses:
class ID12345:pass
class ID01234:pass
# could also be: import idClasses
class ProcessDirector:
def __init__(self):
self.allClasses = []
def construct... |
553,788 | <p>i found a translator for c++ to c# , but it doesn't work. (Code2Code.net)</p>
<p>Test with cout </p>
<pre><code>int main(int argc, char** argv)
{
cout << "Hello World";
return 0;
}
</code></pre>
<p>The Results becomes </p>
<pre><code>public static int Main(string [] argv)
{
cout << "Hello World";
... | [
{
"answer_id": 553805,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 3,
"selected": false,
"text": "<p>I am not aware of any as this kind of translation would be <em>very</em> difficult to do. You are trying to transl... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i found a translator for c++ to c# , but it doesn't work. (Code2Code.net)
Test with cout
```
int main(int argc, char** argv)
{
cout << "Hello World";
return 0;
}
```
The Results becomes
```
public static int Main(string [] argv)
{
cout << "Hello World";
return 0;
}
```
My Question to you, is = is it any o... | I am not aware of any as this kind of translation would be *very* difficult to do. You are trying to translate code that was written in an unmanaged language into a language that is managed. Even if you were able to translate the code you would have almost every method marked as `unsafe` which would negate most of the ... |
553,794 | <p>I've created a Word add-in component, and a visual studio setup project to install the component.</p>
<p>On a clean machine with Office 2003 installed, it does not seem to be possible to get the add-in component to load in Word.</p>
<p>Googling the issue suggests that this is because the assembly is not trusted. I... | [
{
"answer_id": 553839,
"author": "Frederick The Fool",
"author_id": 32688,
"author_profile": "https://Stackoverflow.com/users/32688",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think putting the add-in assembly in GAC is compulsory. I think you're just missing a step in your d... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078/"
] | I've created a Word add-in component, and a visual studio setup project to install the component.
On a clean machine with Office 2003 installed, it does not seem to be possible to get the add-in component to load in Word.
Googling the issue suggests that this is because the assembly is not trusted. I gave the assembl... | You can manually run the following command to set security to allow the word to run the assembly from outside the GAC. This creates a new group with full trust which is what allows the assembly to run.
```
caspol.exe -u -addgroup All_Code -url "\*" FullTrust -n AssemblyName.dll
```
Microsoft have an example custom ... |
553,813 | <p>I have created a SCORM API for our LMS and right now I am using hard coded userID and courseID variables (variables that reference things in the database). I need to pass the real userID and courseID instead of using hard coded ones. I know the userID is stored in the session and the courseID is passed over from the... | [
{
"answer_id": 553829,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://weblogs.asp.net/jgalloway/archive/2008/02/10/getting-javascript-and-asp-net-talking-outside-of-aja... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18309/"
] | I have created a SCORM API for our LMS and right now I am using hard coded userID and courseID variables (variables that reference things in the database). I need to pass the real userID and courseID instead of using hard coded ones. I know the userID is stored in the session and the courseID is passed over from the la... | Probably ~~best~~ easiest to expose them as properties of your page (or master page if used on every page) and reference them via page directives.
```
<script type="text/javascript">
var userID = '<%= UserID %>';
var courseID = '<%= CourseID %>';
.... more stuff....
</script>
```
Then set the value... |
553,822 | <p>I'm using postgresql 8.3 and i would like to know the timezone of a particular timestamp (a column in a table).</p>
<p>In the documentation i've found the keyword <a href="http://www.postgresql.org/docs/8.3/static/functions-datetime.html" rel="noreferrer">"timezone"</a> </p>
<p>But i don't understand how to apply ... | [
{
"answer_id": 553855,
"author": "Johannes Weiss",
"author_id": 55925,
"author_profile": "https://Stackoverflow.com/users/55925",
"pm_score": 5,
"selected": true,
"text": "<p>I assume you have a column named <code>ct</code> which has the type <code>TIMESTAMPTZ</code> in the table <code>t... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41572/"
] | I'm using postgresql 8.3 and i would like to know the timezone of a particular timestamp (a column in a table).
In the documentation i've found the keyword ["timezone"](http://www.postgresql.org/docs/8.3/static/functions-datetime.html)
But i don't understand how to apply it in a column of table. Is it possible ? | I assume you have a column named `ct` which has the type `TIMESTAMPTZ` in the table `t`. Then you can use:
```
SELECT EXTRACT(TIMEZONE FROM ct) FROM t;
```
to get the offset of the timezone in seconds. It that gives you `3600` from `UTC`/`GMT` that means either `GMT+1`, `CET` or whatever. The value returned depends ... |
553,823 | <p>I've created a (System.Windows.Controls.Primitives.)Popup that contains a Treeview that I'm populating with data read in from a file. The Popup is created in code rather than in xaml. I want to add checkboxes to the treeview in a similar way to the CheckedTreeViewItemSample.xaml that comes in the Silverlight Toolk... | [
{
"answer_id": 559387,
"author": "mattmanser",
"author_id": 62829,
"author_profile": "https://Stackoverflow.com/users/62829",
"pm_score": 2,
"selected": true,
"text": "<p>You need to put the controls into the header property of the treeviewitems you're adding:</p>\n\n<pre><code> v... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5025/"
] | I've created a (System.Windows.Controls.Primitives.)Popup that contains a Treeview that I'm populating with data read in from a file. The Popup is created in code rather than in xaml. I want to add checkboxes to the treeview in a similar way to the CheckedTreeViewItemSample.xaml that comes in the Silverlight Toolkit.
... | You need to put the controls into the header property of the treeviewitems you're adding:
```
var myTreeViewItem = new TreeViewItem();
var myContentHolder = new StackPanel();
var myCheckBox = new CheckBox();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "blah";
... |
553,824 | <p>I'm encountering a problem while trying to serialize a multi-dimensioned array of integers via <code>XmlSerializer</code> for an XNA project I'm working on. I'm able to serialize all of my other data (booleans, strings, even Colors, etc) without a hitch. I've also seen plenty of people claim that <code>XmlSerializer... | [
{
"answer_id": 553842,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Read the inner-exceptions:</p>\n\n<ul>\n<li>There was an error reflecting type 'SomeType'. Cannot serialize member ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61665/"
] | I'm encountering a problem while trying to serialize a multi-dimensioned array of integers via `XmlSerializer` for an XNA project I'm working on. I'm able to serialize all of my other data (booleans, strings, even Colors, etc) without a hitch. I've also seen plenty of people claim that `XmlSerializer` will natively han... | Read the inner-exceptions:
* There was an error reflecting type 'SomeType'. Cannot serialize member 'SomeType.Data' of type 'System.Int32[,,]', see inner exception for more details.
* Cannot serialize object of type System.Int32[,,]. Multidimensional arrays are not supported.
So no: multi-dimensional arrays simply ar... |
553,846 | <p>Attempting to <strong>disable</strong> BSTR caching:</p>
<pre><code>SetOaNoCache();
</code></pre>
<p>VC++ compiler <strong>build output</strong>:</p>
<ul>
<li><code>'SetOaNoCache': identifier not found</code></li>
</ul>
<p><strong>Don't</strong> want to use:</p>
<ul>
<li>OANOCACHE=1</li>
</ul>
<p><strong>Quest... | [
{
"answer_id": 553878,
"author": "Patrick Glandien",
"author_id": 66760,
"author_profile": "https://Stackoverflow.com/users/66760",
"pm_score": 4,
"selected": true,
"text": "<p>It is not defined in a header file, it is in OLEAUT32.dll. You can call it like this:</p>\n\n<p><pre><code>type... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51078/"
] | Attempting to **disable** BSTR caching:
```
SetOaNoCache();
```
VC++ compiler **build output**:
* `'SetOaNoCache': identifier not found`
**Don't** want to use:
* OANOCACHE=1
**Question:**
* Where is [SetOaNoCache](http://msdn.microsoft.com/en-us/library/ms644360.aspx) **defined** - header file? | It is not defined in a header file, it is in OLEAUT32.dll. You can call it like this:
```
typedef int (*SETOANOCACHE)(void);
```
void DisableBSTRCache()
{
HINSTANCE hLib = LoadLibrary("OLEAUT32.DLL");
if (hLib != NULL)
{
SETOANOCACHE SetOaNoCache = (SETOANOCACHE)GetProcAddress(hLib, "SetOaNoCache");
if (SetOaNoC... |
553,856 | <p>The first normal form says that row ordering should not matter.
Does this mean that a table with date as part of the key is not 1NF?
e.g.
Consider a table of ticker prices where date/time is part of the PK. In this case, you get the last price by ordering the data by date and selecting the top 1 row.
Does this mean ... | [
{
"answer_id": 553883,
"author": "kmkaplan",
"author_id": 50902,
"author_profile": "https://Stackoverflow.com/users/50902",
"pm_score": 0,
"selected": false,
"text": "<p>No. It means that there is no intrinsic order. If you want the date of the last price you have to <code>select max(d... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The first normal form says that row ordering should not matter.
Does this mean that a table with date as part of the key is not 1NF?
e.g.
Consider a table of ticker prices where date/time is part of the PK. In this case, you get the last price by ordering the data by date and selecting the top 1 row.
Does this mean tha... | `1NF` is aspect of a table representing a *relation*, not of a table as such.
If your relation says `ticket HAS price`, that it's a `1NF` violation, as you cannot determine if a `ticket` `HAS` or `HAS NOT` the `price` by looking on a single record. You'll need to fetch all prices on this ticket and select last of them... |
553,857 | <p>I have a Java library I'm considering porting to C#. The Java library makes extensive use of annotations (at both build time and run time.)</p>
<p>I've never used C# attributes, but understand that they are the rough equivalent of Java annotations.</p>
<p>If I proceed with the port using attributes to replace ann... | [
{
"answer_id": 553898,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>One important aspect of Java annotations which I haven't looked at in detail yet: you can write code which uses annot... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44757/"
] | I have a Java library I'm considering porting to C#. The Java library makes extensive use of annotations (at both build time and run time.)
I've never used C# attributes, but understand that they are the rough equivalent of Java annotations.
If I proceed with the port using attributes to replace annotations, what do ... | Control over when your metadata is made accessible is different between the two languages.
**Java provides the [java.lang.annotation.Retention](http://java.sun.com/javase/6/docs/api/java/lang/annotation/Retention.html) annotation and [java.lang.annotation.RetentionPolicy](http://java.sun.com/javase/6/docs/api/java/la... |
553,863 | <p>When developing a web application using ASP.NET, do you have any hints about how to separate the development of content/functionality from the design, so that the two can be developed separately and in parallel?</p>
<p>The situation is:</p>
<ul>
<li>Customer has agreed on what functionality they want</li>
<li>Cust... | [
{
"answer_id": 553891,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 1,
"selected": false,
"text": "<p>This may seem a bit drastic but one way to do this would be to make your web application service-based. This means... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49942/"
] | When developing a web application using ASP.NET, do you have any hints about how to separate the development of content/functionality from the design, so that the two can be developed separately and in parallel?
The situation is:
* Customer has agreed on what functionality they want
* Customer is changing their mind ... | No easy answer to this one but I would start by making it a little easier on your designer - lay down the basic CSS elements first. For example, if you know the color scheme you already have the background. You probably already have an idea of whether you're going for the wide or narrow look. So, you already have the s... |
553,871 | <p>I'm trying to generate the <a href="http://www.ocf.berkeley.edu/~stoll/answer.html" rel="nofollow noreferrer">morris sequence</a> in python. My current solution is below, but I feel like I just wrote c in python. Can anyone provide a more pythonic solution?</p>
<pre><code>def morris(x):
a = ['1', '11']
yiel... | [
{
"answer_id": 554002,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<pre><code>from itertools import groupby, islice\n\ndef morris():\n morris = '1'\n yield morris\n while True:\n ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7407/"
] | I'm trying to generate the [morris sequence](http://www.ocf.berkeley.edu/~stoll/answer.html) in python. My current solution is below, but I feel like I just wrote c in python. Can anyone provide a more pythonic solution?
```
def morris(x):
a = ['1', '11']
yield a[0]
yield a[1]
while len(a) <= x:
... | [`itertools.groupby`](http://docs.python.org/library/itertools.html#itertools.groupby) seems to fit perfectly! Just define a `next_morris` function as follows:
```
def next_morris(number):
return ''.join('%s%s' % (len(list(group)), digit)
for digit, group in itertools.groupby(str(number)))
```
... |
553,888 | <p>How does one open a semicolon delimited CSV file with VBA in Excel 2000?</p>
<p><strong>Sample data</strong></p>
<pre><code>An ID;TEST20090222
A Name;Firstname Surname
A Date;11.05.2000
Country:;SomeCountryName
Currency;EUR
CostA;
CostB;
CostC;
Part1;10;20;30
Part2;;;;
Part3;34;56;87
</code></pre>
<p><strong>Cod... | [
{
"answer_id": 553943,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure, but you can try recording a macro to do the same thing and check the VBA code it produces. You might get a hint t... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33311/"
] | How does one open a semicolon delimited CSV file with VBA in Excel 2000?
**Sample data**
```
An ID;TEST20090222
A Name;Firstname Surname
A Date;11.05.2000
Country:;SomeCountryName
Currency;EUR
CostA;
CostB;
CostC;
Part1;10;20;30
Part2;;;;
Part3;34;56;87
```
**Code**
In Excel **2003** 11.8231.8221 SP3 with VBA 6.5... | **[Update 22.02.2009]**
In the meantime, I solved the problem by writing an import function myself instead of using Workbooks.OpenText.
I just open the CSV file as a text file, read line by line, split each line into the semicolon separated elements and write each element into a cell.
```
Sub ImportCSVFile(filepath ... |
553,904 | <p>I'm using XSLT to restructure an XML file. The following code copies all child nodes to a new XML file:</p>
<pre><code><!--Add all child elements of the zzz node-->
<xsl:template match="zzz">
<Trade>
<xsl:attribute name="ID">
<xsl:value-of select="TradeId" />
... | [
{
"answer_id": 553959,
"author": "Teun D",
"author_id": 64963,
"author_profile": "https://Stackoverflow.com/users/64963",
"pm_score": 0,
"selected": false,
"text": "<p>You can just include the namespace in your stylesheet like so:</p>\n\n<pre><code><!--Add all child elements of the zz... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60118/"
] | I'm using XSLT to restructure an XML file. The following code copies all child nodes to a new XML file:
```
<!--Add all child elements of the zzz node-->
<xsl:template match="zzz">
<Trade>
<xsl:attribute name="ID">
<xsl:value-of select="TradeId" />
</xsl:attribute>
<xsl:copy-of ... | **The previous two answers (by teun and Craig Bovis) are not correct** -- see my comments to each of these.
**The corect way to move a given element to a new namespace involves re-creating this element as shown below**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output ... |
553,905 | <p>I have a key combination like this</p>
<pre><code>Keys key=Keys.Control | Keys.Shift | Keys.D ...
</code></pre>
<p>I don't know how to expand key variable to separated Keys values. Maybe like this</p>
<pre><code>foreach(Keys k in key)
{
MessageBox.Show(k.ToString());
}
</code></pre>
<p>this seems stupid to me... | [
{
"answer_id": 553930,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 3,
"selected": false,
"text": "<p>See the definition of keys. All values act as normal, mutually-exclusive values, except the following:</p>\n\n<pre><... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60200/"
] | I have a key combination like this
```
Keys key=Keys.Control | Keys.Shift | Keys.D ...
```
I don't know how to expand key variable to separated Keys values. Maybe like this
```
foreach(Keys k in key)
{
MessageBox.Show(k.ToString());
}
```
this seems stupid to me. How to do this? | ```
Keys key = Keys.Control | Keys.Shift | Keys.D;
foreach (string s in key.ToString().Split(','))
{
Keys k = (Keys) Enum.Parse(typeof(Keys), s.Trim());
Console.WriteLine(k);
}
``` |
553,918 | <p>I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole table. </p>
<pre><code>EDIT: Tables:
Person (personid, name)
Personlocation (personid, locationid)
Location (loca... | [
{
"answer_id": 554149,
"author": "giuice",
"author_id": 462814,
"author_profile": "https://Stackoverflow.com/users/462814",
"pm_score": 5,
"selected": true,
"text": "<p>In Lambda :</p>\n\n<pre><code> var persons = Persons.Where(p=>(p.PersonLocations.Select(ps=>ps.Location)\n .... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66873/"
] | I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole table.
```
EDIT: Tables:
Person (personid, name)
Personlocation (personid, locationid)
Location (locationid, descri... | In Lambda :
```
var persons = Persons.Where(p=>(p.PersonLocations.Select(ps=>ps.Location)
.Where(l=>l.Description == "Amsterdam").Count() > 0)
&& (p.PersonRoles.Select(pr=>pr.Role)
.Where(r=>r.Description == "Student").Count() > 0));
```
**query result:**
```
SELECT [t0].[personId] AS [PersonId], [t0]... |
553,936 | <p>In my AJAX call, I want to return a string value back to the calling page.</p>
<p>Should I use <code>ActionResult</code> or just return a string? </p>
| [
{
"answer_id": 553952,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 11,
"selected": true,
"text": "<p>You can just use the <a href=\"https://msdn.microsoft.com/en-us/library/system.web.mvc.contentresult.aspx\" rel=\"norefer... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67033/"
] | In my AJAX call, I want to return a string value back to the calling page.
Should I use `ActionResult` or just return a string? | You can just use the [`ContentResult`](https://msdn.microsoft.com/en-us/library/system.web.mvc.contentresult.aspx "MSDN documentation") to return a plain string:
```
public ActionResult Temp() {
return Content("Hi there!");
}
```
[`ContentResult`](https://msdn.microsoft.com/en-us/library/system.web.mvc.contentre... |
553,942 | <p>I am trying to add and remove events from a timer and I have the following code:</p>
<pre><code>Timer myTimer = new Timer(); // Windows.Forms Timer
public void addEvent(MyDelegate ev)
{
myTimer.Tick += new EventHandler(ev);
}
public void removeEvent(MyDelegate ev)
{
myTimer.Tick -= new EventHandler(ev);
}... | [
{
"answer_id": 553965,
"author": "Factor Mystic",
"author_id": 1569,
"author_profile": "https://Stackoverflow.com/users/1569",
"pm_score": 0,
"selected": false,
"text": "<p>You should just be able to unsubscribe by referencing the name of your even handling method like so:</p>\n\n<pre><c... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] | I am trying to add and remove events from a timer and I have the following code:
```
Timer myTimer = new Timer(); // Windows.Forms Timer
public void addEvent(MyDelegate ev)
{
myTimer.Tick += new EventHandler(ev);
}
public void removeEvent(MyDelegate ev)
{
myTimer.Tick -= new EventHandler(ev);
}
```
I don't... | I believe that this code:
```
myTimer.Tick -= new EventHandler(ev);
```
creates a new EventHandler object. It will never remove an existing EventHandler. To get the functionality you want, you should be passing in EventHandlers, not MyDelegates, to the add and remove methods:
```
Timer myTimer = new Timer(); // Win... |
553,964 | <p>i have a datagrid and for one of the columns im using an item renderer to display content. Im wondering is it possible to access the dataprovider content of the datagrid inside a script block in the itemRenderer.</p>
<p>Currently I can access the dataprovider in a component in the item renderer using data.variableN... | [
{
"answer_id": 554026,
"author": "Buzzy",
"author_id": 38070,
"author_profile": "https://Stackoverflow.com/users/38070",
"pm_score": 3,
"selected": true,
"text": "<p>You can specify your own ItemRenderer component. Within the MXML of that component you can use the Script block however li... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | i have a datagrid and for one of the columns im using an item renderer to display content. Im wondering is it possible to access the dataprovider content of the datagrid inside a script block in the itemRenderer.
Currently I can access the dataprovider in a component in the item renderer using data.variableName.
I wa... | You can specify your own ItemRenderer component. Within the MXML of that component you can use the Script block however like.
Just specify the that component as the ItemRenderer like so:
```
<mx:DataGrid dataProvider="{ac}">
mx:columns>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
... |
553,974 | <p>So I'm learning C++. I've got my "C++ Programming Language" and "Effective C++" out and I'm running through Project Euler. Problem 1...dunzo. Problem 2...not so much. I'm working in VS2008 on a Win32 Console App.</p>
<p>Whats the Sum of all even terms of the Fibonacci Sequence under 4 million? </p>
<p>It wasn... | [
{
"answer_id": 553986,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 7,
"selected": true,
"text": "<p>Casting to <code>int</code> truncates the number - same as if you'd called <code>floor(currentFib)</code>. So even if <code>cu... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6212/"
] | So I'm learning C++. I've got my "C++ Programming Language" and "Effective C++" out and I'm running through Project Euler. Problem 1...dunzo. Problem 2...not so much. I'm working in VS2008 on a Win32 Console App.
Whats the Sum of all even terms of the Fibonacci Sequence under 4 million?
It wasn't working so I cut do... | Casting to `int` truncates the number - same as if you'd called `floor(currentFib)`. So even if `currentFib` is `54.999999`... (a number so close to 55 that it will be rounded up when printed), `(int)currentFib` will produce 54. |
553,990 | <p>Hy,</p>
<p>I'm writing a class which should help me in unit tests. The class offers methods to perform Assertions on Exceptions. </p>
<p>Until now I was able to write methods which take a function with no parameters and no return value as input. To do this I use the System.Action - delegates.
My class looks like t... | [
{
"answer_id": 554022,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 3,
"selected": true,
"text": "<p>You should \"declare\" T and TResult as well, e.g.</p>\n\n<pre><code>public static void Throws<T, TResult, TExcepti... | 2009/02/16 | [
"https://Stackoverflow.com/questions/553990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43532/"
] | Hy,
I'm writing a class which should help me in unit tests. The class offers methods to perform Assertions on Exceptions.
Until now I was able to write methods which take a function with no parameters and no return value as input. To do this I use the System.Action - delegates.
My class looks like this:
```
interna... | You should "declare" T and TResult as well, e.g.
```
public static void Throws<T, TResult, TException>(Func<T, TResult> methodToExecute, T methodArgument) where TException : System.Exception
```
otherwise the compiler does not know what T and TResult are. |
554,009 | <p>I'm using sqlite as a datasource in an iPhone app. I have two questions regarding application upgrades.</p>
<p>1.) The data is all config/nontransactional. Meaning, it is readonly. When I update/add config data, I'll issue an upgrade for the app. When a user gets an updated iPhone app, does the original get unin... | [
{
"answer_id": 557784,
"author": "cdespinosa",
"author_id": 25972,
"author_profile": "https://Stackoverflow.com/users/25972",
"pm_score": 3,
"selected": false,
"text": "<p>When the user upgrades the app, the old app bundle is uninstalled and the new app bundle is installed, but the user ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | I'm using sqlite as a datasource in an iPhone app. I have two questions regarding application upgrades.
1.) The data is all config/nontransactional. Meaning, it is readonly. When I update/add config data, I'll issue an upgrade for the app. When a user gets an updated iPhone app, does the original get uninstalled? If t... | cdespinosa has described scenario #1 well, so I'll tackle #2.
I haven't done this on the iPhone yet, but on a desktop environment the easiest way to handle this is to keep your configuration data in a separate database. You can attach to multiple databases rather easily. Start by opening your main database, which shou... |
554,010 | <p>I am writing an administrative script, and I need to calculate the size of files on disk. </p>
<p>These files are on a compressed NTFS volume.</p>
<p>I can't use <code>FileInfo.Length</code>, because that is file size and not size on disk. For example, if I have a 100MB file, but it is only using 25MB due to NTF... | [
{
"answer_id": 557890,
"author": "Goyuix",
"author_id": 243,
"author_profile": "https://Stackoverflow.com/users/243",
"pm_score": 3,
"selected": false,
"text": "<p>Load up the Managed Windows API (<a href=\"http://mwinapi.sourceforge.net/\" rel=\"noreferrer\"><a href=\"http://mwinapi.sou... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67038/"
] | I am writing an administrative script, and I need to calculate the size of files on disk.
These files are on a compressed NTFS volume.
I can't use `FileInfo.Length`, because that is file size and not size on disk. For example, if I have a 100MB file, but it is only using 25MB due to NTFS compression, I need my scrip... | (edit)
I figured out how to dynamically add a property (called a "script property") to the Fileobject, so now, I can use the syntax: $theFileObject.CompressedSize to read the size.
(end of edit)
Read Goyuix's response, and I thought "Cool, but isn't there some kind of type-extension capability in Powershell?". So th... |
554,011 | <p>A git clone is set up to support pushing/pulling back into the original repository. How do I use git-remote (and/or other commands, configuration files, etc.) to change the two repositories such that the original will now act like the clone, pushing and pulling into it by default, and the clone will now act as the ... | [
{
"answer_id": 554046,
"author": "Paul Beckingham",
"author_id": 14356,
"author_profile": "https://Stackoverflow.com/users/14356",
"pm_score": 4,
"selected": true,
"text": "<p>Issue these commands on what used to be the remote:</p>\n\n<pre><code>% git remote add origin user@machine:/path... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | A git clone is set up to support pushing/pulling back into the original repository. How do I use git-remote (and/or other commands, configuration files, etc.) to change the two repositories such that the original will now act like the clone, pushing and pulling into it by default, and the clone will now act as the orig... | Issue these commands on what used to be the remote:
```
% git remote add origin user@machine:/path/to/repo
% git config branch.master.remote origin
% git config branch.master.merge refs/heads/master
% git pull
```
Then on the old clone:
```
% git remote rm origin
``` |
554,013 | <p>I would like to use the .Net Regex.Split method to split this input string into an array. <strong>It must split on whitespace unless it is enclosed in a quote.</strong></p>
<p>Input:
Here is "my string" it has "six matches"</p>
<p>Expected output:</p>
<ol>
<li>Here</li>
<li>is</... | [
{
"answer_id": 554030,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 1,
"selected": false,
"text": "<p>EDIT: Sorry for my previous post, this is obviously possible.</p>\n\n<p>To handle all the non-alphanumeric characters you... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514/"
] | I would like to use the .Net Regex.Split method to split this input string into an array. **It must split on whitespace unless it is enclosed in a quote.**
Input:
Here is "my string" it has "six matches"
Expected output:
1. Here
2. is
3. my string
4. it
5. has
6. six matches
What pattern do I need? Also do I ... | No options required
Regex:
```
\w+|"[\w\s]*"
```
C#:
```
Regex regex = new Regex(@"\w+|""[\w\s]*""");
```
**Or if you need to exclude " characters:**
```
Regex
.Matches(input, @"(?<match>\w+)|\""(?<match>[\w\s]*)""")
.Cast<Match>()
.Select(m => m.Groups["match"].Value)
.ToLis... |
554,015 | <p>If I intercept a key press using win32 calls, I now have a key code. Is there a way to convert that to a System.Windows.Forms.Keys value?</p>
| [
{
"answer_id": 554069,
"author": "xcud",
"author_id": 61396,
"author_profile": "https://Stackoverflow.com/users/61396",
"pm_score": 4,
"selected": false,
"text": "<p>Use <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.keyinterop.keyfromvirtualkey\" rel=\"nofol... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | If I intercept a key press using win32 calls, I now have a key code. Is there a way to convert that to a System.Windows.Forms.Keys value? | The integer values for System.Windows.Forms.Keys enum match that of the Win32 calls.
```
Keys keyData = (Keys)rawWin32KeyCode;
``` |
554,039 | <p>I am building a Facebook Connect application that runs inside a Google gadget. Being a gadget means that the application runs inside an iframe. Inside the application, there is a form that allows registered users to post comments. The submission is made using AJAX, but I get the same results with a normal form. The ... | [
{
"answer_id": 554415,
"author": "Antoine Aubry",
"author_id": 2680,
"author_profile": "https://Stackoverflow.com/users/2680",
"pm_score": 1,
"selected": false,
"text": "<p>I found a work-around that works, although it is a bit ugly: when the user clicks the 'login' button, it opens a po... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2680/"
] | I am building a Facebook Connect application that runs inside a Google gadget. Being a gadget means that the application runs inside an iframe. Inside the application, there is a form that allows registered users to post comments. The submission is made using AJAX, but I get the same results with a normal form. The pro... | Have you tried adding a P3P policy ?
If the response setting the cookie has a compact policy, IE will use this to determine whether or not to allow the 3rd party cookie.. |
554,044 | <p>Working on Maths problems, I'm very fond of LINQ to Data.</p>
<p>I would like to know if LINQ is smart enough to avoid a cast like .ToArray() when the IEnumerable I work with is already an array.
See example below:</p>
<pre><code>/// <summary> Transforms an array of timeSeries into one ModelData. </summar... | [
{
"answer_id": 554066,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 2,
"selected": false,
"text": "<p>I suspect that it will do what you ask and create a new array. Could you not change your constructor of <code>ModelD... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28216/"
] | Working on Maths problems, I'm very fond of LINQ to Data.
I would like to know if LINQ is smart enough to avoid a cast like .ToArray() when the IEnumerable I work with is already an array.
See example below:
```
/// <summary> Transforms an array of timeSeries into one ModelData. </summary>
public static ModelData ToM... | LINQ creates a copy of the array, *and this is the correct behaviour* IMO. It would be highly confusing if calling `ToArray()` and then modifying the returned array *sometimes* modified the original collection and *sometimes* didn't. |
554,063 | <p>In my <a href="https://stackoverflow.com/questions/553974/why-does-int55-54-in-c">earlier question</a> I was printing a <code>double</code> using <code>cout</code> that got rounded when I wasn't expecting it. How can I make <code>cout</code> print a <code>double</code> using full precision?</p>
| [
{
"answer_id": 554078,
"author": "Paul Beckingham",
"author_id": 14356,
"author_profile": "https://Stackoverflow.com/users/14356",
"pm_score": 6,
"selected": false,
"text": "<p>Use <a href=\"http://en.cppreference.com/w/cpp/io/manip/setprecision\" rel=\"noreferrer\"><code>std::setprecisi... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6212/"
] | In my [earlier question](https://stackoverflow.com/questions/553974/why-does-int55-54-in-c) I was printing a `double` using `cout` that got rounded when I wasn't expecting it. How can I make `cout` print a `double` using full precision? | You can set the precision directly on `std::cout` and use the [`std::fixed`](http://en.cppreference.com/w/cpp/io/manip/fixed) format specifier.
```
double d = 3.14159265358979;
cout.precision(17);
cout << "Pi: " << fixed << d << endl;
```
You can `#include <limits>` to get the maximum precision of a float or double.... |
554,064 | <p>I'm seeing the following errors in my console logs:</p>
<pre><code>HPROF ERROR: unable to resolve a method id
HPROF ERROR: got NULL trace in obj_alloc
HPROF ERROR: duplicate obj_id in object_alloc
HPROF ERROR: unable to resolve a method id
HPROF ERROR: got NULL trace in obj_alloc
HPROF ERROR: unable to resolve a me... | [
{
"answer_id": 554441,
"author": "Peter Lawrey",
"author_id": 57695,
"author_profile": "https://Stackoverflow.com/users/57695",
"pm_score": 1,
"selected": false,
"text": "<p>It could be either</p>\n\n<ul>\n<li>a bug in the JVM, try using a more up to date JVM and see if you get the same ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28991/"
] | I'm seeing the following errors in my console logs:
```
HPROF ERROR: unable to resolve a method id
HPROF ERROR: got NULL trace in obj_alloc
HPROF ERROR: duplicate obj_id in object_alloc
HPROF ERROR: unable to resolve a method id
HPROF ERROR: got NULL trace in obj_alloc
HPROF ERROR: unable to resolve a method id
HPROF ... | It could be either
* a bug in the JVM, try using a more up to date JVM and see if you get the same problem.
* you have a JNI library which is creating objects incorrectly. |
554,074 | <p>Was doing some benchmarking with IsNumeric today and compared it to the following function:</p>
<pre><code>Private Function IsNumeric(ByVal str As String) As Boolean
If String.IsNullOrEmpty(Str) Then Return False
Dim c As Char
For i As Integer = 0 To Str.Length - 1
c = Str(i)
If Not Cha... | [
{
"answer_id": 554084,
"author": "Welbog",
"author_id": 52443,
"author_profile": "https://Stackoverflow.com/users/52443",
"pm_score": 5,
"selected": true,
"text": "<p>Where is your check for locale-specific delimiters and decimal places? Negation? Exponential notation?</p>\n\n<p>You see,... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64730/"
] | Was doing some benchmarking with IsNumeric today and compared it to the following function:
```
Private Function IsNumeric(ByVal str As String) As Boolean
If String.IsNullOrEmpty(Str) Then Return False
Dim c As Char
For i As Integer = 0 To Str.Length - 1
c = Str(i)
If Not Char.IsNumber(c) ... | Where is your check for locale-specific delimiters and decimal places? Negation? Exponential notation?
You see, your function is only a tiny subset of what numeric strings can be.
```
1,000,000.00
1,5E59
-123456789
```
You're missing all of these. |
554,091 | <p>I'm trying to use an unmanaged dll in VB.NET. The example source code provided with the dll is in VB6 and below is my attempt to convert it to .NET. When the dll tries to do a callback I get a "Attempted to read or write protected memory" exception. I really don't care about the callback function getting actually ca... | [
{
"answer_id": 554112,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": true,
"text": "<p>Can you post the original native definiton for AlertManC? </p>\n\n<p>My guess though is that the data parameter of the... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41065/"
] | I'm trying to use an unmanaged dll in VB.NET. The example source code provided with the dll is in VB6 and below is my attempt to convert it to .NET. When the dll tries to do a callback I get a "Attempted to read or write protected memory" exception. I really don't care about the callback function getting actually calle... | Can you post the original native definiton for AlertManC?
My guess though is that the data parameter of the callback function is actually an Integer vs. a Long. In VB6 I believe Long's were actually only 32 bits vs. VB.Net where they are 64 bit. Try this
```
<DllImport("AlertMan.dll")> _
Public Shared Function... |
554,092 | <p>I have an SSIS package to load data; as you may recall there are flags that are in data files as Y/N char(1) when I am trying to load them as bit flags into SQL Server. I am specifying the columns in the data file as <code>String [DT_STR]</code> and I have a data conversion task to convert them to booleans based on... | [
{
"answer_id": 557067,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 4,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>(DT_BOOL)([ColumnName] == \"Y\" ? 1 : 0)\n</code></pre>\n\n<p>This also has the advantage... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40667/"
] | I have an SSIS package to load data; as you may recall there are flags that are in data files as Y/N char(1) when I am trying to load them as bit flags into SQL Server. I am specifying the columns in the data file as `String [DT_STR]` and I have a data conversion task to convert them to booleans based on the following ... | I was able to solve it by using a derived column and, instead of replacing the char columns, creating new columns set to type of `DT_BOOL` like so:
```
[Recycled] == "Y" ? True : False
``` |
554,094 | <p>How do I create a custom attribute to extend existing Authorize attribute in MVC?</p>
| [
{
"answer_id": 554110,
"author": "Mike Chaliy",
"author_id": 38975,
"author_profile": "https://Stackoverflow.com/users/38975",
"pm_score": 2,
"selected": false,
"text": "<pre><code>public class CoolAuthorizeAttribute : AuthorizeAttribute\n{\n}\n</code></pre>\n"
},
{
"answer_id":... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] | How do I create a custom attribute to extend existing Authorize attribute in MVC? | Derive your class from AuthorizeAttribute. Override the OnAuthorization method. Add and set up a CacheValidationHandler.
```
public void CacheValidationHandler( HttpContext context,
object data,
ref HttpValidationStatus validationStatus )
{
va... |
554,100 | <p>TypeInfo(Type) returns the info about the specified type, is there any way to know the typeinfo of a var?</p>
<pre><code>var
S: string;
Instance: IObjectType;
Obj: TDBGrid;
Info: PTypeInfo;
begin
Info:= TypeInfo(S);
Info:= TypeInfo(Instance);
Info:= TypeInfo(Obj);
end
</code></pre>
<p>This code retur... | [
{
"answer_id": 554135,
"author": "Ken White",
"author_id": 62576,
"author_profile": "https://Stackoverflow.com/users/62576",
"pm_score": 2,
"selected": false,
"text": "<p>Not that I know of. You can get RTTI (Run Time Type Information) on published properties of a class, but not for \"no... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36875/"
] | TypeInfo(Type) returns the info about the specified type, is there any way to know the typeinfo of a var?
```
var
S: string;
Instance: IObjectType;
Obj: TDBGrid;
Info: PTypeInfo;
begin
Info:= TypeInfo(S);
Info:= TypeInfo(Instance);
Info:= TypeInfo(Obj);
end
```
This code returns:
**[DCC Error] Unit1.p... | No.
First, there's no such thing as a "non-instantiated variable." You instantiate it by the mere act of typing its name and type into your source file.
Second, you already know all there is to know about a variable by looking at it in your source code. The variable *ceases to exist* once your program is compiled. Af... |
554,111 | <p>Sometimes when displaying a calendar it is necessary to prevent the weekend days and the weekend names in the day header from showing, is there a way to do this using the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.aspx" rel="noreferrer">ASP.NET Calendar control</a>?</p>
| [
{
"answer_id": 554122,
"author": "Mike Chaliy",
"author_id": 38975,
"author_profile": "https://Stackoverflow.com/users/38975",
"pm_score": 0,
"selected": false,
"text": "<p>As far I know you can't, but you can experiment with WeekendDayStyle, for example by setting style with display:non... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] | Sometimes when displaying a calendar it is necessary to prevent the weekend days and the weekend names in the day header from showing, is there a way to do this using the [ASP.NET Calendar control](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.aspx)? | As the control is provided, there is no way to do this without overriding the control. One way of doing this is to is to override the [OnDayRender](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.ondayrender.aspx) and [Render](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.... |
554,120 | <p>I'm building a ResourceBundle from a file, this bundle holds < String, String> values.</p>
<pre><code>InputStream in = getClass().getResourceAsStream("SQL.properties");
properties = new PropertyResourceBundle(in);
in.close();
</code></pre>
<p>I would like to add/<strong>replace</strong> on this bundle some prop... | [
{
"answer_id": 554153,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 0,
"selected": false,
"text": "<p>This might not be the best way to do it but it's the best I can think of: implement a subclass of <code>ResourceBundle<... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55584/"
] | I'm building a ResourceBundle from a file, this bundle holds < String, String> values.
```
InputStream in = getClass().getResourceAsStream("SQL.properties");
properties = new PropertyResourceBundle(in);
in.close();
```
I would like to add/**replace** on this bundle some properties that I'm passing from the command l... | This does some of what you want (converts the System.properties to a ResourceBundle). Better error handling is left up to you :-)
```
public static ResourceBundle createBundle()
{
final ResourceBundle bundle;
final Properties properties;
final CharArrayWriter charWriter;
... |
554,123 | <p>Is there a way to get a site's (site collection) site directory, the one which is defined within the web site collection setting of a collaboration or publishing portal?</p>
<p>Of course I could iterate through all the SPWebs of the site collection but I hope there's a easier way to get the directory as the informa... | [
{
"answer_id": 555384,
"author": "Fuzzy Purple Monkey",
"author_id": 3936,
"author_profile": "https://Stackoverflow.com/users/3936",
"pm_score": 0,
"selected": false,
"text": "<p>Are you referring to the site directory that is under the <strong>Site Content and Structure</strong>?</p>\n\... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19601/"
] | Is there a way to get a site's (site collection) site directory, the one which is defined within the web site collection setting of a collaboration or publishing portal?
Of course I could iterate through all the SPWebs of the site collection but I hope there's a easier way to get the directory as the information seems... | The site directory path is stored in the root web property bag
The code below taken from an internal utility class SiteDirectoryUtil shows the logic of how to determine the path
```
internal static string GetLocalSiteDirectoryLocation(SPWeb rootWeb)
{
if (rootWeb != null)
{
if (rootWeb.AllProperties.... |
554,142 | <p><strong>Question:</strong> What I'm looking for is the <em>most typical or best practice</em> way to use a separate thread to receive data using an IdTCPClient in Indy 10. </p>
<p><strong>Background:</strong> The below code is a sample of what I'm trying to do with the actual data processing parts removed for clari... | [
{
"answer_id": 554246,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 3,
"selected": false,
"text": "<p>You're on the right track. Indy is <em>intended</em> to be used like that. It uses <em>blocking sockets</em>, so th... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2447/"
] | **Question:** What I'm looking for is the *most typical or best practice* way to use a separate thread to receive data using an IdTCPClient in Indy 10.
**Background:** The below code is a sample of what I'm trying to do with the actual data processing parts removed for clarity. The Idea of the Thread is to receive al... | If you want to avoid the overhead imposed by creating thread classes for each and every client-server data exchange, you could create a motile threading class as described in
<http://delphidicas.blogspot.com/2008/08/anonymous-methods-when-should-they-be.html>
I had the same problem a few days ago and I just wrote me... |
554,145 | <p>Let say I have a class like this:</p>
<pre><code>public sealed class Foo
{
public void Bar
{
// Do Bar Stuff
}
}
</code></pre>
<p>And I want to extend it to add something beyond what an extension method could do....My only option is composition:</p>
<pre><code>public class SuperFoo
{
privat... | [
{
"answer_id": 554192,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 4,
"selected": false,
"text": "<p>I found myself asking that same question until I started working on reusable libraries of my own. Many times you wind up... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Let say I have a class like this:
```
public sealed class Foo
{
public void Bar
{
// Do Bar Stuff
}
}
```
And I want to extend it to add something beyond what an extension method could do....My only option is composition:
```
public class SuperFoo
{
private Foo _internalFoo;
public Super... | I'm afraid the short answer is, you can't without doing what is required, i.e. pass the composed instance variable instead.
You **could** allow an implicit or explicit cast to that type (whose implementation simply passed the composed instance) but this would, IMO be pretty evil.
sixlettervariable's answer is good an... |
554,159 | <p>How do you manage this simple scenario when you have an object with a list of items. EG:</p>
<pre><code>public class ContainerObject
{
IList<ChildObject> Children { get; }
public void AddCustom(ChildObject toAdd)
{
// Some validation ...
Children.Add(toAdd);
}
}
</code></pre>
... | [
{
"answer_id": 554176,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>You can make your property return a wrapper around the original list using <a href=\"http://msdn.microsoft.com/en-us/... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31412/"
] | How do you manage this simple scenario when you have an object with a list of items. EG:
```
public class ContainerObject
{
IList<ChildObject> Children { get; }
public void AddCustom(ChildObject toAdd)
{
// Some validation ...
Children.Add(toAdd);
}
}
```
Assuming the collection is i... | Return a [ReadOnlyCollection](http://msdn.microsoft.com/en-us/library/ms132474.aspx) to the world wrapping your list which you manage the Adds to. |
554,167 | <p>I have an HTML page with some textual spans marked up something like this:</p>
<pre><code>...
<span id="T2" class="Protein">p50</span>
...
<span id="T3" class="Protein">p65</span>
...
<span id="T34" ids="T2 T3" class="Positive_regulation">recruitment</span>
...
</code></pre>
<p>... | [
{
"answer_id": 554217,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 6,
"selected": true,
"text": "<p>You have a couple options: <a href=\"http://developer.mozilla.org/en/SVG/Tutorial/Getting_Started\" rel=\"nofollo... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12547/"
] | I have an HTML page with some textual spans marked up something like this:
```
...
<span id="T2" class="Protein">p50</span>
...
<span id="T3" class="Protein">p65</span>
...
<span id="T34" ids="T2 T3" class="Positive_regulation">recruitment</span>
...
```
I.e. each span has an ID and refers to zero or more spans via ... | You have a couple options: [svg](http://developer.mozilla.org/en/SVG/Tutorial/Getting_Started) or [canvas](http://developer.mozilla.org/en/Canvas_tutorial).
From the looks of it you don't need these arrows to have any particular mathematical form, you just need them to go between elements.
Try [WireIt](http://neyric.... |
554,181 | <p>I'm probably missing something obvious, but I don't seem to be able to get my AJAX posts to run consecutively instead of concurrently with jQuery.</p>
<p><code>ad_numbers</code> is an array of numeric IDs.</p>
<pre><code>$(ad_numbers).each(function() {
ad_number = $.trim(this);
if(!ad_number) { return true; }... | [
{
"answer_id": 554190,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "<p>Try adding <code>async: false</code> to your options.</p>\n\n<pre><code>$(ad_numbers).each(function() {\n ad... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902010/"
] | I'm probably missing something obvious, but I don't seem to be able to get my AJAX posts to run consecutively instead of concurrently with jQuery.
`ad_numbers` is an array of numeric IDs.
```
$(ad_numbers).each(function() {
ad_number = $.trim(this);
if(!ad_number) { return true; }
$.post('/fetch.php', { ad_nu... | Try adding `async: false` to your options.
```
$(ad_numbers).each(function() {
ad_number = $.trim(this);
if(!ad_number) { return true; }
$.ajax({
type: 'POST',
url: '/fetch.php',
data: {ad_number: ad_number},
async: false,
success: function(data, textStatus) {
... |
554,201 | <p>I've used Spring before (and like it), but thought I'd take a look at <a href="http://code.google.com/p/google-guice/" rel="nofollow noreferrer">Guice</a>.</p>
<p>Is there a way to initialize something like maps or lists into beans using Guice?</p>
<p>For instance, I've done the following before in Spring to injec... | [
{
"answer_id": 554274,
"author": "Dave Stenglein",
"author_id": 57679,
"author_profile": "https://Stackoverflow.com/users/57679",
"pm_score": 4,
"selected": true,
"text": "<p>Guice2 has MultiBindings and MapBindings, which should work for you.</p>\n\n<p><a href=\"https://github.com/googl... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2890/"
] | I've used Spring before (and like it), but thought I'd take a look at [Guice](http://code.google.com/p/google-guice/).
Is there a way to initialize something like maps or lists into beans using Guice?
For instance, I've done the following before in Spring to inject a list of items I want to process into some bean.
`... | Guice2 has MultiBindings and MapBindings, which should work for you.
<https://github.com/google/guice/wiki/Multibindings>
Updated:
After looking at this again, it seems that you may be asking how you can inject runtime values into Guice, perhaps as arbitrary objects.
Guice is very focused around doing everything as... |
554,204 | <h3>Duplicate of: <a href="https://stackoverflow.com/questions/485525/round-for-float-in-c">round() for float in C++</a></h3>
<hr />
<p>I'm using VS2008 and I've included math.h but I still can't find a round function. Does it exist?</p>
<p>I'm seeing a bunch of "add 0.5 and cast to int" solutions on google.... | [
{
"answer_id": 554215,
"author": "Patrick Glandien",
"author_id": 66760,
"author_profile": "https://Stackoverflow.com/users/66760",
"pm_score": 7,
"selected": true,
"text": "<p>You may use C++11's <a href=\"http://en.cppreference.com/w/cpp/numeric/math/round\" rel=\"noreferrer\"><code>st... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6212/"
] | ### Duplicate of: [round() for float in C++](https://stackoverflow.com/questions/485525/round-for-float-in-c)
---
I'm using VS2008 and I've included math.h but I still can't find a round function. Does it exist?
I'm seeing a bunch of "add 0.5 and cast to int" solutions on google. Is that the best practice? | You may use C++11's [`std::round()`](http://en.cppreference.com/w/cpp/numeric/math/round).
If you are still stuck with older standards, you may use [`std::floor()`](http://en.cppreference.com/w/cpp/numeric/math/floor), which always rounds to the lower number, and [`std::ceil()`](http://en.cppreference.com/w/cpp/numeri... |
554,205 | <p>I have a MySQL database and I would like to insert some values into one table, assuming that a particular value that I am inserting does not match a value in a different table.</p>
<p>Here is a simplified/example structure:</p>
<pre><code>Table: invites
id : int (auto-increment index)
name : varchar
me... | [
{
"answer_id": 554234,
"author": "Kristen",
"author_id": 65703,
"author_profile": "https://Stackoverflow.com/users/65703",
"pm_score": 2,
"selected": false,
"text": "<p>(I'm an MSSQL person, so not sure if all appropriate for MySQL)</p>\n\n<pre><code>INSERT INTO invites\n(\n name, mes... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1892/"
] | I have a MySQL database and I would like to insert some values into one table, assuming that a particular value that I am inserting does not match a value in a different table.
Here is a simplified/example structure:
```
Table: invites
id : int (auto-increment index)
name : varchar
message : varchar
Tabl... | (I'm an MSSQL person, so not sure if all appropriate for MySQL)
```
INSERT INTO invites
(
name, message
)
SELECT name = 'joe', message = 'This is an invite'
WHERE NOT EXISTS
(SELECT *
FROM donotinvite
WHERE name = 'joe')
```
In practice you might put all the Name / Message in a temporary table and t... |
554,227 | <p>I cannot close one of my forms programmatically. Can someone help me?</p>
<p>Here's the code:</p>
<pre><code> private void WriteCheck_Load(object sender, EventArgs e) {
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == Di... | [
{
"answer_id": 554253,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "<p>By calling <code>Form.Close()</code>, the form should close, but not until all waiting events have been processed. You also... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | I cannot close one of my forms programmatically. Can someone help me?
Here's the code:
```
private void WriteCheck_Load(object sender, EventArgs e) {
SelectBankAccountDialog sbad = new SelectBankAccountDialog();
DialogResult result = sbad.ShowDialog();
if (result == DialogResult.Cancel) {
... | As configurator mentioned (in comments), the form must be shown before it can be closed, so, instead of the *Load* event, you should be doing this in the *Shown* event instead.
If you don't want the form visible for the Dialog box, I guess you can wrap the event code in a Visible = false;
In summary, the basic code ... |
554,259 | <p><a href="http://img187.imageshack.us/img187/8453/testhc3.png" rel="nofollow noreferrer">alt text http://img187.imageshack.us/img187/8453/testhc3.png</a></p>
<p><a href="http://img145.imageshack.us/img145/3306/test2bn4.png" rel="nofollow noreferrer">alt text http://img145.imageshack.us/img145/3306/test2bn4.png</a></... | [
{
"answer_id": 554301,
"author": "Quassnoi",
"author_id": 55159,
"author_profile": "https://Stackoverflow.com/users/55159",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to partition by <code>OrarioA</code> only:</p>\n\n<pre><code>SELECT OrarioA, OrarioB, IDOrario, IDDettaglio... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61589/"
] | [alt text http://img187.imageshack.us/img187/8453/testhc3.png](http://img187.imageshack.us/img187/8453/testhc3.png)
[alt text http://img145.imageshack.us/img145/3306/test2bn4.png](http://img145.imageshack.us/img145/3306/test2bn4.png)
The first picture is my query. I need to obtain results in second picture.
```
sele... | If you want to partition by `OrarioA` only:
```
SELECT OrarioA, OrarioB, IDOrario, IDDettaglioOrarioA, IDDettaglioOrarioB
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY OrarioA ORDER BY OrarioB DESC, IDOrario DESC) AS rn
FROM table
) t
WHERE rn = 1
```
, this will result in the resultset as on `picture 2`.
... |
554,266 | <p>How can you get the contents of a text file while preserving whether or not it has a newline at the end of the file? Using this technique, it is impossible to tell if the file ends in a newline:</p>
<pre><code>BufferedReader reader = new BufferedReader(new FileReader(fromFile));
StringBuilder contents = new String... | [
{
"answer_id": 554287,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 3,
"selected": false,
"text": "<p>Don't use readLine(); transfer the contents one character at a time using the read() method. If you use it on... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10475/"
] | How can you get the contents of a text file while preserving whether or not it has a newline at the end of the file? Using this technique, it is impossible to tell if the file ends in a newline:
```
BufferedReader reader = new BufferedReader(new FileReader(fromFile));
StringBuilder contents = new StringBuilder();
Str... | You can read the whole file content using one of the techniques listed [here](https://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file/326440)
My favorite is this one:
```
public static long copyLarge(InputStream input, OutputStream output)
throws IOException {
byte... |
554,270 | <p>My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors:</p>
<pre><code>*** Termina... | [
{
"answer_id": 554330,
"author": "sbooth",
"author_id": 31520,
"author_profile": "https://Stackoverflow.com/users/31520",
"pm_score": 5,
"selected": false,
"text": "<p>There are several ways to do this. The simplest in your case would probably be to use the @synchronized directive. Thi... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors:
```
*** Terminating app due t... | If it's possible that any data (including classes) will be accessed from two threads simultaneously you must take steps to keep these synchronized.
Fortunately Objective-C makes it ridiculously easy to do this using the synchronized keyword. This keywords takes as an argument any Objective-C object. Any other threads ... |
554,273 | <p>My DOM looks like this:</p>
<pre><code><div id="d1">
<div class="c1">
<a href="#"><img src="img1_on.gif"></a>
<a href="#"><img src="img2_on.gif"></a>
</div>
</div>
</code></pre>
<p>When someone clicks on an image, I want the ... | [
{
"answer_id": 554289,
"author": "jonstjohn",
"author_id": 67009,
"author_profile": "https://Stackoverflow.com/users/67009",
"pm_score": 11,
"selected": false,
"text": "<p>You can use jQuery's <a href=\"http://api.jquery.com/attr/\" rel=\"noreferrer\">attr()</a> function. For example, i... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67033/"
] | My DOM looks like this:
```
<div id="d1">
<div class="c1">
<a href="#"><img src="img1_on.gif"></a>
<a href="#"><img src="img2_on.gif"></a>
</div>
</div>
```
When someone clicks on an image, I want the image src to change to `<img src="imgx_off.gif">` where `x` represents the image numbe... | You can use jQuery's [attr()](http://api.jquery.com/attr/) function. For example, if your `img` tag has an `id` attribute of 'my\_image', you would do this:
```
<img id="my_image" src="first.jpg" alt="Insert link 1 alt text here" />
```
Then you can change the `src` of your image with jQuery like this:
```
$("#my_i... |
554,302 | <p>I'm very new to ASP.NET MVC, but even more than that, I'm very new to web development in general. What I want to do is simple. I have a folder in my MVC project called /Content/Images where I have some images. I'd like for my controller to grab all the images in this folder, and send them to the view. The view will ... | [
{
"answer_id": 554333,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 3,
"selected": true,
"text": "<p>You can use DirectoryInfo to get a list of all the files in the images directory</p>\n<pre><code>DirectoryInfo folder = n... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15861/"
] | I'm very new to ASP.NET MVC, but even more than that, I'm very new to web development in general. What I want to do is simple. I have a folder in my MVC project called /Content/Images where I have some images. I'd like for my controller to grab all the images in this folder, and send them to the view. The view will the... | You can use DirectoryInfo to get a list of all the files in the images directory
```
DirectoryInfo folder = new DirectoryInfo(Server.MapPath("/content/images"));
foreach(FileInfo file in folder.Files)
// find all your files here
``` |
554,314 | <p>Is there a library or a class/function that I can use to convert an integer to it's verbal representation?</p>
<p>Example input:</p>
<blockquote>
<p>4,567,788`</p>
</blockquote>
<p>Example output:</p>
<blockquote>
<p>Four million, Five hundred sixty-seven thousand, seven hundred eighty-eight</p>
</blockquote... | [
{
"answer_id": 7829529,
"author": "Ruben Carreon",
"author_id": 986718,
"author_profile": "https://Stackoverflow.com/users/986718",
"pm_score": 6,
"selected": true,
"text": "<p>if you use the code found in:\n<a href=\"https://stackoverflow.com/questions/2729752/converting-numbers-in-to-w... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | Is there a library or a class/function that I can use to convert an integer to it's verbal representation?
Example input:
>
> 4,567,788`
>
>
>
Example output:
>
> Four million, Five hundred sixty-seven thousand, seven hundred eighty-eight
>
>
> | if you use the code found in:
[converting numbers in to words C#](https://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp)
and you need it for decimal numbers, here is how to do it:
```
public string DecimalToWords(decimal number)
{
if (number == 0)
return "zero";
if (number... |
554,345 | <p>The testit() method is a closure. aString has fallen out of scope but testit() can still execute on it. testit2() is using a variable that hasn't fallen out of scope (mystring) but which was also not been passed into testit2(). Is testit2() considered a closure?</p>
<pre><code>string mystring = "hello world";
Act... | [
{
"answer_id": 554354,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": true,
"text": "<p>Both examples are anonymous functions. The second of which use a closure in order to capture the local variables. The... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | The testit() method is a closure. aString has fallen out of scope but testit() can still execute on it. testit2() is using a variable that hasn't fallen out of scope (mystring) but which was also not been passed into testit2(). Is testit2() considered a closure?
```
string mystring = "hello world";
Action testit = new... | Both examples are anonymous functions. The second of which use a closure in order to capture the local variables. The scope lifetime of the variable with respect to the anonymous function does not affect whether or not a closure is created to use it. As long as the variable is defined outside a anonymous function and u... |
554,348 | <p>I have a bunch of div's on my page with class testClass.</p>
<p>I want to load them into an array and then check the array's size.</p>
<p>But its not working?</p>
<pre><code>myArray = $('testClass');
alert(myArray.count);
</code></pre>
<p>What's wrong?</p>
| [
{
"answer_id": 554365,
"author": "jonstjohn",
"author_id": 67009,
"author_profile": "https://Stackoverflow.com/users/67009",
"pm_score": 4,
"selected": false,
"text": "<p>The code that you have provided returns an iterable jQuery object, but not an array. Also, you have made a mistake i... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67033/"
] | I have a bunch of div's on my page with class testClass.
I want to load them into an array and then check the array's size.
But its not working?
```
myArray = $('testClass');
alert(myArray.count);
```
What's wrong? | The code that you have provided returns an iterable jQuery object, but not an array. Also, you have made a mistake in your class selector.
For check the size of that jQuery object, you can use:
```
var $j_object = $(".testClass");
alert($j_object.size());
```
To loop over that object, you can use the each() functio... |
554,349 | <p>i have two tables, products and categories. how do i convert the following sql query to linq format?</p>
<pre><code>select c.Name, c.DisplayName, count(p.id) from categories as c
LEFT join products as p on p.categoryId = c.id
group by c.Name, c.DisplayName
</code></pre>
<p>some categories will have 0 products in t... | [
{
"answer_id": 554496,
"author": "Tomas Petricek",
"author_id": 33518,
"author_profile": "https://Stackoverflow.com/users/33518",
"pm_score": 3,
"selected": true,
"text": "<p>if you correctly define the relations in your model then the customers table should have an association with all ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65005/"
] | i have two tables, products and categories. how do i convert the following sql query to linq format?
```
select c.Name, c.DisplayName, count(p.id) from categories as c
LEFT join products as p on p.categoryId = c.id
group by c.Name, c.DisplayName
```
some categories will have 0 products in them so the LEFT JOIN is im... | if you correctly define the relations in your model then the customers table should have an association with all the products, so you'll be able to access products associated with the customer just using 'c.Products'. Then should be able to write simply something like this:
```
var q =
from c in categories
... |
554,369 | <p>This doesn't seem possible in VB.NET with properties since the property statement itself must describe whether it is <code>ReadOnly</code> or not.</p>
<p>In my example below, it doesn't let me make the <code>ReadWriteChild</code> compile. I guess I could make the parent Read/Write, and then have the ReadOnlyChild'... | [
{
"answer_id": 554396,
"author": "Bevan",
"author_id": 30280,
"author_profile": "https://Stackoverflow.com/users/30280",
"pm_score": 2,
"selected": false,
"text": "<p>Might be a longshot ... given that my knowledge of VB.NET is minimal ...</p>\n\n<p>In C# you can specify the visibility o... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132931/"
] | This doesn't seem possible in VB.NET with properties since the property statement itself must describe whether it is `ReadOnly` or not.
In my example below, it doesn't let me make the `ReadWriteChild` compile. I guess I could make the parent Read/Write, and then have the ReadOnlyChild's setter not do anything, but tha... | Given what you're trying to accomplish, and with the sample code you posted, VB.NET will not let you do this.
Ordinarily, you can declare a property in VB.NET like so:
```vb
Public Class qwqwqw
Public Property xyz() As String
Get
Return ""
End Get
Private Set(ByVal value As String)
... |
554,405 | <p>Is there a way to stipulate that the clients of a class should specify a value for a set of properties in a class. For example (see below code), Can i stipulate that "EmploymentType" property in Employment class should be specified at compile time? I know i can use parametrized constructor and such. I am specifi... | [
{
"answer_id": 554416,
"author": "cmsjr",
"author_id": 23114,
"author_profile": "https://Stackoverflow.com/users/23114",
"pm_score": 2,
"selected": false,
"text": "<p>You could achieve what you want to do by not having a default constructor, and instead defining a constructor that takes ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to stipulate that the clients of a class should specify a value for a set of properties in a class. For example (see below code), Can i stipulate that "EmploymentType" property in Employment class should be specified at compile time? I know i can use parametrized constructor and such. I am specifically l... | As cmsjr stated what you need to do is this:
```
public class Employment
{
public Employment(EmploymentType employmentType)
{
this.EmploymentType = employmentType;
}
public EmploymentType EmploymentType { get; set; }
}
```
This will force callers to pass in the value at creation like this:
... |
554,408 | <p>I have an application that has been getting strange errors when canceling out of a dialog box. The application can't continue if the box is cancelled out of, so it exits, but it is not working for some reason, and thus it keeps running and crashes.</p>
<p>I debugged this problem, and somehow the application runs ri... | [
{
"answer_id": 554417,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 0,
"selected": false,
"text": "<p>Is this application run (in the <code>Main</code> method) using <code>Application.Run()</code>? Otherwise, <code>App... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26140/"
] | I have an application that has been getting strange errors when canceling out of a dialog box. The application can't continue if the box is cancelled out of, so it exits, but it is not working for some reason, and thus it keeps running and crashes.
I debugged this problem, and somehow the application runs right past t... | This is an article which expands on the same train of thought you are going through: <http://www.dev102.com/2008/06/24/how-do-you-exit-your-net-application/>
Basically:
>
> * Environment.Exit - From MSDN: Terminates this process and gives the
> underlying operating system the
> specified exit code. This is the code
... |
554,419 | <p>I use this code to set my constants</p>
<pre><code>// Constants.h
extern NSInteger const KNameIndex;
// Constants.m
NSInteger const KNameIndex = 0;
</code></pre>
<p>And in a switch statement within a file that imports the Constant.h file I have this:</p>
<pre><code>switch (self.sectionFromParentTable) {
case... | [
{
"answer_id": 554456,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": -1,
"selected": false,
"text": "<p>I think you are stuck with using a <code>const int</code> instead of a <code>const NSInteger</code> as switch only wor... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51420/"
] | I use this code to set my constants
```
// Constants.h
extern NSInteger const KNameIndex;
// Constants.m
NSInteger const KNameIndex = 0;
```
And in a switch statement within a file that imports the Constant.h file I have this:
```
switch (self.sectionFromParentTable) {
case KNameIndex:
self.types = sel... | For C/C++ and Objective-C must the case statement have fixed values - "reduced to an integer *(read value)*" at compile time
Your constants is not a real "constant" because it is a variable and I imagine it can be changed through a pointer - ie `&KNameIndex`
Usually one defines constants as `enum`
```
enum {
KN... |
554,422 | <p>I would like to create a deep clone of a usercontrol in my program. How do this.
thanks</p>
| [
{
"answer_id": 554456,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": -1,
"selected": false,
"text": "<p>I think you are stuck with using a <code>const int</code> instead of a <code>const NSInteger</code> as switch only wor... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54009/"
] | I would like to create a deep clone of a usercontrol in my program. How do this.
thanks | For C/C++ and Objective-C must the case statement have fixed values - "reduced to an integer *(read value)*" at compile time
Your constants is not a real "constant" because it is a variable and I imagine it can be changed through a pointer - ie `&KNameIndex`
Usually one defines constants as `enum`
```
enum {
KN... |
554,425 | <p>We are using VSTS 2008 to perform some relatively simple web testing of a web application that we have under development. We have data sources defined to provide input data to the tests, and would like to perform our validations based on this data source also. The problem that I have is the VS GUI does not allow me ... | [
{
"answer_id": 655748,
"author": "Rhys Jones",
"author_id": 16643,
"author_profile": "https://Stackoverflow.com/users/16643",
"pm_score": 2,
"selected": true,
"text": "<p>Some more analysis shows that there isn't a way to do this through the VS GUI. It can be achieved by converting the t... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16643/"
] | We are using VSTS 2008 to perform some relatively simple web testing of a web application that we have under development. We have data sources defined to provide input data to the tests, and would like to perform our validations based on this data source also. The problem that I have is the VS GUI does not allow me to ... | Some more analysis shows that there isn't a way to do this through the VS GUI. It can be achieved by converting the test to code, and updating the code to use the data source:
```
validationRule.FindText = this.Context["UsersDataSource.Users#csv.?UserName"].ToString();
```
Perhaps in a future version this will be po... |
554,430 | <p>I have a block of code which is similar to the following:</p>
<pre><code>for (NSDictionary *tmp in aCollection) {
if ([[bar valueForKey:@"id"] isEqualToString:[tmp valueForKey:@"id"]])
{
break;
}
else
{
[aCollection addObject:bar];
}
}
</code></pre>
<p>Is this technically an exce... | [
{
"answer_id": 554454,
"author": "mouviciel",
"author_id": 45249,
"author_profile": "https://Stackoverflow.com/users/45249",
"pm_score": 2,
"selected": false,
"text": "<p>From <a href=\"http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_8_section_2.html... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I have a block of code which is similar to the following:
```
for (NSDictionary *tmp in aCollection) {
if ([[bar valueForKey:@"id"] isEqualToString:[tmp valueForKey:@"id"]])
{
break;
}
else
{
[aCollection addObject:bar];
}
}
```
Is this technically an exception in Objective-C 2.0? ... | Well the way to solve it is not to mutate the array (e.g. add an object) while enumerating it :)
The problem here is that modifying the array by adding/removing elements could cause the enumeration values to become invalid, hence why it's a problem.
In your case The easiest way to solve this is fixing the bug in your... |
554,440 | <p>Entity Framework magically interprets the following table structure as a many-to-many relationship.</p>
<pre><code>table foo (int id)
table foo_bar (int foo_id, int bar_id)
table bar (int id)
</code></pre>
<p>But if the join table has any additional fields it will instead be interpreted as two one-to-many relation... | [
{
"answer_id": 554504,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": true,
"text": "<p>I am positive that this cannot be done using the designer. I don't know if there is a way to do it in EDMX manually, ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/276/"
] | Entity Framework magically interprets the following table structure as a many-to-many relationship.
```
table foo (int id)
table foo_bar (int foo_id, int bar_id)
table bar (int id)
```
But if the join table has any additional fields it will instead be interpreted as two one-to-many relationships.
I am using a datab... | I am positive that this cannot be done using the designer. I don't know if there is a way to do it in EDMX manually, but I have never seen an example of it. One possible workaround might be to not map the surrogate key at all. If you can generate that on the database, you might not need it in your model. |
554,446 | <p>I am currently trying to log into a site using Python however the site seems to be sending a cookie and a redirect statement on the same page. Python seems to be following that redirect thus preventing me from reading the cookie send by the login page. How do I prevent Python's urllib (or urllib2) urlopen from fol... | [
{
"answer_id": 554475,
"author": "joeforker",
"author_id": 36330,
"author_profile": "https://Stackoverflow.com/users/36330",
"pm_score": 4,
"selected": false,
"text": "<p><code>urllib2.urlopen</code> calls <code>build_opener()</code> which uses this list of handler classes:</p>\n\n<pre><... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61663/"
] | I am currently trying to log into a site using Python however the site seems to be sending a cookie and a redirect statement on the same page. Python seems to be following that redirect thus preventing me from reading the cookie send by the login page. How do I prevent Python's urllib (or urllib2) urlopen from followin... | You could do a couple of things:
1. Build your own HTTPRedirectHandler that intercepts each redirect
2. Create an instance of HTTPCookieProcessor and install that opener so that you have access to the cookiejar.
This is a quick little thing that shows both
```
import urllib2
#redirect_handler = urllib2.HTTPRedirect... |
554,468 | <p><strong>Answered</strong>:</p>
<blockquote>
<p>They don't allow any kind of redistribution with 2.6, supposedly, unless you have licenses for it. But they don't sell licenses for it. But they give it away free. But, who knows, i think they just want us to buy an overpriced thing we don't need to write a free u... | [
{
"answer_id": 554475,
"author": "joeforker",
"author_id": 36330,
"author_profile": "https://Stackoverflow.com/users/36330",
"pm_score": 4,
"selected": false,
"text": "<p><code>urllib2.urlopen</code> calls <code>build_opener()</code> which uses this list of handler classes:</p>\n\n<pre><... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15127/"
] | **Answered**:
>
> They don't allow any kind of redistribution with 2.6, supposedly, unless you have licenses for it. But they don't sell licenses for it. But they give it away free. But, who knows, i think they just want us to buy an overpriced thing we don't need to write a free utility. I guess I'll look at NVeloci... | You could do a couple of things:
1. Build your own HTTPRedirectHandler that intercepts each redirect
2. Create an instance of HTTPCookieProcessor and install that opener so that you have access to the cookiejar.
This is a quick little thing that shows both
```
import urllib2
#redirect_handler = urllib2.HTTPRedirect... |
554,476 | <p>Does doing something like this use dynamic memory allocation?</p>
<pre><code>template <class T, int _size>
class CArray
{
public:
...
private:
T m_data[_size];
};
</code></pre>
<p>Can someone explain to me what's going on behind the scenes when I create the object?</p>
<pre><code>CArray<Some... | [
{
"answer_id": 554487,
"author": "Ryan Graham",
"author_id": 62525,
"author_profile": "https://Stackoverflow.com/users/62525",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.cplusplus.com/doc/tutorial/templates.html\" rel=\"nofollow noreferrer\">Templates</a> are eval... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22386/"
] | Does doing something like this use dynamic memory allocation?
```
template <class T, int _size>
class CArray
{
public:
...
private:
T m_data[_size];
};
```
Can someone explain to me what's going on behind the scenes when I create the object?
```
CArray<SomeObject, 32> myStupidArray;
``` | As mentioned in the other answers, templates are evaluated at compile time. If you're interested you can have g++ spit out the class hierarchy where you can verify its size:
```
template <class T, int _size>
class CArray
{
public:
private:
T m_data[_size];
};
int main(int argc, char **argv) {
CArray<int, 32> mySt... |
554,481 | <p>Is there a way to get the (to-be-generated) SQL from a Hibernate <code>Criteria</code>?</p>
<p>Ideally, I would have something like:</p>
<pre><code>Criteria criteria = session.createCriteria(Operator.class);
... build up the criteria ...
... and then do something like ...
String sql = criteria.toSql()
(But this... | [
{
"answer_id": 555192,
"author": "Brian Deterling",
"author_id": 14619,
"author_profile": "https://Stackoverflow.com/users/14619",
"pm_score": 6,
"selected": true,
"text": "<p>I've done something like this using Spring AOP so I could grab the sql, parameters, errors, and execution time f... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45671/"
] | Is there a way to get the (to-be-generated) SQL from a Hibernate `Criteria`?
Ideally, I would have something like:
```
Criteria criteria = session.createCriteria(Operator.class);
... build up the criteria ...
... and then do something like ...
String sql = criteria.toSql()
(But this of course does not exist)
```
... | I've done something like this using Spring AOP so I could grab the sql, parameters, errors, and execution time for any query run in the application whether it was HQL, Criteria, or native SQL.
This is obviously fragile, insecure, subject to break with changes in Hibernate, etc, but it illustrates that it's possible to... |
554,509 | <p>Is there a way I can improve this kind of SQL query performance: </p>
<pre><code>INSERT
INTO ...
WHERE NOT EXISTS(Validation...)
</code></pre>
<p>The problem is when I have many data in my table (like million of rows), the execution of the <code>WHERE NOT EXISTS</code> clause if very slow. I have to do this verifi... | [
{
"answer_id": 554513,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 5,
"selected": true,
"text": "<p>Make sure you are searching on indexed columns, with no manipulation of the data within those columns (like substring etc.)<... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60002/"
] | Is there a way I can improve this kind of SQL query performance:
```
INSERT
INTO ...
WHERE NOT EXISTS(Validation...)
```
The problem is when I have many data in my table (like million of rows), the execution of the `WHERE NOT EXISTS` clause if very slow. I have to do this verification because I can't insert duplica... | Make sure you are searching on indexed columns, with no manipulation of the data within those columns (like substring etc.) |
554,515 | <p>How can I use two separate CABasicAnimations to simultaneously animate the same property?</p>
<p>For example Two CABasicAnimations, both animate position.y.</p>
<p>The first animation will be a bounce (from 100, to 300, duration = 1, autoreverse = yes, repeatcount = 10)</p>
<p>The second animation will be a slow ... | [
{
"answer_id": 555411,
"author": "GoldenBoy",
"author_id": 67088,
"author_profile": "https://Stackoverflow.com/users/67088",
"pm_score": 0,
"selected": false,
"text": "<p>You can use CAAnimationGroup if you want to bundle multiple animations across different properties, but I'm not sure ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67099/"
] | How can I use two separate CABasicAnimations to simultaneously animate the same property?
For example Two CABasicAnimations, both animate position.y.
The first animation will be a bounce (from 100, to 300, duration = 1, autoreverse = yes, repeatcount = 10)
The second animation will be a slow scroll (by 100, duration... | If I understand you correctly, you want the view to bounce up and down while the whole bouncing motion shifts slowly downwards. You can do this by making the animations additive using their additive property. For example:
```
CABasicAnimation *bounceAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
b... |
554,519 | <p>I would like to know if attributes can be used to "mix-in" functionality to a class / method / property.</p>
<p>Something like:</p>
<pre><code>[TrackChanges]
public Foo
{
get;
set;
}
</code></pre>
<p>Does anyone how this would be implemented, if at all possible?</p>
| [
{
"answer_id": 554524,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 0,
"selected": false,
"text": "<p>They certainly can but you will have to use reflection to do it. Also just because you can do it does not mean it ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I would like to know if attributes can be used to "mix-in" functionality to a class / method / property.
Something like:
```
[TrackChanges]
public Foo
{
get;
set;
}
```
Does anyone how this would be implemented, if at all possible? | Have a look at [PostSharp](http://www.postsharp.org/about/getting-started), an [AOP](http://www.postsharp.org/aop-net/overview) framework. It is a post-compiler, which uses custom attributes to inject additional behavior to existing code. Most of the examples are usually tracing and security. |
554,521 | <p>I fear there's a simple and obvious answer to this question. I need to determine how many digits wide a count of items is, so that I can pad each item number with the <em>minimum</em> number of leading zeros required to maintain alignment. For example, I want no leading zeros if the total is < 10, 1 if it's betwe... | [
{
"answer_id": 554533,
"author": "Nicholas Mancuso",
"author_id": 8945,
"author_profile": "https://Stackoverflow.com/users/8945",
"pm_score": 7,
"selected": true,
"text": "<p>This should do it:</p>\n\n<pre><code>int length = (number ==0) ? 1 : (int)Math.log10(number) + 1;\n</code></pre>\... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40356/"
] | I fear there's a simple and obvious answer to this question. I need to determine how many digits wide a count of items is, so that I can pad each item number with the *minimum* number of leading zeros required to maintain alignment. For example, I want no leading zeros if the total is < 10, 1 if it's between 10 and 99,... | This should do it:
```
int length = (number ==0) ? 1 : (int)Math.log10(number) + 1;
``` |
554,522 | <p>Suppose you were setting up a database to store crash test data of various vehicles. You want to store data of crash tests for speedboats, cars, and go-karts.</p>
<p>You could create three separate tables: SpeedboatTests, CarTests, and GokartTests. But a lot of your columns are going to be the same in each table (f... | [
{
"answer_id": 554541,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 0,
"selected": false,
"text": "<p>I would break it up into different tables, e.g. Vehicle (ID, type, etc) VehicleAttributes ()VehicleID, AttributeID, Value),... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65393/"
] | Suppose you were setting up a database to store crash test data of various vehicles. You want to store data of crash tests for speedboats, cars, and go-karts.
You could create three separate tables: SpeedboatTests, CarTests, and GokartTests. But a lot of your columns are going to be the same in each table (for example... | The `type` and `id_in_type` design is called [Polymorphic Associations](http://en.wikipedia.org/wiki/Polymorphic_association). This design breaks rules of normalization in multiple ways. If nothing else, it should be a red flag that you *can't* declare a real foreign key constraint, because the `id_in_type` may referen... |
554,546 | <p>I'd like to implement a Rails <code>User</code> model that has a DB column called <code>password</code>. I want to make it so that when I call...</p>
<pre><code>user_instance.password = 'cleartext'
</code></pre>
<p>the method hashes the cleartext before setting it on the instance like so:</p>
<pre><code>Digest::S... | [
{
"answer_id": 554569,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 4,
"selected": true,
"text": "<p>FYI, you may want to check out restful_authentication plugin as it will do this for you. Why roll your own?</p>\n\n<p>... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I'd like to implement a Rails `User` model that has a DB column called `password`. I want to make it so that when I call...
```
user_instance.password = 'cleartext'
```
the method hashes the cleartext before setting it on the instance like so:
```
Digest::SHA1.hexdigest(cleartext)
```
I've tried using a callback,... | FYI, you may want to check out restful\_authentication plugin as it will do this for you. Why roll your own?
The way acts\_as\_authenticated does it:
1. Database/model has a column called "encrypted\_password"
2. Create a virtual attribute called password
3. Password isn't populated on a find(..) so if the password i... |
554,548 | <p>I'm new to LINQ, I've used LINQ to SQL to link to two tables, it does return data, which is cool. What I'm trying to understand is what datatype is being returned and how do I work with this datatype?</p>
<p>I'm used to dealing with datatables. Are we throwing out datatables (and all the other ADO.Net object like... | [
{
"answer_id": 554554,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>It is returning an <code>IQueryable<lkpMarketCode></code>, assuming that that <code>lkpMarketCode</code> is t... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61639/"
] | I'm new to LINQ, I've used LINQ to SQL to link to two tables, it does return data, which is cool. What I'm trying to understand is what datatype is being returned and how do I work with this datatype?
I'm used to dealing with datatables. Are we throwing out datatables (and all the other ADO.Net object like rows, datas... | It is returning an `IQueryable<lkpMarketCode>`, assuming that that `lkpMarketCode` is the type of data in `db.lkpMarketCodes`. If you want the strings, you need to `select p.SomeProperty;`, not just `select p;`.
You shouldn't need to cast (since `IQueryable<T>` implements `IEnumerable<T>`); it should also tell you thi... |
554,566 | <p>I don't really get it: what's the purpose of a new line character?</p>
<p>If I do this:</p>
<pre><code><?php
echo "This is a test. \n";
echo "This is another test.";
?>
</code></pre>
<p>Code results in both sentences being in the same line. Why doesn't the \n causes the second sentence being in second line... | [
{
"answer_id": 554571,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 6,
"selected": true,
"text": "<p>The <a href=\"http://www.w3.org/TR/html401/struct/text.html#h-9.1\" rel=\"nofollow noreferrer\">HTML standard</a> treat... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42803/"
] | I don't really get it: what's the purpose of a new line character?
If I do this:
```
<?php
echo "This is a test. \n";
echo "This is another test.";
?>
```
Code results in both sentences being in the same line. Why doesn't the \n causes the second sentence being in second line?
The sentences are each in it's own l... | The [HTML standard](http://www.w3.org/TR/html401/struct/text.html#h-9.1) treats a line break as just another white space character, which is why the `<br>` tag exists. Note however a line break will work within a `<pre>` tag, or an element with the [white-space:pre](https://developer.mozilla.org/en/CSS/white-space) CSS... |
554,587 | <p>I have a list of type <code>System.IO.FileInfo</code>, and I would like to randomize the list. I thought I remember seeing something like <code>list.randomize()</code> a little while back but I cannot find where I may have seen that.</p>
<p>My first foray into this yielded me with this function:</p>
<pre><code>Pr... | [
{
"answer_id": 554595,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": -1,
"selected": false,
"text": "<p>You could create custom comparer that just returns a random number, then sort the list using this comparer. It could be h... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I have a list of type `System.IO.FileInfo`, and I would like to randomize the list. I thought I remember seeing something like `list.randomize()` a little while back but I cannot find where I may have seen that.
My first foray into this yielded me with this function:
```
Private Shared Sub GetRandom(ByVal oMax As Int... | Build a Comparer:
```
Public Class Randomizer(Of T)
Implements IComparer(Of T)
''// Ensures different instances are sorted in different orders
Private Shared Salter As New Random() ''// only as random as your seed
Private Salt As Integer
Public Sub New()
Salt = Salter.Next(Integer.MinValue... |
554,588 | <p>On each page I create my custom js object.</p>
<p>I want to subscribe to the $().ready event so that when it fires, my objects init function also fires.</p>
<p>Is this possible?</p>
<p><strong>Updated</strong></p>
<p>My object looks like:</p>
<pre><code>var blah = function() {
var init = function() {
/... | [
{
"answer_id": 554607,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$(document).ready(function() {\n YourObject.init();\n});\n</code></pre>\n"
},
{
"answer_id": 55... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67033/"
] | On each page I create my custom js object.
I want to subscribe to the $().ready event so that when it fires, my objects init function also fires.
Is this possible?
**Updated**
My object looks like:
```
var blah = function() {
var init = function() {
//init function stuff
};
return {
InitPage:... | ```
$(document).ready(function() {
YourObject.init();
});
``` |
554,594 | <p>I'm working with FOAF and RDFa, and struggling to figure out whether I should be using foaf:depiction or foaf:depicts and the correct way to use them. Here's what I've already established:</p>
<pre><code><div class="profile" typeof="foaf:Person">
<p>Employee Name: <span property="foaf:name">Fred F... | [
{
"answer_id": 567371,
"author": "Scott",
"author_id": 6126,
"author_profile": "https://Stackoverflow.com/users/6126",
"pm_score": 3,
"selected": true,
"text": "<p>Looks like I'm dealing with a niche subject. I've done some more searching and reading, and I think I found my answer here: ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6126/"
] | I'm working with FOAF and RDFa, and struggling to figure out whether I should be using foaf:depiction or foaf:depicts and the correct way to use them. Here's what I've already established:
```
<div class="profile" typeof="foaf:Person">
<p>Employee Name: <span property="foaf:name">Fred Flintstone</span></p>
<p><img src... | Looks like I'm dealing with a niche subject. I've done some more searching and reading, and I think I found my answer here: [<http://www.w3.org/TR/2008/WD-xhtml-rdfa-primer-20080317/#using-src-on-img>](http://www.w3.org/TR/2008/WD-xhtml-rdfa-primer-20080317/#using-src-on-img).
To summarize, my suspicions on the termin... |
554,615 | <p>I want my ASP.NET site to have simple menu string aka Breadcrumbs.
I have created Sitemap with all required elements and registered into Web.config. For example:</p>
<pre><code><siteMap>
<siteMapNode url="Default.aspx" title="Home" >
<siteMapNode url="hosting/Default.aspx" title="Hosting"... | [
{
"answer_id": 554627,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 3,
"selected": false,
"text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sitemappath.aspx\" rel=\"norefe... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41956/"
] | I want my ASP.NET site to have simple menu string aka Breadcrumbs.
I have created Sitemap with all required elements and registered into Web.config. For example:
```
<siteMap>
<siteMapNode url="Default.aspx" title="Home" >
<siteMapNode url="hosting/Default.aspx" title="Hosting" />
<siteMapNode url=... | [ASP.NET SiteMapPath Control](http://msdn.microsoft.com/en-us/library/x20z8c51.aspx)
```
<asp:SiteMapPath ID="SiteMapPath1" Runat="server" />
``` |
554,622 | <p>I'm having troubles right now, I can't update a table X in DBDataContext, so this is my snippet, by the way when I update just one table it works! But when I Insert and then update, it throws exception: "can't cast object from System.Int32 to System.String type"</p>
<pre><code>{
using (DBDataContext db ... | [
{
"answer_id": 554642,
"author": "Bramha Ghosh",
"author_id": 3268,
"author_profile": "https://Stackoverflow.com/users/3268",
"pm_score": 0,
"selected": false,
"text": "<p>Open your DMBL file as an XML file. Check your types for each column, and see if something that should be an int is... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388553/"
] | I'm having troubles right now, I can't update a table X in DBDataContext, so this is my snippet, by the way when I update just one table it works! But when I Insert and then update, it throws exception: "can't cast object from System.Int32 to System.String type"
```
{
using (DBDataContext db = new DBDataCo... | After a lot of research, I found out that this bug only exists on WinXP-Machines with .net 3.5 SP1.
On Windows 7 it works fine. Unfortunately, there are two different builds of the same framework.
There is a hotfix from microsoft, which resolves my problem on the xp machines.
<http://support.microsoft.com/hotfix/KBHot... |
554,631 | <h2>How do I properly draw one vector object onto a specific position of another in ActionScript, accounting for positioning, transparency, etc?</h2>
<p>My idea (as suggested e.g. <a href="http://www.actionscript.org/forums/archive/index.php3/t-157588.html" rel="nofollow noreferrer">here</a>) was to use <code>beginBit... | [
{
"answer_id": 554890,
"author": "Theo.T",
"author_id": 64223,
"author_profile": "https://Stackoverflow.com/users/64223",
"pm_score": 2,
"selected": true,
"text": "<p>Using the display objects getBounds function can be a reliable solution to translate the coordinates while drawing :</p>\... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7724/"
] | How do I properly draw one vector object onto a specific position of another in ActionScript, accounting for positioning, transparency, etc?
--------------------------------------------------------------------------------------------------------------------------------------------
My idea (as suggested e.g. [here](htt... | Using the display objects getBounds function can be a reliable solution to translate the coordinates while drawing :
```
private function drawOntoGraphics(source : IBitmapDrawable, target : Graphics, position : Point = null) : void
{
position = position == null ? new Point() : position;
var bounds : R... |
554,645 | <p>I have defined an interface for a data structure type. I am trying to force whatever class implementing that interface to also implement two other interfaces (iterator and countable).</p>
<p>Is there a way to do this?</p>
| [
{
"answer_id": 554648,
"author": "Malfist",
"author_id": 12243,
"author_profile": "https://Stackoverflow.com/users/12243",
"pm_score": 0,
"selected": false,
"text": "<p>Have your interface implement them and then just pass on the abstract methods (i.e. don't implement the methods in your... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63414/"
] | I have defined an interface for a data structure type. I am trying to force whatever class implementing that interface to also implement two other interfaces (iterator and countable).
Is there a way to do this? | If you want to force it, you could declare that your interface extends the interfaces you required, e.g.
```
interface c extends a, b
{
...
}
```
Generally speaking though, you should probably be writing code which checks that an object has all the interfaces required for a particular operation before carrying it... |
554,649 | <p>The last two lines of this code do not work correctly -- the results are coming back from the LINQ query. I'm just not sure how to successfully bind the indicated columns in the results to the textfield and valuefield of the dropdownlist:</p>
<pre><code> protected void BindMarketCodes()
{
List<lk... | [
{
"answer_id": 554663,
"author": "James",
"author_id": 56753,
"author_profile": "https://Stackoverflow.com/users/56753",
"pm_score": 6,
"selected": true,
"text": "<p>See revised code below </p>\n\n<pre><code>protected void BindMarketCodes()\n{ \n using (var dataContext = new LIN... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61639/"
] | The last two lines of this code do not work correctly -- the results are coming back from the LINQ query. I'm just not sure how to successfully bind the indicated columns in the results to the textfield and valuefield of the dropdownlist:
```
protected void BindMarketCodes()
{
List<lkpMarketCode> mcode... | See revised code below
```
protected void BindMarketCodes()
{
using (var dataContext = new LINQOmniDataContext()) {
//bind to Country COde droplist
dd2.DataSource = from p in dataContext.lkpMarketCodes
orderby p.marketName
select new {p.marketCodeID, p.marketName};
... |
554,650 | <p>I know how to use MVC's AntiForgeryToken attribute and it's associated HTML helper to help XSRF-secure my application's form POSTs.</p>
<p>Can something similar can be done for JsonResults that implement GET?</p>
<p>For instance, my View contains an onSubmit jQuery call like such:</p>
<pre><code>$.getJSON("/allow... | [
{
"answer_id": 554839,
"author": "TomHastjarjanto",
"author_id": 53170,
"author_profile": "https://Stackoverflow.com/users/53170",
"pm_score": 0,
"selected": false,
"text": "<p>You can do something similar as the anti XSRF methods. Just generate some ID insert it into the javascript and ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56018/"
] | I know how to use MVC's AntiForgeryToken attribute and it's associated HTML helper to help XSRF-secure my application's form POSTs.
Can something similar can be done for JsonResults that implement GET?
For instance, my View contains an onSubmit jQuery call like such:
```
$.getJSON("/allowActivity/YesOrNo/" + someFor... | You may use the AntiForgeryToken combined with some custom logic. The creation of the AntiForgery token on the server is the same, but by default the value is not included in your XmlHttpRequest.
The value of this token is in the HTTP only cookie "\_\_RequestVerificationToken" and should also be in the form data poste... |
554,660 | <p>At some point in our past branches of development in git were merged. However, the wrong merge decision was made and therefore some code didn't make it into master branch that we expected would be there. (There were multiple merges of different branches before a final merge to a master branch. So the branching a... | [
{
"answer_id": 554672,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": false,
"text": "<p>Can <a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html\" rel=\"nofollow noreferrer\">git-bisect</a> he... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48658/"
] | At some point in our past branches of development in git were merged. However, the wrong merge decision was made and therefore some code didn't make it into master branch that we expected would be there. (There were multiple merges of different branches before a final merge to a master branch. So the branching and merg... | If you know a line in a file that was modified by the git branch merge, you can do 'git blame file.txt' and determine the commit hash number and commit author of the line in the file. Then you can go through the git log and pull up the exact commit associated with the bad branch merge.
EDIT:
In response to the author'... |
554,666 | <p>I'm looking for a better way to merge variables into a string, in Ruby.</p>
<p>For example if the string is something like:</p>
<p>"The <code>animal</code> <code>action</code> the <code>second_animal</code>"</p>
<p>And I have variables for <code>animal</code>, <code>action</code> and <code>second_animal</code>, w... | [
{
"answer_id": 554677,
"author": "Mike Woodhouse",
"author_id": 1060,
"author_profile": "https://Stackoverflow.com/users/1060",
"pm_score": 9,
"selected": true,
"text": "<p>The idiomatic way is to write something like this:</p>\n\n<pre><code>\"The #{animal} #{action} the #{second_animal}... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67113/"
] | I'm looking for a better way to merge variables into a string, in Ruby.
For example if the string is something like:
"The `animal` `action` the `second_animal`"
And I have variables for `animal`, `action` and `second_animal`, what is the prefered way to put those variables in to the string? | The idiomatic way is to write something like this:
```
"The #{animal} #{action} the #{second_animal}"
```
Note the double quotes (") surrounding the string: this is the trigger for Ruby to use its built-in placeholder substitution. You cannot replace them with single quotes (') or the string will be kept as is. |
554,679 | <p>I have the following situation:</p>
<pre><code><table><tr><td width="50">
<select name="angle">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</op... | [
{
"answer_id": 554690,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>If you right click the file in \"Solution Explorer\" you get a \"View Markup\" option.</p>\n"
},
{
"answer_id": 5... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I have the following situation:
```
<table><tr><td width="50">
<select name="angle">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</td><td>
<input type="text" name="what" value="" ... | Tools > Options > Keyboard
Search for `View.ToggleDesigner` in "Show Commands Containing".
Add new shortcut to Global/Editor with F7.
This works without needing a macro for VS2008/2010 |
554,688 | <p>When I sign the assemblies in my service with the Verisign signtool.exe, it fails to start when the machine starts, on a machine running Windows 2003 Server. The event log has two events:</p>
<p>"Timeout (30000 milliseconds) waiting for the xxx Service service to connect."
and
"The xxx Service service failed to sta... | [
{
"answer_id": 554700,
"author": "Two Bit Gangster",
"author_id": 63694,
"author_profile": "https://Stackoverflow.com/users/63694",
"pm_score": 2,
"selected": false,
"text": "<p>Authenticode signing your assemblies can have a very negative effect on cold startup. See this KB article for... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14842/"
] | When I sign the assemblies in my service with the Verisign signtool.exe, it fails to start when the machine starts, on a machine running Windows 2003 Server. The event log has two events:
"Timeout (30000 milliseconds) waiting for the xxx Service service to connect."
and
"The xxx Service service failed to start due to ... | This problem is very common for signed .NET service executables: the service will fail to start at boot time, but run fine when started manually afterwards. Whether ServiceBase.RequestAdditionalTime is used is irrelevant: in fact, no user code is executed at all prior to the service start request timing out. This effec... |
554,692 | <p>I'm currently working on a web application and I need to display some fields in a tabular way. For example:</p>
<pre>------------------------------------------------------
First Name: John Last Name: Smith Age: 26
------------------------------------------------------
Town: Madrid Country: Canada Colour... | [
{
"answer_id": 554711,
"author": "Scott",
"author_id": 6126,
"author_profile": "https://Stackoverflow.com/users/6126",
"pm_score": 2,
"selected": false,
"text": "<p>Semantically, you might want to use a definition list. You can specify a width for the dt and dd elements to line them up a... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15928/"
] | I'm currently working on a web application and I need to display some fields in a tabular way. For example:
```
------------------------------------------------------
First Name: John Last Name: Smith Age: 26
------------------------------------------------------
Town: Madrid Country: Canada Colour: Blue
... | I think you're a bit confused as to when to use CSS and when to use tables. When you have that much data, you probably should be using tables. It's fine to position the actual BOX that it's in using CSS, but from what I can see the data inside the box should be inside a table. |
554,693 | <p>What do you do when you notice that an app has a lot of classes, but the classes are not really intantiable objects but rather a grouping of common functions?</p>
<p>Example:</p>
<pre><code>Class Point
{
calculatePoints(something) {}
calculatePointsAnotherWay(something) {}
}
</code></pre>
| [
{
"answer_id": 554706,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 2,
"selected": false,
"text": "<p>If it's allowed by the language, I'd make them free (nonmember) functions. If they don't belong in a class, they belong ou... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67117/"
] | What do you do when you notice that an app has a lot of classes, but the classes are not really intantiable objects but rather a grouping of common functions?
Example:
```
Class Point
{
calculatePoints(something) {}
calculatePointsAnotherWay(something) {}
}
``` | I'd look at the functions to see how they are using instantiable objects. If a function:
* takes an object of a user-defined type as an argument,
* extracts data from that object, and
* produces a result based on computations over those extracted data,
then that function is a candidate for becoming a method on the cl... |
554,695 | <p>I am trying to reference a js file in a class in an ASP.NET and I receive this error:</p>
<p>Assembly 'XXX' contains a Web resource with name 'XXX' but does not contain an embedded resource with name 'XXX'</p>
<p>Searching the web tell me I must have a Path referencing problem, but I can't figure what is it.</p>
... | [
{
"answer_id": 554857,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": 2,
"selected": true,
"text": "<p>You would think this is possible, but honestly I can't find how. I may be just missing something really simple...</p>\n\n<p>You ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47109/"
] | I am trying to reference a js file in a class in an ASP.NET and I receive this error:
Assembly 'XXX' contains a Web resource with name 'XXX' but does not contain an embedded resource with name 'XXX'
Searching the web tell me I must have a Path referencing problem, but I can't figure what is it.
Here is the hierarchy... | You would think this is possible, but honestly I can't find how. I may be just missing something really simple...
You always have one other option, which is to create a separate Class Library project, embed your resources there, and reference it from your web site project. |