qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
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>&lt;Car&gt; &lt;Color&gt; &lt;Paint&gt; &lt;AnotherUselessTag&gt; &lt;SomeSemanticBs&gt; &lt;TheImportantData&gt; </code></pre> <p>With LINQ its easy to get what I want: ( not exactly, but you get the point )</p> <pre><code>from x in car.Descendants("x") from y in x.Descendants("y") from z in y.Descendants("z") select z.WhatIWant(); </code></pre> <p>I'm asking if there is a better way to do this? Some way of navigating the DOM with Linq?</p>
[ { "answer_id": 425164, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 4, "selected": true, "text": "TheImporantData Car TheImportantData" }, { "answer_id": 426031, "author": "Robert Rossney", "author_i...
2009/01/08
[ "https://Stackoverflow.com/questions/425125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25300/" ]
425,130
<p>One of our clients has an application (FoxPro 9) running on top of a SQL Server 2005 backend. Intermittently, they are losing their ODBC connection with the SQL Server database. Below is the initial error information:</p> <blockquote> <p>Err Msg: Connectivity error: [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (recv()). </p> <p>ODBC Err Msg: [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (recv()). </p> <p>SQL State: 01000 </p> <p>ODBC Err No: 10054 </p> <p>ODBC Handle: 1 </p> <p>FoxPro Error No: 1526 </p> </blockquote> <p>We cannot duplicate this error on command. We have tried any number of solutions to no avail. One such hardware base solution which we found was described in: <a href="http://support.microsoft.com/kb/942861/en-us" rel="nofollow noreferrer">http://support.microsoft.com/kb/942861/en-us</a> </p> <p>I mention this because it almost perfectly matches what we have been seeing. However, we have implemented all the workarounds listed in that posting (and in this one <a href="http://support.microsoft.com/kb/948496" rel="nofollow noreferrer">http://support.microsoft.com/kb/948496</a> ) - and the problem still continues. </p> <p>This issue seems to show itself after the execution of long running queries, but we are not receiving any timeout errors, either from the application, or from SQL Server. I do not believe that this is the result of an idle timeout, because it sometimes occurs in the middle of an executing program.</p> <p>I am not a hardware guy, but both the network, and the server (Windows Server 2003), appear to be fast and well designed. There are times however, when the database server is under significant stress.</p> <p>If anyone has any suggestions on things we could try...please let us know!</p>
[ { "answer_id": 617421, "author": "Clinemi", "author_id": 14947, "author_profile": "https://Stackoverflow.com/users/14947", "pm_score": 1, "selected": false, "text": "Error: 1203, Severity: 20, State: 1.\nProcess ID 94 attempted to unlock a resource it does not own: OBJECT: 25:1699834390:...
2009/01/08
[ "https://Stackoverflow.com/questions/425130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14947/" ]
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 volatile" </code></pre> <p>Am I doing something wrong here to raise this warning? Why does the compiler me warn about this?</p>
[ { "answer_id": 425141, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 2, "selected": false, "text": "volatile" }, { "answer_id": 425145, "author": "Jon Skeet", "author_id": 22656, "author_profile": "...
2009/01/08
[ "https://Stackoverflow.com/questions/425132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
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 &gt; database.sql </code></pre> <p>But is there a similar way to dump all the tables <em>except</em> table1 and table2? I haven't found anything in the mysqldump documentation, so is brute-force (specifying all the table names) the only way to go?</p>
[ { "answer_id": 425172, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 11, "selected": true, "text": "mysqldump -u USERNAME -pPASSWORD DATABASE --ignore-table=DATABASE.table1 > database.sql\n -p #!/bin/bash\nPASSWORD=XX...
2009/01/08
[ "https://Stackoverflow.com/questions/425158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5630/" ]
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 way to pass back a confirmation or failure message to the form page? I can do it in the URL but I rather keep that clean looking.</p>
[ { "answer_id": 425200, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 5, "selected": true, "text": "// process something\nif($success) {\n flash_message('success','Did whatever successfully.');\n} else {\n fl...
2009/01/08
[ "https://Stackoverflow.com/questions/425178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49887/" ]
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 leaving the normal array object unaltered.<br> So I came up with the following construction (which was inspired on the jQuery source code) :</p> <pre><code>var arrayFunction = window.arrayFunction = function(array) { return new arrayFunction.fn.init(array); } arrayFunction.fn = arrayFunction.prototype = { init: function(array){ this.a = array; //should I return something here? }, someSpecialArrayFunction: function(){ //Super cool custom stuff here. } } </code></pre> <p>However this does not work (obviously). What should happen in the init function()?</p> <p>The error right now is that when I try:</p> <pre><code> arrayFunction(array).someSpecialArrayFunction(); </code></pre> <p>it says that someSpecialArrayFunction() is not a function?</p> <p>How should one do this?</p> <p><B>edit</b><br> Yes, this is indeed a simpliefied example. The actual thing has way more methods.</p> <p>Also, I just though of how awesome it would be if it also supported chaning, how would you do that?</p>
[ { "answer_id": 425243, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 1, "selected": false, "text": "var arrayFunction = window.arrayFunction = function(array) {\n return new arrayFunction.fn.init(array);\n}\narrayFunction.fn = ...
2009/01/08
[ "https://Stackoverflow.com/questions/425189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35197/" ]
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 will be displayed in the alert box.</p> <p>How could I do this? There doesn't seem to be an event handler for clicking an item member in a flex horizontal list?</p> <p>Thanks</p>
[ { "answer_id": 426388, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 1, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\" layout=\...
2009/01/08
[ "https://Stackoverflow.com/questions/425191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
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 Maven newbie.</p> <p><strong>EDIT:</strong> I've seen <a href="http://docs.codehaus.org/display/MAVENUSER/Required+Declaration+of+Properties" rel="noreferrer">this link</a>, which seems to imply it's not possible, but am not sure how up to date it is.</p>
[ { "answer_id": 428549, "author": "Olivier", "author_id": 53369, "author_profile": "https://Stackoverflow.com/users/53369", "pm_score": 1, "selected": false, "text": "<project>\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.yourcompany</groupId>\n <artifactId>yourproject</artifact...
2009/01/08
[ "https://Stackoverflow.com/questions/425198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1714/" ]
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(&amp;ts); </code></pre> <p>N.B. My uber goal is to use a C library with many vector-math functions, hence the need to find out some viable way to mix C and Objective-C</p>
[ { "answer_id": 425214, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 6, "selected": true, "text": "TestStruct *ts = malloc(sizeof(TestStruct));\nts->value = 33;\nfree(ts);\n TestStruct *newTestStruct(int value)\n{\n Tes...
2009/01/08
[ "https://Stackoverflow.com/questions/425205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50335/" ]
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></pre> <p>This is exactly how I get this problem. I click a link included in an Gmail's email and I get something wrong (no background). I then refresh the page and the background is colored completely.</p> <p>How do fix this problem? </p>
[ { "answer_id": 425718, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "html, body \n{\n background: black;\n color: white;\n font-family: Chaparral Pro, lucida grande, verdana, sans-serif;\n}...
2009/01/08
[ "https://Stackoverflow.com/questions/425216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
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 working. However, when I start the thread the ProgressBar freezes. I have already tried the BackgroundWorker but that didn't work so I used my own threading.</p> <p>The reason I use the Invoke() method is because I can't make changes to the ReportViewer control on the thread I created because it was created on the UI thread.</p> <p>The method that takes the most time processing is the RefreshReport() method of the ReportViewer control which is why I'm trying to do that on its own thread instead of the UI thread.</p> <p>Any help would be appreciated. Thanks.</p> <p>Here is the code for my thread variable:</p> <pre><code>Private t As New Thread(New ParameterizedThreadStart(AddressOf GenerateReport)) </code></pre> <p>Here is the code for the button that generates the report:</p> <pre><code>Private Sub btnGenerateReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerateReport.Click pbReports.Style = ProgressBarStyle.Marquee If t.ThreadState = ThreadState.Unstarted Then t.IsBackground = True t.Start(ReportType.Roads) ElseIf t.ThreadState = ThreadState.Stopped Then t = Nothing t = New Thread(New ParameterizedThreadStart(AddressOf GenerateReport)) t.IsBackground = True t.Start(ReportType.Roads) End If End Sub </code></pre> <p>Here is the code that generates the report:</p> <pre><code>Public Sub GenerateReport(ByVal rt As ReportType) If rvReport.InvokeRequired Then Dim d As New GenerateReportCallBack(AddressOf GenerateReport) Me.Invoke(d, New Object() {rt}) Else rvReport.ProcessingMode = ProcessingMode.Remote rvReport.ShowParameterPrompts = False rvReport.ServerReport.ReportServerUrl = New Uri("My_Report_Server_URL") rvReport.ServerReport.ReportPath = "My_Report_Path" rvReport.BackColor = Color.White rvReport.RefreshReport() End If If pbReports.InvokeRequired Then Dim d As New StopProgressBarCallBack(AddressOf StopProgressBar) Me.Invoke(d) Else StopProgressBar() End If End Sub </code></pre>
[ { "answer_id": 425280, "author": "Noah", "author_id": 47496, "author_profile": "https://Stackoverflow.com/users/47496", "pm_score": 0, "selected": false, "text": "Private Sub btnGenerateReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerateReport.Cli...
2009/01/08
[ "https://Stackoverflow.com/questions/425226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299/" ]
425,234
<p>I'd like to add an &lt;option&gt; element to a &lt;select&gt; element where the &lt;option&gt; element's text contains an HTML entity: &amp;mdash;</p> <p>In HTML, the code would look like this:</p> <pre><code>&lt;select name="test" id="test"&gt; &lt;option value=""&gt;&amp;mdash; Select One &amp;mdash;&lt;/option&gt; &lt;/select&gt; </code></pre> <p>My JavaScript code looks like this:</p> <pre><code>function selectOne() { var e = document.getElementById('test'); e.options[0] = new Option('&amp;mdash; Select One &amp;mdash;', ''); } </code></pre> <p>However, as you will see if you test this, the &amp;mdash; becomes escaped. I had the same outcome when I tried:</p> <pre><code>e.options[o].text = '&amp;mdash; Select One &amp;mdash;'; </code></pre> <p>(Observed behavior was in Internet&nbsp;Explorer 7 ... did not test with Firefox, Safari, etc. -- Internet&nbsp;Explorer 7 is the only browser I need at the moment.)</p>
[ { "answer_id": 425256, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 3, "selected": false, "text": "function selectOne() {\n var e = document.getElementById('test');\n e.options[0] = new Option('— Select One ...
2009/01/08
[ "https://Stackoverflow.com/questions/425234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53035/" ]
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't work. Only a complete restart of the software works.</p> <p>Suggestions?</p> <hr> <p>I can't use the using keyword because TpcClient is only defined in one location, but used throughout the library. (And there is only one connection at any given time)</p> <p>It's a library that handles communication. The software itself can call the ResetConnection() method of the Controller class (which represents the hardware).</p> <p>It currently looks like</p> <pre><code>if (tcpClient != null) { tcpClient.Close(); tcpClient = null; } </code></pre> <p>Now from what I've read here I should use tcpClient.Dispose() instead of " = null"</p> <p>I'll give that a try and see if it makes a difference.</p>
[ { "answer_id": 425363, "author": "Michał Ziober", "author_id": 51591, "author_profile": "https://Stackoverflow.com/users/51591", "pm_score": 5, "selected": false, "text": "using using (TcpClient tcpClient = new TcpClient())\n{\n //operations\n tcpClient.Close();\n}\n" }, { ...
2009/01/08
[ "https://Stackoverflow.com/questions/425235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
425,241
<p>I come from the VBA world, and remember there was a <code>BeforeUpdate</code> call I could make on a combobox. Now I am in C# (and loving it) and I was wondering is there a <code>BeforeUpdate</code> call for a <code>ComboBox</code> on a Winform?</p> <p>I can make an invisible textbox and store the info I need there and after the update, look at that box for what I need, but I was hoping there was a simplier solution.</p>
[ { "answer_id": 425311, "author": "Matt Brunell", "author_id": 24970, "author_profile": "https://Stackoverflow.com/users/24970", "pm_score": 4, "selected": true, "text": "SelectionChangeCommited" }, { "answer_id": 425323, "author": "Hans Passant", "author_id": 17034, "...
2009/01/08
[ "https://Stackoverflow.com/questions/425241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19802/" ]
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": "$(\"#idContentEditable\").keypress(function(e){ return e.which != 13; });\n" }, { "answer_id": 590628, "author": "...
2009/01/08
[ "https://Stackoverflow.com/questions/425274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31662/" ]
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 StaticData, which just returns some pre-defined constant data.</p> <p>Now, upon reading the file, an IOException may be thrown in FileData, but StaticData will never throw. Most style guides recommend propagating an Exception up the call stack until a sufficient amount of context is available to effectively deal with it.</p> <p>But I don't really want to add a throws clause to the abstract read() method. Why? Because Data and the complicated machinery using it knows nothing about files, it just knows about Data. Moreover, there may be other Data subclasses (and more of them) that never throw exceptions and deliver data flawlessly.</p> <p>On the other hand, the IOException is necessary, for if the disk is unreadable (or some such) an error <em>must</em> be thrown. So the only way out that I see is catching the IOException and throwing some RuntimeException in its place.</p> <p>Is this the correct philosophy?</p>
[ { "answer_id": 425288, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 2, "selected": false, "text": "IOException Data read RuntimeException" }, { "answer_id": 425289, "author": "Allain Lalonde", ...
2009/01/08
[ "https://Stackoverflow.com/questions/425281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
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 double clicked. <b>But how do I find out within my application what data file was chosen so I can load it?</b></p>
[ { "answer_id": 425384, "author": "Timothy Carter", "author_id": 4660, "author_profile": "https://Stackoverflow.com/users/4660", "pm_score": 1, "selected": true, "text": " //program.cs\n [STAThread]\n static void Main(string[] args)\n {\n Application.EnableVisualStyles(...
2009/01/08
[ "https://Stackoverflow.com/questions/425292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10722/" ]
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 this case it is not obvious which domain class to run executeQuery against, since really we are just using that domain class in order to run the query against a completely unrelated entity (the view).</p> <p>Would it be preferred to create a domain class representing the view and we could then just use list() against that domain class? It seems like there would be problems with this as Grails probably expects to be able to insert, update, delete, and modify the table schema of any domain class.</p> <p>[Edit:<br /> Follow up question here: <a href="https://stackoverflow.com/questions/430004/grails-domain-class-without-id-field-or-with-partially-null-composite-field]">Grails Domain Class without ID field or with partially NULL composite field</a></p>
[ { "answer_id": 425345, "author": "Siegfried Puchbauer", "author_id": 46301, "author_profile": "https://Stackoverflow.com/users/46301", "pm_score": 6, "selected": true, "text": "import groovy.sql.Sql\n\nclass MyFancySqlController {\n\n def dataSource // the Spring-Bean \"dataSource\" i...
2009/01/08
[ "https://Stackoverflow.com/questions/425294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33752/" ]
425,306
<p>update: I know there is no one best way to do everything. Sorry for not saying that right off. In the context of the data-access tutorials, if you had to do the project he did in that tutorial, would you do what he did or would use use MVC, if you had to choose one of them?</p> <p><strong>Update:</strong> Is MVC the more appropriate way to program asp.net applications, instead of the tutorials found here:</p> <p><a href="http://www.asp.net/Learn/data-access/" rel="nofollow noreferrer">http://www.asp.net/Learn/data-access/</a></p> <p><strong>Original:</strong></p> <p>I ask, because I initially learned about MVC with Java applications, then things like RoR, and Django. These other projects and companies spoke as if MVC had been around for a very long time, and from what I found out it had. Then Microsoft started putting MVC into the .net framework.</p> <p>I ask because I don't know how to design things very well and thought I was doing well to emulate what's on the asp.net site with Scott Mitchell's tutorial. I thought that creating abstract layers in a BLL was the way to go until I found out about MVC and now asp.net's MVC.</p> <p>I honestly don't know what the "right" way is to do things. I just create what I need, but I can't help feel like I am missing something.</p> <p>Is MVC the correct way to start doing things in large projects, specifically I mean MVC and ASP.NET, but could just as well mean PHP and one of their MVC frameworks.</p> <p>I'd like to settle on a standard way of doing things...for now anyway.</p> <p>And, out of curiosity, why did Microsoft only now start doing MVC?</p> <p><strong>UPDATE:</strong> Is MVC better than the current tutorial set on asp.net?</p> <p>I'm referring to the Scott Mitchell tutorials where he creates the BLL for abstraction. Or is that a linq question as well. I should have said that I understand the need for keeping logic and presentation separate but unsure the best way to do it. I was using the asp.net tutorials. It worked fine. Then I found out the rest of the world, as I saw it anyway, was using MVC. Then Microsoft started developing MVC, so to me the other method seems obsolete and the wrong way to do things.</p>
[ { "answer_id": 425329, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 5, "selected": true, "text": "ViewState WebControl WebControl ViewState" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28045/" ]
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 &lt;&lt;</a></p> <p>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 of the div - preferably without adding up the widths of all the thumbnail images and margins.</p> <p>I've put an alert in my window.onload function so I can test the various element dimension functions in different browsers. currently it's showing the value of scrollWidth, which is reported as 1540px by IE and 920px by FireFox, Safari, Opera, etc.</p> <p>The value 1540 is the correct one for my purposes, Can anyone tell me how to obtain this value in FireFox, etc.</p>
[ { "answer_id": 425355, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 0, "selected": false, "text": "var elemWidth = (elem.offsetWidth > elem.scrollWidth) ? elem.offsetWidth : elem.scrollWidth;\nvar elemHeight = (elem....
2009/01/08
[ "https://Stackoverflow.com/questions/425308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53030/" ]
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('&lt;scr'+'ipt defer src="//:" ' + 'onreadystatechange="if(this.readyState==\'complete\'){' + dojo._scopeName + '._loadInit();}"&gt;' + '&lt;/scr'+'ipt&gt;' ); } </code></pre> <p>Is that an issue with the dojo? I would like to move the commented code to another custom file so that the dojo framework is not affected. Can you suggest a better way of implementing it. Thanks.</p>
[ { "answer_id": 425355, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 0, "selected": false, "text": "var elemWidth = (elem.offsetWidth > elem.scrollWidth) ? elem.offsetWidth : elem.scrollWidth;\nvar elemHeight = (elem....
2009/01/08
[ "https://Stackoverflow.com/questions/425315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 htmlLocation = "VirtualEarth.html" </code></pre> <p>Supposedly the project I got this from was in working order, but I haven't changed any code. If I run this the new Uri() line give me an error, "Invalid URI: The format of the URI could not be determined."</p> <p>The file is present (as indicated by passing successfully through the Exists() method in the If). What is the correct way to reference a Url on the WebBrowser control when you want it to load a HTML file in the default application directory?</p> <p>Edit:</p> <p>I should clarify that this is a winforms project, not a web project.</p>
[ { "answer_id": 425332, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 3, "selected": true, "text": "public void LoadPageFromDisk(string filePath)\n{\n Uri targetPage = null;\n\n string workingPageURI = filePath.Trim();\n\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/425325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42620/" ]
425,350
<p>An upcoming project of mine is considering a design that involves (what I'm calling) "abstract entity references". It's quite a departure from a more common data model design, but it may be necessary to achieve the flexibility we want. I'm wondering if other architects have experience with systems like this and where the caveats are.</p> <p>The project has a requirement for a to control access to various entities (logically: business objects; physically: database rows) by various people. For example, we might want to create rules like:</p> <ul> <li>User Alice is a member of Company Z</li> <li>User Bob is the manager of Group Y, which has users Charlie, Dave, and Eve.</li> <li>User Frank may enter data for [critical business object] X, and also the [critical business objects] in [critical business object group] U.</li> <li>User George is not a member of Company T but may view the reports for Company T.</li> </ul> <p>The idea is that we have a lot of different securable objects, roles, groups, and permissions, and we want a system to handle this. Ideally this system would require little to no coding for new situations once it's launched; it should be very flexible.</p> <p>In a "traditional" data design, we might have entities/tables like this:</p> <ul> <li>User</li> <li>Company</li> <li>User/Company Cross-Reference</li> <li>UserGroup</li> <li>User/UserGroup Cross-Reference</li> <li>CBO ("Critical Business Object")</li> <li>User/CBO Cross-Reference</li> <li>CBOGroup</li> <li>User/CBOGroup Cross-Reference</li> <li>CBO/CBOGroup Cross-Reference</li> <li>ReportAccess, which is a cross-reference between User and Company specifically for access to reports</li> </ul> <p>Note the big number of cross-reference tables. This system isn't terribly flexible as any time we want to add a new means of access we'd need to introduce a new cross-reference table; that, in turn, means additional coding.</p> <p>The proposed system has all of the major entities (User, Company, CBO) reference a value in a new table called Entity. (In the code we'd probably make all of these entities subclasses of an Entity superclass). Then there's two additional tables that reference Entity * Group, which is also an Entity "subclass". * EntityRelation, which is a relation between two entities of any type (including Group). This will probably also have some sort of "Relationship Type" field to explain/qualify the relationship.</p> <p>This system, at least at first glance, looks like it would meet a lot of our requirements. We might introduce new Entities down the road, but we'd never need to do additional tables to handle the grouping and relationships between these entities, because Group and EntityRelation can already handle that.</p> <p>I'm concerned, however, whether this might not work very well in practice. The relationships between entities would become very complex and might be very hard for people (users and developers alike) to understand them. Also, they'd be very recursive; this would make things more difficult for our SQL-dependent report writing staff.</p> <p>Does anyone have experiences with a similar system?</p>
[ { "answer_id": 425485, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "Bob IsMemberOf UserGroup4 CBO CanViewReportsOf Bob Bob IsMemberOf Company1 Bob IsMemberOf Company2 Bob CanViewReportsOf...
2009/01/08
[ "https://Stackoverflow.com/questions/425350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
425,354
<p>Can anyone clarify/elucidate the situation with respect to <code>-[NSNotificationCenter addObserver:selector:name:object:]</code>?</p> <ul> <li><p>What types of references are kept by the notification center of the 'observer' and 'object' arguments?</p></li> <li><p>What are the best practices for removing observers from the notification center?</p></li> <li><p>What are the special concerns for multi-threaded applications, especially with respect to the 'object' argument?</p></li> <li><p>What are the differences in behavior of this method in GC and non-GC environments?</p></li> <li><p>Are the any significant differences (from a client perspective) between mobile and desktop environments in this method's behavior?</p></li> </ul> <p>Also, any pointers to existing articles which cover this would be greatly appreciated. I Googled, but was surprised to find little <em>in-depth</em> discussion of these issues (although maybe I didn't use the right magic keywords).</p>
[ { "answer_id": 37043371, "author": "samwize", "author_id": 242682, "author_profile": "https://Stackoverflow.com/users/242682", "pm_score": 4, "selected": false, "text": "NSNotificationCenter removeObserver" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34934/" ]
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 (which I'm distributing via gem). Any way I can make it easy for my users to figure out which version of library/script they're currently using.</p> <p>Is there any way I can access the version I specify in my gemspec from the ruby files in my <code>lib/</code> or <code>bin/</code> directories? That way, I don't have to update it multiple places at once - just in my gemspec.</p> <p>Currently I generate my gemspecs by hand, I haven't jumped on the Rake train yet. If I can't do what I want directly with only what rubygems gives me, would rake or another tool allow me to do this?</p>
[ { "answer_id": 494091, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": true, "text": "Gem.loaded_specs Gem.loaded_specs[\"mygemname\"].version.to_s #=> \"1.2.3\"\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9859/" ]
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 a way to dump data from a table into a CSV text file using <code>SQLCMD</code>?</p>
[ { "answer_id": 425387, "author": "Sarel Botha", "author_id": 35264, "author_profile": "https://Stackoverflow.com/users/35264", "pm_score": -1, "selected": false, "text": "sqlcmd '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n' Data Exporter ...
2009/01/08
[ "https://Stackoverflow.com/questions/425379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
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 and simple, just a list of fields from the three tables that are to be used in the results.</p> <p>But the tables and the where clauses in the 8 minute run time version are:</p> <p>(The first parameter is the lower bound of the user-selected date range, the second is the upper bound.)</p> <pre><code>FROM "AR_InvoiceHistoryDetail" "AR_InvoiceHistoryDetail", "AR_InvoiceHistoryHeader" "AR_InvoiceHistoryHeader", "IM1_InventoryMasterfile" "IM1_InventoryMasterfile" WHERE "AR_InvoiceHistoryDetail"."InvoiceNo" = "AR_InvoiceHistoryHeader"."InvoiceNo" AND "AR_InvoiceHistoryDetail"."ItemCode" = "IM1_InventoryMasterfile"."ItemNumber" AND "AR_InvoiceHistoryHeader"."SalespersonNo" = 'SMC' AND "AR_InvoiceHistoryHeader"."OrderDate" &gt;= @p_dr AND "AR_InvoiceHistoryHeader"."OrderDate" &lt;= @p_d2 </code></pre> <p>However, it turns out that another date field in the same table needs to be the one that the Date Range is compared with. So I changed the Order Dates at the end of the WHERE clause to InvoiceDate. I haven't had the query run successfully at all yet. And I've waited over 40 minutes. I have no control over indexing because this is a MAS 90 database which I don't believe I can directly change the database characteristics of.</p> <p>What could cause such a large (at least 5 fold) difference in performance. Is it that OrderDate might have been indexed while InvoiceDate was not? I have tried BETWEEN clauses but it doesn't seem to work in the providex dialect. I am using the ODBC interface through .NET in my custom report engine. I have been debugging the report and it is running at the database execution point when I asked VS to Break All, at the same spot where the 8 minute report was waiting, so it is almost certainly either something in my query or something in the database that is screwed up.</p> <p>If its just the case that InvoiceDates aren't indexed, what else can I do in the providex dialect of SQL to optimize the performance of these queries? Should I change the order of my criteria? This report gets results for a specific salesperson which is why the SMC clause exists. The prior clauses are for the inner joins, and the last clause is for the date range.</p> <p>I used an identical date range in both the OrderDate and InvoiceDate versions and have ran them all mulitiple times and got the same results.</p>
[ { "answer_id": 435648, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "AND \"AR_InvoiceHistoryHeader\".\"SalespersonNo\" = 'SMC'\nAND \"AR_InvoiceHistoryHeader\".\"OrderDate\" >= @p_dr\nAND \"AR_In...
2009/01/08
[ "https://Stackoverflow.com/questions/425382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
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> <p><strong>Date and Time</strong></p> <pre><code>date datetimeoffset datetime2 smalldatetime datetime time </code></pre> <hr> <p><strong>Character Strings</strong></p> <pre><code>char varchar text </code></pre> <hr> <p><strong>Unicode Character Strings</strong></p> <pre><code>nchar nvarchar ntext </code></pre> <hr> <p><strong>Binary Strings</strong></p> <pre><code>binary varbinary image </code></pre> <hr> <p><strong>Other Data Types</strong></p> <pre><code>cursor timestamp hierarchyid uniqueidentifier sql_variant xml table </code></pre> <p>(source: <a href="http://msdn.microsoft.com/en-us/library/ms187752.aspx" rel="noreferrer">MSDN</a>)</p>
[ { "answer_id": 55018803, "author": "AndreFeijo", "author_id": 2946773, "author_profile": "https://Stackoverflow.com/users/2946773", "pm_score": 4, "selected": false, "text": "private readonly string[] SqlServerTypes = { \"bigint\", \"binary\", \"bit\", \"char\", \"date\", \"datetime...
2009/01/08
[ "https://Stackoverflow.com/questions/425389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16587/" ]
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('medium').addClass('small'); setTimeout(function() { smalltomedium(visiblespan); },150); }; function smalltomedium(visiblespan) { visiblespan.removeClass('small').addClass('medium'); setTimeout(function() { mediumtobig(visiblespan); },150); }; function mediumtobig(visiblespan) { visiblespan.removeClass('medium').addClass('big'); setTimeout(function() { bigtomedium(visiblespan); },150); }; </code></pre> <p>Which is activated in jquery onclick:</p> <pre><code> $('div.click').click( function(event) { var visiblespan = $('span:visible'); mediumtosmall(visiblespan); } ); </code></pre> <p>What I need to do, is to get the click to hide invisible span as well.</p> <pre><code> $('div.click').click( function(event) { var visiblespan = $('span:visible'); var invisiblespan = $('span:not(:visible)'); mediumtosmall(visiblespan); clearTimeout(invisiblespan); } ); </code></pre> <p>What I'm not sure how to do is to write the clearTimeout function that will stop the loop. Any help is greatly appreciated. Thanks.</p>
[ { "answer_id": 425413, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 5, "selected": true, "text": " function mediumtosmall(visiblespan) {\n vt.removeClass('medium').addClass('small');\n\n // St...
2009/01/08
[ "https://Stackoverflow.com/questions/425392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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, CRITICAL_SECTION, LRESULT, etc do not have to be defined.</p> <p>I know I could split it into two classes, an abstract class with just the public interface, and an implementation class which is hidden that contains the members that require windows.h.</p> <p>The problem here is that the visible class can no longer be created itsself, and an additional create function (eg CreateMainWindow) is required. That is fine in this case since it is most likly that just a single instance created on the heap is wanted but for other classes this is not.</p> <pre><code>class MainWindow { HWND hwnd; int width, height; std::string caption; bool started,exited; bool closeRequest; unsigned loopThread; CRITICAL_SECTION inputLock; Input *input; public: static void init_type(); Py::Object getattr(const char *name); MainWindow(int width, int height, std::string caption); ~MainWindow(); bool CloseRequest(const Py::Tuple &amp;args); bool CloseRequestReset(const Py::Tuple &amp;args); HWND GetHwnd(); int GetWidth(); int GetHeight(); Input* GetInput(); protected: unsigned static __stdcall loopThreadWrap(void *arg); unsigned LoopThreadMain(); LRESULT WndProc(UINT msg, WPARAM wParam, LPARAM lParam); LRESULT static CALLBACK WndProcWrapper(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); }; </code></pre>
[ { "answer_id": 425436, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 4, "selected": true, "text": "class MainWindow\n{\nprivate:\n //opaque data\n class ImplementationDetails;\n ImplementationDetails* m_data;\npubl...
2009/01/08
[ "https://Stackoverflow.com/questions/425400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
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 growing with old-school graphics card I have this bad conscience leaning over me and telling me I shouldn't use textures that large.</p> <p>What is the preferred way nowadays? Is it to just cram that thing into video memory, tile it, or let the CPU do the work and glDrawPixels? Or something more elaborate?</p>
[ { "answer_id": 425770, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 4, "selected": true, "text": "glDrawPixels GLint width = 0;\nwhile ( 0 == width ) { /* use a better condition to prevent possible endless loop */\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/425401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46991/" ]
425,402
<p>Other than the Java language itself, you have to learn the java framework. Similiar to how you have to learn the .net framework in addition to the language (C#/VB).</p> <p>How important is it to know unix? Or rather, what unix areas should one focus on?</p> <p>Seeing as many people run java based applications (desktop/web) on unix boxes, <strong>what sort of unix skills do you need</strong>? Are we just talking basic directory traversing, creating files, etc or is there much more to it?</p>
[ { "answer_id": 425670, "author": "Dan Monego", "author_id": 32771, "author_profile": "https://Stackoverflow.com/users/32771", "pm_score": 5, "selected": true, "text": "ifconfig netstat traceroute chmod chown" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
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 enclosing it in an anonymous function, but the only way I've been able to figure out how to do it is by adding a public function to <strong>MyClass</strong> that takes the callBack function as a parameter and returns the modified version.</p> <pre><code>function MyClass () { this.modifyCallBack = function ( callBack ) { var oldCallBack = callBack; callBack = function () { oldCallBack(); // call the original functionality /* new code goes here */ } return callBack; } } /* elsewhere on the page, after the class is instantiated and the callback function defined */ myCallBackFunction = MyClassInstance.modifyCallBack( myCallBackFunction ); </code></pre> <p>Is it possible to make this work when passing the callBack function as a parameter to the class? Attempting to modify the function in this manner when passign it as a parameter seems to only affect the instance of it in within the class, but that doesn't seem like it's a valid assumption since functions are Objects in javascript, and are hence passed by reference.</p> <p><strong>Update:</strong> as crescentfresh pointed out (and I failed to explain well), I want to modify the callBack function in-place. I'd rather not call a second function if it's possible to do all of this when the class is instantiated.</p>
[ { "answer_id": 425441, "author": "FallenAvatar", "author_id": 36965, "author_profile": "https://Stackoverflow.com/users/36965", "pm_score": 0, "selected": false, "text": "function MyClass ( callBack ) {\n var myCallBack;\n\n if (typeof callBack !== 'function')\n throw \"You didn't p...
2009/01/08
[ "https://Stackoverflow.com/questions/425407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8636/" ]
425,421
<p>I am trying to do a comparison between company names using SOUNDEX, but the php call for soundex only outputs 3 digits so the comparisons aren't quite accurate. Is there a way to get a better soundex output so that the results are more accurate?</p>
[ { "answer_id": 428632, "author": "Ry Biesemeyer", "author_id": 53098, "author_profile": "https://Stackoverflow.com/users/53098", "pm_score": 1, "selected": false, "text": "$result = $db->query(\"\n SELECT\n company.id,\n company.name,\n SOUNDEX(company.name) AS so...
2009/01/08
[ "https://Stackoverflow.com/questions/425421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43980/" ]
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 it:</p> <pre><code> this.txtName.DataBindings.Add("Text", _dtRow, "Name"); </code></pre> <p>I get this exception:</p> <blockquote> <p>Cannot bind to the property or column Name on the DataSource. Parameter name: dataMember</p> </blockquote> <p>Any idea why this works on a datatable created by a dataAdapter, but not on a programmaticly created one?</p>
[ { "answer_id": 425477, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 1, "selected": false, "text": "this.txtName.DataBindings.Add(\"Text\", dt, \"Name\");\n DataTable dt = new DataTable(\"Woot\");\n\n dt.Columns....
2009/01/08
[ "https://Stackoverflow.com/questions/425424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
425,429
<p>I've a problem which is most likely some ugly CSS mistake, but I just can't spot the solution (and a few changes I tried did not help).</p> <p>Some of in-text hyperlinks (not all!) are shown by Internet Explorer without the following space.</p> <p><a href="http://blog.mekk.waw.pl/archives/28-Picking-the-games-to-watch.html" rel="nofollow noreferrer">here is the example</a></p> <p>See the link <em>WatchBot</em> just below the <em>Rationale</em> title (and a few similar links deeper in the article). Firefox, Opera, Chrome, Konqueror - all display it properly: <strong>WatchBot</strong> <em>can</em>. IE (6.0 but IIRC also 7.0) displays it as **WatchBot***can*. </p> <p>I am using Yui-reset and yui-base. Is it possible that those libraries cause the problem?</p>
[ { "answer_id": 425454, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 1, "selected": false, "text": "<p>Have you ever been curious how is \n<a href=\"http://mekk.waw.pl/mk/watchbot/index\">WatchBot</a>\npicking the games to obse...
2009/01/08
[ "https://Stackoverflow.com/questions/425429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48167/" ]
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 explanaions, I don't think I'm <em>that</em> far off, it just won't compile.</p> <pre><code>template&lt;class T&gt; class Table { public: ... vector&lt;shared_ptr&lt;vector&lt;T&gt;&gt;&gt;::iterator GetRowIterator(); //vector&lt;shared_ptr&lt;vector&lt;CellValueType&gt; &gt; &gt;::const_iterator GetRowIterator(); ... protected: vector&lt;shared_ptr&lt;vector&lt;CellValueType&gt; &gt; &gt; data; //outside vector is rows, inside vector is columns ... }; vector&lt;shared_ptr&lt;vector&lt;T&gt; &gt; &gt;::const_iterator Table&lt;T&gt;::GetRowIterator() { return data.begin(); } </code></pre> <p>The errors that I get are: </p> <pre><code>error C2146: syntax error : missing ';' before identifier 'GetRowIterator' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int </code></pre> <p><em>Edit:</em><br/> Changed the end angle brackets so they are not as close together - same error.<br/><br/> Any thoughts as to why this is occurring?<br/> As always, thanks for advice/help in advance!</p>
[ { "answer_id": 425442, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "vector<shared_ptr<vector<T>>>\n vector<shared_ptr<vector<T> > >\n" }, { "answer_id": 425456, "author": "Fa...
2009/01/08
[ "https://Stackoverflow.com/questions/425430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23553/" ]
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</code> will include all <code>null</code> elements as well. How do you go about checking for <code>null</code> elements in an array? For example in the following code will throw an NPE for me.</p> <pre><code>Object[][] someArray = new Object[5][]; for (int i=0; i&lt;=someArray.length-1; i++) { if (someArray[i]!=null) { //do something } } </code></pre>
[ { "answer_id": 425466, "author": "Richard Campbell", "author_id": 12254, "author_profile": "https://Stackoverflow.com/users/12254", "pm_score": 6, "selected": true, "text": "public class test {\n\n public static void main(String[] args) {\n Object[][] someArray = new Object[5][...
2009/01/08
[ "https://Stackoverflow.com/questions/425439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37857/" ]
425,457
<p>Let's say we have a class, MyParent:</p> <pre><code>class MyParent { public: template&lt;namespace T&gt; MyParent() { T* Something; } }; </code></pre> <p>And a derived class, which uses this constructor:</p> <pre><code>class MyDerived : public MyParent { public: MyDerived() : MyParent&lt;int&gt;() { } }; </code></pre> <p>Then I get a compiling error, because there's ambiguity. The compiler thinks that the <strong><em>int</em></strong> is a template argument to the class, not the constructor.</p> <p>How do I specify that I want the <strong><em>int</em></strong> to be an argument to the constructor?</p>
[ { "answer_id": 425466, "author": "Richard Campbell", "author_id": 12254, "author_profile": "https://Stackoverflow.com/users/12254", "pm_score": 6, "selected": true, "text": "public class test {\n\n public static void main(String[] args) {\n Object[][] someArray = new Object[5][...
2009/01/08
[ "https://Stackoverflow.com/questions/425457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51747/" ]
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": 440551, "author": "aronchick", "author_id": 4322, "author_profile": "https://Stackoverflow.com/users/4322", "pm_score": 2, "selected": true, "text": "insert into user(host,user,password) values ('localhost','local_rails_user','');\ngrant SELECT, INSERT, UPDATE, DELETE, CRE...
2009/01/08
[ "https://Stackoverflow.com/questions/425461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4322/" ]
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? </p>
[ { "answer_id": 425484, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 3, "selected": false, "text": "sp_helptext 'sp_helpindex'\n" }, { "answer_id": 425523, "author": "splattne", "author_id": 6461, "aut...
2009/01/08
[ "https://Stackoverflow.com/questions/425475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33178/" ]
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/MouseNavi.aspx" rel="nofollow noreferrer">VS add-in hack</a> just to work around the "bug".</p> <p>Any idea why this functionality fails for some users and how to fix it?</p>
[ { "answer_id": 32636798, "author": "miroxlav", "author_id": 2392157, "author_profile": "https://Stackoverflow.com/users/2392157", "pm_score": 2, "selected": false, "text": "View.NavigateBackward View.NavigateForward XButton1::^-\nXButton2::^+-\n ^ + - SetTitleMatchMode, RegEx\n#IfWinActi...
2009/01/08
[ "https://Stackoverflow.com/questions/425492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31624/" ]
425,497
<p>does jquery have any plugin that prevents entering any input to a textbox that doesnt match a regexp pattern. for example , i have a textbox for entering payment amount, i want user t be able to enter only numebers and . in the textbox, all other input wont have any effect on the textbox..</p> <p>thanks</p>
[ { "answer_id": 425515, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 3, "selected": false, "text": "jQuery(function($){ \n $(\"#paymentAmount\").mask(\"9999.99\");\n});\n" }, { "answer_id": 426043, "author": "meouw"...
2009/01/08
[ "https://Stackoverflow.com/questions/425497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53055/" ]
425,511
<p>I've never developed Flash before but I have a project where I want to use an ActionScript 3 library and I'm not sure what tools I need to start. To further complicate things my main development box is an Ubuntu box. Are there any necessary packages I need to install? Or any <code>.deb</code>'s I can buy?</p>
[ { "answer_id": 850191, "author": "Luke Bayes", "author_id": 105023, "author_profile": "https://Stackoverflow.com/users/105023", "pm_score": 2, "selected": false, "text": "rake debug rake test rake deploy rake swc rake doc" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
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 going to need to use asp: controls on. I assume the best way for me to bypass a few particular requests would be to inherit System.Web.UI.PageHandlerFactory and just call the MyBase implementation when I need to (please correct me if I am wrong here). But how do I transfer all other requests to my custom handler?</p>
[ { "answer_id": 425553, "author": "DavGarcia", "author_id": 40161, "author_profile": "https://Stackoverflow.com/users/40161", "pm_score": 3, "selected": true, "text": "using System;\nusing System.Data;\nusing System.Collections.Generic;\nusing System.Configuration;\nusing System.Reflectio...
2009/01/08
[ "https://Stackoverflow.com/questions/425512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54420/" ]
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"=&gt;"Create", "authenticity_token"=&gt;"0000000000000000000000000" "page"=&gt;{ "body"=&gt;"TEST", "link_attributes"=&gt;[ {"action"=&gt;"Foo"}, {"action"=&gt;"Bar"}, {"action"=&gt;"Test"}, {"action"=&gt;"Blah"} ] } } </code></pre> <p><strong>What I want</strong></p> <pre><code>{"commit"=&gt;"Create", "authenticity_token"=&gt;"0000000000000000000000000" "page"=&gt;{ "body"=&gt;"TEST", "link_attributes"=&gt;[ {"action"=&gt;"Foo", "source_id"=&gt;1}, {"action"=&gt;"Bar", "source_id"=&gt;1}, {"action"=&gt;"Test", "source_id"=&gt;1}, {"action"=&gt;"Blah", "source_id"=&gt;1}, ] } } </code></pre> <p>Is this feasible? Basically, I'm trying to submit two types of data at once ("page" and "link"), and assign the "source_id" of the "links" to the "id" of the "page."</p>
[ { "answer_id": 425771, "author": "Kevin Davis", "author_id": 49993, "author_profile": "https://Stackoverflow.com/users/49993", "pm_score": 5, "selected": true, "text": "FooController < ApplicationController\n\n def update\n params[:page] ||= {}\n params[:page][:link_attributes] ||...
2009/01/08
[ "https://Stackoverflow.com/questions/425521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34795/" ]
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="nofollow noreferrer">alt text http://img370.imageshack.us/img370/2548/ss20090108212745qz2.png</a></p> <p>How do I prevent this behaviour, please?</p> <p>Thank you very much for helping.</p>
[ { "answer_id": 425771, "author": "Kevin Davis", "author_id": 49993, "author_profile": "https://Stackoverflow.com/users/49993", "pm_score": 5, "selected": true, "text": "FooController < ApplicationController\n\n def update\n params[:page] ||= {}\n params[:page][:link_attributes] ||...
2009/01/08
[ "https://Stackoverflow.com/questions/425531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50173/" ]
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": "Grid.SetRow(MyControl, myRowNumber); \n" }, { "answer_id": 426263, "author": "Michael S. Scherotter", ...
2009/01/08
[ "https://Stackoverflow.com/questions/425537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
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> &lt;Columns&gt; &lt;asp:CheckBoxField DataField="Locked" Visible="true" AccessibleHeaderText="On Hold" ReadOnly="false"/&gt; &lt;/Columns&gt; </code></pre> <p>Couple of questions here: 1. If I do the above said, my page loads and certain rows have their records marked as checked and certain rows do not, as per data. However, the user is unable to click on any records to undo their check marks. It appears that this is in a disabled state.</p> <ol start="2"> <li><p>It seems there is no onclick event with this checkboxfield. I want to update my records instantly when the user checks or unchecks each record. yes bad design here but my hands are tied</p></li> <li><p>If i were to go with <code>&lt;asp:checkbox&gt;</code> within an <code>&lt;itemtemplate&gt;</code> how do i bind that to my locked column within the object datasource or do i have to do that by overiding onne of the methods of the gridview control?</p></li> </ol>
[ { "answer_id": 425599, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 0, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing System.Data.Linq;\nusi...
2009/01/08
[ "https://Stackoverflow.com/questions/425548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38230/" ]
425,559
<p>When I type the trigger the auto comment feature in Visual Studio (by typing "'''" or "///"), most of the XML commenting details show up that I like. However, I typically add the history tag to the documentation so I can track and changes that are made to the method over time.</p> <p>Is there any way I can customize the auto commenting feature so that it will add the history tag, and potentially some generic Name - Date - Change placeholder text?</p>
[ { "answer_id": 426326, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 1, "selected": false, "text": " ''// InsertDocComments goes through the current document using the VS Code Model\n ''// to add documentation style comme...
2009/01/08
[ "https://Stackoverflow.com/questions/425559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
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.createTemplate( pageImageableWidth, pageImageableHeight ); Graphics2D g2d = tp.createGraphics( pageImageableWidth, pageImageableHeight, new DefaultFontMapper( ) ); g2d.translate( pf.getImageableX( ), pf.getImageableY( ) ); g2d.scale( 0.4d, 0.4d ); com.paint( g2d ); cb.addTemplate( tp, 25, 200 ); g2d.dispose( ); </code></pre> <p>Unfortunately nothing is shown in the PDF file. Do you know how to solve this problem?</p>
[ { "answer_id": 425658, "author": "Michael Myers", "author_id": 13531, "author_profile": "https://Stackoverflow.com/users/13531", "pm_score": 1, "selected": false, "text": "PdfWriter" }, { "answer_id": 768762, "author": "Sam Barnum", "author_id": 14467, "author_profile...
2009/01/08
[ "https://Stackoverflow.com/questions/425590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49964/" ]
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>Example usage (Sequence in Sequence):</p> <pre><code>&gt;&gt;&gt; seq_in_seq([5,6], [4,'a',3,5,6]) 3 &gt;&gt;&gt; seq_in_seq([5,7], [4,'a',3,5,6]) -1 # or None, or whatever </code></pre> <p>So far, I just rely on brute force and it seems slow, ugly, and clumsy.</p>
[ { "answer_id": 425764, "author": "mcella", "author_id": 53081, "author_profile": "https://Stackoverflow.com/users/53081", "pm_score": 2, "selected": false, "text": ">>> def seq_in_seq(subseq, seq):\n... while subseq[0] in seq:\n... index = seq.index(subseq[0])\n... if...
2009/01/08
[ "https://Stackoverflow.com/questions/425604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15842/" ]
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 { mixin(ImagesMixin) // ... } </code></pre> <p>It compiles fine, but for some reason it won't work. The file containing ImagesMixin is located in my <code>/src/groovy/</code> directory.</p> <p>I've tried it using Groovy versions 1.5.7 and 1.6-RC1 without any luck. Does anyone know what I'm doing wrong?</p> <p>stacktrace:</p> <pre><code>2008-12-30 17:58:25.258::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@562791{/FinalTransmission,/home/kuccello/Development/workspaces/lifeforce/FinalTransmission/web-app} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError at java.security.AccessController.doPrivileged(Native Method) at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:67) at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy) at Init_groovy$_run_closure6.doCall(Init_groovy:131) at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:66) at RunApp_groovy$_run_closure2.doCall(RunApp_groovy) at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:57) at RunApp_groovy$_run_closure1.doCall(RunApp_groovy) at gant.Gant.dispatch(Gant.groovy:271) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:436) at gant.Gant.processArgs(Gant.groovy:372) Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at Episode.class$(Episode.groovy) at Episode.&lt;clinit&gt;(Episode.groovy) ... 13 more Caused by: groovy.lang.MissingMethodException: No signature of method: static Person.mixin() is applicable for argument types: (java.lang.Class) values: {class ImagesMixin} at Broadcast.&lt;clinit&gt;(MyClass.groovy:17) ... 17 more 2008-12-30 17:58:25.259::WARN: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError: groovy.lang.MissingMethodException: No signature of method: Person.mixin() is applicable for argument types: (java.lang.Class) values: {class ImagesMixin} at Broadcast.&lt;clinit&gt;(Person.groovy:17) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at Episode.class$(BelongsToMyClass.groovy) at Episode.&lt;clinit&gt;(BelongsToMyClass.groovy) at java.security.AccessController.doPrivileged(Native Method) at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:67) at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy) at Init_groovy$_run_closure6.doCall(Init_groovy:131) at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:66) at RunApp_groovy$_run_closure2.doCall(RunApp_groovy) at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:57) at RunApp_groovy$_run_closure1.doCall(RunApp_groovy) at gant.Gant.dispatch(Gant.groovy:271) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:436) at gant.Gant.processArgs(Gant.groovy:372) 2008-12-30 17:58:25.271::INFO: Started SelectChannelConnector@0.0.0.0:8080 </code></pre>
[ { "answer_id": 469470, "author": "Matthew Taylor", "author_id": 154560, "author_profile": "https://Stackoverflow.com/users/154560", "pm_score": 4, "selected": false, "text": "class MyMixin {\n static doStuff(Person) {\n 'stuff was done'\n }\n}\n\nclass Person {}\n\nPerson.mi...
2009/01/08
[ "https://Stackoverflow.com/questions/425617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5447/" ]
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 generate parts of the function dynamically using groovy code. Unfortunately, ${some groovy code} does not appear to be processed within separate javascript source files.</p> <p>Is the only way to do this by defining the javascript function within a script tag on a GSP page, or is there a more general solution? Obviously we could define the javascript function in a script tag within a template GSP file which would be reused, but there is a lot of push to keep our javascript functions defined all together in one place (i.e. the external javascript source file). This has performance benefits as well (the javascript source files are usually just downloaded once by each client's browser, instead of reloading the same javascript functions within the source of every html page they visit). I have toyed around with the idea of breaking the function up into static and dynamic pieces, putting the static ones in the external source and putting the dynamic ones in the template GSP, then gluing them together, but this seems like an unnecessary hack.</p> <p>Any ideas?</p> <p>(edit: It may sound like the idea of dynamically generating parts of a JavaScript function, which is then downloaded once and used over and over again by the client, would be a bad idea. However, the piece which is "dynamic" only changes perhaps once a week or month, and then only very slightly. Mostly we just want this piece generated off the database, even if only once, instead of hard coded.)</p>
[ { "answer_id": 425674, "author": "gabriel", "author_id": 5447, "author_profile": "https://Stackoverflow.com/users/5447", "pm_score": 5, "selected": true, "text": "UrlMappings.groovy \"/js/$action\"{\n controller = \"javascript\"\n}\n <%@ page contentType=\"text/javascript; UTF-8\" %>" ...
2009/01/08
[ "https://Stackoverflow.com/questions/425618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33752/" ]
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.Generic; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MyNameSpace { public partial class MyFormName : Form { ... </code></pre> <p>(...and the second is "MyFormName2" but no differences besides that)</p> <p>I want to write a function that I know both forms are going to need to access. I right-clicked on my project, selected "Add", selected "New Item" then selected "Code File" and named my file "Common.cs" and it gave me a completely blank file that's in my project.</p> <p>How do I set this up...? I thought I should do the following...</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MyNameSpace { } </code></pre> <p>...but then when I try to add a function like:</p> <p>public void mytestfunc() { } within that namespace I get the following error: </p> <p>"Expected class, delegate, enum, interface, or struct"</p> <p>How do I set things up so I can have "mytestfunc" be available to both MyFormName and MyFormName2?</p> <p>Thanks!</p> <p>-Adeena</p> <p>UPDATE: Understand (now) that everything must be in a class, but then I don't understand how to really use it. Does that mean I have to create an object? This common function happens to just be some math... </p> <p>so now if I have this:</p> <pre><code>namespace MyNameSpace { public class MyCommonClass { public void testFunc() { MessageBox.Show("Hee hee!"); return; } } } </code></pre> <p>...how do I call testFunc from my Form? Must I do the following:</p> <pre><code>MyCommonClass temp = new MyCommonClass; temp.testFunc(); </code></pre> <p>or is there another way to call testFunc?</p>
[ { "answer_id": 425653, "author": "Maxime Rouiller", "author_id": 24975, "author_profile": "https://Stackoverflow.com/users/24975", "pm_score": 0, "selected": false, "text": "using System;\n\nnamespace MyNameSpace\n{\n public class CommonHelper\n {\n public string FormatMyData(o...
2009/01/08
[ "https://Stackoverflow.com/questions/425634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
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 per-type basis.</p> <pre><code>public interface IParentInterface { } public interface IChildInterface : IParentInterface { } public class ParentClass&lt;T&gt; where T: IParentInterface { } public class ChildClass : ParentClass&lt;IChildInterface&gt; { } public class TestClass { public ChildClass Property { get; set; } } [TestFixture] public class ScratchPad { [Test] public void Assignabl() { var tc = new TestClass(); var tct = tc.GetType(); var pi = tct.GetProperty("Property"); Assert.IsNotNull(pi); Assert.IsTrue(typeof(ParentClass&lt;IChildInterface&gt;).IsAssignableFrom(pi.PropertyType)); Assert.IsTrue(typeof(ParentClass&lt;&gt;).IsAssignableFrom(pi.PropertyType)); Assert.IsTrue(typeof(ParentClass&lt;IParentInterface&gt;).IsAssignableFrom(pi.PropertyType)); } } </code></pre>
[ { "answer_id": 425704, "author": "flq", "author_id": 51428, "author_profile": "https://Stackoverflow.com/users/51428", "pm_score": 2, "selected": false, "text": "public class ParentClass<ParentInterface>\n public class ChildClass : ParentClass<ChildInterface>\n public class ParentClass<T...
2009/01/08
[ "https://Stackoverflow.com/questions/425655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 preview / detail window (I intend to load data for the selected row into the bottom panel via jQuery).</p> <p>In the old world (table layouts), I might have something like:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;table height="100%" border="1" width="100%"&gt; &lt;tr height="*"&gt;&lt;td&gt;master&lt;/td&gt;&lt;/tr&gt; &lt;tr height="100"&gt;&lt;td&gt;detail&lt;/td&gt;&lt;/tr&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So how does this translate to CSS? (and in particular, getting the scrollbars on the two windows).</p>
[ { "answer_id": 425682, "author": "Michael T. Smith", "author_id": 22292, "author_profile": "https://Stackoverflow.com/users/22292", "pm_score": 4, "selected": true, "text": "#window-one, #window-two {\n width: 100%;\n height: 50%;\n overflow: scroll;\n} <html>\n <body>\n <di...
2009/01/08
[ "https://Stackoverflow.com/questions/425661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23354/" ]
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); prm.Add(p2); prm.Add(p3); prm.Add(p4); prm.Add(p5); sqlcommand cmd = getCommand(prm); </code></pre>
[ { "answer_id": 425678, "author": "Damien", "author_id": 35454, "author_profile": "https://Stackoverflow.com/users/35454", "pm_score": 3, "selected": false, "text": "SqlCommand SqlCommand query = new SqlCommand(sqlString, Connection);\nquery.Parameters.AddWithValue(parameter,valueToPass);...
2009/01/08
[ "https://Stackoverflow.com/questions/425668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51151/" ]
425,680
<p>Is there a pattern where in WPF, I can build a simple UI form from an XML like definition file pulled from a database? </p> <p>It would allow the user to enter data into this form, and submit it back. The data would be sent back in an XML structure that would closely/exactly mimic the UI definition. </p> <p>The definition should include the data-type, and if it was a required value or not. I would then like to map these data-types and required values to Data Validation Rules, so the form could not be submitted unless it passes the check. </p> <p>It should also handle the ability to have lists of repeating data.</p> <p>I am in the planning stages of this project and have fairly good flexibility in the design at this point, though I am pretty sure I need to stick to the desktop, not web since I may be doing some Office Inter-op stuff as well.</p> <p>What technology stack would you recommend? I think XMAL and WPF may be close to the answer. </p> <p>I have also looked at <a href="http://www.mozilla.org/projects/xul" rel="nofollow noreferrer">XUL</a>, but it doesn't seem ready or useful for C#. (Found this <a href="http://msdn.microsoft.com/en-us/magazine/cc188912.aspx" rel="nofollow noreferrer">article</a> from MSDN in 2002)</p> <p>Thank you,<br> Keith</p>
[ { "answer_id": 425697, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 0, "selected": false, "text": "XmlReader tXml = XmlReader.Create(myXamlString);\nUIElement MyElement = (UIElement)XamlReader.Load(tXml);\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
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 couldn't find a way to set permission for NetworkService to access the private key. </p> <p>Can anyone shed some light? Thanks in advance.</p>
[ { "answer_id": 426171, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 4, "selected": false, "text": "winhttpcertcfg -g -c LOCAL_MACHINE\\My -s test -a NetworkService\n FindPrivateKey My LocalMachine -n \"CN=test\...
2009/01/08
[ "https://Stackoverflow.com/questions/425688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11413/" ]
425,692
<p>I'm beginning a new project in PHP and I'd love to get some feedback from other developers on their preferred strategy for PHP deployment. I'd love to automate things a bit so that once changes are committed they can be quickly migrated to a development or production server.</p> <p>I have experience with deployments using Capistrano with Ruby as well as some basic shell scripting.</p> <p>Before I dive head first on my own it would be great to hear how others have approached this in their projects.</p> <h2>Further information</h2> <p>Currently developers work on local installations of the site and commit changes to a subversion repository. Initial deployments are made by exporting a tagged release from svn and uploading that to the server.</p> <p>Additional changes are typically made piecemeal by manually uploading changed files.</p>
[ { "answer_id": 426793, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "git push --mirror" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238/" ]
425,709
<p>Lots of developers think that testing private methods is a bad idea. However, all examples I've found were based on the idea that private methods are private because calling them could break internal object's state. But that's not only reason to hide methods.</p> <p>Let's consider Facade pattern. My class users need the 2 public methods. They would be too large. In my example, they need to load some complex structure from the database's BLOB, parse it, fill some temporary COM objects, run user's macro to validate and modify these objects, and serialize modified objects to XML. Quite large functionality for the single metod :-) Most of these actions are required for both public methods. So, I've created about 10 private methods, and 2 public methods do call them. Actually, my private methods should not necessarily be private; they'll not break the internal state of instance. But, when I don't wont to test private methods, I have the following problems:</p> <ol> <li>Publishing them means complexity for users (they have a choice they don't need) </li> <li>I cannot imagine TDD style for such a large public methods, when you're to write 500+ lines of code just to return something (even not real result). </li> <li>Data for these methods is retrieved from database, and testing DB-related functionality is much more difficult.</li> </ol> <p>When I'm testing private methods:</p> <ol> <li>I don't publish details that would confuse users. Public interface includes 2 methods.</li> <li>I can work in TDD style (write small methods step-by-step). </li> <li>I can cover most of class's functionality using test data, without database connection.</li> </ol> <p>Could somebody describe, what am I doing wrong? What design should I use to obtain the same bonuses and do not test private methods?</p> <p>UPDATE: It seems to me I've extracted everything I was able to another classes. So, I cannot imagine what could I extract additionally. Loading from database is performed by ORM layer, parsing stream, serializing to XML, running macro - everything is done by standalone classes. This class contains quite complex data structure, routines to search and conversion, and calls for all mentioned utilities. So, I don't think something else could be extracted; otherwise, its responsibility (knowledge about the data structure) would be divided between classes.</p> <p>So, the best method to solve I see now is dividing into 2 objects (Facade itself and real object, with private methods become public) and move real object to somewhere nobody would try to find it. In my case (Delphi) it would be a standalone unit, in other languages it could be a separate name space. Other similar option is 2 interfaces, thanks for idea.</p>
[ { "answer_id": 426172, "author": "Domchi", "author_id": 29192, "author_profile": "https://Stackoverflow.com/users/29192", "pm_score": 2, "selected": false, "text": "import java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport junit.framework.Assert;\n\npu...
2009/01/08
[ "https://Stackoverflow.com/questions/425709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11391/" ]
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, their "persons" table record is all the information we need to store about them. Many others though have to be able to assume different roles for a variety of systems. Of these, most start out as students. Some start as employees. People who are students can become interns or performers; employees can become students; all teachers are employees and performers, etc.</p> <p>In essence, their are a variety of different "hats" that any individual person may have to wear in order to access and interact with different parts of the system, as well as have information about them made available on public pages on our site.</p> <p>My choice for implementing this model is to have several other tables which represent these "hats" - tables which contain meta-information to supplement the basic "person" info, all of which use the "persons" id as their primary key. For example, a person who is a teacher has a record in a teachers table containing his or her short biographical information and pay rate. All teachers are also employees (but not all employees are teachers), meaning they have a record in the employees table which allows them to submit their hours into our payroll system.</p> <p>My question is, what are the drawbacks to implementing the model as such? The only other option I can think of is to inflate the persons table with fields that will be empty and useless for most entries and then have a cumbersome table of "groups" to which persons can belong, and then to have almost every table for every system have a person <code>person_id</code> foreign key and then depend on business logic to verify that the person_id referenced belongs to the appropriate group; But that's stupid, isn't it?</p> <p>A few example table declarations follow below, which hopefully should demonstrate how I'm currently putting all this together, and hopefully show why I think it is a more sensible way to model the reality of the various situations the systems have to deal with.</p> <p>Any and all suggestions and comments are welcome. I appreciate your time.</p> <p><strong>EDIT</strong> A few respondents have mentioned using ACLs for security - I did not mention in my original question that I am in fact using a separate ACL package for fine-grained access control for actual users of the different systems. My question is more about the best practices for storing metadata about people in the database schema. </p> <pre><code>CREATE TABLE persons ( `id` int(11) NOT NULL auto_increment, `firstName` varchar(50) NOT NULL, `middleName` varchar(50) NOT NULL default '', `lastName` varchar(75) NOT NULL, `email` varchar(100) NOT NULL default '', `address` varchar(255) NOT NULL default '', `address2` varchar(255) NOT NULL default '', `city` varchar(75) NOT NULL default '', `state` varchar(75) NOT NULL default '', `zip` varchar(10) NOT NULL default '', `country` varchar(75) NOT NULL default '', `phone` varchar(30) NOT NULL default '', `phone2` varchar(30) NOT NULL default '', `notes` text NOT NULL default '', `birthdate` date NOT NULL default '0000-00-00', `created` datetime NOT NULL default '0000-00-00 00:00', `updated` timestamp NOT NULL, PRIMARY KEY (`id`), KEY `lastName` (`lastName`), KEY `email` (`email`) ) ENGINE=InnoDB; CREATE TABLE teachers ( `person_id` int(11) NOT NULL, `bio` text NOT NULL default '', `image` varchar(150) NOT NULL default '', `payRate` float(5,2) NOT NULL, `active` boolean NOT NULL default 0, PRIMARY KEY (`person_id`), FOREIGN KEY(`person_id`) REFERENCES `persons` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB; CREATE TABLE classes ( `id` int(11) NOT NULL auto_increment, `teacher_id` int(11) default NULL, `classstatus_id` int(11) NOT NULL default 0, `description` text NOT NULL default '', `capacity` tinyint NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY(`classstatus_id`) REFERENCES `classstatuses` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, KEY (`teacher_id`,`level_id`), KEY (`teacher_id`,`classstatus_id`) ) ENGINE=InnoDB; CREATE TABLE students ( `person_id` int(11) NOT NULL, `image` varchar(150) NOT NULL default '', `note` varchar(255) NOT NULL default '', PRIMARY KEY (`person_id`), FOREIGN KEY(`person_id`) REFERENCES `persons` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB; CREATE TABLE enrollment ( `id` int(11) NOT NULL auto_increment, `class_id` int(11) NOT NULL, `student_id` int(11) NOT NULL, `enrollmenttype_id` int(11) NOT NULL, `created` datetime NOT NULL default '0000-00-00 00:00', `modified` timestamp NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY(`student_id`) REFERENCES `students` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY(`enrollmenttype_id`) REFERENCES `enrollmenttypes` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB; </code></pre>
[ { "answer_id": 426094, "author": "Glazius", "author_id": 34384, "author_profile": "https://Stackoverflow.com/users/34384", "pm_score": 1, "selected": false, "text": "SELECT firstName, lastName \nFROM persons \nINNER JOIN teachers ON persons.id = teachers.person_id \n INNER JOIN original_...
2009/01/08
[ "https://Stackoverflow.com/questions/425711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53075/" ]
425,717
<p>I have a local server which needs to make changes to a virtual hosts apache config file and then restart apache so the new config takes effect.</p> <p>Can PHP do this? I tried passthru and exec but they didn't work. Maybe the problem is that I'm trying to restart PHP's parent process?</p> <p>Thanks for any help!!</p>
[ { "answer_id": 425962, "author": "mark", "author_id": 47573, "author_profile": "https://Stackoverflow.com/users/47573", "pm_score": 4, "selected": false, "text": "ssh -i /path/to/key-file wwwctrl@localhost sudo /etc/init.d/apache2 reload\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 working with MySQL, DB2, SQL Server at the moment, but the solution needs to be database agnostic (for XML in SQL Server isn't a viable option).</p>
[ { "answer_id": 425875, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 2, "selected": true, "text": "<ResultSet>\n <MetaData>\n <Column name=\"....\" type=\"...\"/>\n ....\n <MetaData>\n <Data>\n <Row>...
2009/01/08
[ "https://Stackoverflow.com/questions/425745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36924/" ]
425,759
<p>A lot of the collection classes in .Net (i.e., List&lt;T&gt;, Dictionary&lt;TKey, TValue&gt;) have an overloaded constructor that lets you specify an initial capacity size. Is it a best practice to use this constructor? If so, is there a rule of them as to some kind of "Magic Number" you should use? It's one thing If I know the exact size ahead of time, but what if I don't? </p>
[ { "answer_id": 425777, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": true, "text": "List Add Add" }, { "answer_id": 425779, "author": "Tamas Czinege", "author_id": 8954, "author_prof...
2009/01/08
[ "https://Stackoverflow.com/questions/425759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
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": "using System.ComponentModel;\nusing System.Windows;\nusing System.Windows.Controls;\n\npublic class MyUserContro...
2009/01/08
[ "https://Stackoverflow.com/questions/425760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32772/" ]
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": "XmlReader tXml = XmlReader.Create(myXamlString);\nUIElement MyElement = (UIElement)XamlReader.Load(tXml);\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
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 best do I handle this? In ASP.NET, I would have simply created a LinkButton and written a handler, but Rails doesn't work that way, so I'm trying to figure out how to essentially replicate what a LinkButton would do. </p> <p>Right now, I'm coding two forms on the same view, nearly identical, that look like this:</p> <pre><code>&lt;%= form_for @thing do |f| %&gt; &lt;%= hidden_field_tag 'thing[is_accepted]', '1' %&gt; &lt;%= f.submit "Accept" %&gt; &lt;% end %&gt; &lt;%= form_for @thing do |f| %&gt; &lt;%= hidden_field_tag 'thing[is_accepted]', '0' %&gt; &lt;%= f.submit "Reject" %&gt; &lt;% end %&gt; </code></pre> <p>This feels weird to me, but I can't seem to find anything that says this is the wrong way to do it.</p> <p>I could, I assume, dry things up by using a partial and/or a helper method, but I wanted to make sure I'm on the right track and not doing something totally wrongly.</p>
[ { "answer_id": 425966, "author": "Bill", "author_id": 36285, "author_profile": "https://Stackoverflow.com/users/36285", "pm_score": 2, "selected": false, "text": "<%= form_for @thing do |f| %>\n <%= hidden_field_tag 'thing[is_accepted]' %>\n <%= f.submit \"Accept\", :name => 'accept' %...
2009/01/08
[ "https://Stackoverflow.com/questions/425805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/722/" ]
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 right now and we are using the standard JDBC/ODBC/ADO driver bridge to connect to SQL Server.</p> <p>Should we consider using connection pooling to eliminate the problem?</p> <p>Also, should we change our driver to something like jTDS?</p>
[ { "answer_id": 425966, "author": "Bill", "author_id": 36285, "author_profile": "https://Stackoverflow.com/users/36285", "pm_score": 2, "selected": false, "text": "<%= form_for @thing do |f| %>\n <%= hidden_field_tag 'thing[is_accepted]' %>\n <%= f.submit \"Accept\", :name => 'accept' %...
2009/01/08
[ "https://Stackoverflow.com/questions/425809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407003/" ]
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>&lt;ListBox IsSynchronizedWithCurrentItem="True" Height="Auto" Width="Auto" DockPanel.Dock="Top" ItemContainerStyle="{StaticResource lbcStyle}" /&gt; &lt;Style TargetType="ListBoxItem" x:Key="lbcStyle"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter Property="ContentTemplate" Value="{StaticResource editable}"/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;Setter Property="ContentTemplate" Value="{StaticResource nonEditable}"/&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt; '//i have tried stretch here also &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt; &lt;/Style&gt; </code></pre> <p>CheckBoxes get this style:</p> <pre><code>&lt;Style x:Key="editorCheckBox" TargetType="{x:Type CheckBox}"&gt; &lt;Setter Property="MinWidth" Value="67" /&gt; &lt;Setter Property="Height" Value="25" /&gt; &lt;Setter Property="Margin" Value="5,0,5,0" /&gt; &lt;Setter Property="VerticalAlignment" Value="Center" /&gt; &lt;Setter Property="HorizontalAlignment" Value="Center" /&gt; &lt;/Style&gt; </code></pre> <p>Here are editable / non-editable:</p> <pre><code>&lt;DataTemplate x:Key="editable"&gt; &lt;Border x:Name="brdEditable" Width="Auto" HorizontalAlignment="Stretch"&gt; &lt;DockPanel x:Name="dpdEditable" LastChildFill="True" Width="Auto" Height="Auto"&gt; &lt;Grid x:Name="grdEditable" Width="Auto" Height="Auto"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="25" /&gt; &lt;ColumnDefinition Width="25" /&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="80" /&gt; &lt;ColumnDefinition Width="110" /&gt; &lt;ColumnDefinition Width="110" /&gt; &lt;ColumnDefinition Width="60" /&gt; &lt;ColumnDefinition Width="90" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;/Grid.RowDefinitions&gt; '... &lt;CheckBox x:Name="chkActive" Grid.Column="7" Height="25" Style="{StaticResource editorCheckBox}" ToolTip="Is Construction Active?" IsEnabled="true" Validation.ErrorTemplate="{StaticResource validationTemplate}"&gt; &lt;CheckBox.IsChecked&gt; &lt;Binding Path="Active"&gt; &lt;Binding.ValidationRules&gt; &lt;DataErrorValidationRule&gt;&lt;/DataErrorValidationRule&gt; &lt;ExceptionValidationRule&gt;&lt;/ExceptionValidationRule&gt; &lt;/Binding.ValidationRules&gt; &lt;/Binding&gt; &lt;/CheckBox.IsChecked&gt; &lt;/CheckBox&gt; '... &lt;ContentControl Name="ExpanderContent" Visibility="Collapsed" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="14"&gt;&lt;/ContentControl&gt; &lt;/Grid&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;DataTemplate x:Key="nonEditable"&gt; &lt;Border x:Name="brdNonEditable" Width="Auto" HorizontalAlignment="Stretch"&gt; &lt;DockPanel Width="Auto" Height="25"&gt; &lt;Grid Width="Auto" Height="25"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="25" /&gt; &lt;ColumnDefinition Width="25" /&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="80" /&gt; &lt;ColumnDefinition Width="110" /&gt; &lt;ColumnDefinition Width="110" /&gt; &lt;ColumnDefinition Width="60" /&gt; &lt;ColumnDefinition Width="90" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;CheckBox x:Name="chkActive" Grid.Column="7" Height="25" Style="{StaticResource editorCheckBox}" ToolTip="Is Construction Active?" IsEnabled="false" Validation.ErrorTemplate="{StaticResource validationTemplate}"&gt; &lt;CheckBox.IsChecked&gt; &lt;Binding Path="Active"&gt; &lt;Binding.ValidationRules&gt; &lt;DataErrorValidationRule&gt;&lt;/DataErrorValidationRule&gt; &lt;ExceptionValidationRule&gt;&lt;/ExceptionValidationRule&gt; &lt;/Binding.ValidationRules&gt; &lt;/Binding&gt; &lt;/CheckBox.IsChecked&gt; &lt;/CheckBox&gt; &lt;Label Content="calCompDate" Style="{StaticResource editorLabelList}" Grid.Column="8" ToolTip="{Binding Path= CompDate}" /&gt; &lt;/Grid&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; </code></pre> <p>And thanks so much to everyone who has tried to help me solve this!</p>
[ { "answer_id": 3573791, "author": "Alex Paven", "author_id": 430661, "author_profile": "https://Stackoverflow.com/users/430661", "pm_score": 2, "selected": false, "text": "ScrollViewer.HorizontalScrollBarVisibility \"Disabled\"" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33102/" ]
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>12345678901234</p> </blockquote> <p>in the database. In various parts of my application, however, I would like to convert this normalized phone number back to</p> <blockquote> <p>(123) 456-7890 x1234</p> </blockquote> <p>What's the best way to do such a thing? (Don't worry about accounting for international phone number formats, by the way.)</p>
[ { "answer_id": 425850, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 2, "selected": false, "text": "(\\d{3})(\\d{3})(\\d{4})(\\d{4})\n (\\1) \\2-\\3 x\\4\n" }, { "answer_id": 425869, "author": "casperOne", "aut...
2009/01/08
[ "https://Stackoverflow.com/questions/425814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31516/" ]
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... } }); </code></pre> <p>The error function returns</p> <pre><code>Undefined parsererror OK </code></pre> <p>No request is made to the server so I don't think its a problem with the JSON.</p> <p><strong>Fixed, See #1351389</strong></p>
[ { "answer_id": 426012, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 3, "selected": false, "text": "o = { a:1, b:2, c:3, };\n o = { a:1, b:2, c:3 };\n" }, { "answer_id": 426246, "author": "Luca Matteis", "au...
2009/01/08
[ "https://Stackoverflow.com/questions/425854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428/" ]
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] </code></pre> <p>Thank you</p> <p><strong>EDIT:</strong> I would like to clarify the question. I should delete all the symbols between marker1 and marker2. Marker1 and marker2 are just some words or parts of text but not obligatory lines. For example I would have:</p> <pre><code>[aaa bbb] [ccc] 1 2 3 4 5 [www yyy] </code></pre> <p>If I want to delete the text between [aaa bbb] and [www yyy] I should have as output:</p> <pre><code>[aaa bbb] [www yyy] </code></pre>
[ { "answer_id": 425934, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "Dim pat, patparts, rxp, inp\npat = WScript.Arguments(0)\npatparts = Split(pat,\"/\")\nSet rxp = new RegExp\nrxp.Global = True\n...
2009/01/08
[ "https://Stackoverflow.com/questions/425864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46503/" ]
425,867
<p>I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically have is a flow layout panel that has 3 sections.</p> <p>Section #1 is a set of 2 controls .. two dropdown controls, they are always in the same order, always visible in all instances</p> <p>Section #2 is a set of 5 different controls ... based on a series of factors, 1 of the 5 controls is made visible, all others have the Visible propert set to false</p> <p>Section #3 is a set of 3 controls .. like Section #1 they are always in the same order and always visible.</p> <p>So what this boils down to is that Section #2 is variable, the others are static.</p> <p>The problem comes with Section #2 ... when I change the visibility of any of the controls they appear just fine (I.E. ... Section 1 then Section 2 then Section 3) ... EXCEPT when I set the combobox control to be Visible .... in that case, and ONLY in that case .. the order becomes (Section 1 then Section 3 then Section 2) ... I can't figure out what would cause the ordering to be out of sync in just that case.</p> <p>What I basically do at the beginning of my method is set ALL controls to Visible = false ... then I set Section 1 Visible = true ... then loop through the conditions of Section 2 and set the appropriate controls Visible = true and finally set Section 3 controls Visible = true.</p> <p>Does anyone have any experience with the flow layout panel control ordering? I can't figure out what is happening for the ComboBox.</p>
[ { "answer_id": 1207363, "author": "Gary Kindel", "author_id": 44597, "author_profile": "https://Stackoverflow.com/users/44597", "pm_score": 5, "selected": false, "text": "FlowLayoutPanel.Controls SetChildIndex(Control c, int index) flowLayoutPanel1 public partial class TestForm: Form\n{\...
2009/01/08
[ "https://Stackoverflow.com/questions/425867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 about the date format. </p> <p>When I run SQL Profiler to watch the calls, I then copy paste the <code>exec</code> call to see what's going on. These are my observations and notes about what I've attempted:</p> <p>1) If I pass the <code>DateTime</code> in directly as a <code>DateTime</code> or converted to <code>SqlDateTime</code>, the field is surrounding by a PAIR of single quotes, such as</p> <pre><code>@Date_Of_Birth=N''1/8/2009 8:06:17 PM'' </code></pre> <p>2) If I pass the <code>DateTime</code> in as a string, I only get the single quotes</p> <p>3) Using <code>SqlDateTime.ToSqlString()</code> does not result in a UTC formatted datetime string (even after converting to universal time)</p> <p>4) Using <code>DateTime.ToString()</code> does not result in a UTC formatted datetime string.</p> <p>5) Manually setting the <code>DbType</code> for the <code>SqlParameter</code> to <code>DateTime</code> does not change the above observations.</p> <p>So, my questions then, is how on earth do I get C# to pass the properly formatted time in the <code>SqlParameter</code>? Surely this is a common use case, why is it so difficult to get working? I can't seem to convert <code>DateTime</code> to a string that is SQL compatable (e.g. '2009-01-08T08:22:45')</p> <p><strong>EDIT</strong></p> <p>RE: BFree, the code to actually execute the sproc is as follows:</p> <pre><code>using (SqlCommand sprocCommand = new SqlCommand(sprocName)) { sprocCommand.Connection = transaction.Connection; sprocCommand.Transaction = transaction; sprocCommand.CommandType = System.Data.CommandType.StoredProcedure; sprocCommand.Parameters.AddRange(parameters.ToArray()); sprocCommand.ExecuteNonQuery(); } </code></pre> <p>To go into more detail about what I have tried:</p> <pre><code>parameters.Add(new SqlParameter("@Date_Of_Birth", DOB)); parameters.Add(new SqlParameter("@Date_Of_Birth", DOB.ToUniversalTime())); parameters.Add(new SqlParameter("@Date_Of_Birth", DOB.ToUniversalTime().ToString())); SqlParameter param = new SqlParameter("@Date_Of_Birth", System.Data.SqlDbType.DateTime); param.Value = DOB.ToUniversalTime(); parameters.Add(param); SqlParameter param = new SqlParameter("@Date_Of_Birth", SqlDbType.DateTime); param.Value = new SqlDateTime(DOB.ToUniversalTime()); parameters.Add(param); parameters.Add(new SqlParameter("@Date_Of_Birth", new SqlDateTime(DOB.ToUniversalTime()).ToSqlString())); </code></pre> <p><strong>Additional EDIT</strong></p> <p>The one I thought most likely to work:</p> <pre><code>SqlParameter param = new SqlParameter("@Date_Of_Birth", System.Data.SqlDbType.DateTime); param.Value = DOB; </code></pre> <p>Results in this value in the exec call as seen in the SQL Profiler</p> <pre><code>@Date_Of_Birth=''2009-01-08 15:08:21:813'' </code></pre> <p>If I modify this to be:</p> <pre><code>@Date_Of_Birth='2009-01-08T15:08:21' </code></pre> <p>It works, but it won't parse with pair of single quotes, and it wont convert to a <code>DateTime</code> correctly with the space between the date and time and with the milliseconds on the end.</p> <p><strong>Update and Success</strong></p> <p>I had copy/pasted the code above after the request from below. I trimmed things here and there to be concise. Turns out my problem was in the code I left out, which I'm sure any one of you would have spotted in an instant. I had wrapped my sproc calls inside a transaction. Turns out that I was simply not doing <code>transaction.Commit()</code>!!!!! I'm ashamed to say it, but there you have it.</p> <p>I still don't know what's going on with the syntax I get back from the profiler. A coworker watched with his own instance of the profiler from his computer, and it returned proper syntax. Watching the very SAME executions from my profiler showed the incorrect syntax. It acted as a red-herring, making me believe there was a query syntax problem instead of the much more simple and true answer, which was that I need to commit the transaction! </p> <p>I marked an answer below as correct, and threw in some up-votes on others because they did, after all, answer the question, even if they didn't fix my specific (brain lapse) issue.</p>
[ { "answer_id": 425896, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 6, "selected": true, "text": "SqlParameter SqlDbType SqlDbType.DateTime DateTime static void Main(string[] args)\n{\n // Create the connection.\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/425870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17803/" ]
425,902
<p>I have a sprite that I do some custom drawing in, but I would like the container to know where to position the sprite properly. To do this, the container needs to know how big the sprite is. UIComponents go through a measure stage, but sprites don't . How do I calculate the size that a sprite will be?</p> <p><strong>Edit:</strong> I'm doing the drawing in Event.ENTER_FRAME, and it's animated, so I can't tell ahead of time how big it's going to be. The UIComponent has a measure function and I'd like to create something similar.</p>
[ { "answer_id": 426161, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 0, "selected": false, "text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\" layout=...
2009/01/08
[ "https://Stackoverflow.com/questions/425902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
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 string. I am looking to something like this:</p> <pre><code>var myString = "micah"; myString = myString.Format(FormattingOptions.Capitalize) //Micah </code></pre>
[ { "answer_id": 425941, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 4, "selected": true, "text": "public static string ToTitleCase(string inputString)\n\n{\n\n System.Globalization.CultureInfo cultureInfo =\n System.Thr...
2009/01/08
[ "https://Stackoverflow.com/questions/425908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
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 email address in the same domain.</p>
[ { "answer_id": 425992, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": true, "text": "HELO example.com\nMAIL FROM: <me@me.com>\nRCPT TO: <him@him.com>\nDATA\nSubject: test message\nFrom: Me <me@me.com>\nTo:...
2009/01/08
[ "https://Stackoverflow.com/questions/425924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46780/" ]
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 fractals, I get a lot of (complicated) information but I would like to start with a simple algorithm and play with it.</p> <p>Suggestions to improve on the basic algorithm are also welcome, like how to make them in those lovely colors and such.</p>
[ { "answer_id": 426018, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 2, "selected": false, "text": "MAX_COUNT = 64 // if we haven't escaped to infinity after 64 iterations, \n // then we're inside the mandelbrot ...
2009/01/08
[ "https://Stackoverflow.com/questions/425953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2172/" ]
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 then some other reason? I could look for the "The process cannot access the file because it is being used by another process." message... But I don't like that idea.</p>
[ { "answer_id": 426467, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 3, "selected": false, "text": "private void RobustMoveFile( System.IO.DirectoryInfo destinationDirectory, System.IO.FileInfo sourceFile, Boolean retr...
2009/01/08
[ "https://Stackoverflow.com/questions/425956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5618/" ]
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 frequently. I'm wondering if there's some way I can keep a project in two repositories and keep them both up to date. That way I'd always be able to check in somewhere in case my HD dies. I have my own repository on a VPS server that I use for personal projects.</p> <p>I investigated the <code>svn switch</code> command. With my current project in both repos I tried switching my working copy from personal to work SVN servers...</p> <pre><code>$ svn switch --relocate svn+ssh://personalvps.com/svn/project/trunk svn://worksvn/project/trunk svn: The repository at 'svn://worksvn/project/trunk' has uuid '2baef97e-42ce-488c-bbba-c2625158c643', but the WC has 'f13e1f32-dc92-4c4a-b84d-34a59fe32063' </code></pre> <p>Then I tried adding the <code>--username</code> and <code>--password</code> params but got an error saying "no entry found."</p> <p>Is this even possible or is it totally impractical?</p> <hr> <p>UPDATE</p> <p>Thanks for the answers. Unfortunately, any solution that involves action from I.T. (slight policy change, change a setting somewhere, install something) is not on the table. I have to find a solution within the current setup, which is no connections from outside except our Web servers.</p> <p>I'll take a look at distributed version control.</p>
[ { "answer_id": 426136, "author": "rmeador", "author_id": 10861, "author_profile": "https://Stackoverflow.com/users/10861", "pm_score": 3, "selected": true, "text": "svn switch --relocate" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/425975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
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": "BasicHttpBinding b = new BasicHttpBinding();\nb.Security.Mode = BasicHttpSecurityMode.Transport ;\nb.Security.Transport.Cl...
2009/01/08
[ "https://Stackoverflow.com/questions/425978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
425,987
<p>Currently i am working on a desktop application which consists mathematical analysiss.I am using qt for GUI and project written in c++. When user starts an analysis, i open a worker thread and start a progress bar.Everything is ok up to now, problem starts when user cancels operation.Operation is complex, i am using several functions and objects, i allocate/deallocate memory at several times.I want to learn what should i do for recovering in cancel operation.Because there can be memory leaks.Which pattern or method i should use to be robust and safe for cancelling operation?</p> <p>My idea is throwing an exception, but operation is really complex so should i put try-catch to all of my functions or is there a more generic way, pattern..</p> <p>Edit: Problem is my objects are transfered between scopes, so shared_ptr or auto_ptr doesnt solve my problem, Flag idea can be, but i think it requires so much code and there should be an easy way.</p>
[ { "answer_id": 426064, "author": "mmr", "author_id": 21981, "author_profile": "https://Stackoverflow.com/users/21981", "pm_score": 0, "selected": false, "text": "class MySmartPointer { \n Object* MyObject;\n MySmartPointer() { MyObject = new Object(); }\n ~MySmartPointer() { ...
2009/01/08
[ "https://Stackoverflow.com/questions/425987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46145/" ]
425,988
<p>Does anyone happen to know what the maximum length of a method name is in your programming language of choice? I was going to make this a C# specific question, but I think it would be nice to know across the spectrum.</p> <p>What are the factors involved as well:</p> <ul> <li>Does the language specification limit this?</li> <li>What does the compiler limit it to? <ul> <li>Is it different on 32bit vs 64bit machines?</li> </ul></li> </ul>
[ { "answer_id": 426067, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": false, "text": "<?php\nini_set('memory_limit', '128M');\n$i = 1024 * 1024;\n\nwhile ($i < 10000000)\n{\n $className = str_repeat('i', $i);...
2009/01/08
[ "https://Stackoverflow.com/questions/425988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11702/" ]
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 convert the equiv MsSql / C# time into this unix standard.</p> <p>Any help would be appreciated.</p>
[ { "answer_id": 426013, "author": "FallenAvatar", "author_id": 36965, "author_profile": "https://Stackoverflow.com/users/36965", "pm_score": 1, "selected": true, "text": "DateTime dt = something; //Get from db\n\nTimeSpan ts = dt - new DateTime(1,1,1970); // off the top of my head, check ...
2009/01/08
[ "https://Stackoverflow.com/questions/426001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53084/" ]
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": "git mergetool merge.tool mergetool.<tool>.path <tool> merge.tool mergetool.<tool>.cmd $BASE, $LOCAL, $REMOTE, $MERGED gi...
2009/01/08
[ "https://Stackoverflow.com/questions/426026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
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&lt;IProductAdmin&gt; factory = new ChannelFactory&lt;IProductAdmin&gt;(); productAdminChannel = factory.CreateChannel(); } </code></pre> <p>In my app.config file, I have the following configuration:</p> <pre><code>&lt;system.serviceModel&gt; &lt;client&gt; &lt;endpoint address="net.tcp://localhost:8002/ProductBrowser" binding="netTcpBinding" contract="Contracts.IProductAdmin" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p>But, when I run the constructor for AdminClient I get an exception saying that the endpoint isn't defined. However, if I change my configuration to give the endpoint a name, and then create the factory as follows, it works. </p> <pre><code>public AdminClient() { var fac = new ChannelFactory&lt;IProductAdmin&gt;("admin"); productAdminChannel = fac.CreateChannel(); } </code></pre> <hr> <pre><code>&lt;system.serviceModel&gt; &lt;client&gt; &lt;endpoint name="admin" address="net.tcp://localhost:8002/ProductBrowser" binding="netTcpBinding" contract="Contracts.IProductAdmin" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p>I'd love an explanation for this. The documentation in MSDN isn't much help...</p>
[ { "answer_id": 440949, "author": "Tad Donaghe", "author_id": 1572436, "author_profile": "https://Stackoverflow.com/users/1572436", "pm_score": 2, "selected": false, "text": " using System;\n using System.ServiceModel;\n\n namespace CoDeMagazine.ServiceArticle\n {\n public cla...
2009/01/08
[ "https://Stackoverflow.com/questions/426041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
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 upon reboot. So I'm left with writing some code to do it for me.</p> <p>I created a batch file with the "w32tm /resync" command, and scheduled it to run on system startup, but it doesn't work because the network connection isn't available when the batch file is run. How can I cause the time sync to start after the OS is fully loaded and the network connection is available? I need the time to be correct ASAP after the computer boots so timestamps in my database will be correct.</p>
[ { "answer_id": 426113, "author": "ccoxtn", "author_id": 43722, "author_profile": "https://Stackoverflow.com/users/43722", "pm_score": 5, "selected": true, "text": "REM *** Retry for up to 15 minutes (90 retries @ 10 seconds each)\nset retryCount=0\n\n:SyncStart\nif %retryCount == 90 goto...
2009/01/08
[ "https://Stackoverflow.com/questions/426071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43722/" ]
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": 426137, "author": "Bob", "author_id": 32224, "author_profile": "https://Stackoverflow.com/users/32224", "pm_score": 0, "selected": false, "text": "create or replace function lob2char(clob_col clob) return varchar2 IS\nbuffer varchar2(4000);\namt BINARY_INTEGER := 4000;\npo...
2009/01/08
[ "https://Stackoverflow.com/questions/426079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]
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 current buffer, but there seems to be no such function in vim. Am I missing something?</p>
[ { "answer_id": 426262, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 0, "selected": false, "text": ":%!wc -c \n u" }, { "answer_id": 426306, "author": "m0j0", "author_id": 31319, "author_profile":...
2009/01/08
[ "https://Stackoverflow.com/questions/426081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
426,084
<p>Using Eclipse I want to view the source code for a core Java class (E.g. <code>java.util.concurrent.ConcurrentHashMap</code>) but when I navigate to the source using 'Open Declaration' it says 'Source not found' and gives me the option to attach the source.</p> <p>My question is; how do i attach the source? Where do i get the source .jar from for the <code>java.util.concurrent</code> library?</p>
[ { "answer_id": 426131, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 7, "selected": true, "text": "JDK_INSTALL_DIR\\src.zip C:\\Program Files\\java\\jdk1.6.0_11\\" }, { "answer_id": 47505839, "author": "Nidhi Shar...
2009/01/08
[ "https://Stackoverflow.com/questions/426084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 he is logged in).</p> <p>However, I noticed that in this abstract base class the <code>User</code> property is always <code>null</code>. What do I have to do to get this working?</p> <p>Thanks a lot</p>
[ { "answer_id": 426296, "author": "Adam Right", "author_id": 53124, "author_profile": "https://Stackoverflow.com/users/53124", "pm_score": 2, "selected": false, "text": "HttpContext.Current.User.Identity.Name\n" }, { "answer_id": 1650661, "author": "Melethril", "author_id"...
2009/01/08
[ "https://Stackoverflow.com/questions/426110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53102/" ]
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 fruit that has been rated by someone. But now, I want to exclude all fruit that has been rated by one specific user, so I tried this:</p> <pre><code>select fruit.id, fruit.name from fruit, fruit_rating where fruit_rating.fruit_id=fruit.id and fruit_rating.user_id != 10 group by fruit.name; </code></pre> <p>That's ok, but not quite right. It shows all the fruit that have been rated by people other than 10, but if users 1 and 10 have both rated the same fruit, it still shows that one. Can anyone tell me how to construct a query that shows only the fruit that have NOT Been rated by user 10, regardless of who else has rated them?</p>
[ { "answer_id": 426153, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 4, "selected": true, "text": "... WHERE fruit_rating.fruit_id=fruit.id \n and fruit.id not in \n (select fruit_rating.fruit_id \n ...
2009/01/08
[ "https://Stackoverflow.com/questions/426128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
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 =&gt; false </code></pre> <p>I want to say "If the two strings are not equal, print whatever it is that is different between them. In this case, I'm just looking to print "John."</p>
[ { "answer_id": 426202, "author": "gabriel", "author_id": 5447, "author_profile": "https://Stackoverflow.com/users/5447", "pm_score": 3, "selected": false, "text": " def compare(a, b)\n diff = a.split(', ') - b.split(', ')\n if diff === [] // a and b are the same\n true\n else\n...
2009/01/08
[ "https://Stackoverflow.com/questions/426159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2293/" ]
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 (basically) an <code>std::vector&lt;location*&gt;</code>.Originally I was going to code something like the following into the a <code>Party</code> member function:</p> <pre><code>if(!CurrLocation-&gt;fork_.empty()) // Loop through forks and show options to the player, go where s/he wants else (CurrLocation++) </code></pre> <p>But I was wondering if some variant of the following might be better:</p> <pre><code>CurrLocation = CurrLocation-&gt;getNext(); </code></pre> <p>With Fork actually being derived from Location, and overloading some new function <code>getNext()</code>. But in the latter case, the <code>location</code> (a low level structure) would have to be the one to present the message to the user instead of "passing this back up", which I don't feel is elegant as it couples <code>location</code> to <code>UserInterface::*</code>.</p> <p>Your opinions?</p>
[ { "answer_id": 426592, "author": "SCFrench", "author_id": 4928, "author_profile": "https://Stackoverflow.com/users/4928", "pm_score": 4, "selected": true, "text": "class Location; \n\nclass IDirectionChooser\n{\npublic:\n virtual bool ShouldIGoThisWay(Location & way) = 0;\n};\n\nclass L...
2009/01/08
[ "https://Stackoverflow.com/questions/426162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52806/" ]
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: 1 2 3 4 5 item 1 $10 off $15 off item 2 $5 off $15 off $25 off $35 off item 3 $2 off </code></pre> <p>I have manually worked out the best actions for this example:</p> <ul> <li>If I have 1 coupon, item 1 gets it for $10 off</li> <li>If I have 2 coupons, item 1 gets them for $15 off</li> <li>If I have 3 coupons, item 1 gets 2, and item 3 gets 1, for $17 off</li> <li>If I have 4 coupons, then <strong>either</strong>: <ul> <li>Item 1 gets 1 and item 2 gets 3 for a total of $25 off, or</li> <li>Item 2 gets all 4 for $25 off.</li> </ul></li> <li>If I have 5 coupons, then item 2 gets all 5 for $35 off.</li> </ul> <p>However, I need to develop a general algorithm which will handle different matrices and any number of items and coupons.</p> <p>I suspect I will need to iterate through every possible combination to find the best price for <em>n</em> coupons. Does anyone here have any ideas?</p>
[ { "answer_id": 426320, "author": "FryGuy", "author_id": 28776, "author_profile": "https://Stackoverflow.com/users/28776", "pm_score": 3, "selected": true, "text": "//int[,] discountTable = new int[NumItems][NumCoupons+1]\n\n// bestDiscount[i][c] means the best discount if you can spend c...
2009/01/08
[ "https://Stackoverflow.com/questions/426173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
426,199
<p>I'm using the latest nightly build, VS2008 prof trial and .NET 3.5 and I'm getting this error</p> <p>"Solution format of file 'C:\test\Project\src\project.sln' is not supported."</p> <p>Any Solution to overcome from it</p>
[ { "answer_id": 426228, "author": "Dan Monego", "author_id": 32771, "author_profile": "https://Stackoverflow.com/users/32771", "pm_score": 3, "selected": true, "text": "exec <exec program=\"msbuild.exe\" \n basedir=\"C:\\windows\\microsoft.net\\Framework\\v3.5\\\" \n commandline...
2009/01/08
[ "https://Stackoverflow.com/questions/426199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47868/" ]
426,212
<p>I must use a corporate class that re-uses or re-creates a transaction after every <code>Commit()</code> or <code>Rollback()</code>. This class is told to use (or not use) transactions via a <code>Boolean</code> ctor parameter.</p> <p>I am thinking of wrapping this API to separate the transaction support (to rely explicitly on Transaction objects or the ambient <code>TransactionScope</code>). But this requires a transaction class that is re-usable. Is there any such class in .NET? Or how would I begin to develop my own?</p>
[ { "answer_id": 426259, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 2, "selected": false, "text": "using (TransactionScope ts = new TransactionScope())" }, { "answer_id": 431400, "author": "Christian.K",...
2009/01/08
[ "https://Stackoverflow.com/questions/426212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3619/" ]
426,219
<p>Pardon the dumb newbie question here; web programming isn't my forte... (blush)</p> <p>I have an aspx page running on a web server. I have a blob (byte array) containing any kind of binary file, plus a file name.</p> <p>I would like to push this file to be downloaded through the browser onto the client, and opened using whatever application is default for this file type. I really don't want to save the blob as a file on the server; that will leave a terrible housekeeping mess that I just don't want to think about.</p> <p>I did try googling this question, but I guess I'm using the wrong keywords.</p> <p>This really should be obvious how to do it, but I'm having no joy.</p> <p>What is the trick?</p> <p>Thanks!</p>
[ { "answer_id": 426236, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 4, "selected": true, "text": "Response.BinaryWrite(byteArray);\n Response.ContentType = \"application/pdf\";\n Response.AddHeader(\"content-disposition\", \n Str...
2009/01/08
[ "https://Stackoverflow.com/questions/426219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7850/" ]