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 |
|---|---|---|---|---|---|---|
424,927 | <p>I've been developing a very large LOB app using my flavor of M-V-VM which I call M-V-MC (Model-View-ModelController), which is a kind of a combination between M-V-C and M-V-VM. I had posted <a href="https://stackoverflow.com/questions/322612/what-are-the-most-common-mistakes-made-in-wpf-development#322679">this answ... | [
{
"answer_id": 425037,
"author": "Matthew Wright",
"author_id": 47006,
"author_profile": "https://Stackoverflow.com/users/47006",
"pm_score": 0,
"selected": false,
"text": "<p>New and delete from a list would be good examples. In those cases, a blank record is added or the current record... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I've been developing a very large LOB app using my flavor of M-V-VM which I call M-V-MC (Model-View-ModelController), which is a kind of a combination between M-V-C and M-V-VM. I had posted [this answer](https://stackoverflow.com/questions/322612/what-are-the-most-common-mistakes-made-in-wpf-development#322679) regardi... | Never thought I'd see myself being quoted in a question.
I pondered this question myself for some time, and made a rather pragmatic decision for my code base:
In my code base, the ViewModel is getting called when actions happen, and I wanted it to stay this way. Additionally I do not want the ViewModel to control the... |
424,932 | <p>When a select field is changed, I would like to loop through all of the input values in the form it belongs to using jQuery. This doesn't work below, but I can't figure out exactly how to do this.</p>
<pre><code>$("select.mod").change(function(){
$(this).parent().get(0).$(":input").each(function(i){
alert(... | [
{
"answer_id": 425003,
"author": "Steve Losh",
"author_id": 13498,
"author_profile": "https://Stackoverflow.com/users/13498",
"pm_score": 4,
"selected": true,
"text": "<p>It's probably the selection of the \"parent form\" that's causing the problem. </p>\n\n<p>The <code>.parent()</code>... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/497/"
] | When a select field is changed, I would like to loop through all of the input values in the form it belongs to using jQuery. This doesn't work below, but I can't figure out exactly how to do this.
```
$("select.mod").change(function(){
$(this).parent().get(0).$(":input").each(function(i){
alert(this.name + " =... | It's probably the selection of the "parent form" that's causing the problem.
The `.parent()` function returns just the immediate parent, which won't let you get the form element if your `select.mod` is nested in a `<p>` or something.
The `.parents()` function returns *all* the parents of the element; but the first o... |
424,938 | <p>How do I write a .net regex which will match a string that does NOT start with "Seat"</p>
| [
{
"answer_id": 424951,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>Writing a regex for a \"does not start with\" can be a little tricky. It's often easier to write a regex to detect th... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48892/"
] | How do I write a .net regex which will match a string that does NOT start with "Seat" | What you're looking for is:
```
^(?!Seat).+
```
[This article](http://timstall.dotnetdevelopersjournal.com/regular_expressions_does_not_start_with.htm) has more information about look aheads. |
424,949 | <p>I have a MATLAB class which contains a reference to a java object</p>
<pre><code>classdef MyClass
properties
j = myJavaClass
end
methods
...
end
end
</code></pre>
<p>and after I use it (using clear, scope exit or explicitly setting myClass = 0; ) the java object is still alive - even after calling Runt... | [
{
"answer_id": 425102,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if this will fix it, but try making the assignment in the constructor, not in the properties block. Also,... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28772/"
] | I have a MATLAB class which contains a reference to a java object
```
classdef MyClass
properties
j = myJavaClass
end
methods
...
end
end
```
and after I use it (using clear, scope exit or explicitly setting myClass = 0; ) the java object is still alive - even after calling Runtime.gc.
I see in the dump... | The workaround gnovice suggested seem to work - adding to the destructor the line
```
function delete( obj )
...
jObject = 0;
end
```
Caused the object not to be present in MATLAB's JVM heap.
It look like a bug in MATLAB that causes the referencing of the JAVA objects in unreferenced MCOS classes. |
424,967 | <p>I asked this question already at the Microsoft forums, but no answer until now. I am stuck here. I have a quite nested xml snippet, which i like to bind via hierarchical Data templates.</p>
<p>Here is the xml snippet:</p>
<pre><code><project>
<products>
<product name="Product2" foldername="strin... | [
{
"answer_id": 424974,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 6,
"selected": false,
"text": "<p>You shouldn't be multi-threading unless the application <em>needs</em> to be multi-threaded.</p>\n\n<p>Just because you <... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I asked this question already at the Microsoft forums, but no answer until now. I am stuck here. I have a quite nested xml snippet, which i like to bind via hierarchical Data templates.
Here is the xml snippet:
```
<project>
<products>
<product name="Product2" foldername="string" dbkey="-2405" dbtable="string"> ... | Since threading always adds extra complexity to applications, **I believe that single threaded applications will always have their place.**
Not even when single core processors are completely obsolete will single threaded programming be gone.
Dual cores, especially in the consumer market, are great for multitasking. ... |
424,978 | <p>I have a VS2005 solution which uses Visual SourceSafe 6.0 source control. I am using Vista Ultimate 32 bit.</p>
<p>I keep getting this error when I close a file, and seeming more often when the file is not actually under source control (e.g. afxwin.h or something like that). Does not happen 100% of the time thou... | [
{
"answer_id": 425012,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 2,
"selected": false,
"text": "<p>Your best option (if you can) is to move away from VSS6.0. Its old technology, and especially given that it uses the files... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] | I have a VS2005 solution which uses Visual SourceSafe 6.0 source control. I am using Vista Ultimate 32 bit.
I keep getting this error when I close a file, and seeming more often when the file is not actually under source control (e.g. afxwin.h or something like that). Does not happen 100% of the time though. Any worka... | Your best option (if you can) is to move away from VSS6.0. Its old technology, and especially given that it uses the filesystem, could give you some serious issues under Vista with the new security.
There are a lot of free options available, but if you want to buy something, TFS works quite nicely, although you will a... |
424,982 | <p>Meaning, if I have:</p>
<pre><code><mx:Tree>
<!-- ... -->
</mx:Tree>
</code></pre>
<p>and I want to change some of the control's behaviour or add functionality, by doing (in AS):</p>
<pre><code>class ChristmasTree extends mx.controls.Tree {
// ...
}
</code></pre>
<p>how do I change the ... | [
{
"answer_id": 425001,
"author": "Hanno Fietz",
"author_id": 2077,
"author_profile": "https://Stackoverflow.com/users/2077",
"pm_score": 4,
"selected": true,
"text": "<p>OK, that was lazyweb at its best. Of course it's also in <a href=\"http://livedocs.adobe.com/flex/3/html/ascomponents_... | 2009/01/08 | [
"https://Stackoverflow.com/questions/424982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | Meaning, if I have:
```
<mx:Tree>
<!-- ... -->
</mx:Tree>
```
and I want to change some of the control's behaviour or add functionality, by doing (in AS):
```
class ChristmasTree extends mx.controls.Tree {
// ...
}
```
how do I change the MXML so that my class is used?
In [the manual it says how to exten... | OK, that was lazyweb at its best. Of course it's also in [TFM](http://livedocs.adobe.com/flex/3/html/ascomponents_3.html#170709), and actually quite neat. In AS, you do:
```
package myComponents
{
// as/myComponents/TextAreaFontControl.as
import mx.controls.TextArea;
public class TextAreaFontControl e... |
425,020 | <p>I have the following SQL Statement. I need to select the latest record for each System.Id using the System.RevisedDate</p>
<pre><code>SELECT [System.Id],[System.RevisedDate], [System.Title], [System.State], [System.Reason], [System.CreatedDate], [System.WorkItemType], [System.TeamProject],
... | [
{
"answer_id": 425041,
"author": "Alex Shnayder",
"author_id": 26042,
"author_profile": "https://Stackoverflow.com/users/26042",
"pm_score": 1,
"selected": false,
"text": "<p>In general it should go some thing like</p>\n\n<pre><code>SELECT ID,DATE_FIELD,FIELD1,FIELD2\nFROM TBL1 AS A WHER... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44785/"
] | I have the following SQL Statement. I need to select the latest record for each System.Id using the System.RevisedDate
```
SELECT [System.Id],[System.RevisedDate], [System.Title], [System.State], [System.Reason], [System.CreatedDate], [System.WorkItemType], [System.TeamProject],
[Microsoft.V... | Try this:
```
SELECT * FROM WorkItems w
JOIN (
SELECT [System.Id],MAX([System.RevisedDate])
FROM WorkItems
WHERE ([System.WorkItemType] = 'Change Request')
AND ([System.CreatedDate] >= '09/30/2008')
AND ([System.TeamProject] NOT LIKE '%Deleted%')
AND ([System.TeamProject] NOT LIKE '%Sandbox%')
GROUP BY {System.... |
425,029 | <p>I'm trying to connect to an oracle database with SQL Developer. </p>
<p>I've installed the .Net oracle drivers and placed the <code>tnsnames.ora</code> file at<br>
<code>C:\Oracle\product\11.1.0\client_1\Network\Admin</code></p>
<p>I'm using the following format in tnsnames.ora:</p>
<pre><code>dev =
(DESCRIPTIO... | [
{
"answer_id": 425104,
"author": "JaseAnderson",
"author_id": 4138,
"author_profile": "https://Stackoverflow.com/users/4138",
"pm_score": 9,
"selected": true,
"text": "<p>SQL Developer will look in the following location in this order for a tnsnames.ora file</p>\n\n<ol>\n<li>$HOME/.tnsna... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52996/"
] | I'm trying to connect to an oracle database with SQL Developer.
I've installed the .Net oracle drivers and placed the `tnsnames.ora` file at
`C:\Oracle\product\11.1.0\client_1\Network\Admin`
I'm using the following format in tnsnames.ora:
```
dev =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.... | SQL Developer will look in the following location in this order for a tnsnames.ora file
1. $HOME/.tnsnames.ora
2. $TNS\_ADMIN/tnsnames.ora
3. TNS\_ADMIN lookup key in the registry
4. /etc/tnsnames.ora ( non-windows )
5. $ORACLE\_HOME/network/admin/tnsnames.ora
6. LocalMachine\SOFTWARE\ORACLE\ORACLE\_HOME\_KEY
7. Local... |
425,039 | <p>I've tried figuring out this problem for the last 2 days with no luck. I'm simply trying to create an annotation based JUnit test using the spring framework along with hibernate.</p>
<p>My IDE is netbeans 6.5 and I'm using hibernate 3, spring 2.5.5 and JUnit 4.4.</p>
<p>Here's the error I'm getting:</p>
<pre><co... | [
{
"answer_id": 425096,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are picking up an incorrect version of asm.jar somewhere in the classpath you are using for your tests.<... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] | I've tried figuring out this problem for the last 2 days with no luck. I'm simply trying to create an annotation based JUnit test using the spring framework along with hibernate.
My IDE is netbeans 6.5 and I'm using hibernate 3, spring 2.5.5 and JUnit 4.4.
Here's the error I'm getting:
```
Testcase: testFindContacts... | The `java.lang.NoSuchMethodError` always indicates that the version of a class that was on your compiler's classpath is different from the version of the class that is on your runtime classpath (had the method been missing at compile-time, the compile would have failed.)
In this case, you had a different version of `o... |
425,049 | <p>I want to declare two beans and instantiate them using Spring dependency injection?</p>
<pre><code><bean id="sessionFactory" class="SessionFactoryImpl">
<property name="entityInterceptor" ref="entityInterceptor"/>
</bean>
<bean id="entityInterceptor" class="EntityInterceptorImpl">
<pro... | [
{
"answer_id": 425076,
"author": "neesh",
"author_id": 43864,
"author_profile": "https://Stackoverflow.com/users/43864",
"pm_score": 5,
"selected": true,
"text": "<p>Unfortunately the way container initialization works in Spring, a bean can only be injected in another bean once it is ful... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51402/"
] | I want to declare two beans and instantiate them using Spring dependency injection?
```
<bean id="sessionFactory" class="SessionFactoryImpl">
<property name="entityInterceptor" ref="entityInterceptor"/>
</bean>
<bean id="entityInterceptor" class="EntityInterceptorImpl">
<property name="sessionFactory" ref="sessionF... | Unfortunately the way container initialization works in Spring, a bean can only be injected in another bean once it is fully initialized. In your case you have a circular dependency that prevents either bean to be initialized because they depend on each other. To get around this you can implement BeanFactoryAware in on... |
425,071 | <p>I don't think this is possible with just regular expressions, but I'm not an expert so i thought it was worth asking.</p>
<p>I'm trying to do a massive search and replace of C# code, using .NET regex. What I want to do is find a line of code where a specific function is called on a variable that is of type DateTime... | [
{
"answer_id": 425110,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 1,
"selected": false,
"text": "<p>This will be difficult to do with a single regex expression. However it is possible to do if you consider a processin... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45139/"
] | I don't think this is possible with just regular expressions, but I'm not an expert so i thought it was worth asking.
I'm trying to do a massive search and replace of C# code, using .NET regex. What I want to do is find a line of code where a specific function is called on a variable that is of type DateTime. e.g:
`... | Try this:
```
@"(?s)set_Field\(""[^""]*"",\s*(?<vname>\w+)(?<=\bDateTime\s+\k<vname>\b.+)"
```
By doing the lookbehind first, you're forcing the regex to search for the method calls in a particular order: the order in which the variables are declared. What you want to do is match a likely-looking method call first,... |
425,077 | <p>i have a weird problem.
i would like to delete an assembly(plugin.dll on harddisk) which is already loaded, but the assembly is locked by the operating system (vista), even if i have unloaded it. </p>
<p>f.e.</p>
<pre><code>AppDomainSetup setup = new AppDomainSetup();
setup.ShadowCopyFiles = "true";
AppDomain appD... | [
{
"answer_id": 425167,
"author": "Stever B",
"author_id": 47939,
"author_profile": "https://Stackoverflow.com/users/47939",
"pm_score": 2,
"selected": false,
"text": "<p>What we do, is to have one folder that is watched for assemblies. When an assembly is added, the application copies it... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52418/"
] | i have a weird problem.
i would like to delete an assembly(plugin.dll on harddisk) which is already loaded, but the assembly is locked by the operating system (vista), even if i have unloaded it.
f.e.
```
AppDomainSetup setup = new AppDomainSetup();
setup.ShadowCopyFiles = "true";
AppDomain appDomain = AppDomain.Cre... | I think i've the answer!
the answer from Øyvind Skaar will not work, if you would like to delete the loaded assembly.
instead of
```
using (FileStream dll = File.OpenRead(path))
{
fileContent = new byte[dll.Length];
dll.Read(fileContent, 0, (int)dll.Length);
}
Assembly assembly = appDomain.Load(fileContent);
... |
425,092 | <p>I have used Excel in my VB6 apps many times before, and have never run into such a weird problem trying to accomplish something very easy..</p>
<p>I am trying to open an excel (xls or xlsx) file and read through values, as you can probably see.</p>
<p>When I try to open the file, I get an error 70 (permission deni... | [
{
"answer_id": 425106,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 1,
"selected": false,
"text": "<p>Can you open a newly created empty spreadsheet document?</p>\n\n<p>If that doesn't work it might be that your Exce... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53017/"
] | I have used Excel in my VB6 apps many times before, and have never run into such a weird problem trying to accomplish something very easy..
I am trying to open an excel (xls or xlsx) file and read through values, as you can probably see.
When I try to open the file, I get an error 70 (permission denied) error. The od... | Can you open a newly created empty spreadsheet document?
If that doesn't work it might be that your Excel installation needs to be re-registered. Open a command prompt and navigate to the folder where Excel is installed, typically something like
```
cd "C:\Program Files\Microsoft Office\Office12"
```
and then start... |
425,095 | <p>It seems like this should be something built into jQuery without the need for more than a few lines of code, but I can't find the "simple" solution. Say, I have an HTML form:</p>
<pre><code><form method="get" action="page.html">
<input type="hidden" name="field1" value="value1" />
<input typ... | [
{
"answer_id": 425109,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 5,
"selected": false,
"text": "<p>There is a nice <a href=\"http://malsup.com/jquery/form/\" rel=\"noreferrer\">form plugin</a> that allows you to... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/497/"
] | It seems like this should be something built into jQuery without the need for more than a few lines of code, but I can't find the "simple" solution. Say, I have an HTML form:
```
<form method="get" action="page.html">
<input type="hidden" name="field1" value="value1" />
<input type="hidden" name="field2" value... | This is what ended up working.
```
$("select").change(function(){
$.get("/page.html?" + $(this).parent("form").find(":input").serialize());
});
``` |
425,113 | <p>I've got some code that was at the bottom of a php file that is in javascript. It goes through lots of weird contortions like converting hex to ascii then doing regex replacements, executing code and so on...</p>
<p>Is there any way to find out what it's executing before it actually does it?</p>
<p>The code is he... | [
{
"answer_id": 425144,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 2,
"selected": false,
"text": "<p>Just write a perl script or something that changes all escaped hex characters to ascii? Then just look through the re... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46782/"
] | I've got some code that was at the bottom of a php file that is in javascript. It goes through lots of weird contortions like converting hex to ascii then doing regex replacements, executing code and so on...
Is there any way to find out what it's executing before it actually does it?
The code is here:
<http://paste... | You can just go through it stage by stage - since it's Javascript, and it's interpreted, it needs to be its own decryptor. If you have access to a command-line Javascript interpreter (such as the Console in [Firebug](http://www.getfirebug.com/)), this will be fairly straightforward.
I'll have a look and see what comes... |
425,117 | <p>I want to pull a series of relationships out of xml files and transform them into a graph I generate with dot. I can obviously do this with a scripting language, but I was curious whether or not this was possible with xslt. Something like: </p>
<pre><code>xsltproc dot.xsl *.xml
</code></pre>
<p>which would produ... | [
{
"answer_id": 425846,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Using an <a href=\"http://www.w3.org/TR/xslt20/\" rel=\"noreferrer\">XSLT 2.0</a> processor and the <a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to pull a series of relationships out of xml files and transform them into a graph I generate with dot. I can obviously do this with a scripting language, but I was curious whether or not this was possible with xslt. Something like:
```
xsltproc dot.xsl *.xml
```
which would produce a file like
```
diagraph... | **Using an [XSLT 2.0](http://www.w3.org/TR/xslt20/) processor and the [`collection()`](http://www.w3.org/TR/xpath-functions/#func-collection) function this is really easy**.
Below is an example using **[Saxon](http://www.saxonica.com/documentation/index/intro.html)**:
```
<xsl:stylesheet version="2.0"
xmlns:xsl="... |
425,122 | <p>We are trying to get data out of a SQL Server DB and submit it to a WCF web service. Since using a windows service is not a option in this case, I thought of using SSIS. </p>
<p>I have tried using the Web Service Task, but I'm having difficulties getting it to work. I also understand there are limitation to using W... | [
{
"answer_id": 425846,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Using an <a href=\"http://www.w3.org/TR/xslt20/\" rel=\"noreferrer\">XSLT 2.0</a> processor and the <a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We are trying to get data out of a SQL Server DB and submit it to a WCF web service. Since using a windows service is not a option in this case, I thought of using SSIS.
I have tried using the Web Service Task, but I'm having difficulties getting it to work. I also understand there are limitation to using Web Service... | **Using an [XSLT 2.0](http://www.w3.org/TR/xslt20/) processor and the [`collection()`](http://www.w3.org/TR/xpath-functions/#func-collection) function this is really easy**.
Below is an example using **[Saxon](http://www.saxonica.com/documentation/index/intro.html)**:
```
<xsl:stylesheet version="2.0"
xmlns:xsl="... |
425,125 | <p>I'm working with XML that was designed by somebody who got paid by the level of nesting. The different xml files always looks something like this:</p>
<pre><code><Car>
<Color>
<Paint>
<AnotherUselessTag>
<SomeSemanticBs>
<The... | [
{
"answer_id": 425164,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 4,
"selected": true,
"text": "<p>If you are sure that all you want are <code>TheImporantData</code> elements from a <code>Car</code> element and th... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] | I'm working with XML that was designed by somebody who got paid by the level of nesting. The different xml files always looks something like this:
```
<Car>
<Color>
<Paint>
<AnotherUselessTag>
<SomeSemanticBs>
<TheImportantData>
```
With LINQ its easy to get w... | If you are sure that all you want are `TheImporantData` elements from a `Car` element and that `TheImportantData` isn't used as a tag name else where then:-
from x in car.Descendants("TheImportantData")
select x.WhatIWant();
Will do. |
425,132 | <p>The following code</p>
<pre><code>using System.Threading;
class Test
{
volatile int counter = 0;
public void Increment()
{
Interlocked.Increment(ref counter);
}
}
</code></pre>
<p>Raises the following compiler warning:</p>
<pre><code>"A reference to a volatile field will not be treated as... | [
{
"answer_id": 425141,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 2,
"selected": false,
"text": "<p>You're getting the error because you're passing the field by reference. I think what this means is that the target ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | The following code
```
using System.Threading;
class Test
{
volatile int counter = 0;
public void Increment()
{
Interlocked.Increment(ref counter);
}
}
```
Raises the following compiler warning:
```
"A reference to a volatile field will not be treated as volatile"
```
Am I doing something... | You are not doing anything wrong. According to the [documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0420):
>
> A volatile field should not normally
> be passed using a ref or out
> parameter, since it will not be
> treated as volatile within the scope
> of the... |
425,158 | <p>Is there a way to restrict certain tables from the mysqldump command?</p>
<p>For example, I'd use the following syntax to dump <em>only</em> <code>table1</code> and <code>table2</code>:</p>
<pre><code>mysqldump -u username -p database table1 table2 > database.sql
</code></pre>
<p>But is there a similar way to dum... | [
{
"answer_id": 425172,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 11,
"selected": true,
"text": "<p>You can use the <a href=\"https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_ignore-table\" r... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5630/"
] | Is there a way to restrict certain tables from the mysqldump command?
For example, I'd use the following syntax to dump *only* `table1` and `table2`:
```
mysqldump -u username -p database table1 table2 > database.sql
```
But is there a similar way to dump all the tables *except* table1 and table2? I haven't found a... | You can use the [--ignore-table](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_ignore-table) option. So you could do
```
mysqldump -u USERNAME -pPASSWORD DATABASE --ignore-table=DATABASE.table1 > database.sql
```
There is no whitespace after `-p` (this is not a typo).
To ignore multiple ta... |
425,178 | <p>I have a form on a page where the user has inputs to edit a XML file, the action for the form is to send it to a separate PHP script where the editing takes place after they hit submit. The script will either write successful or fail, either way I have it redirect back to the form page via a header. Is there an easy... | [
{
"answer_id": 425196,
"author": "Sarel Botha",
"author_id": 35264,
"author_profile": "https://Stackoverflow.com/users/35264",
"pm_score": 2,
"selected": false,
"text": "<p>I prefer to put the form handling code and the form show code in the same page. If you really want to separate it y... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49887/"
] | I have a form on a page where the user has inputs to edit a XML file, the action for the form is to send it to a separate PHP script where the editing takes place after they hit submit. The script will either write successful or fail, either way I have it redirect back to the form page via a header. Is there an easy wa... | The way that I've seen it done (and I personally use) is simply sessions.
```
// process something
if($success) {
flash_message('success','Did whatever successfully.');
} else {
flash_message('error','Oops, something went wrong.');
}
header('Location: whatever.php');
```
Then somewhere else, in your library ... |
425,189 | <p>I'm creating a small code plugin which allows you to do some things with arrays. I do not wish to add the functions to the array object using a prototype construction, what I want is that people can do something like:</p>
<pre><code>arrayFunction( [1, 2, 3] ).someSpecialArrayFunction();
</code></pre>
<p>Thus leavi... | [
{
"answer_id": 425243,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 1,
"selected": false,
"text": "<p>I am not sure this is the best syntax to get what you want, but I suppose this is a trimmed down example ... Anyways here is a ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] | I'm creating a small code plugin which allows you to do some things with arrays. I do not wish to add the functions to the array object using a prototype construction, what I want is that people can do something like:
```
arrayFunction( [1, 2, 3] ).someSpecialArrayFunction();
```
Thus leaving the normal array object... | Or simply:
```
var arrayFunction = function(array) {
var someSpecialArrayFunction = function() {
// do something with array
};
return {
someSpecialArrayFunction: someSpecialArrayFunction
}
};
arrayFunction( [1, 2, 3] ).someSpecialArrayFunction();
```
Although be careful with this, if ... |
425,191 | <p>I want to make a horizontal list in my application, which will display images. While this is quite trivial, I want the image to open a flex alert box (the built in one) and display some text. For example, I will have an image of the .NET logo and I will enter some text somewhere (like in a collection), and this text... | [
{
"answer_id": 425237,
"author": "Malfist",
"author_id": 12243,
"author_profile": "https://Stackoverflow.com/users/12243",
"pm_score": 0,
"selected": false,
"text": "<p>Just add an event handler to the image</p>\n"
},
{
"answer_id": 426388,
"author": "Christian Nunciato",
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | I want to make a horizontal list in my application, which will display images. While this is quite trivial, I want the image to open a flex alert box (the built in one) and display some text. For example, I will have an image of the .NET logo and I will enter some text somewhere (like in a collection), and this text wi... | If you're asking how to capture the selection of an item in a list, there are a number of events available to you: itemClick, itemDoubleClick, change:
```
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="this_initialize()" creationComplete="... |
425,198 | <p>I'm setting up a maven build, and the destination server needs to be specified on the command line as a property (which is then used to select the appropriate profile), eg</p>
<pre><code>mvn -Denv=test
</code></pre>
<p>I'd like the build to fail if the property's not set - is that possible?</p>
<p>Yes, I'm a Mave... | [
{
"answer_id": 425971,
"author": "Ed Brannin",
"author_id": 25625,
"author_profile": "https://Stackoverflow.com/users/25625",
"pm_score": 2,
"selected": false,
"text": "<p>My first inclination would be to make a Profile that's active whenever the env property is unset, and have it fail s... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714/"
] | I'm setting up a maven build, and the destination server needs to be specified on the command line as a property (which is then used to select the appropriate profile), eg
```
mvn -Denv=test
```
I'd like the build to fail if the property's not set - is that possible?
Yes, I'm a Maven newbie.
**EDIT:** I've seen [t... | Everyone is close, but there's a rule in the enforcer to specifically check for a property, no ant or funky profiles required: <http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html>
The rule can also check the value of the property. |
425,205 | <p>Given a struct, e.g.</p>
<pre><code>typedef struct
{
int value;
} TestStruct;
</code></pre>
<p>Why does the following code (in the context of an Objective-C class running on the IPhone) throw a "non-aligned pointer being freed" exception?</p>
<pre><code>TestStruct ts = {33};
free(&ts);
</code></pre>
<p>N.B... | [
{
"answer_id": 425211,
"author": "JSBձոգչ",
"author_id": 8078,
"author_profile": "https://Stackoverflow.com/users/8078",
"pm_score": 3,
"selected": false,
"text": "<p>Because you are trying to free something that was allocated on the stack. The function free() can only be called on memor... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50335/"
] | Given a struct, e.g.
```
typedef struct
{
int value;
} TestStruct;
```
Why does the following code (in the context of an Objective-C class running on the IPhone) throw a "non-aligned pointer being freed" exception?
```
TestStruct ts = {33};
free(&ts);
```
N.B. My uber goal is to use a C library with many vector... | It looks to me like you're trying to free a stack or static variable. You need to have malloc()'d something for it to be able to be free()'d.
Try this instead:
```
TestStruct *ts = malloc(sizeof(TestStruct));
ts->value = 33;
free(ts);
```
For those more familiar with object-oriented languages, you might find it hel... |
425,216 | <p>Sometimes I get a broken background in Chrome. I do not get this error with any other browser. </p>
<p>This is the simple CSS line responsible for the background color of body:</p>
<pre><code>body
{
background: black;
color: white;
font-family: Chaparral Pro, lucida grande, verdana, sans-serif;
}
</code>... | [
{
"answer_id": 425718,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I am not sure 100%, but try to replace selector with \"html, body\":</p>\n\n<pre><code>html, body \n{\n background: black... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | Sometimes I get a broken background in Chrome. I do not get this error with any other browser.
This is the simple CSS line responsible for the background color of body:
```
body
{
background: black;
color: white;
font-family: Chaparral Pro, lucida grande, verdana, sans-serif;
}
```
This is exactly how I ... | Never heard of it. Try:
```css
html, body {
width: 100%;
height: 100%;
background-color: #000;
color: #fff;
font-family: ...;
}
``` |
425,226 | <p>I have a ProgressBar that uses the marquee style when a report is being generated. The reason I am doing this is because the ReportViewer control I use takes some time to generate the report thus making the form unresponsive. I generate the report using a thread so the ProgressBar can show that the program is workin... | [
{
"answer_id": 425245,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>Your code is starting a new thread from the UI thread. The new thread then immediately marshals back to the UI thread ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] | I have a ProgressBar that uses the marquee style when a report is being generated. The reason I am doing this is because the ReportViewer control I use takes some time to generate the report thus making the form unresponsive. I generate the report using a thread so the ProgressBar can show that the program is working. ... | Your code is starting a new thread from the UI thread. The new thread then immediately marshals back to the UI thread using Invoke - so basically it's as if you hadn't made it multithreaded at all.
Instead of that, make the new thread do all the background processing it can and only marshal back to the UI for parts of... |
425,234 | <p>I'd like to add an <option> element to a <select> element where the <option> element's text contains an HTML entity: &mdash;</p>
<p>In HTML, the code would look like this:</p>
<pre><code><select name="test" id="test">
<option value="">&mdash; Select One &mdash;</opt... | [
{
"answer_id": 425256,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 3,
"selected": false,
"text": "<p>You don't need to escape the entity - it works like this:</p>\n\n<pre><code>function selectOne() {\n var e = d... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53035/"
] | I'd like to add an <option> element to a <select> element where the <option> element's text contains an HTML entity: —
In HTML, the code would look like this:
```
<select name="test" id="test">
<option value="">— Select One —</option>
</select>
```
My JavaScript code looks like this:
```
func... | I just realized I could use a Unicode JavaScript escape:
```
e.options[0] = new Option('\u2014 Select One \u2014', '');
``` |
425,235 | <p>What is the correct way to close or reset a TcpClient connection?
We have software that communicates with hardware but sometimes something
goes wrong and we are no longer to communicate with it, until we restart the software.</p>
<p>I have tried forcing TcpClient.Close() and even setting it to null but that doesn'... | [
{
"answer_id": 425291,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried calling <a href=\"http://msdn.microsoft.com/en-us/library/vstudio/bb340916(v=vs.100).aspx\" rel=\"nofollow... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28149/"
] | What is the correct way to close or reset a TcpClient connection?
We have software that communicates with hardware but sometimes something
goes wrong and we are no longer to communicate with it, until we restart the software.
I have tried forcing TcpClient.Close() and even setting it to null but that doesn't work.
Onl... | You have to close the stream before closing the connection:
```
tcpClient.GetStream().Close();
tcpClient.Close();
```
Closing the client does not close the stream. |
425,274 | <p>When using contentEditable in Firefox, is there a way to prevent the user from inserting paragraph or line breaks by pressing enter or shift+enter?</p>
| [
{
"answer_id": 428139,
"author": "kamens",
"author_id": 1335,
"author_profile": "https://Stackoverflow.com/users/1335",
"pm_score": 7,
"selected": true,
"text": "<p>You can attach an event handler to the keydown or keypress event for the contentEditable field and cancel the event if the ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31662/"
] | When using contentEditable in Firefox, is there a way to prevent the user from inserting paragraph or line breaks by pressing enter or shift+enter? | You can attach an event handler to the keydown or keypress event for the contentEditable field and cancel the event if the keycode identifies itself as enter (or shift+enter).
This will disable enter/shift+enter completely when focus is in the contentEditable field.
If using jQuery, something like:
```
$("#idContent... |
425,281 | <p>I keep getting stuck conceptually on deciding an Exception-handling structure for my project.</p>
<p>Suppose you have, as an example:</p>
<pre><code>public abstract class Data {
public abstract String read();
}
</code></pre>
<p>And two subclasses FileData, which reads your data from some specified file, and St... | [
{
"answer_id": 425288,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 2,
"selected": false,
"text": "<p>Throw the <code>IOException</code> wrapped in an exception type that is appropriate to the \"<code>Data</co... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] | I keep getting stuck conceptually on deciding an Exception-handling structure for my project.
Suppose you have, as an example:
```
public abstract class Data {
public abstract String read();
}
```
And two subclasses FileData, which reads your data from some specified file, and StaticData, which just returns some... | You're right.
The exception should be at the same level of abstraction where is used. This is the reason why since java 1.4 Throwable supports exception chaining. There is no point to throw FileNotFoundException for a service that uses a Database for instance, or for a service that is "store" agnostic.
It could be li... |
425,292 | <p>When you double-click on a Word document, Word is automatically run and the document is loaded.</p>
<p>What steps are needed to do the same thing with my C# application?</p>
<p>In other words, assume my application uses ".XYZ" data files. I know how to tell Windows to start my application when a .XYZ data file is... | [
{
"answer_id": 425305,
"author": "Sarel Botha",
"author_id": 35264,
"author_profile": "https://Stackoverflow.com/users/35264",
"pm_score": 1,
"selected": false,
"text": "<p>The arguments should contain the path to the data file.</p>\n\n<p>You can tweak this behavior and pass additional a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10722/"
] | When you double-click on a Word document, Word is automatically run and the document is loaded.
What steps are needed to do the same thing with my C# application?
In other words, assume my application uses ".XYZ" data files. I know how to tell Windows to start my application when a .XYZ data file is double clicked. *... | I did this in a project I was working on awhile ago and don't have the source code handy, but I believe it really came down to this:
```
//program.cs
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
... |
425,294 | <p>Does anybody know what is the best approach to accessing a sql view through Grails (or if this is even possible)? It seems an obvious way of doing this would be to use executeQuery against the view to select a collection of rows from the view which we would not treat as a list of domain objects. However, even in thi... | [
{
"answer_id": 425345,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 6,
"selected": true,
"text": "<p>You can use plain SQL in Grails which is in the case of accessing a view the preferable way (IMO):</p>\n\n<p... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33752/"
] | Does anybody know what is the best approach to accessing a sql view through Grails (or if this is even possible)? It seems an obvious way of doing this would be to use executeQuery against the view to select a collection of rows from the view which we would not treat as a list of domain objects. However, even in this c... | You can use plain SQL in Grails which is in the case of accessing a view the preferable way (IMO):
For example in your controller:
```
import groovy.sql.Sql
class MyFancySqlController {
def dataSource // the Spring-Bean "dataSource" is auto-injected
def list = {
def db = new Sql(dataSource) // Crea... |
425,308 | <p>I'm writing a javascript based photo gallery with a horizontally scrollable thumbnail bar.</p>
<p><a href="http://www.sharehost.co.uk/gallerytest/" rel="nofollow noreferrer">>> My current work-in-progress is here <<</a></p>
<p>I would like the thumbnail bar to stop scrolling when it gets to the last thumbnai... | [
{
"answer_id": 425355,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>I think you're looking for \"offsetWidth\".\nFor a cross-browser experience its either scroll[Width/Height] or off... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53030/"
] | I'm writing a javascript based photo gallery with a horizontally scrollable thumbnail bar.
[>> My current work-in-progress is here <<](http://www.sharehost.co.uk/gallerytest/)
I would like the thumbnail bar to stop scrolling when it gets to the last thumbnail. To do this I need to find the total width of the contents... | Maybe you're just referencing the wrong element.
```
document.getElementById('thumb_window').scrollWidth
```
is giving me 1540 on that page in both IE6 and firefox 2. Is that what you're looking for?
BTW in IE6 the thumbnails extend way past the right scroller. |
425,315 | <p>I'm getting "This page contains bothe Secure and Non secure items"message in IE. When I commented the following piece of code from dojo.js.uncompressed.js file, the message is gone.</p>
<pre><code>if(dojo.isIE){
if(!dojo.config.afterOnLoad){
document.write('<scr'+'ipt defer src="//:" '
+ 'onreadysta... | [
{
"answer_id": 425355,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>I think you're looking for \"offsetWidth\".\nFor a cross-browser experience its either scroll[Width/Height] or off... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm getting "This page contains bothe Secure and Non secure items"message in IE. When I commented the following piece of code from dojo.js.uncompressed.js file, the message is gone.
```
if(dojo.isIE){
if(!dojo.config.afterOnLoad){
document.write('<scr'+'ipt defer src="//:" '
+ 'onreadystatechange="if(this.... | Maybe you're just referencing the wrong element.
```
document.getElementById('thumb_window').scrollWidth
```
is giving me 1540 on that page in both IE6 and firefox 2. Is that what you're looking for?
BTW in IE6 the thumbnails extend way past the right scroller. |
425,325 | <p>I have the following code:</p>
<pre><code>if (System.IO.File.Exists(htmlLocation))
{
vEarthBrowser.ObjectForScripting = this;
vEarthBrowser.Url = new Uri(htmlLocation);
}
else
{
throw new Exception("HTML file not found!");
}
</code></pre>
<p>htmlLocation is defined as:</p>
<pre><code>private string ht... | [
{
"answer_id": 425332,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 3,
"selected": true,
"text": "<p>Try passing htmlLocation to Path.GetFullPath(). </p>\n\n<p>That automatically returns an absolute path to the file in the cur... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42620/"
] | I have the following code:
```
if (System.IO.File.Exists(htmlLocation))
{
vEarthBrowser.ObjectForScripting = this;
vEarthBrowser.Url = new Uri(htmlLocation);
}
else
{
throw new Exception("HTML file not found!");
}
```
htmlLocation is defined as:
```
private string htmlLocation = "VirtualEarth.html"
```... | Try passing htmlLocation to Path.GetFullPath().
That automatically returns an absolute path to the file in the current exe directory.
Here's a helper function I've written:
```
public void LoadPageFromDisk(string filePath)
{
Uri targetPage = null;
string workingPageURI = filePath.Trim();
workingPageU... |
425,342 | <p>The JavaScript security settings on Internet Explorer for my customers disallow using window.external.AddFavorite, and it generates (best case) an error in the status bar when the users click the "Add Bookmark" link on my website. Is there a way to explicitly request permission to use the window.external.AddFavorit... | [
{
"answer_id": 425573,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<p>I'd just pull the \"Add Bookmark\" link off the site. Users know how to do that if they really want to.</p>\n"
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21973/"
] | The JavaScript security settings on Internet Explorer for my customers disallow using window.external.AddFavorite, and it generates (best case) an error in the status bar when the users click the "Add Bookmark" link on my website. Is there a way to explicitly request permission to use the window.external.AddFavorite me... | It will work, but it HAS to be triggered by a user driven event. (e.g. the onclick of a link/button)
This is to stop spam/adware/pr0n sites from auto stuffing your bookmarks with garbage. |
425,372 | <p>So, I've been writing a bunch of ruby gems recently, and one thing I would find convenient is to include the current version (as specified in the gemspec) in the <code>rdoc</code>-generated documentation for my libraries, and in the <code>OptionParser</code>-generated <code>--help</code> sections used by my scripts ... | [
{
"answer_id": 427471,
"author": "Marcin Gil",
"author_id": 5731,
"author_profile": "https://Stackoverflow.com/users/5731",
"pm_score": 0,
"selected": false,
"text": "<p>You might want to take a look at <a href=\"http://rubyforge.org/forum/forum.php?forum_id=28119\" rel=\"nofollow norefe... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9859/"
] | So, I've been writing a bunch of ruby gems recently, and one thing I would find convenient is to include the current version (as specified in the gemspec) in the `rdoc`-generated documentation for my libraries, and in the `OptionParser`-generated `--help` sections used by my scripts (which I'm distributing via gem). An... | There isn't a way, I don't think, because Rubygems is just an installation mechanism for Ruby libraries, which have no predefined notion of versioning.
However, possible workarounds could include using `Gem.loaded_specs` to find which gems have been loaded:
```
Gem.loaded_specs["mygemname"].version.to_s #=> "1.2.3"
... |
425,379 | <p>I can quite easily dump data into a text file such as:</p>
<pre><code>sqlcmd -S myServer -d myDB -E -Q "select col1, col2, col3 from SomeTable"
-o "MyData.txt"
</code></pre>
<p>However, I have looked at the help files for <code>SQLCMD</code> but have not seen an option specifically for CSV. </p>
<p>Is there... | [
{
"answer_id": 425387,
"author": "Sarel Botha",
"author_id": 35264,
"author_profile": "https://Stackoverflow.com/users/35264",
"pm_score": -1,
"selected": false,
"text": "<p>You can do it in a hackish way. Careful using the <code>sqlcmd</code> hack. If the data has double quotes or comma... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | I can quite easily dump data into a text file such as:
```
sqlcmd -S myServer -d myDB -E -Q "select col1, col2, col3 from SomeTable"
-o "MyData.txt"
```
However, I have looked at the help files for `SQLCMD` but have not seen an option specifically for CSV.
Is there a way to dump data from a table into a CSV ... | You can run something like this:
```
sqlcmd -S MyServer -d myDB -E -Q "select col1, col2, col3 from SomeTable"
-o "MyData.csv" -h-1 -s"," -w 700
```
* `-h-1` removes column name headers from the result
* `-s","` sets the column seperator to ,
* `-w 700` sets the row width to 700 chars (this will need to be a... |
425,382 | <p>I am running a query against a providex database that we use in MAS 90. The query has three tables joined together, and has been slow but not unbearably, taking about 8 minutes per run. The query has a fair number of conditions in the where clause:</p>
<p>I'm going to omit the select part of the query as its long a... | [
{
"answer_id": 435648,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "<p>I've never used providex before.</p>\n\n<p>A search turned up <a href=\"http://www.pvx.com/support/docs/reference/PVXLangua... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26140/"
] | I am running a query against a providex database that we use in MAS 90. The query has three tables joined together, and has been slow but not unbearably, taking about 8 minutes per run. The query has a fair number of conditions in the where clause:
I'm going to omit the select part of the query as its long and simple,... | I still don't know exactly why it was so slow, but we had another problem with the results coming from the query (we switched back to using OrderDate). We weren't getting some of the results because of the nature of the IM1 table.
So I added a Left Outer Join once I figured out Providex's syntax for that. And for some... |
425,389 | <p>For the following SQL Server datatypes, what would be the corresponding datatype in C#?</p>
<p><strong>Exact Numerics</strong></p>
<pre><code>bigint
numeric
bit
smallint
decimal
smallmoney
int
tinyint
money
</code></pre>
<hr>
<p><strong>Approximate Numerics</strong></p>
<pre><code>float
real
</code></pre>
<hr>... | [
{
"answer_id": 968734,
"author": "Örjan Jämte",
"author_id": 19311,
"author_profile": "https://Stackoverflow.com/users/19311",
"pm_score": 11,
"selected": true,
"text": "<p>This is for <a href=\"http://msdn.microsoft.com/en-us/library/ms131092(SQL.90).aspx\" rel=\"noreferrer\">SQL Server... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16587/"
] | For the following SQL Server datatypes, what would be the corresponding datatype in C#?
**Exact Numerics**
```
bigint
numeric
bit
smallint
decimal
smallmoney
int
tinyint
money
```
---
**Approximate Numerics**
```
float
real
```
---
**Date and Time**
```
date
datetimeoffset
datetime2
smalldatetime
datetime
tim... | This is for [SQL Server 2005](http://msdn.microsoft.com/en-us/library/ms131092(SQL.90).aspx). There are updated versions of the table for [SQL Server 2008](http://msdn.microsoft.com/en-us/library/ms131092%28v=sql.100%29.aspx), [SQL Server 2008 R2](http://msdn.microsoft.com/en-us/library/ms131092%28v=sql.105%29.aspx), [... |
425,392 | <p>I have multiple setTimeout functions like this:</p>
<pre><code> function bigtomedium(visiblespan) {
visiblespan.removeClass('big').addClass('medium');
setTimeout(function(){ mediumtosmall(visiblespan);},150);
};
function mediumtosmall(visiblespan) {
visiblespan.removeClass('medi... | [
{
"answer_id": 425413,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 5,
"selected": true,
"text": "<p>Not sure if you are already aware of this but, clearTimeout accepts a timeoutID that is previously returned from a call to set... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have multiple setTimeout functions like this:
```
function bigtomedium(visiblespan) {
visiblespan.removeClass('big').addClass('medium');
setTimeout(function(){ mediumtosmall(visiblespan);},150);
};
function mediumtosmall(visiblespan) {
visiblespan.removeClass('medium').addClass(... | Not sure if you are already aware of this but, clearTimeout accepts a timeoutID that is previously returned from a call to setTimeout.
Therefore you need to assign this timeout id to a variable that remains in scope for when you need to cancel it. Then pass it to the clearTimeout call when you need to stop the loop.
... |
425,400 | <p>How can I "hide" parts of a class so that whoever is using the libary does not have to include headers for all the types used in my class. Ie take the MainWindow class below, ho can I have it so when compiled in a static/dynamic libary, whoever is useing the libary does NOT have to include windows.h, ie HWND, CRITIC... | [
{
"answer_id": 425411,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 0,
"selected": false,
"text": "<p>This book may give you some ideas:</p>\n\n<p><a href=\"https://rads.stackoverflow.com/amzn/click/com/0201633620\" ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | How can I "hide" parts of a class so that whoever is using the libary does not have to include headers for all the types used in my class. Ie take the MainWindow class below, ho can I have it so when compiled in a static/dynamic libary, whoever is useing the libary does NOT have to include windows.h, ie HWND, CRITICAL\... | You can hide parts of a class using the so-called "cheshire cat", "letter/envelope", or "pimpl" technique (which are, all, different names for the same technique):
```
class MainWindow
{
private:
//opaque data
class ImplementationDetails;
ImplementationDetails* m_data;
public:
... declare your public m... |
425,401 | <p>I've had this problem a couple of times. Let's say I want to display a splash-screen or something in an OpenGL context (or DirectX for that matter, it's more of a conceptual thing), now, I could either just load a 2048x2048 texture and hope that the graphics card will cope with it (most will nowadays I suppose), but... | [
{
"answer_id": 425719,
"author": "Bryan Denny",
"author_id": 396,
"author_profile": "https://Stackoverflow.com/users/396",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there is a built-in opengl function, but you might find a library (or write the function yourself) to bre... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46991/"
] | I've had this problem a couple of times. Let's say I want to display a splash-screen or something in an OpenGL context (or DirectX for that matter, it's more of a conceptual thing), now, I could either just load a 2048x2048 texture and hope that the graphics card will cope with it (most will nowadays I suppose), but gr... | If this is a single frame splash image with no animations, then there's no harm using `glDrawPixels`. If performance is crucial and you are required to use a texture, then the correct way to do it is to determine at runtime, the maximum supported texture size, using a proxy texture.
```
GLint width = 0;
while ( 0 == w... |
425,407 | <p>I have a javascript function (class) that takes a function reference as one paremter.</p>
<pre><code>function MyClass ( callBack ) {
if (typeof callBack !== 'function')
throw "You didn't pass me a function!"
}
</code></pre>
<p>For reasons I won't go in to here, I need to append something to the function by e... | [
{
"answer_id": 425441,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 0,
"selected": false,
"text": "<p>I assume you are saving this callback somewhere... Any reason this won't work?</p>\n\n<pre><code>function MyClass ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8636/"
] | I have a javascript function (class) that takes a function reference as one paremter.
```
function MyClass ( callBack ) {
if (typeof callBack !== 'function')
throw "You didn't pass me a function!"
}
```
For reasons I won't go in to here, I need to append something to the function by enclosing it in an anonymou... | Function objects don't provide methods to modify them. Therefore, what you want to do is impossible the way you want to do it. It's the same thing Jon Skeet likes to point out about Java: Objects are not really passed by reference, but instead a pointer to them is passed by value. That means that changing the value of ... |
425,424 | <p>Suppose I have a datatable like this:</p>
<pre><code> DataTable dt = new DataTable("Woot");
dt.Columns.AddRange(new DataColumn[]{
new DataColumn("ID",typeof(System.Guid)),
new DataColumn("Name",typeof(String))
});
</code></pre>
<p>When I try to bind a control to ... | [
{
"answer_id": 425477,
"author": "Igor Zelaya",
"author_id": 22769,
"author_profile": "https://Stackoverflow.com/users/22769",
"pm_score": 1,
"selected": false,
"text": "<p>shouldn't you reference dt instead of _dtRow?</p>\n\n<p>For example:</p>\n\n<pre><code>this.txtName.DataBindings.Ad... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Suppose I have a datatable like this:
```
DataTable dt = new DataTable("Woot");
dt.Columns.AddRange(new DataColumn[]{
new DataColumn("ID",typeof(System.Guid)),
new DataColumn("Name",typeof(String))
});
```
When I try to bind a control to it:
```
this.txtN... | OK, after messing with your code for a while, I kept getting stumped. Then I finally realized the issue. I'm assuming \_dtRow is a DataRow. You need to reference the actual DataTable (dt).
```
this.textBox1.DataBindings.Add("Text", dt, "Name");
```
EDIT: After seeing your comment on Igor's post. If you bind to dt, ... |
425,430 | <p>I'm trying to return an iterator for a vector in a templated class (I'm not sure if that makes a difference, but I've read that may, so I thought I'd mention it). The problem is that I get an error about C++ not supporting default-int when I try this. I've looked online and from what I can see in forums and explan... | [
{
"answer_id": 425442,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "<p>This part here:</p>\n\n<pre><code>vector<shared_ptr<vector<T>>>\n</code></pre>\n\n<p>It is a prob... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23553/"
] | I'm trying to return an iterator for a vector in a templated class (I'm not sure if that makes a difference, but I've read that may, so I thought I'd mention it). The problem is that I get an error about C++ not supporting default-int when I try this. I've looked online and from what I can see in forums and explanaions... | Also remember to use typename when declaring the template-dependent return type:
```
typename vector< shared_ptr< vector< T > > >::iterator GetRowIterator();
```
and the method definition
```
typename vector< shared_ptr< vector< T > > >::const_iterator Table<T>::GetRowIterator()
{
return data.begin();
}
```
Not... |
425,439 | <p>I have a partially nfilled array of objects, and when I iterate through them I tried to check to see whether the selected object is <code>null</code> before I do other stuff with it. However, even the act of checking if it is <code>null</code> seem to through a <code>NullPointerException</code>. <code>array.length</... | [
{
"answer_id": 425466,
"author": "Richard Campbell",
"author_id": 12254,
"author_profile": "https://Stackoverflow.com/users/12254",
"pm_score": 6,
"selected": true,
"text": "<p>You have more going on than you said. I ran the following expanded test from your example:</p>\n\n<pre><code>p... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37857/"
] | I have a partially nfilled array of objects, and when I iterate through them I tried to check to see whether the selected object is `null` before I do other stuff with it. However, even the act of checking if it is `null` seem to through a `NullPointerException`. `array.length` will include all `null` elements as well.... | You have more going on than you said. I ran the following expanded test from your example:
```
public class test {
public static void main(String[] args) {
Object[][] someArray = new Object[5][];
someArray[0] = new Object[10];
someArray[1] = null;
someArray[2] = new Object[1];
... |
425,457 | <p>Let's say we have a class, MyParent:</p>
<pre><code>class MyParent
{
public:
template<namespace T>
MyParent()
{
T* Something;
}
};
</code></pre>
<p>And a derived class, which uses this constructor:</p>
<pre><code>class MyDerived : public MyParent
{
public:
MyDerived()
: MyParent<int>()... | [
{
"answer_id": 425466,
"author": "Richard Campbell",
"author_id": 12254,
"author_profile": "https://Stackoverflow.com/users/12254",
"pm_score": 6,
"selected": true,
"text": "<p>You have more going on than you said. I ran the following expanded test from your example:</p>\n\n<pre><code>p... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51747/"
] | Let's say we have a class, MyParent:
```
class MyParent
{
public:
template<namespace T>
MyParent()
{
T* Something;
}
};
```
And a derived class, which uses this constructor:
```
class MyDerived : public MyParent
{
public:
MyDerived()
: MyParent<int>()
{
}
};
```
Then I get a compiling error, b... | You have more going on than you said. I ran the following expanded test from your example:
```
public class test {
public static void main(String[] args) {
Object[][] someArray = new Object[5][];
someArray[0] = new Object[10];
someArray[1] = null;
someArray[2] = new Object[1];
... |
425,461 | <p>I have a problem where I always need to give simple access to my local account, and don't want to deal with typing in my root password a million times on my local machine. How do I give perms so i can type 'mysql' with my local user and get access to everything?</p>
| [
{
"answer_id": 427500,
"author": "brian",
"author_id": 53224,
"author_profile": "https://Stackoverflow.com/users/53224",
"pm_score": 0,
"selected": false,
"text": "<p>Why not just use root? This is your local machine, after all.</p>\n\n<p>There is such a thing as being too paranoid.</p>... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4322/"
] | I have a problem where I always need to give simple access to my local account, and don't want to deal with typing in my root password a million times on my local machine. How do I give perms so i can type 'mysql' with my local user and get access to everything? | This gives the local user to the dev machine perms to select from databases, and a local\_rails\_user account (feel free to sub your own) permissions to run any migrations. Just thought i'd store it here in case anyone else wants to use it. NOT FOR PRODUCTION MACHINES.
Local Rails User:
```
insert into user(host,user... |
425,475 | <p>I'm wondering what the <em>simplest</em> way to list all indexes for all tables in a database is. </p>
<p>Should I call <code>sp_helpindex</code> for each table and store the results in a temp table, or is there an easier way?</p>
<p>Can anyone explain why constraints are stored in sysobjects but indexes are not?... | [
{
"answer_id": 425484,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 3,
"selected": false,
"text": "<p>You could reference <a href=\"http://msdn.microsoft.com/en-us/library/ms190283.aspx\" rel=\"noreferrer\">sysindexes</a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33178/"
] | I'm wondering what the *simplest* way to list all indexes for all tables in a database is.
Should I call `sp_helpindex` for each table and store the results in a temp table, or is there an easier way?
Can anyone explain why constraints are stored in sysobjects but indexes are not? | Here's an example of the kind of query you need:
```
select
i.name as IndexName,
o.name as TableName,
ic.key_ordinal as ColumnOrder,
ic.is_included_column as IsIncluded,
co.[name] as ColumnName
from sys.indexes i
join sys.objects o on i.object_id = o.object_id
join sys.index_columns ic on ic.o... |
425,492 | <p>My install of Visual Studio 2008 does not support IE style back and forward navigation withe the mouse in the C# code editor. </p>
<p>Searches show that multiple people have run into this problem but I have yet to find a correct solution. </p>
<p>There's even a <a href="http://www.codeproject.com/KB/macros/MouseNa... | [
{
"answer_id": 32636649,
"author": "ΩmegaMan",
"author_id": 285795,
"author_profile": "https://Stackoverflow.com/users/285795",
"pm_score": 0,
"selected": false,
"text": "<p>Visual Studio 2008 is an editor and the apps built in it can also be built in any later version such as Visual Stu... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | My install of Visual Studio 2008 does not support IE style back and forward navigation withe the mouse in the C# code editor.
Searches show that multiple people have run into this problem but I have yet to find a correct solution.
There's even a [VS add-in hack](http://www.codeproject.com/KB/macros/MouseNavi.aspx) ... | You can mitigate the problem by [AutoHotKey](http://ahkscript.org) tool (free, open source).
Let's assume your Visual Studio 2008 has these editor commands and their respective shortcuts:
* `View.NavigateBackward` = `Ctrl`+`-`
* `View.NavigateForward` = `Ctrl`+`Shift`+`-`
You should be able to **verify** these short... |
425,512 | <p>I am building a fairly simple CMS. I need to intercept requests for the majority of .aspx pages in my web application, in order to gain complete control over the output. In most cases, the output will be pulled from cache and will just be plain HTML.</p>
<p>However, there still are a couple of pages that I am goi... | [
{
"answer_id": 425553,
"author": "DavGarcia",
"author_id": 40161,
"author_profile": "https://Stackoverflow.com/users/40161",
"pm_score": 3,
"selected": true,
"text": "<p>When I wrote a simple CMS, I had a difficult time using the PageHandlerFactory to get it to do what I wanted. In the e... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54420/"
] | I am building a fairly simple CMS. I need to intercept requests for the majority of .aspx pages in my web application, in order to gain complete control over the output. In most cases, the output will be pulled from cache and will just be plain HTML.
However, there still are a couple of pages that I am going to need t... | When I wrote a simple CMS, I had a difficult time using the PageHandlerFactory to get it to do what I wanted. In the end I switched to a IHttpModule.
My module would first check to see if there was an .aspx file in the requested path. I'd only do that if the page has user controls on it or didn't fit into the CMS for ... |
425,521 | <p>I'm working on a Rails app that sends data through a form. I want to modify some of the "parameters" of the form <em>after</em> the form sends, but <em>before</em> it is processed.</p>
<p><strong>What I have right now</strong></p>
<pre><code>{"commit"=>"Create",
"authenticity_token"=>"000000000000000000000... | [
{
"answer_id": 425771,
"author": "Kevin Davis",
"author_id": 49993,
"author_profile": "https://Stackoverflow.com/users/49993",
"pm_score": 5,
"selected": true,
"text": "<p>Before it's submitted to the database you can write code in the controller that will take the parameters and append ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34795/"
] | I'm working on a Rails app that sends data through a form. I want to modify some of the "parameters" of the form *after* the form sends, but *before* it is processed.
**What I have right now**
```
{"commit"=>"Create",
"authenticity_token"=>"0000000000000000000000000"
"page"=>{
"body"=>"TEST",
"link_attrib... | Before it's submitted to the database you can write code in the controller that will take the parameters and append different information before saving. For example:
```
FooController < ApplicationController
def update
params[:page] ||= {}
params[:page][:link_attributes] ||= []
params[:page][:link_attri... |
425,531 | <p>I have bound my ListBox to some data.</p>
<p>The problem is when I call myTableAdapter.Fill(..) method, SelectedValue changes to whatever is the first item ID in the list. Although "Selected Value" in VS is not bound anywhere (see image).
<a href="http://img370.imageshack.us/img370/2548/ss20090108212745qz2.png" rel... | [
{
"answer_id": 425771,
"author": "Kevin Davis",
"author_id": 49993,
"author_profile": "https://Stackoverflow.com/users/49993",
"pm_score": 5,
"selected": true,
"text": "<p>Before it's submitted to the database you can write code in the controller that will take the parameters and append ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50173/"
] | I have bound my ListBox to some data.
The problem is when I call myTableAdapter.Fill(..) method, SelectedValue changes to whatever is the first item ID in the list. Although "Selected Value" in VS is not bound anywhere (see image).
[alt text http://img370.imageshack.us/img370/2548/ss20090108212745qz2.png](http://img37... | Before it's submitted to the database you can write code in the controller that will take the parameters and append different information before saving. For example:
```
FooController < ApplicationController
def update
params[:page] ||= {}
params[:page][:link_attributes] ||= []
params[:page][:link_attri... |
425,537 | <p>Suppose I have a grid with some row definitions, and a child control in that grid. How would I go about setting the Grid.Row property of the child control programatically?</p>
| [
{
"answer_id": 425569,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not 100% sure this is in SilverLight, but in WPF you call a static method (called SetX, where X is the prope... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | Suppose I have a grid with some row definitions, and a child control in that grid. How would I go about setting the Grid.Row property of the child control programatically? | To set the value:
```
textBlock.SetValue(Grid.RowProperty, 3);
```
To reset the value:
```
textBlock.SetValue(Grid.RowProperty, null);
``` |
425,548 | <p>I have a gridview control bound to an object data source. in addition to the columns that i want to display i want to display this</p>
<pre><code> <Columns>
<asp:CheckBoxField DataField="Locked" Visible="true" AccessibleHeaderText="On Hold" ReadOnly="false"/>
</Columns>
</code></pre>
<p... | [
{
"answer_id": 425599,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 0,
"selected": false,
"text": "<p>For the click Event I could not figure out the OnClickChange either, so I rolled my own.</p>\n\n<pre><code>using Sy... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38230/"
] | I have a gridview control bound to an object data source. in addition to the columns that i want to display i want to display this
```
<Columns>
<asp:CheckBoxField DataField="Locked" Visible="true" AccessibleHeaderText="On Hold" ReadOnly="false"/>
</Columns>
```
Couple of questions here:
1. If I do the ab... | To answer #2, I would go with a `<asp:CheckBox>` control in the `<ItemTemplate>` and then set the `Checked` property in the `GridView_RowDataBound` event:
```
protected void grdSomething_RowDataBound ( Object sender, GridViewRowEventArgs e )
{
if ( e.Row.RowType == DataControlRowType.DataRow )
{
Busine... |
425,558 | <p>I'm testing out my application with the hopes of migrating to SQL Server 2008 (From 200). In the SQL Server profiler, I'm seeing </p>
<pre>
Audit Login
SQL:BatchStarting SELECT .....
SQL:BatchCompleted SELECT .....
Audit Logout
</pre>
<p>for every single query that is being ... | [
{
"answer_id": 425570,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 3,
"selected": true,
"text": "<p>This is expected behavior. From the documentation for the <a href=\"http://msdn.microsoft.com/en-us/library/ms190260.... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] | I'm testing out my application with the hopes of migrating to SQL Server 2008 (From 200). In the SQL Server profiler, I'm seeing
```
Audit Login
SQL:BatchStarting SELECT .....
SQL:BatchCompleted SELECT .....
Audit Logout
```
for every single query that is being run. From what... | This is expected behavior. From the documentation for the [Audit Login Event Class](http://msdn.microsoft.com/en-us/library/ms190260.aspx):
The Audit Login event class indicates that a user has successfully logged in to Microsoft SQL Server. Events in this class are fired by new connections or by connections that are ... |
425,576 | <p>An explicit instantiation of a static template member function keeps failing to compile with the message <code>error C2785: 'at_Intermediate CUtil::convert_variant(const VARIANT &)' and '<Unknown>' have different return types</code></p>
<p>When I make a corresponding class with non-static member functions... | [
{
"answer_id": 425584,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 3,
"selected": true,
"text": "<p>Here is the download like: <a href=\"http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6610/"
] | An explicit instantiation of a static template member function keeps failing to compile with the message `error C2785: 'at_Intermediate CUtil::convert_variant(const VARIANT &)' and '<Unknown>' have different return types`
When I make a corresponding class with non-static member functions, the compiler likes me.
```
... | Here is the download like: [Microsoft ASP.NET MVC Beta](http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&displaylang=en)
The main site is [www.asp.net/mvc](http://www.asp.net/mvc)
Source code is here: [www.codeplex.com/aspnet](http://www.codeplex.com/aspnet) |
425,590 | <p>I would like to print my Swing JComponent via iText to pdf. </p>
<pre><code>JComponent com = new JPanel();
com.add( new JLabel("hello") );
PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream( dFile ) );
document.open( );
PdfContentByte cb = writer.getDirectContent( );
PdfTemplate tp = cb.crea... | [
{
"answer_id": 425658,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know that much about iText, but... you did close the <code>PdfWriter</code> at some point, right?</p>\n"
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49964/"
] | I would like to print my Swing JComponent via iText to pdf.
```
JComponent com = new JPanel();
com.add( new JLabel("hello") );
PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream( dFile ) );
document.open( );
PdfContentByte cb = writer.getDirectContent( );
PdfTemplate tp = cb.createTemplate( pa... | I have figured it out adding addNotify and validate helps.
```
com.addNotify( );
com.validate( );
``` |
425,604 | <p>This is a generalization of the "string contains substring" problem to (more) arbitrary types.</p>
<p>Given an sequence (such as a list or tuple), what's the best way of determining whether another sequence is inside it? As a bonus, it should return the index of the element where the subsequence starts:</p>
<p>E... | [
{
"answer_id": 425622,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 2,
"selected": false,
"text": "<p>Brute force may be fine for small patterns.</p>\n\n<p>For larger ones, look at the <a href=\"http://en.wikipedia.or... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15842/"
] | This is a generalization of the "string contains substring" problem to (more) arbitrary types.
Given an sequence (such as a list or tuple), what's the best way of determining whether another sequence is inside it? As a bonus, it should return the index of the element where the subsequence starts:
Example usage (Seque... | I second the Knuth-Morris-Pratt algorithm. By the way, your problem (and the KMP solution) is exactly recipe 5.13 in [Python Cookbook](https://rads.stackoverflow.com/amzn/click/com/0596007973) 2nd edition. You can find the related code at <http://code.activestate.com/recipes/117214/>
It finds *all* the correct subsequ... |
425,617 | <p>I'm trying to mix-in a class in my Groovy/Grails app, and I'm using <a href="http://docs.codehaus.org/display/GroovyJSR/Mixins#Mixins-StaticMixing" rel="noreferrer">the syntax defined in the docs</a>, but I keep getting an error.</p>
<p>I have a domain class that looks like this:</p>
<pre><code>class Person {
mi... | [
{
"answer_id": 425721,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 2,
"selected": false,
"text": "<p>I guess what you've seen there is rather a proposal than a feature ;) Groovy does not support mixins out of... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5447/"
] | I'm trying to mix-in a class in my Groovy/Grails app, and I'm using [the syntax defined in the docs](http://docs.codehaus.org/display/GroovyJSR/Mixins#Mixins-StaticMixing), but I keep getting an error.
I have a domain class that looks like this:
```
class Person {
mixin(ImagesMixin)
// ...
}
```
It compiles fi... | I don't think you are using the proper mixin syntax. Try this:
```
class MyMixin {
static doStuff(Person) {
'stuff was done'
}
}
class Person {}
Person.mixin MyMixin
new Person().doStuff()
``` |
425,618 | <p>There are essentially 2 places to define JavaScript functions in Grails, directly in a element on the GSP, and within a separate javascript source file under /web-app/js (for example, application.js). We have defined a commonly reused javascript function within application.js, but we also need to be able to generat... | [
{
"answer_id": 425674,
"author": "gabriel",
"author_id": 5447,
"author_profile": "https://Stackoverflow.com/users/5447",
"pm_score": 5,
"selected": true,
"text": "<p>An easy solution to keep your JavaScript unobtrusive is to create a JavaScriptController and map its actions \"/js/*\" by ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33752/"
] | There are essentially 2 places to define JavaScript functions in Grails, directly in a element on the GSP, and within a separate javascript source file under /web-app/js (for example, application.js). We have defined a commonly reused javascript function within application.js, but we also need to be able to generate pa... | An easy solution to keep your JavaScript unobtrusive is to create a JavaScriptController and map its actions "/js/\*" by adding this to your `UrlMappings.groovy` file:
```
"/js/$action"{
controller = "javascript"
}
```
then just create an action for each dynamic JS file you want, include in in your layout <HEAD>, ... |
425,620 | <p>I am using the AJAX Toolkit:</p>
<pre><code> <ajaxToolkit:CascadingDropDown ID="CategoryDDL_C" runat="server" TargetControlID="CategoryDDL"
Category="Main" PromptText="Please select a category" LoadingText="[Loading...]"
ServiceMethod="MainDDL" />
</code></pre>
<p>And for the Service... | [
{
"answer_id": 425665,
"author": "alex",
"author_id": 50564,
"author_profile": "https://Stackoverflow.com/users/50564",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if this is a bug of some sort, or some strange caching issue, but I've encountered the same thing in the past. Th... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | I am using the AJAX Toolkit:
```
<ajaxToolkit:CascadingDropDown ID="CategoryDDL_C" runat="server" TargetControlID="CategoryDDL"
Category="Main" PromptText="Please select a category" LoadingText="[Loading...]"
ServiceMethod="MainDDL" />
```
And for the Service Method:
```
[WebMethod]
[Syste... | Web *application* projects need to be recompiled when codebehind files change, web *site* projects do not. Which is yours? |
425,634 | <p>(I still feel like a complete newbie in MS Visual environments... so please bear with!)</p>
<p>I'm using Microsoft Visual C# 2008 Express Edition.</p>
<p>I have a project and in that project are two different forms. The .cs file for each form starts out:</p>
<pre><code>using System;
using System.Collections.Gene... | [
{
"answer_id": 425653,
"author": "Maxime Rouiller",
"author_id": 24975,
"author_profile": "https://Stackoverflow.com/users/24975",
"pm_score": 0,
"selected": false,
"text": "<p>Code need to be inside classes.</p>\n\n<p>It would look something like this:</p>\n\n<pre><code>using System;\n\... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44004/"
] | (I still feel like a complete newbie in MS Visual environments... so please bear with!)
I'm using Microsoft Visual C# 2008 Express Edition.
I have a project and in that project are two different forms. The .cs file for each form starts out:
```
using System;
using System.Collections.Generic;
using System.ComponentMo... | If you do something like:
```
namespace MyNameSpace
{
public class myclass
{
public myMethod()
{
// Code
}
}
}
```
You will be able to instantiate and access it. If you change it to:
```
namespace MyNameSpace
{
public class myclass
{
public static myMe... |
425,655 | <p>I've made a test case to illustrate the problem I've run into.</p>
<p>The first assert passes, but the second and third both fail. </p>
<p>Is there a way to check either of the two failing conditions k in a different way that will work? It would be OK if it's not terribly fast as I intend to cache the results on a... | [
{
"answer_id": 425702,
"author": "peSHIr",
"author_id": 50846,
"author_profile": "https://Stackoverflow.com/users/50846",
"pm_score": 0,
"selected": false,
"text": "<p>Isn't this <a href=\"https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282003\" rel=\"nof... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've made a test case to illustrate the problem I've run into.
The first assert passes, but the second and third both fail.
Is there a way to check either of the two failing conditions k in a different way that will work? It would be OK if it's not terribly fast as I intend to cache the results on a per-type basis.
... | It is by design that your second assertion fails. When you write
```
public class ParentClass<ParentInterface>
```
it actually means that "ParentInterface" is now a symbol for a type argument (doing that is so confusing that, indeed, it totally confused you).
Writing
```
public class ChildClass : ParentClass<ChildI... |
425,661 | <p>In the modern era of CSS, how would I create a pair of panels (for example, a preview window like in Outlook, or for master/detail views)? Ideally where the top (master) pane would get scrollbars, etc.?</p>
<p>The intended use-case is so that a user can scroll in the top window while always being able to see the pr... | [
{
"answer_id": 425682,
"author": "Michael T. Smith",
"author_id": 22292,
"author_profile": "https://Stackoverflow.com/users/22292",
"pm_score": 4,
"selected": true,
"text": "<p>Well, if you're actually using windows, then it sounds like you're talking about frames or even iFrames.</p>\n\... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23354/"
] | In the modern era of CSS, how would I create a pair of panels (for example, a preview window like in Outlook, or for master/detail views)? Ideally where the top (master) pane would get scrollbars, etc.?
The intended use-case is so that a user can scroll in the top window while always being able to see the preview / de... | Well, if you're actually using windows, then it sounds like you're talking about frames or even iFrames.
My assumption, though, is that when you say "window" you're just referring to the idea of a scrollable area. To do that, the css property "overflow" can be set to "scroll" and it will scroll if the contained elemen... |
425,668 | <p>I have 5 parameters and I want to send them to the method:</p>
<pre><code>public static SqlCommand getCommand(string procedure, SqlParameter[] parameter)
{
Sqlcommand cmd;
return cmd
}
</code></pre>
<p>Can I send these paramters at one time like this?</p>
<pre><code>SqlParameterCollection prm;
prm.Add(p1);
... | [
{
"answer_id": 425678,
"author": "Damien",
"author_id": 35454,
"author_profile": "https://Stackoverflow.com/users/35454",
"pm_score": 3,
"selected": false,
"text": "<p>I don't see what's wrong with that? You do know that, if this is .NET, you need to attach the parameters to the <code>Sq... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51151/"
] | I have 5 parameters and I want to send them to the method:
```
public static SqlCommand getCommand(string procedure, SqlParameter[] parameter)
{
Sqlcommand cmd;
return cmd
}
```
Can I send these paramters at one time like this?
```
SqlParameterCollection prm;
prm.Add(p1);
prm.Add(p2);
prm.Add(p3);
prm.Add(p4)... | Or create an array of parameters by hand:
```
SqlParameter[] parameter = {
new SqlParameter(...),
new SqlParameter(...),
new SqlParameter(...)
};
```
But I don't see what should be wrong with your approach. It simple, readable and understendable. |
425,688 | <p>Here is the code to add a pfx to the Cert store.</p>
<pre><code>X509Store store = new X509Store( StoreName.My, StoreLocation.LocalMachine );
store.Open( OpenFlags.ReadWrite );
X509Certificate2 cert = new X509Certificate2( "test.pfx", "password" );
store.Add( cert );
store.Close();
</code></pre>
<p>However, I could... | [
{
"answer_id": 426171,
"author": "Enrico Campidoglio",
"author_id": 26396,
"author_profile": "https://Stackoverflow.com/users/26396",
"pm_score": 4,
"selected": false,
"text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/aa384088.aspx\" rel=\"noreferrer\">WinHttp... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11413/"
] | Here is the code to add a pfx to the Cert store.
```
X509Store store = new X509Store( StoreName.My, StoreLocation.LocalMachine );
store.Open( OpenFlags.ReadWrite );
X509Certificate2 cert = new X509Certificate2( "test.pfx", "password" );
store.Add( cert );
store.Close();
```
However, I couldn't find a way to set perm... | To do it programmatically, you have to do three things:
1. Get the path of the private key folder.
2. Get the file name of the private key within that folder.
3. Add the permission to that file.
See [this post](http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2062983) for some example code that does al... |
425,711 | <p>I have medium sized MySQL database with a primary "persons" table which contains basic contact information about every human being connected to the theatre and theatre school for which I am responsible for maintaining and developing a number of web applications.</p>
<p>Some persons are just contacts - that is, thei... | [
{
"answer_id": 425761,
"author": "Dan R.",
"author_id": 8219,
"author_profile": "https://Stackoverflow.com/users/8219",
"pm_score": 0,
"selected": false,
"text": "<p>Are teachers the only 'person' that has a pay rate? You may be limiting your design by doing it this way. What you may wa... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53075/"
] | I have medium sized MySQL database with a primary "persons" table which contains basic contact information about every human being connected to the theatre and theatre school for which I am responsible for maintaining and developing a number of web applications.
Some persons are just contacts - that is, their "persons... | I went through a similar thing last year. There the question was: do we model our entities explicitly or generically? In your example, that would mean having entities/tables like teacher, student, etc with direct relationships between them or not.
In the end we went for a generic "Party" model. The Party model is as f... |
425,744 | <p>I run into a common problem when trying to do AJAX development. Where possible, I like to try and just update data in an existing layout, and not the layout itself. For example, take the div below:</p>
<pre><code><div id="content-5">Here is some content</div>
</code></pre>
<p>I would get the updated va... | [
{
"answer_id": 425788,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 2,
"selected": false,
"text": "<p>Complete personal opinion <em>ex nihil</em>, my rule of thumb is to change <strong>no more than 1 \"panel\" unit or 33... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50453/"
] | I run into a common problem when trying to do AJAX development. Where possible, I like to try and just update data in an existing layout, and not the layout itself. For example, take the div below:
```
<div id="content-5">Here is some content</div>
```
I would get the updated value for `content-5` from the server an... | Complete personal opinion *ex nihil*, my rule of thumb is to change **no more than 1 "panel" unit or 33% of the page whichever is less**.
The basis for this is that the user should be able to clearly recognise the previous page state is related to the new state - how would you feel if you were suddenly teleported into... |
425,745 | <p>I'm looking for the best approach to getting an XML document from a JDBC resultset. The structure of the XML isn't awfully important, but it should be fairly speedy.</p>
<p>For clearification, I would like the data from the resultset and only enough metadata to identify the data (field names essentially). I'm worki... | [
{
"answer_id": 425875,
"author": "Miserable Variable",
"author_id": 18573,
"author_profile": "https://Stackoverflow.com/users/18573",
"pm_score": 2,
"selected": true,
"text": "<p>Are you looking to convert the ResultSet table into XML? I don't know of any thirdparty tool, but tt is not v... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36924/"
] | I'm looking for the best approach to getting an XML document from a JDBC resultset. The structure of the XML isn't awfully important, but it should be fairly speedy.
For clearification, I would like the data from the resultset and only enough metadata to identify the data (field names essentially). I'm working with My... | Are you looking to convert the ResultSet table into XML? I don't know of any thirdparty tool, but tt is not very difficult to roll one of your own.
Your two options are to either have a constant format:
```
<ResultSet>
<MetaData>
<Column name="...." type="..."/>
....
<MetaData>
<Data>
<Row><Cell val... |
425,760 | <p>In Winforms you can say </p>
<pre><code>if ( DesignMode )
{
// Do something that only happens on Design mode
}
</code></pre>
<p>is there something like this in WPF?</p>
| [
{
"answer_id": 426072,
"author": "Enrico Campidoglio",
"author_id": 26396,
"author_profile": "https://Stackoverflow.com/users/26396",
"pm_score": 8,
"selected": true,
"text": "<p><strong>Indeed there is</strong>:</p>\n\n<p><strong><a href=\"http://msdn.microsoft.com/en-us/library/system.... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32772/"
] | In Winforms you can say
```
if ( DesignMode )
{
// Do something that only happens on Design mode
}
```
is there something like this in WPF? | **Indeed there is**:
**[System.ComponentModel.DesignerProperties.GetIsInDesignMode](http://msdn.microsoft.com/en-us/library/system.componentmodel.designerproperties.getisindesignmode.aspx)**
Example:
```
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
public class MyUserControl : U... |
425,767 | <p>Can I dynamically create an XAML and pop it into my app? How would it be done?</p>
| [
{
"answer_id": 425791,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 3,
"selected": true,
"text": "<p>Yep, it's pretty simple:</p>\n\n<pre><code>XmlReader tXml = XmlReader.Create(myXamlString);\nUIElement MyElement ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] | Can I dynamically create an XAML and pop it into my app? How would it be done? | Yep, it's pretty simple:
```
XmlReader tXml = XmlReader.Create(myXamlString);
UIElement MyElement = (UIElement)XamlReader.Load(tXml);
```
Then you can do what you like with it. |
425,805 | <p>One of the things I'm doing includes several links on the <strong>show</strong> view. For instance, I have a link (or button) for "Accepting", and another one for "Rejecting". Click on Accept, and the model updates the is_accepted field as true, click on Reject, and the is_accepted field is false.</p>
<p>Now, how b... | [
{
"answer_id": 425965,
"author": "Kevin Davis",
"author_id": 49993,
"author_profile": "https://Stackoverflow.com/users/49993",
"pm_score": 0,
"selected": false,
"text": "<p>Depending on how you want your UI to work you might consider link_to_remote (part of the prototype helper) - you ca... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722/"
] | One of the things I'm doing includes several links on the **show** view. For instance, I have a link (or button) for "Accepting", and another one for "Rejecting". Click on Accept, and the model updates the is\_accepted field as true, click on Reject, and the is\_accepted field is false.
Now, how best do I handle this?... | I think you're going about it the right way. One way to clean up your forms is by using the model form helpers all the way through, so you'd end up with something like
```
<%= form_for @thing do |f| %>
<%= f.hidden_field :accepted, :value => true %>
<%= f.submit "Accept" %>
<% end %>
<%= form_for @thing do |f| %>... |
425,809 | <p>We are having trouble with a Java web application running within Tomcat 6 that uses JDBC to connect to a SQL Server database.</p>
<p>After a few requests, the application server dies and the in the log files we find exceptions related to database connection failures.</p>
<p>We are not using any connection pooling ... | [
{
"answer_id": 425965,
"author": "Kevin Davis",
"author_id": 49993,
"author_profile": "https://Stackoverflow.com/users/49993",
"pm_score": 0,
"selected": false,
"text": "<p>Depending on how you want your UI to work you might consider link_to_remote (part of the prototype helper) - you ca... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/407003/"
] | We are having trouble with a Java web application running within Tomcat 6 that uses JDBC to connect to a SQL Server database.
After a few requests, the application server dies and the in the log files we find exceptions related to database connection failures.
We are not using any connection pooling right now and we ... | I think you're going about it the right way. One way to clean up your forms is by using the model form helpers all the way through, so you'd end up with something like
```
<%= form_for @thing do |f| %>
<%= f.hidden_field :accepted, :value => true %>
<%= f.submit "Accept" %>
<% end %>
<%= form_for @thing do |f| %>... |
425,811 | <p>I have a ListBox that uses an ItemContainerStyle. I have tried everything I can think of to get a CheckBox control to center vertically and horizontally. Any ideas?</p>
<pre><code><ListBox
IsSynchronizedWithCurrentItem="True"
Height="Auto" Width="Auto" DockPanel.Dock="Top"
ItemContainerStyle="{StaticResou... | [
{
"answer_id": 425828,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<p>I've had the same issue to. Have you tried setting \"HorizontalAlignment\" directly on the ListBoxItem in the style? (not... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33102/"
] | I have a ListBox that uses an ItemContainerStyle. I have tried everything I can think of to get a CheckBox control to center vertically and horizontally. Any ideas?
```
<ListBox
IsSynchronizedWithCurrentItem="True"
Height="Auto" Width="Auto" DockPanel.Dock="Top"
ItemContainerStyle="{StaticResource lbcStyle}" />... | Try setting the `ScrollViewer.HorizontalScrollBarVisibility` property to `"Disabled"` on the ListBox. This forces the item containers to have a fixed width; otherwise, they can have any horizontal size, and horizontal alignment cannot be calculated sensibly.
Vertical alignment should be a matter of modifying the ListB... |
425,814 | <p>In my C# application, I use a regular expression to validate the basic format of a US phone number to make sure that the user isn't just entering bogus data. Then, I strip out everything except numbers, so this:</p>
<blockquote>
<p>(123) 456-7890 x1234</p>
</blockquote>
<p>becomes</p>
<blockquote>
<p>12345678... | [
{
"answer_id": 425850,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": false,
"text": "<p>Using a regex you can replace:</p>\n\n<pre><code>(\\d{3})(\\d{3})(\\d{4})(\\d{4})\n</code></pre>\n\n<p>with:</p>\n\n<pre><c... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31516/"
] | In my C# application, I use a regular expression to validate the basic format of a US phone number to make sure that the user isn't just entering bogus data. Then, I strip out everything except numbers, so this:
>
> (123) 456-7890 x1234
>
>
>
becomes
>
> 12345678901234
>
>
>
in the database. In various part... | ```
String.Format("{0:(###) ###-#### x ###}", double.Parse("1234567890123"))
```
Will result in (123) 456-7890 x 123 |
425,854 | <p>The following AJAX call is failing in IE.</p>
<pre><code>$.ajax({
url:"{{SITE_URL}}/content/twitter.json",
dataType:"json",
error:function(xhr, status, errorThrown) {
alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
},
success:function(json) {
...Snip...
}
});
</cod... | [
{
"answer_id": 426012,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 3,
"selected": false,
"text": "<p>is this a copy/paste? the one thing that gets me all the time is leaving the last ',' in an object constructor. that i... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428/"
] | The following AJAX call is failing in IE.
```
$.ajax({
url:"{{SITE_URL}}/content/twitter.json",
dataType:"json",
error:function(xhr, status, errorThrown) {
alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
},
success:function(json) {
...Snip...
}
});
```
The error fun... | Fixed, I changed the content-type from `application/json; charset=utf8` to just plain `application/json`.
I hate IE :)
Also to avoid IE super-caching try this:
```
var d = new Date();
$.ajax({
url:"{{SITE_URL}}/content/twitter.json?_="+d.getTime(),
...Snip...
```
That way each request is a new url for I... |
425,864 | <p>I have a bat file that I should use to delete a part of one file and save into another one. I need to delete all the symbols between text "[aaa bbb]" and "[ccc ddd]". That is if I have the text:</p>
<pre><code>[aaa bbb]
1
2
3
[ccc ddd]
</code></pre>
<p>I should have as output:</p>
<pre><code>[aaa bbb]
[ccc ddd]
<... | [
{
"answer_id": 425933,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I looked at cmd and at power shell - can't find anything useful. Get yourself ActivePerl?</p>\n"
},
{
"answer_id": ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46503/"
] | I have a bat file that I should use to delete a part of one file and save into another one. I need to delete all the symbols between text "[aaa bbb]" and "[ccc ddd]". That is if I have the text:
```
[aaa bbb]
1
2
3
[ccc ddd]
```
I should have as output:
```
[aaa bbb]
[ccc ddd]
```
Thank you
**EDIT:** I would lik... | Take a look at the section "Delete between marker 1 and marker2" on [this sed hints page](http://www.cit.gu.edu.au/~anthony/info/shell/sed.hints)
Applying it on your example. **clean.sed**:
```
/^\[aaa bbb\]$/,/^\[ccc ddd\]$/{
/^\[aaa bbb\]$/!{
/^\[ccc ddd\]$/!d
}
}
```
Run using:
```
sed -f clean.sed inputfi... |
425,870 | <p>I'm trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using <code>DateTime</code> as a value to a <code>SqlParameter</code>. The SQL type in the stored procedure is 'datetime'.</p>
<p>Executing the sproc from SQL Management Studio works fine. But everytime I call it from C# I get an error... | [
{
"answer_id": 425896,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 6,
"selected": true,
"text": "<p>How are you setting up the <a href=\"http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx\"... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17803/"
] | I'm trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using `DateTime` as a value to a `SqlParameter`. The SQL type in the stored procedure is 'datetime'.
Executing the sproc from SQL Management Studio works fine. But everytime I call it from C# I get an error about the date format.
When I r... | How are you setting up the [`SqlParameter`](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx)? You should set the [`SqlDbType` property](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.sqldbtype.aspx) to [`SqlDbType.DateTime`](http://msdn.microsoft.com/en-us/lib... |
425,908 | <p>Are there any built-in functions in .Net that allow to capitalize strings, or handling proper casing? I know there are some somewhere in the Microsoft.VB namespace, but I want to avoid those if possible.</p>
<p>I'm aware of functions like string.ToUpper and string.ToLower() functions however it affects the entire s... | [
{
"answer_id": 425941,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 4,
"selected": true,
"text": "<p>Just to throw another option into the mix. This will capitalize every word in the given string:</p>\n\n<pre><code>public s... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | Are there any built-in functions in .Net that allow to capitalize strings, or handling proper casing? I know there are some somewhere in the Microsoft.VB namespace, but I want to avoid those if possible.
I'm aware of functions like string.ToUpper and string.ToLower() functions however it affects the entire string. I a... | Just to throw another option into the mix. This will capitalize every word in the given string:
```
public static string ToTitleCase(string inputString)
{
System.Globalization.CultureInfo cultureInfo =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textInfo = cultureInfo... |
425,924 | <p>I created a new email box for general support questions. When I try to send an email through SMTP I receive the following error:</p>
<blockquote>
<p>Mailbox unavailable. The server response was: No such recipient</p>
</blockquote>
<p>I am able to email the box through Outlook and SMTP works when I send to other... | [
{
"answer_id": 425939,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 1,
"selected": false,
"text": "<p>Is your DNS configured properly? You need an MX record specifying which host handles incoming messages for that do... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46780/"
] | I created a new email box for general support questions. When I try to send an email through SMTP I receive the following error:
>
> Mailbox unavailable. The server response was: No such recipient
>
>
>
I am able to email the box through Outlook and SMTP works when I send to other email address in the same domain... | The great thing about SMTP is that it's easy to spoof the conversation. The terrible thing about SMTP is also that it's easy to spoof the conversation. What makes this great is that if you want to figure out what's going wrong in a SMTP connection you can just "telnet mailhost 25" and start issuing SMTP commands like:
... |
425,953 | <p>I do not have any experience with programming fractals. Of course I've seen the famous Mandelbrot images and such.</p>
<p>Can you provide me with simple algorithms for fractals.</p>
<p>Programming language doesn't matter really, but I'm most familiar with actionscript, C#, Java.</p>
<p>I know that if I google fra... | [
{
"answer_id": 426018,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 2,
"selected": false,
"text": "<p>The mandelbrot set is generated by repeatedly evaluating a function until it overflows (some defined limit), then checking ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2172/"
] | I do not have any experience with programming fractals. Of course I've seen the famous Mandelbrot images and such.
Can you provide me with simple algorithms for fractals.
Programming language doesn't matter really, but I'm most familiar with actionscript, C#, Java.
I know that if I google fractals, I get a lot of (c... | Programming the Mandelbrot is easy.
My quick-n-dirty code is below (not guaranteed to be bug-free, but a good outline).
Here's the outline:
The Mandelbrot-set lies in the Complex-grid completely within a circle with radius 2.
So, start by scanning every point in that rectangular area.
Each point represents a Compl... |
425,956 | <p>I have a C# application and I want to copy a file to a new location. Some times I need to overwrite an existing file.
when this happens I receive a System.IO.IOException. I want to recover from a Sharing violation but how do I determine that IOException was returned because the destination file is in use rather t... | [
{
"answer_id": 426102,
"author": "cookre",
"author_id": 39195,
"author_profile": "https://Stackoverflow.com/users/39195",
"pm_score": -1,
"selected": false,
"text": "<p>Look for the explicit error codes that you can deal with, for example:</p>\n\n<p>catch (Exception u)\n {... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5618/"
] | I have a C# application and I want to copy a file to a new location. Some times I need to overwrite an existing file.
when this happens I receive a System.IO.IOException. I want to recover from a Sharing violation but how do I determine that IOException was returned because the destination file is in use rather then s... | This was the solution I came up with.
```
private void RobustMoveFile( System.IO.DirectoryInfo destinationDirectory, System.IO.FileInfo sourceFile, Boolean retryMove )
{
try
{
string DestinationFile = Path.Combine( destinationDirectory.Ful... |
425,975 | <p>Our I.T. dept doesn't allow connections to the SVN server from outside the physical office. (They're just kind of like that.) I need to work on projects when I'm not at the office.</p>
<p>I could just check out the project and wait until I come in to do a check-in. Maybe that would be best. But I like to check in f... | [
{
"answer_id": 425997,
"author": "krusty.ar",
"author_id": 43981,
"author_profile": "https://Stackoverflow.com/users/43981",
"pm_score": 3,
"selected": false,
"text": "<p>Have you read about <a href=\"http://git-scm.com/\" rel=\"nofollow noreferrer\">git</a>? it uses a local repository f... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | Our I.T. dept doesn't allow connections to the SVN server from outside the physical office. (They're just kind of like that.) I need to work on projects when I'm not at the office.
I could just check out the project and wait until I come in to do a check-in. Maybe that would be best. But I like to check in frequently.... | As a last-ditch effort, you can always poke a hole in your corporate firewall with SSH. Look into "ssh tunnels" (and also, come to think of it, "poke a hole in the firewall" might be a good search term too). I think you'll want either the -L or -R ssh option, but I can't recall which or even if they're the right ones f... |
425,978 | <p>I have a WCF service that uses basicHttpbinding in development.</p>
<p>Now in product we want to use SSL, what changes do I have to make to force SSL connections only?</p>
| [
{
"answer_id": 426019,
"author": "Stever B",
"author_id": 47939,
"author_profile": "https://Stackoverflow.com/users/47939",
"pm_score": 7,
"selected": true,
"text": "<p>This page on MSDN explains WCF Binding Security.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms729700.a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | I have a WCF service that uses basicHttpbinding in development.
Now in product we want to use SSL, what changes do I have to make to force SSL connections only? | This page on MSDN explains WCF Binding Security.
<http://msdn.microsoft.com/en-us/library/ms729700.aspx>
>
> The BasicHttpBinding class is
> primarily used to interoperate with
> existing Web services, and many of
> those services are hosted by Internet
> Information Services (IIS).
> Consequently, the trans... |
425,996 | <p>When I run this through FireFox 3: </p>
<pre><code><script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dijit.js"></script>
<script type="text/javascript"&... | [
{
"answer_id": 427179,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Yah, I tried it myself but it's working for me, at least against the latest code. (I'm running on FF3/mac.)</p>\n\n<p>The ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/425996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31892/"
] | When I run this through FireFox 3:
```
<script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dijit.js"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.requir... | This problem *appears to be* caused by the Firebug extension to Firefox. I say that because when I disable Firebug and use the control, it works normally. |
426,001 | <p>I'm inserting a DateTime into MsSQL using the GetUTCDate() function provided by MsSQL.</p>
<p>I need to convert the time in C# to show it as the Unix / MySQL integer, so that it can be eventually manipulated with PHP.</p>
<p>I believe the Unix / PHP / MySQL ticks start at 1/1/1970, but I'm not sure how I would con... | [
{
"answer_id": 426013,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 1,
"selected": true,
"text": "<pre><code>DateTime dt = something; //Get from db\n\nTimeSpan ts = dt - new DateTime(1,1,1970); // off the top of my h... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53084/"
] | I'm inserting a DateTime into MsSQL using the GetUTCDate() function provided by MsSQL.
I need to convert the time in C# to show it as the Unix / MySQL integer, so that it can be eventually manipulated with PHP.
I believe the Unix / PHP / MySQL ticks start at 1/1/1970, but I'm not sure how I would convert the equiv Ms... | ```
DateTime dt = something; //Get from db
TimeSpan ts = dt - new DateTime(1,1,1970); // off the top of my head, check order of params
long ticks = ts.TotalTicks; // again off the top of my head, check property name
``` |
426,026 | <p>I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.</p>
<p>Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)</p>
| [
{
"answer_id": 426089,
"author": "CB Bailey",
"author_id": 19563,
"author_profile": "https://Stackoverflow.com/users/19563",
"pm_score": 4,
"selected": false,
"text": "<p><code>git mergetool</code> is fully configurable so you can pretty much chose your favourite tool.</p>\n\n<p>The full... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] | I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.
Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.) | To follow-up on Charles Bailey's answer, here's my git setup that's using [p4merge](http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools) (free cross-platform 3way merge tool); tested on msys Git (Windows) install:
```
git config --global merge.tool p4merge
git config --global mergetool.p4me... |
426,041 | <p>I've been following Miguel Castro's excellent article on WCF <a href="http://www.devx.com/codemag/Article/39837" rel="noreferrer">here</a> and it's all working nicely, except that I have the following code</p>
<pre><code>public AdminClient()
{
ChannelFactory<IProductAdmin> factory = new ChannelFactory<... | [
{
"answer_id": 426311,
"author": "Raymond Roestenburg",
"author_id": 50142,
"author_profile": "https://Stackoverflow.com/users/50142",
"pm_score": 2,
"selected": false,
"text": "<p>You need to specify the endpoint name, because you can have many endpoints for the same type of contract. (... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] | I've been following Miguel Castro's excellent article on WCF [here](http://www.devx.com/codemag/Article/39837) and it's all working nicely, except that I have the following code
```
public AdminClient()
{
ChannelFactory<IProductAdmin> factory = new ChannelFactory<IProductAdmin>();
productAdminChannel = factory... | Use "\*" to use the first qualifying endpoint.
```
public AdminClient()
{
ChannelFactory<IProductAdmin> factory
= new ChannelFactory<IProductAdmin>("*");
productAdminChannel = factory.CreateChannel();
}
```
[MSDN Example](https://msdn.microsoft.com/en-us/library/aa344553(v=vs.110).aspx) |
426,071 | <p>I have several servers hosted with GoGrid, and every time I reboot one of my cloud servers, the system clock is incorrect. The server isn't a member of a domain, so I just have the OS set to sync with an Internet time server. This only happens once a day, and I don't see an option to make this happen automatically u... | [
{
"answer_id": 426099,
"author": "Ian Jacobs",
"author_id": 22818,
"author_profile": "https://Stackoverflow.com/users/22818",
"pm_score": 1,
"selected": false,
"text": "<p>scheduled task that runs on login maybe?</p>\n\n<p>EDIT: you may want to put a 30 second or so hold in the script to... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43722/"
] | I have several servers hosted with GoGrid, and every time I reboot one of my cloud servers, the system clock is incorrect. The server isn't a member of a domain, so I just have the OS set to sync with an Internet time server. This only happens once a day, and I don't see an option to make this happen automatically upon... | On Windows 2008, there is an option in the Task Scheduler that will allow you to wait until a network connection is available before the task is run. In the task properties dialog, create a new "At Startup" trigger, and be sure to check the "Enabled" box. Add an action to run your batch file. Finally, add a Condition t... |
426,079 | <p>I have an Oracle table that contains a field of LONG RAW type that contains ASCII character data. How can I write a query or view that will convert this to a more easily consumed character string? These are always going to be single-byte characters, FWIW.</p>
| [
{
"answer_id": 426119,
"author": "tuinstoel",
"author_id": 43901,
"author_profile": "https://Stackoverflow.com/users/43901",
"pm_score": 0,
"selected": false,
"text": "<p>I found this quote:</p>\n\n<blockquote>\n <p>In Oracle9i, you can even:</p>\n \n <p>alter table old_table modify (... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | I have an Oracle table that contains a field of LONG RAW type that contains ASCII character data. How can I write a query or view that will convert this to a more easily consumed character string? These are always going to be single-byte characters, FWIW. | Maybe
`select ...., to_lob(long_raw) from old_table`
(<http://www.psoug.org/reference/convert_func.html>)
or
```
UTL_RAW.CAST_TO_VARCHAR2(b)
```
(<http://www.dbasupport.com/forums/showthread.php?t=5342>). |
426,081 | <p>When viewing (or editing) a .gz file, vim knows to locate gunzip and display the file properly.<br>
In such cases, getfsize(expand("%")) would be the size of the gzipped file. </p>
<p>Is there a way to get the size of the expanded file?</p>
<p>[EDIT]<br>
Another way to solve this might be getting the size of cu... | [
{
"answer_id": 426262,
"author": "Zsolt Botykai",
"author_id": 11621,
"author_profile": "https://Stackoverflow.com/users/11621",
"pm_score": 0,
"selected": false,
"text": "<p>If you're on Unix/linux, try </p>\n\n<pre><code>:%!wc -c \n</code></pre>\n\n<p>That's in bytes. (It works on wind... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When viewing (or editing) a .gz file, vim knows to locate gunzip and display the file properly.
In such cases, getfsize(expand("%")) would be the size of the gzipped file.
Is there a way to get the size of the expanded file?
[EDIT]
Another way to solve this might be getting the size of current buffer, but ther... | There's no easy way to get the uncompressed size of a gzipped file, short of uncompressing it and using the getfsize() function. That might not be what you want. I took at a look at [RFC 1952 - GZIP File Format Specification](http://www.gzip.org/zlib/rfc-gzip.html "RFC 1952 - GZIP File Format Specification"), and the o... |
426,110 | <p>As described in <a href="http://www.asp.net/Learn/mvc/tutorial-13-cs.aspx" rel="nofollow noreferrer">this post</a>, I created an abstract base controller class in order to be able to pass data from a controller to master.page. In this case, I want to lookup a user in my db, querying for User.Identity.Name (only if h... | [
{
"answer_id": 426296,
"author": "Adam Right",
"author_id": 53124,
"author_profile": "https://Stackoverflow.com/users/53124",
"pm_score": 2,
"selected": false,
"text": "<p>To use the user, you should get the current page from </p>\n\n<pre><code>HttpContext.Current.User.Identity.Name\n</c... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53102/"
] | As described in [this post](http://www.asp.net/Learn/mvc/tutorial-13-cs.aspx), I created an abstract base controller class in order to be able to pass data from a controller to master.page. In this case, I want to lookup a user in my db, querying for User.Identity.Name (only if he is logged in).
However, I noticed tha... | As Paco suggested, the viewdata isn't initialized till after you are trying to use it.
Try overriding Controller.Initialize() instead:
```
public abstract class ApplicationController : Controller
{
private IUserRepository _repUser;
public ApplicationController()
{
}
protected override void Initi... |
426,128 | <p>I'm pulling a list of items from one table, on the basis of their being included in another table, like this:</p>
<pre><code>select fruit.id, fruit.name from fruit, fruit_rating where fruit_rating.fruit_id=fruit.id group by fruit.name;
</code></pre>
<p>That works fine -- it basically produces a list of all the fru... | [
{
"answer_id": 426153,
"author": "Rockcoder",
"author_id": 5290,
"author_profile": "https://Stackoverflow.com/users/5290",
"pm_score": 4,
"selected": true,
"text": "<pre><code>... WHERE fruit_rating.fruit_id=fruit.id \n and fruit.id not in \n (select fruit_rating.fruit_id \... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I'm pulling a list of items from one table, on the basis of their being included in another table, like this:
```
select fruit.id, fruit.name from fruit, fruit_rating where fruit_rating.fruit_id=fruit.id group by fruit.name;
```
That works fine -- it basically produces a list of all the fruit that has been rated by ... | ```
... WHERE fruit_rating.fruit_id=fruit.id
and fruit.id not in
(select fruit_rating.fruit_id
from fruit_rating
where fruit_rating.user_id = 10)
``` |
426,159 | <p>I need to take two strings, compare them, and print the difference between them.</p>
<p>So say I have:</p>
<pre><code>teamOne = "Billy, Frankie, Stevie, John"
teamTwo = "Billy, Frankie, Stevie"
$ teamOne.eql? teamTwo
=> false
</code></pre>
<p>I want to say "If the two strings are not equal, print whatever it... | [
{
"answer_id": 426201,
"author": "erik",
"author_id": 1191,
"author_profile": "https://Stackoverflow.com/users/1191",
"pm_score": 3,
"selected": false,
"text": "<p>If the real string you are comparing are similar to the strings you provided, then this should work:</p>\n\n<pre>\nteamOneAr... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2293/"
] | I need to take two strings, compare them, and print the difference between them.
So say I have:
```
teamOne = "Billy, Frankie, Stevie, John"
teamTwo = "Billy, Frankie, Stevie"
$ teamOne.eql? teamTwo
=> false
```
I want to say "If the two strings are not equal, print whatever it is that is different between them. ... | All of the solutions so far ignore the fact that the second array can also have elements that the first array doesn't have. Chuck has pointed out a fix (see comments on other posts), but there is a more elegant solution if you work with sets:
```
require 'set'
teamOne = "Billy, Frankie, Stevie, John"
teamTwo = "Billy... |
426,162 | <p>I'm writing a simplistic game to learn get some more C++ experience, and I have an idea where I feel polymorphism <em>almost</em> works, but doesn't. In this game, the <code>Party</code> moves fairly linearly through a <code>Map</code>, but can occasionally encounter a <code>Fork</code> in the road. A fork is (basic... | [
{
"answer_id": 426188,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 1,
"selected": false,
"text": "<p>You should use polymorphism as long as it makes sense and simplifies your design. You shouldn't use it just because it exis... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52806/"
] | I'm writing a simplistic game to learn get some more C++ experience, and I have an idea where I feel polymorphism *almost* works, but doesn't. In this game, the `Party` moves fairly linearly through a `Map`, but can occasionally encounter a `Fork` in the road. A fork is (basically) an `std::vector<location*>`.Originall... | All problems can be solved by adding a level of indirection. I would use your suggested variant, and decouple Location from Party by allowing getNext to accept an object that resolves directional choices. Here is an example (untested):
```
class Location;
class IDirectionChooser
{
public:
virtual bool ShouldIGoThi... |
426,173 | <p>Here is my problem. Imagine I am buying 3 different items, and I have up to 5 coupons. The coupons are interchangeable, but worth different amounts when used on different items.</p>
<p>Here is the matrix which gives the result of spending different numbers of coupons on different items:</p>
<pre><code>coupons: ... | [
{
"answer_id": 426206,
"author": "Samuel",
"author_id": 32465,
"author_profile": "https://Stackoverflow.com/users/32465",
"pm_score": -1,
"selected": false,
"text": "<p>This problem is similar in concept to the <a href=\"http://en.wikipedia.org/wiki/Traveling_salesman_problem\" rel=\"nof... | 2009/01/08 | [
"https://Stackoverflow.com/questions/426173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | Here is my problem. Imagine I am buying 3 different items, and I have up to 5 coupons. The coupons are interchangeable, but worth different amounts when used on different items.
Here is the matrix which gives the result of spending different numbers of coupons on different items:
```
coupons: 1 2 3... | This seems like a good candidate for dynamic programming:
```
//int[,] discountTable = new int[NumItems][NumCoupons+1]
// bestDiscount[i][c] means the best discount if you can spend c coupons on items 0..i
int[,] bestDiscount = new int[NumItems][NumCoupons+1];
// the best discount for a set of one item is just use t... |