qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
10,915
<p>Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lists payment plans that have been accepted by a customer. Each payment plan has an ID which links back to a reference table to get the plan's terms, conditions, etc. In my object model, I have an AcceptedPlan class, and a Plan class. Originally, I used a many-to-one relationship from the detail table back to the ref table to model this relationship in NHibernate. I also created a one-to-many relationship going in the opposite direction from the Plan class over to the AcceptedPlan class. This was fine while I was simply reading data. I could go to my Plan object, which was a property of my AcceptedPlan class to read the plan's details. My problem arose when I had to start inserting new rows to the details table. From my reading, it seems the only way to create a new child object is to add it to the parent object and then save the session. But I don't want to have to create a new parent Plan object every time I want to create a new detail record. This seems like unnecessary overhead. Does anyone know if I am going about this in the wrong way?</p>
[ { "answer_id": 11164, "author": "DavidWhitney", "author_id": 1297, "author_profile": "https://Stackoverflow.com/users/1297", "pm_score": 3, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<hibernate-mapping default-cascade=\"save-update\" xmlns=\"urn:nhibernate-ma...
2008/08/14
[ "https://Stackoverflow.com/questions/10915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
10,926
<p>I'm building a listing/grid control in a <code>Flex</code> application and using it in a <code>.NET</code> web application. To make a really long story short I am getting XML from a webservice of serialized objects. I have a page limit of how many things can be on a page. I've taken a data grid and made it page, sort across pages, and handle some basic filtering. </p> <p>In regards to paging I'm using a Dictionary keyed on the page and storing the XML for that page. This way whenever a user comes back to a page that I've saved into this dictionary I can grab the XML from local memory instead of hitting the webservice. Basically, I'm caching the data retrieved from each call to the webservice for a page of data.</p> <p>There are several things that can expire my cache. Filtering and sorting are the main reason. However, a user may edit a row of data in the grid by opening an editor. The data they edit could cause the data displayed in the row to be stale. I could easily go to the webservice and get the whole page of data, but since the page size is set at runtime I could be looking at a large amount of records to retrieve.</p> <p>So let me now get to the heart of the issue that I am experiencing. In order to prevent getting the whole page of data back I make a call to the webservice asking for the completely updated record (the editor handles saving its data).</p> <p>Since I'm using custom objects I need to serialize them on the server to XML (this is handled already for other portions of our software). All data is handled through XML in e4x. The cache in the Dictionary is stored as an XMLList.</p> <p><strong>Now let me show you my code...</strong></p> <pre><code>var idOfReplacee:String = this._WebService.GetSingleModelXml.lastResult.*[0].*[0].@Id; var xmlToReplace:XMLList = this._DataPages[this._Options.PageIndex].Data.(@Id == idOfReplacee); if(xmlToReplace.length() &gt; 0) { delete (this._DataPages[this._Options.PageIndex].Data.(@Id == idOfReplacee)[0]); this._DataPages[this._Options.PageIndex].Data += this._WebService.GetSingleModelXml.lastResult.*[0].*[0]; } </code></pre> <p>Basically, I get the id of the node I want to replace. Then I find it in the cache's Data property (<code>XMLList</code>). I make sure it exists since the filter on the second line returns the <code>XMLList</code>.</p> <p>The problem I have is with the delete line. I cannot make that line delete that node from the list. The line following the delete line works. I've added the node to the list.</p> <p>How do I replace or delete that node (meaning the node that I find from the filter statement out of the .Data property of the cache)???</p> <p>Hopefully the underscores for all of my variables do not stay escaped when this is posted! otherwise <code>this.&amp;#95 == this</code>._</p>
[ { "answer_id": 11048, "author": "Matt Dillard", "author_id": 863, "author_profile": "https://Stackoverflow.com/users/863", "pm_score": 0, "selected": false, "text": "delete" }, { "answer_id": 11059, "author": "Theo", "author_id": 1109, "author_profile": "https://Stack...
2008/08/14
[ "https://Stackoverflow.com/questions/10926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1290/" ]
10,933
<p>We have an SVN repository running on a Windows server, and I want to link internal documentation, feature changes, bugs and so on to code changes.</p> <p>We've found WebSVN to be amazingly slow - the repository is too large for it (I think).</p> <p>The team using it is primarily coding in C#, and while some have experience with other languages I'd really like a tool anyone on the team can maintain.</p> <p>Most of the tools I've seen are based on PHP, Java, Python, etc. All languages the team could learn, but I'd rather something that uses the skills we already have.</p> <p>Can you recommend a good web-based repository browser for SVN, ideally one that uses ASP.NET, <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL&nbsp;Server</a> and that runs on <a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="nofollow noreferrer">IIS</a>?</p>
[ { "answer_id": 11772, "author": "icco", "author_id": 1063, "author_profile": "https://Stackoverflow.com/users/1063", "pm_score": 2, "selected": false, "text": "svn log --xml\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/10933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
10,949
<p>Let's say I have a complex .NET class, with lots of arrays and other class object members. I need to be able to generate a deep clone of this object - so I write a Clone() method, and implement it with a simple BinaryFormatter serialize/deserialize - or perhaps I do the deep clone using some other technique which is more error prone and I'd like to make sure is tested.</p> <p>OK, so now (ok, I should have done it first) I'd like write tests which cover the cloning. All the members of the class are private, and my architecture is so good (!) that I haven't needed to write hundreds of public properties or other accessors. The class isn't IComparable or IEquatable, because that's not needed by the application. My unit tests are in a separate assembly to the production code.</p> <p>What approaches do people take to testing that the cloned object is a good copy? Do you write (or <em>rewrite</em> once you discover the need for the clone) all your unit tests for the class so that they can be invoked with <em>either</em> a 'virgin' object <em>or</em> with a clone of it? How would you test if part of the cloning wasn't deep enough - as this is just the kind of problem which can give hideous-to-find bugs later?</p>
[ { "answer_id": 24166, "author": "Andrew", "author_id": 1948, "author_profile": "https://Stackoverflow.com/users/1948", "pm_score": 1, "selected": false, "text": "[Conditional(\"DEBUG\")]\npublic static void DebugAssertValueEquality<T>(T current, T other, bool expected, \n ...
2008/08/14
[ "https://Stackoverflow.com/questions/10949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987/" ]
10,985
<p>Does anyone know how I can, in platform-independent C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this:</p> <pre><code>Foo *ptr = new Foo; </code></pre> <p>and only allow them to do this:</p> <pre><code>Foo myfooObject; </code></pre> <p>Does anyone have any ideas?</p> <p>Cheers,</p>
[ { "answer_id": 11003, "author": "Nick", "author_id": 1236, "author_profile": "https://Stackoverflow.com/users/1236", "pm_score": 4, "selected": false, "text": "class Foo {\nprivate:\n void* operator new(size_t size);\n};\n" }, { "answer_id": 11014, "author": "pauldoo", "...
2008/08/14
[ "https://Stackoverflow.com/questions/10985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1304/" ]
10,990
<p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p> <p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:</p> <pre><code>chown apache:apache -R uploads/ chmod 755 -R uploads/ </code></pre> <p>The only problem now is that the FTP user can not modify the uploaded files at all.</p> <p>Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?</p>
[ { "answer_id": 11029, "author": "Max", "author_id": 1309, "author_profile": "https://Stackoverflow.com/users/1309", "pm_score": 4, "selected": false, "text": "move_uploaded_file" }, { "answer_id": 9460755, "author": "M. Ahmad Zafar", "author_id": 462732, "author_profi...
2008/08/14
[ "https://Stackoverflow.com/questions/10990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1153/" ]
11,028
<p>When I'm joining three or more tables together by a common column, I'd write my query like this:</p> <pre><code>SELECT * FROM a, b, c WHERE a.id = b.id AND b.id = c.id </code></pre> <p>a colleague recently asked my why I didn't do explicit <em>Join Transitive Closure</em> in my queries like this:</p> <pre><code>SELECT * FROM a, b, c WHERE a.id = b.id AND b.id = c.id AND c.id = a.id </code></pre> <p>are the really any advantages to this? Surely the optimiser can imply this for itself?</p> <p><em>edit: I know it's evil syntax, but it's a quick and dirty example of legitimate legacy code +1 @<a href="https://stackoverflow.com/questions/11028/what-are-the-advantages-of-explicit-join-transitive-closure-in-sql#11114">Stu</a> for cleaning it up</em></p>
[ { "answer_id": 11114, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 2, "selected": false, "text": "Select\n * -- Oh, and don't ever use *, either\nFrom\n A \n Inner Join B On A.ID = B.ID\n Inner Join C On B.ID = C.ID\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
11,043
<p>What are the pros and cons of using table aliases in SQL? I personally try to avoid them, as I think they make the code less readable (especially when reading through large where/and statements), but I'd be interested in hearing any counter-points to this. When is it generally a good idea to use table aliases, and do you have any preferred formats?</p>
[ { "answer_id": 11053, "author": "Rob Allen", "author_id": 149, "author_profile": "https://Stackoverflow.com/users/149", "pm_score": 6, "selected": true, "text": "select person.FirstName\n ,person.LastName\n ,addr.StreetAddress\n ,addr.City\n ,addr.State\n ,addr.Z...
2008/08/14
[ "https://Stackoverflow.com/questions/11043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/637/" ]
11,045
<p>How can I get a user-defined function to re-evaluate itself based on changed data in the spreadsheet?</p> <p>I tried <strong><kbd>F9</kbd></strong> and <strong><kbd>Shift</kbd>+<kbd>F9</kbd></strong>.</p> <p>The only thing that seems to work is editing the cell with the function call and then pressing Enter.</p>
[ { "answer_id": 12018, "author": "vzczc", "author_id": 224, "author_profile": "https://Stackoverflow.com/users/224", "pm_score": 8, "selected": true, "text": "Application.Volatile" }, { "answer_id": 120363, "author": "Community", "author_id": -1, "author_profile": "htt...
2008/08/14
[ "https://Stackoverflow.com/questions/11045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767/" ]
11,060
<p>This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.</p> <p>I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.</p> <p>The problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.</p> <p>So I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.</p> <p>Has anyone got any experiences of something similar to this they would care to share?</p>
[ { "answer_id": 70778, "author": "0124816", "author_id": 11521, "author_profile": "https://Stackoverflow.com/users/11521", "pm_score": 0, "selected": false, "text": "int x = 0;\nGENERATED_CODE\nassert(x == 100);\n" }, { "answer_id": 2870088, "author": "Sean B", "author_id"...
2008/08/14
[ "https://Stackoverflow.com/questions/11060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/912/" ]
11,085
<p>In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed reference, you are returned the name of the package that reference has been blessed into. </p> <p>I want to know the actual underlying type of the blessed reference. How can I determine this?</p>
[ { "answer_id": 64160, "author": "Michael Carman", "author_id": 8233, "author_profile": "https://Stackoverflow.com/users/8233", "pm_score": 5, "selected": true, "text": "Scalar::Util::reftype()" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166/" ]
11,088
<p>In Java, there is no such thing as an unsigned byte.</p> <p>Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.</p> <p>What's a good way to work around this? (Saying don't use Java is not an option)</p>
[ { "answer_id": 11101, "author": "pauldoo", "author_id": 755, "author_profile": "https://Stackoverflow.com/users/755", "pm_score": 5, "selected": true, "text": "byte[] foobar = ..;\nint value = foobar[10];\nif (value < 0) value += 256 // Patch up the 'falsely' negative value\n" }, { ...
2008/08/14
[ "https://Stackoverflow.com/questions/11088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1309/" ]
11,099
<p>In the case of languages that support single decision and action without brackets, such as the following example:</p> <pre><code>if (var == true) doSomething(); </code></pre> <p>What is the preferred way of writing this? Should brackets always be used, or should their usage be left as a preference of the individual developer? Additionally, does this practice depend on the size of the code block, such as in the following example:</p> <pre><code>if (var == 1) doSomething(1); else if (var &gt; 1 &amp;&amp; var &lt; 10) doSomething(2); else { validate(var); doSomething(var); } </code></pre>
[ { "answer_id": 11106, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "if (cond1)\n{\n SomeOperation();\n Another();\n}\nelseif (cond2)\n{\n DoSomething();\n}\nelse\n{\n DoNothing();\n ...
2008/08/14
[ "https://Stackoverflow.com/questions/11099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
11,112
<p>Most wiki software I've presents lots of "features" on their pages. This is fine for desktop users, but is annoying when using an iPhone or other mobile device. <br /><br />I'd prefer pages that just had the content, along with maybe an Edit button and a Search button. The editors are also often too fancy for mobile users; a simple multi-line edit field would be better for mobile users than a bunch of formatting controls.</p> <p>What is a good wiki package for mobile users?</p>
[ { "answer_id": 11106, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "if (cond1)\n{\n SomeOperation();\n Another();\n}\nelseif (cond2)\n{\n DoSomething();\n}\nelse\n{\n DoNothing();\n ...
2008/08/14
[ "https://Stackoverflow.com/questions/11112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
11,127
<p>In a C++ Windows (XP and NT, if it makes a difference) application I'm working on, I need to get the network name associated with the computer the code is executing on, so that I can convert local filenames from C:\filename.ext to \\network_name\C$\filename.ext. How would I do this?</p> <p>Alternatively, if there's a function that will just do the conversion I described, that would be even better. I looked into WNetGetUniversalName, but that doesn't seem to work with local (C drive) files.</p>
[ { "answer_id": 71343, "author": "jilles de wit", "author_id": 7531, "author_profile": "https://Stackoverflow.com/users/7531", "pm_score": 1, "selected": false, "text": "#include <winsock2.h> //of course this is the way to go on windows only\n\n#pragma comment(lib, \"Ws2_32.lib\")\n\nvoid...
2008/08/14
[ "https://Stackoverflow.com/questions/11127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179/" ]
11,135
<p>I need to create an ASP page (classic, not ASP.NET) which runs remote shell scripts on a UNIX server, then captures the output into variables in VBScript within the page itself.</p> <p>I have never done ASP or VBScipt before. I have tried to google this stuff, but all I find are references to remote server side scripting, nothing concrete. </p> <p>I could really use:</p> <ol> <li>An elementary example of how this could be done.</li> <li>Any other better alternatives to achieve this in a secure manner.</li> </ol> <hr> <p>Are there any freeware/open source alternatives to these libraries? Any examples?</p>
[ { "answer_id": 71343, "author": "jilles de wit", "author_id": 7531, "author_profile": "https://Stackoverflow.com/users/7531", "pm_score": 1, "selected": false, "text": "#include <winsock2.h> //of course this is the way to go on windows only\n\n#pragma comment(lib, \"Ws2_32.lib\")\n\nvoid...
2008/08/14
[ "https://Stackoverflow.com/questions/11135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1311/" ]
11,145
<p>I am trying to code a flowchart generator for a language using Ruby. </p> <p>I wanted to know if there were any libraries that I could use to draw various shapes for the various flowchart elements and write out text to those shapes. </p> <p>I would really prefer not having to write code for drawing basic shapes, if I can help it. </p> <p>Can someone could point me to some reference documentation with examples of using that library?</p>
[ { "answer_id": 11191, "author": "Nathan Clark", "author_id": 1331, "author_profile": "https://Stackoverflow.com/users/1331", "pm_score": 2, "selected": false, "text": "draw.rectangle(x1, y1, x2, y2)\ndraw.polygon(x1, y1,...,xN, yN)\n" }, { "answer_id": 12120, "author": "Mike ...
2008/08/14
[ "https://Stackoverflow.com/questions/11145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1311/" ]
11,194
<p>We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to do it with Linq. How can I conditionally add where-clauses?</p>
[ { "answer_id": 11201, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 0, "selected": false, "text": "var items = dc.Users.Where(l => l.Date == DateTime.Today && l.Severity == \"Critical\")\n" }, { "answer_id": 1...
2008/08/14
[ "https://Stackoverflow.com/questions/11194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1204/" ]
11,200
<p>I'm guessing it needs to be something like:</p> <pre><code>CONVERT(CHAR(24), lastModified, 101) </code></pre> <p>However I'm not sure of the right value for the third parameter.</p> <p>Thanks!</p> <hr> <p>Well I'm trying to write a script to copy my sql server db to a sqlite file, which gets downloaded to an air app, which then syncs the data to another sqlite file. I'm having a ton of trouble with dates. If I select a date in air and try to insert it, it fails because it's not in the right format... even if it was a valid date to begin with. I figured I'd try to experiment with the unix time since that's the only thing thats worked so far. I am considering just leaving them as varchar because I don't sort by them anyway.</p>
[ { "answer_id": 11216, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 2, "selected": false, "text": "SELECT DATEDIFF(s,'19700101 05:00:00:000',lastModified)\n" }, { "answer_id": 11234, "author": "SQLMenace", "a...
2008/08/14
[ "https://Stackoverflow.com/questions/11200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
11,219
<p>I'd like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of the developers where I work keep programming in Classic ASP. Ideally, then, for them to benefit from the advantages of a unique set of web APIs, it would have to be called from Classic ASP pages.</p> <p>I haven't the slightest idea how to do that. </p>
[ { "answer_id": 11238, "author": "KP.", "author_id": 439, "author_profile": "https://Stackoverflow.com/users/439", "pm_score": 6, "selected": true, "text": "Set HttpReq = Server.CreateObject(\"MSXML2.ServerXMLHTTP\")\nHttpReq.open \"GET\", \"Rest_URI\", False\nHttpReq.send\n" }, { ...
2008/08/14
[ "https://Stackoverflow.com/questions/11219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/160/" ]
11,279
<p>I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the <strong>Publish</strong> properties of the project, I have it set to <em>Automatically increment revision with each publish</em>.</p> <p>The issue is that it's only incrementing the revision in the Setup files. It doesn't seem to be updating the version number in the About Box (which is the generic, built-in, About Box template). That version number seems to be coming from <em>My.Application.Info.Version</em>.</p> <p>What should I be using instead so that my automatically incrementing revision number shows up in the about box?</p>
[ { "answer_id": 11297, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 2, "selected": true, "text": "Me.LabelVersion.Text = String.Format(\"Version {0}\", My.Application.Deployment.CurrentVersion.ToString)\n" }, { "answer_id"...
2008/08/14
[ "https://Stackoverflow.com/questions/11279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
11,288
<p>So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so what would be a best practice for solving this problem. </p> <p>There are two or more object collections of different types. You want to combine them into a single sortable and filterable collection (withing having to manually implement sort or filter).</p> <p>One of the approaches I've considered is to create a new object collection with only a few core properties, including the ones that I would want the collection sorted on, and an object instance of each type. </p> <pre><code>class MyCompositeObject { enum ObjectType; DateTime CreatedDate; string SomeAttribute; myObjectType1 Obj1; myObjectType2 Obj2; { class MyCompositeObjects : List&lt;MyCompositeObject&gt; { } </code></pre> <p>And then loop through my two object collections to build the new composite collection. Obviously this is a bit of a brute force method, but it would work. I'd get all the default view sorting and filtering behavior on my new composite object collection, and I'd be able to put a data template on it to display my list items properly depending on which type is actually stored in that composite item.</p> <p>What suggestions are there for doing this in a more elegant way?</p>
[ { "answer_id": 11297, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 2, "selected": true, "text": "Me.LabelVersion.Text = String.Format(\"Version {0}\", My.Application.Deployment.CurrentVersion.ToString)\n" }, { "answer_id"...
2008/08/14
[ "https://Stackoverflow.com/questions/11288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1346/" ]
11,291
<p>I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help? </p>
[ { "answer_id": 11312, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 5, "selected": true, "text": "- (void)keyUp:(NSEvent *)theEvent\n" }, { "answer_id": 12874, "author": "Brian Warshaw", "author_id": 1...
2008/08/14
[ "https://Stackoverflow.com/questions/11291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1344/" ]
11,305
<p>I work in VBA, and want to parse a string eg</p> <pre><code>&lt;PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema'&gt; &lt;X&gt;24.365&lt;/X&gt; &lt;Y&gt;78.63&lt;/Y&gt; &lt;/PointN&gt; </code></pre> <p>and get the X &amp; Y values into two separate integer variables.</p> <p>I'm a newbie when it comes to XML, since I'm stuck in VB6 and VBA, because of the field I work in.</p> <p>How do I do this?</p>
[ { "answer_id": 11406, "author": "Devdatta Tengshe", "author_id": 895, "author_profile": "https://Stackoverflow.com/users/895", "pm_score": 6, "selected": false, "text": "Dim objXML As MSXML2.DOMDocument\n\nSet objXML = New MSXML2.DOMDocument\n\nIf Not objXML.loadXML(strXML) Then 'strXML...
2008/08/14
[ "https://Stackoverflow.com/questions/11305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/895/" ]
11,311
<p>Is it possible to format certain text in a WinForm Label instead of breaking the text into multiple labels? Please disregard the HTML tags within the label's text; it's only used to get my point out.</p> <p>For example:</p> <pre><code>Dim myLabel As New Label myLabel.Text = "This is &lt;b&gt;bold&lt;/b&gt; text. This is &lt;i&gt;italicized&lt;/i&gt; text." </code></pre> <p>Which would produce the text in the label as:</p> <blockquote> <p>This is <strong>bold</strong> text. This is <em>italicized</em> text.</p> </blockquote>
[ { "answer_id": 24207716, "author": "Geoff", "author_id": 55487, "author_profile": "https://Stackoverflow.com/users/55487", "pm_score": 4, "selected": false, "text": "Links.Add()" }, { "answer_id": 28728824, "author": "Nigrimmist", "author_id": 1151741, "author_profile...
2008/08/14
[ "https://Stackoverflow.com/questions/11311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299/" ]
11,318
<p>Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?</p> <ul> <li>Invalidate the Form as soon as you are done drawing?</li> <li>Setup a second timer and invalidate the form on a regular interval?</li> <li>Perhaps there is a common pattern for this thing?</li> <li>Are there any useful .NET classes to help out?</li> </ul> <p>Each time I need to do this I discover a new method with a new drawback. What are the experiences and recommendations from the SO community?</p>
[ { "answer_id": 11404, "author": "Peteter", "author_id": 1192, "author_profile": "https://Stackoverflow.com/users/1192", "pm_score": 4, "selected": true, "text": "private void AnimationTimer_Tick(object sender, EventArgs args)\n{\n // First paint background, like Clear(Control.Backgrou...
2008/08/14
[ "https://Stackoverflow.com/questions/11318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322/" ]
11,330
<p>Let's say I'm creating a chess program. I have a function</p> <pre><code>void foreachMove( void (*action)(chess_move*), chess_game* game); </code></pre> <p>which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? For example:</p> <pre><code>chess_move getNextMove(chess_game* game, int depth){ //for each valid move, determine how good the move is foreachMove(moveHandler, game); } void moveHandler(chess_move* move){ //uh oh, now I need the variables "game" and "depth" from the above function } </code></pre> <p>Redefining the function pointer is not the optimal solution. The foreachMove function is versatile and many different places in the code reference it. It doesn't make sense for each one of those references to have to update their function to include parameters that they don't need.</p> <p>How can I pass extra parameters to a function that I'm calling through a pointer?</p>
[ { "answer_id": 11335, "author": "Antonio Haley", "author_id": 390, "author_profile": "https://Stackoverflow.com/users/390", "pm_score": 3, "selected": false, "text": "void foreachMove( void (*action)(chess_move*, int), chess_game* game )\n" }, { "answer_id": 11379, "author": ...
2008/08/14
[ "https://Stackoverflow.com/questions/11330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
11,341
<p>I would like to automatically generate PDF documents from <a href="https://en.wikipedia.org/wiki/WebObjects" rel="nofollow noreferrer">WebObjects</a> based on mulitpage forms. Assuming I have a class which can assemble the related forms (java/wod files) is there a good way to then parse the individual forms into a PDF instead of going to the screen?</p>
[ { "answer_id": 13431, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 3, "selected": true, "text": "WOComponent" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1104/" ]
11,345
<p>What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces? If I have a document where elements have been given a default namespace: </p> <pre><code>&lt;foo xmlns="uri" /&gt; </code></pre> <p>It appears as though some of the XPath processor libraries won't recognize <code>//foo</code> because of the namespace whereas others will. The option my team has thought about is to add a namespace prefix using regular expressions to the XPath (you can add a namespace prefix via XmlNameTable) but this seems brittle since XPath is such a flexible language when it comes to node tests.</p> <p>Is there a standard that applies to this?</p> <p>My approach is a bit hackish but it seems to work fine; I remove the <code>xmlns</code> declaration with a search/replace and then apply XPath.</p> <pre><code>string readyForXpath = Regex.Replace(xmldocument, "xmlns=\".+\"", String.Empty ); </code></pre> <p>Is that a fair approach or has anyone solved this differently?</p>
[ { "answer_id": 11351, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 4, "selected": false, "text": "<foo xmlns='urn:foo'>\n <bar>\n <asdf/>\n </bar> \n</foo>\n" }, { "answer_id": 11370, "author": "paleho...
2008/08/14
[ "https://Stackoverflow.com/questions/11345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
11,381
<p>Here's a coding problem for those that like this kind of thing. Let's see your implementations (in your language of choice, of course) of a function which returns a human readable String representation of a specified Integer. For example:</p> <ul> <li>humanReadable(1) returns "one". <li>humanReadable(53) returns "fifty-three". <li>humanReadable(723603) returns "seven hundred and twenty-three thousand, six hundred and three". <li>humanReadable(1456376562) returns "one billion, four hundred and fifty-six million, three hundred and seventy-six thousand, five hundred and sixty-two". </ul> <p>Bonus points for particularly clever/elegant solutions!</p> <p>It might seem like a pointless exercise, but there are number of real world applications for this kind of algorithm (although supporting numbers as high as a billion may be overkill :-)</p>
[ { "answer_id": 11415, "author": "Ryan Ahearn", "author_id": 75, "author_profile": "https://Stackoverflow.com/users/75", "pm_score": 1, "selected": false, "text": "String humanReadable(int inputNumber) {\n if (inputNumber == -1) {\n return \"\";\n }\n int remainder;\n int quotient;...
2008/08/14
[ "https://Stackoverflow.com/questions/11381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
11,405
<p>The following code doesn't compile with gcc, but does with Visual Studio:</p> <pre><code>template &lt;typename T&gt; class A { public: T foo; }; template &lt;typename T&gt; class B: public A &lt;T&gt; { public: void bar() { cout &lt;&lt; foo &lt;&lt; endl; } }; </code></pre> <p>I get the error:</p> <blockquote> <p>test.cpp: In member function ‘void B::bar()’:</p> <p>test.cpp:11: error: ‘foo’ was not declared in this scope</p> </blockquote> <p>But it should be! If I change <code>bar</code> to</p> <pre><code>void bar() { cout &lt;&lt; this-&gt;foo &lt;&lt; endl; } </code></pre> <p>then it <em>does</em> compile, but I don't think I have to do this. Is there something in the official specs of C++ that GCC is following here, or is it just a quirk?</p>
[ { "answer_id": 11425, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 4, "selected": false, "text": "template <typename T> struct B {\n int m;\n int n;\n int f ();\n int g ();\n};\nint n;\nint g ();\ntemplate <typename T>...
2008/08/14
[ "https://Stackoverflow.com/questions/11405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/112/" ]
11,491
<p>What is the best way people have found to do String to Lower case / Upper case in C++?</p> <p>The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method?</p>
[ { "answer_id": 11502, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 6, "selected": true, "text": "#include <algorithm>\nstd::string data = \"Abc\";\nstd::transform(data.begin(), data.end(), data.begin(), ::toupper);\n" }, ...
2008/08/14
[ "https://Stackoverflow.com/questions/11491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366/" ]
11,532
<p>How can I find any unused functions in a PHP project?</p> <p>Are there features or APIs built into PHP that will allow me to analyse my codebase - for example <a href="http://ie.php.net/manual/en/language.oop5.reflection.php" rel="noreferrer">Reflection</a>, <a href="http://php.net/manual/en/function.token-get-all.php" rel="noreferrer"><code>token_get_all()</code></a>?</p> <p>Are these APIs feature rich enough for me not to have to rely on a third party tool to perform this type of analysis?</p>
[ { "answer_id": 14625, "author": "Stacey Richards", "author_id": 1142, "author_profile": "https://Stackoverflow.com/users/1142", "pm_score": 6, "selected": true, "text": "<?php\n $functions = array();\n $path = \"/path/to/my/php/project\";\n define_dir($path, $functions);\n re...
2008/08/14
[ "https://Stackoverflow.com/questions/11532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1142/" ]
11,561
<p>I've used Apache CXF to expose about ten java classes as web services.</p> <p>I've generated clients using CXF, Axis, and .NET.</p> <p>In Axis and CXF a "Service" or "Locator" is generated. From this service you can get a "Port". The "Port" is used to make individual calls to the methods exposed by the web service.</p> <p>In .NET the "Service" directly exposes the calls to the web service.</p> <p>Can someone explain the difference between a port, a service, a locator, and an endpoint when it comes to web services?</p> <p>Axis:</p> <pre><code>PatientServiceImplServiceLocator locator = new PatientServiceImplServiceLocator(); PatientService service = locator.getPatientServiceImplPort(); </code></pre> <p>CXF:</p> <pre><code>PatientServiceImplService locator = new PatientServiceImplService(); PatientService service = locator.getPatientServiceImplPort(); </code></pre> <p>.net:</p> <pre><code>PatientServiceImplService service = new PatientServiceImplService(); </code></pre>
[ { "answer_id": 23066361, "author": "pHneutre", "author_id": 1585148, "author_profile": "https://Stackoverflow.com/users/1585148", "pm_score": 2, "selected": false, "text": "<port>" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
11,562
<p><code>std::swap()</code> is used by many std containers (such as <code>std::list</code> and <code>std::vector</code>) during sorting and even assignment.</p> <p>But the std implementation of <code>swap()</code> is very generalized and rather inefficient for custom types.</p> <p>Thus efficiency can be gained by overloading <code>std::swap()</code> with a custom type specific implementation. But how can you implement it so it will be used by the std containers?</p>
[ { "answer_id": 11599, "author": "Wilka", "author_id": 1367, "author_profile": "https://Stackoverflow.com/users/1367", "pm_score": 6, "selected": false, "text": "namespace std\n{\n template<>\n void swap(my_type& lhs, my_type& rhs)\n {\n // ... blah\n }\n}\n" }, { ...
2008/08/14
[ "https://Stackoverflow.com/questions/11562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366/" ]
11,585
<p>For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine...</p> <pre><code>&lt;%@OutputCache Duration="600" VaryByParam="*" %&gt; </code></pre> <p>However, if someone posts a comment, I want to clear the cache so that the page is refreshed and the comment can be seen.</p> <p>How do I do this in ASP.Net C#?</p>
[ { "answer_id": 11621, "author": "palmsey", "author_id": 521, "author_profile": "https://Stackoverflow.com/users/521", "pm_score": 1, "selected": false, "text": "//add dependency\nstring key = \"post.aspx?id=\" + PostID.ToString();\nCache[key] = new object();\nResponse.AddCacheItemDepende...
2008/08/14
[ "https://Stackoverflow.com/questions/11585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
11,586
<p>What's the penetration of design patterns in the real world? Do you use them in your day to day job - discussing how and where to apply them with your coworkers - or do they remain more of an academic concept? </p> <p>Do they actually provide actual value to your job? Or are they just something that people talk about to sound smart?</p> <p>Note: For the purpose of this question ignore 'simple' design patterns like <em>Singleton</em>. I'm talking about designing your code so you can take advantage of <em>Model View Controller</em>, etc.</p>
[ { "answer_id": 11617, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 7, "selected": true, "text": "Facade" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322/" ]
11,620
<p>I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.</p> <p>How can I kill all the connections to the database so that I can rename it?</p>
[ { "answer_id": 11624, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 10, "selected": true, "text": "-- set your current connection to use master otherwise you might get an error\n\nuse master\nALTER DATABASE YourDatabase SET ...
2008/08/14
[ "https://Stackoverflow.com/questions/11620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
11,632
<p>Certainly there's the difference in general syntax, but what other critical distinctions exist? There are <em>some</em> differences, right?</p>
[ { "answer_id": 11677, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 1, "selected": false, "text": "handles" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
11,635
<p>What is the best way of doing case-insensitive string comparison in C++ without transforming a string to all uppercase or all lowercase?</p> <p>Please indicate whether the methods are Unicode-friendly and how portable they are.</p>
[ { "answer_id": 11654, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 4, "selected": false, "text": "_wcsnicmp" }, { "answer_id": 11669, "author": "Wedge", "author_id": 332, "author_profile": "https://Stack...
2008/08/14
[ "https://Stackoverflow.com/questions/11635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366/" ]
11,665
<p>Here is the sample code for my accordion:</p> <pre><code>&lt;mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion"&gt; &lt;mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off"&gt; &lt;mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1" verticalGap="1"&gt; &lt;mx:Repeater id="rptrSpotlight" dataProvider="{aSpotlight}"&gt; &lt;sm:SmallCourseListItem viewClick="PlayFile(event.currentTarget.getRepeaterItem().fileID);" Description="{rptrSpotlight.currentItem.fileDescription}" FileID = "{rptrSpotlight.currentItem.fileID}" detailsClick="{detailsView.SetFile(event.currentTarget.getRepeaterItem().fileID,this)}" Title="{rptrSpotlight.currentItem.fileTitle}" FileIcon="{iconLibrary.getIcon(rptrSpotlight.currentItem.fileExtension)}" /&gt; &lt;/mx:Repeater&gt; &lt;/mx:VBox&gt; &lt;/mx:Canvas&gt; &lt;/mx:Accordion&gt; </code></pre> <p>I would like to include a button in each header like so:</p> <p><img src="https://i.stack.imgur.com/EN3kP.jpg" alt="wishful&quot; onclick=&quot;alert(&#39;xss&#39;)"></p>
[ { "answer_id": 12266, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 1, "selected": false, "text": "<mx:Accordion>\n <mx:headerRenderer>\n <mx:Component>\n <AccordionHeader xmlns=\"mx.containers.accordionCla...
2008/08/14
[ "https://Stackoverflow.com/questions/11665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
11,689
<p>I am intentionally leaving this quite vague at first. I'm looking for discussion and what issues are important more than I'm looking for hard answers.</p> <p>I'm in the middle of designing an app that does something like portfolio management. The design I have so far is</p> <ul> <li>Problem: a problem that needs to be solved</li> <li>Solution: a proposed solution to one or more problems</li> <li>Relationship: a relationship among two problems, two solutions, or a problem and a solution. Further broken down into: <ul> <li>Parent-child - some sort of categorization / tree hierarchy</li> <li>Overlap - the degree to which two solutions or two problems really address the same concept</li> <li>Addresses - the degree to which a problem addresses a solution</li> </ul></li> </ul> <p>My question is about the temporal nature of these things. Problems crop up, then fade. Solutions have an expected resolution date, but that might be modified as they are developed. The degree of a relationship might change over time as problems and solutions evolve.</p> <p>So, the question: what is the best design for versioning of these things so I can get both a current and an historical perspective of my portfolio?</p> <p><em>Later: perhaps I should make this a more specific question, though @Eric Beard's answer is worth an up.</em></p> <p>I've considered three database designs. I'll enough of each to show their drawbacks. My question is: which to pick, or can you think of something better?</p> <h2>1: Problems (and separately, Solutions) are self-referential in versioning.</h2> <pre><code>table problems int id | string name | text description | datetime created_at | int previous_version_id foreign key previous_version_id -&gt; problems.id </code></pre> <p>This is problematic because every time I want a new version, I have to duplicate the entire row, including that long <code>description</code> column.</p> <h2>2: Create a new Relationship type: Version.</h2> <pre><code>table problems int id | string name | text description | datetime created_at </code></pre> <p>This simply moves the relationship from the Problems and Solutions tables into the Relationships table. Same duplication problem, but perhaps a little "cleaner" since I already have an abstract Relationship concept.</p> <h2>3: Use a more Subversion-like structure; move all Problem and Solution attributes into a separate table and version them.</h2> <pre><code>table problems int id table attributes int id | int thing_id | string thing_type | string name | string value | datetime created_at | int previous_version_id foreign key (thing_id, thing_type) -&gt; problems.id or solutions.id foreign key previous_version_id -&gt; attributes.id </code></pre> <p>This means that to load the current version of a Problem or Solution I have to fetch all versions of the attribute, sort them by date and then use the most current. That might not be terrible. What seems really bad to me is that I can't type-check these attributes in the database. That <code>value</code> column has to be free-text. I can make the <code>name</code> column a reference into a separate <code>attribute_names</code> table that has a <code>type</code> column, but that doesn't <em>force</em> the correct type in the <code>attributes</code> table.</p> <p><em>later still: response to @Eric Beard's comments about multi-table foreign keys:</em></p> <p>Alas, what I've described is simplistic: there are only two types of Things (Problems and Solutions). I actually have about 9 or 10 different types of Things, so I'd have 9 or 10 columns of foreign keys under your strategy. I wanted to use single-table inheritance, but the Things have so little in common that it would be <em>extremely</em> wasteful to do combine them into one table.</p>
[ { "answer_id": 12231, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 1, "selected": false, "text": "foreign key (thing_id, thing_type) -> problems.id or solutions.id\n" }, { "answer_id": 12278, "author": "Jam...
2008/08/14
[ "https://Stackoverflow.com/questions/11689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
11,690
<p>I've got some Japanese in the ALT attribute, but the tooltip is showing me the ugly block characters in the tooltip. The rest of the content on the page renders correctly. So far, it seems to be limited to the tooltips.</p>
[ { "answer_id": 11747, "author": "eplawless", "author_id": 1370, "author_profile": "https://Stackoverflow.com/users/1370", "pm_score": 1, "selected": false, "text": "<img src=\"test.png\" alt=\"日本語\" />\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
11,699
<p>I'm getting notifications to back up my encryption key for EFS in Vista, however i haven't enabled bit locker or drive encryption.</p> <p>Anyone know how to find out what files may be encrypted or have an explanation for why it would notify me?</p>
[ { "answer_id": 232734, "author": "ParanoidMike", "author_id": 452120, "author_profile": "https://Stackoverflow.com/users/452120", "pm_score": 5, "selected": false, "text": "CIPHER.EXE /U /N\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580/" ]
11,720
<p>What I would like to do is create a clean virtual machine image as the output of a build of an application.</p> <p>So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a location on the virtual machine hard disk, and IIS configured correctly, the VM would start up and run.</p> <p>I know there are MSBuild tasks to script all the administrative actions in IIS, but how do you script all the actions with Virtual machines? Specifically, creating a new virtual machine from a template, naming it uniquely, starting it, configuring it, etc...</p> <p>Specifically I was wondering if anyone has successfully implemented any VM scripting as part of a build process.</p> <p>Update: I assume with Hyper-V, there is a different set of libraries/APIs to script virtual machines, anyone played around with this? And anyone with real practical experience of doing something like this?</p>
[ { "answer_id": 232734, "author": "ParanoidMike", "author_id": 452120, "author_profile": "https://Stackoverflow.com/users/452120", "pm_score": 5, "selected": false, "text": "CIPHER.EXE /U /N\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
11,724
<p>On my <strong>Windows XP</strong> machine Visual Studio 2003 2005 and 2008 all complain that I cannot start debugging my <strong>web application</strong> because I must either be a member of the Debug Users group or of the Administrators group. So, I am an Administrator and I added Debug Users just in case, and it still complains.</p> <p>Short of reformatting my machine and starting over, has anyone encountered this and fixed it [with some undocumented command]?</p>
[ { "answer_id": 11842, "author": "Matt Nelson", "author_id": 788, "author_profile": "https://Stackoverflow.com/users/788", "pm_score": 0, "selected": false, "text": "VsJITDebugger.exe -p <PID>" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
11,734
<p>I am developing an application to install a large number of data files from multiple DVDs. The application will prompt the user to insert the next disk, however Windows will automatically try to open that disk either in an explorer window or ask the user what to do with the new disk.<br> How can I intercept and cancel auto play messages from my application?</p>
[ { "answer_id": 11735, "author": "Brian Ensink", "author_id": 1254, "author_profile": "https://Stackoverflow.com/users/1254", "pm_score": 3, "selected": true, "text": "IQueryCancelAutoPlay" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1254/" ]
11,740
<p>In a web application like wiki or forums or blogging software, it is often useful to store your data in a relational database. Since many hosting companies offer a single database with their hosting plans (with additional databases costing extra) it is very useful for your users when your database objects (tables, views, constraints, and stored procedures) have a common prefix. It is typical for applications aware of database scarcity to have a hard-coded table prefix. I want more, however. Specifically, I'd like to have a table prefix that users can designate—say in the web.config file (with an appropriate default, of course).</p> <p>Since I hate coding <a href="https://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete" rel="nofollow noreferrer">CRUD</a> operations by hand, I prefer to work through a competent OR/M and have used (and enjoyed) LINQ to SQL, Subsonic, and ADO.Net. I'm having some thrash in a new project, however, when it comes to putting a table prefix in a user's web.config file. Are there any .Net-based OR/M products that can handle this scenario elegantly?</p> <p>The best I have been able to come up with so far is using LINQ to SQL with an external mapping file that I'd have to update somehow based on an as-yet hypothetical web.config setting.</p> <p>Anyone have a better solution? I tried to make it happen in Entity Framework, but that turned into a mess quickly. (Due to my unfamiliarity with EF? Possibly.) How about SubSonic? Does it have an option to apply a table prefix besides at code generation time?</p>
[ { "answer_id": 12089, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 1, "selected": false, "text": "schema" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1336/" ]
11,761
<p>I have a web service that queries data from this json file, but I don't want the web service to have to access the file every time. I'm thinking that maybe I can store the data somewhere else (maybe in memory) so the web service can just get the data from there the next time it's trying to query the same data. I kinda understand what needs to be done but I'm just not sure how to actually do it. How do we persist data in a web service? </p> <p><strong>Update:</strong> Both suggestions, caching and using static variables, look good. Maybe I should just use both so I can look at one first, and if it's not in there, use the second one, if it's not in there either, then I'll look at the json file.</p>
[ { "answer_id": 11826, "author": "Mark Glorie", "author_id": 952, "author_profile": "https://Stackoverflow.com/users/952", "pm_score": 4, "selected": true, "text": "Context.Cache.Insert(\"foo\", _\n Foo, _\n Nothing, _\n DateAdd(DateInterval...
2008/08/14
[ "https://Stackoverflow.com/questions/11761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1381/" ]
11,762
<p>I needed some simple string encryption, so I wrote the following code (with a great deal of "inspiration" from <a href="http://www.codeproject.com/KB/security/DotNetCrypto.aspx" rel="noreferrer">here</a>):</p> <pre><code> // create and initialize a crypto algorithm private static SymmetricAlgorithm getAlgorithm(string password) { SymmetricAlgorithm algorithm = Rijndael.Create(); Rfc2898DeriveBytes rdb = new Rfc2898DeriveBytes( password, new byte[] { 0x53,0x6f,0x64,0x69,0x75,0x6d,0x20, // salty goodness 0x43,0x68,0x6c,0x6f,0x72,0x69,0x64,0x65 } ); algorithm.Padding = PaddingMode.ISO10126; algorithm.Key = rdb.GetBytes(32); algorithm.IV = rdb.GetBytes(16); return algorithm; } /* * encryptString * provides simple encryption of a string, with a given password */ public static string encryptString(string clearText, string password) { SymmetricAlgorithm algorithm = getAlgorithm(password); byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, algorithm.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(clearBytes, 0, clearBytes.Length); cs.Close(); return Convert.ToBase64String(ms.ToArray()); } /* * decryptString * provides simple decryption of a string, with a given password */ public static string decryptString(string cipherText, string password) { SymmetricAlgorithm algorithm = getAlgorithm(password); byte[] cipherBytes = Convert.FromBase64String(cipherText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, algorithm.CreateDecryptor(), CryptoStreamMode.Write); cs.Write(cipherBytes, 0, cipherBytes.Length); cs.Close(); return System.Text.Encoding.Unicode.GetString(ms.ToArray()); } </code></pre> <p>The code appears to work fine, except that when decrypting data with an incorrect key, I get a CryptographicException - "Padding is invalid and cannot be removed" - on the cs.Close() line in decryptString. </p> <p>example code:</p> <pre><code> string password1 = "password"; string password2 = "letmein"; string startClearText = "The quick brown fox jumps over the lazy dog"; string cipherText = encryptString(startClearText, password1); string endClearText = decryptString(cipherText, password2); // exception thrown </code></pre> <p>My question is, is this to be expected? I would have thought that decrypting with the wrong password would just result in nonsense output, rather than an exception.</p>
[ { "answer_id": 14971080, "author": "jbtule", "author_id": 637783, "author_profile": "https://Stackoverflow.com/users/637783", "pm_score": 3, "selected": false, "text": "AESThenHMAC.AesSimpleDecryptWithPassword(ciphertext, password)" }, { "answer_id": 19835066, "author": "Yani...
2008/08/14
[ "https://Stackoverflow.com/questions/11762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
11,767
<p>How can I present a control to the user that allows him/her to select a directory?</p> <p>There doesn't seem to be any native .net controls which do this?</p>
[ { "answer_id": 11781, "author": "David Wengier", "author_id": 489, "author_profile": "https://Stackoverflow.com/users/489", "pm_score": 3, "selected": false, "text": "FolderBrowserDialog" }, { "answer_id": 7634179, "author": "Chandima", "author_id": 976547, "author_pr...
2008/08/14
[ "https://Stackoverflow.com/questions/11767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
11,783
<p>Given an empty method body, will the JIT optimize out the call (I know the C# compiler won't). How would I go about finding out? What tools should I be using and where should I be looking?</p> <p>Since I'm sure it'll be asked, the reason for the empty method is a preprocessor directive.</p> <hr> <p>@Chris: Makes sense, but it could optimize out calls to the method. So the method would still exist, but static calls to it could be removed (or at least inlined...)</p> <p>@Jon: That just tells me the language compiler doesn't do anything. I think what I need to do is run my dll through ngen and look at the assembly.</p>
[ { "answer_id": 12078, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 4, "selected": false, "text": "void DoSomethingIfCompFlag() {\n#if COMPILER_FLAG\n //your code\n#endif\n}\n" } ]
2008/08/14
[ "https://Stackoverflow.com/questions/11783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34/" ]
11,804
<p>I'm working on a web service at the moment and there is the potential that the returned results could be quite large ( > 5mb). </p> <p>It's perfectly valid for this set of data to be this large and the web service can be called either sync or async, but I'm wondering what people's thoughts are on the following:</p> <ol> <li><p>If the connection is lost, the entire resultset will have to be regenerated and sent again. Is there any way I can do any sort of "resume" if the connection is lost or reset?</p></li> <li><p>Is sending a result set this large even appropriate? Would it be better to implement some sort of "paging" where the resultset is generated and stored on the server and the client can then download chunks of the resultset in smaller amounts and re-assemble the set at their end?</p></li> </ol>
[ { "answer_id": 920922, "author": "DavidValeri", "author_id": 107057, "author_profile": "https://Stackoverflow.com/users/107057", "pm_score": 3, "selected": true, "text": "WS-ReliableMessaging" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/11804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
11,806
<p>I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem that I noticed was that Powershell was logged in as ASPNET instead of my Active Directory Account. How do I force my Powershell session to be authenticated with another Active Directory Account?</p> <p>Basically, the script that I have so far looks something like this:</p> <pre><code>RunspaceConfiguration rc = RunspaceConfiguration.Create(); PSSnapInException snapEx = null; rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapEx); Runspace runspace = RunspaceFactory.CreateRunspace(rc); runspace.Open(); Pipeline pipeline = runspace.CreatePipeline(); using (pipeline) { pipeline.Commands.AddScript("Get-Mailbox -identity 'user.name'"); pipeline.Commands.Add("Out-String"); Collection&lt;PSObject&gt; results = pipeline.Invoke(); if (pipeline.Error != null &amp;&amp; pipeline.Error.Count &gt; 0) { foreach (object item in pipeline.Error.ReadToEnd()) resultString += "Error: " + item.ToString() + "\n"; } runspace.Close(); foreach (PSObject obj in results) resultString += obj.ToString(); } return resultString; </code></pre>
[ { "answer_id": 12554, "author": "Otto", "author_id": 519, "author_profile": "https://Stackoverflow.com/users/519", "pm_score": 3, "selected": false, "text": "using System;\nusing System.Data;\nusing System.Configuration;\nusing System.Web;\nusing System.Web.Security;\nusing System.Web.UI...
2008/08/15
[ "https://Stackoverflow.com/questions/11806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
11,809
<p>The only thing I've found has been;</p> <pre class="lang-css prettyprint-override"><code>.hang { text-indent: -3em; margin-left: 3em; } </code></pre> <p>The only way for this to work is putting text in a paragraph, which causes those horribly unsightly extra lines. I'd much rather just have them in a <code>&lt;span class="hang"&gt;&lt;/span&gt;</code> type of thing.</p> <p>I'm also looking for a way to further indent than just a single-level of hanging. Using paragraphs to stack the indentions doesn't work.</p>
[ { "answer_id": 11815, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 5, "selected": true, "text": "<span>" }, { "answer_id": 8090502, "author": "David Barnett", "author_id": 1008297, "author_profile": "https:/...
2008/08/15
[ "https://Stackoverflow.com/questions/11809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/362/" ]
11,820
<p>This <a href="https://stackoverflow.com/questions/11782/file-uploads-via-web-services">question and answer</a> shows how to send a file as a byte array through an XML web service. How much overhead is generated by using this method for file transfer? I assume the data looks something like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;bytes&gt; &lt;byte&gt;16&lt;/byte&gt; &lt;byte&gt;28&lt;/byte&gt; &lt;byte&gt;127&lt;/byte&gt; ... &lt;/bytes&gt; </code></pre> <p>If this format is correct, the bytes must first be converted to UTF-8 characters. Each of these characters allocates 8 bytes. Are the bytes stored in base 10, hex, or binary characters? How much larger does the file appear as it is being sent due to the XML data and character encoding? Is compression built into web services?</p>
[ { "answer_id": 11832, "author": "Kevin Dente", "author_id": 9, "author_profile": "https://Stackoverflow.com/users/9", "pm_score": 5, "selected": true, "text": "base64" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/11820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
11,854
<p>In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, which would be very easily achieved with polymorphism. The problem I have with it is that inheritance implies the <em>is a</em> relationship, rather than the <em>has a</em> relationship. For example, several objects <em>have a</em> damage counter, but to make this easy to use in an object list, polymorphism could be used - except that would imply an <em>is a</em> relationship which wouldn't be true. (A person <em>is not a</em> damage counter.)</p> <p>The only solution I can think of is to have a member of the class return the proper object type when implicitly casted instead of relying on inheritance. Would it be better to forgo the <em>is a</em> / <em>has a</em> ideal in exchange for ease of programming?</p> <p>Edit: To be more specific, I am using C++, so using polymorphism would allow the different objects to "act the same" in the sense that the derived classes could reside within a single list and be operated upon by a virtual function of the base class. The use of an interface (or imitating them via inheritance) seems like a solution I would be willing to use.</p>
[ { "answer_id": 11859, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 0, "selected": false, "text": "Damageable" }, { "answer_id": 11864, "author": "Derek Park", "author_id": 872, "author_profile": "https:...
2008/08/15
[ "https://Stackoverflow.com/questions/11854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256/" ]
11,879
<p>Instead of returning a common string, is there a way to return classic objects? If not: what are the best practices? Do you transpose your object to xml and rebuild the object on the other side? What are the other possibilities? </p>
[ { "answer_id": 11899, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 4, "selected": true, "text": "[Serializable]\npublic class MyClass\n{\n public string MyString {get; set;}\n\n [Serializable]\n public MyOtherClass My...
2008/08/15
[ "https://Stackoverflow.com/questions/11879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391/" ]
11,915
<p>How would you reccommend handling RSS Feeds in ASP.NET MVC? Using a third party library? Using the RSS stuff in the BCL? Just making an RSS view that renders the XML? Or something completely different?</p>
[ { "answer_id": 13662, "author": "Ricky", "author_id": 653, "author_profile": "https://Stackoverflow.com/users/653", "pm_score": 5, "selected": false, "text": "<%@ Page ContentType=\"application/rss+xml\" Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"PostRSS.aspx.cs\" Inherits=\"r...
2008/08/15
[ "https://Stackoverflow.com/questions/11915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
11,919
<p>Okay, I've looked all over the internet for a good solution to get PHP and MySQL working on IIS7.0. It's nearly impossible, I've tried it so many times and given up in vain. Please please help by linking some great step-by-step tutorial to adding PHP and MySQL on IIS7.0 from scratch. PHP and MySQL are essential for installing any CMS.</p>
[ { "answer_id": 94341, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 2, "selected": false, "text": ";extension=php_mysql.dll\n" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/11919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1392/" ]
11,926
<p>I'm new to MVC (and ASP.Net routing). I'm trying to map <code>*.aspx</code> to a controller called <code>PageController</code>. </p> <pre><code>routes.MapRoute( "Page", "{name}.aspx", new { controller = "Page", action = "Index", id = "" } ); </code></pre> <p>Wouldn't the code above map *.aspx to <code>PageController</code>? When I run this and type in any .aspx page I get the following error:</p> <blockquote> <p>The controller for path '/Page.aspx' could not be found or it does not implement the IController interface. Parameter name: controllerType</p> </blockquote> <p>Is there something I'm not doing here?</p>
[ { "answer_id": 11937, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 0, "selected": false, "text": "routes.MapRoute(\n \"Page\", \n \"{Page}.aspx\", \n new { controller = \"Page\", action = \"Index\", id = \"\" }\...
2008/08/15
[ "https://Stackoverflow.com/questions/11926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/105/" ]
11,930
<p>How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?</p> <p>This is somewhat easy in .NET if you know your way around. But how do you do it in Java?</p>
[ { "answer_id": 11960, "author": "Nick Brosnahan", "author_id": 528, "author_profile": "https://Stackoverflow.com/users/528", "pm_score": 1, "selected": false, "text": "traceroute to www.amazon.com (72.21.203.1), 1 hops max, 40 byte packets\n 1 10.0.1.1 (10.0.1.1) 0.694 ms 0.445 ms 0....
2008/08/15
[ "https://Stackoverflow.com/questions/11930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
11,950
<p>I'm looking for the best way to log errors in an ASP.NET application. I want to be able to receive emails when errors occurs in my application, with detailed information about the Exception and the current Request.</p> <p>In my company we used to have our own ErrorMailer, catching everything in the Global.asax Application_Error. It was "Ok" but not very flexible nor configurable.</p> <p>We switched recently to NLog. It's much more configurable, we can define different targets for the errors, filter them, buffer them (not tried yet). It's a very good improvement.</p> <p>But I discovered lately that there's a whole Namespace in the .Net framework for this purpose : <a href="http://msdn.microsoft.com/en-us/library/system.web.management.aspx" rel="noreferrer">System.Web.Management</a> and it can be configured in the <a href="http://msdn.microsoft.com/en-us/library/2fwh2ss9(VS.80).aspx" rel="noreferrer">healthMonitoring</a> section of web.config.</p> <p>Have you ever worked with .Net health monitoring? What is your solution for error logging?</p>
[ { "answer_id": 11961, "author": "brendan", "author_id": 225, "author_profile": "https://Stackoverflow.com/users/225", "pm_score": 0, "selected": false, "text": "Try\n Dim p as New Person()\n p.Name = \"Joe\"\n p.Age = 30\nCatch ex as Exception\n Log.LogException(ex,\"Err creating per...
2008/08/15
[ "https://Stackoverflow.com/questions/11950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130/" ]
12,009
<p>How can I pipe the new password to smbpasswd so I can automate my installation process.</p>
[ { "answer_id": 12026, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 4, "selected": false, "text": "(echo oldpasswd; echo newpasswd) | smbpasswd -s\n" }, { "answer_id": 12032, "author": "UnkwnTech", "autho...
2008/08/15
[ "https://Stackoverflow.com/questions/12009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
12,039
<p>I have an application that sometimes causes a BSOD on a Win XP machine. Trying to find out more, I loaded up the resulting *.dmp file (from C:\Windows\Minidump), but get this message when in much of the readout when doing so:</p> <pre><code>********************************************************************* * Symbols can not be loaded because symbol path is not initialized. * * * * The Symbol Path can be set by: * * using the _NT_SYMBOL_PATH environment variable. * * using the -y &lt;symbol_path&gt; argument when starting the debugger. * * using .sympath and .sympath+ * ********************************************************************* </code></pre> <p>What does this mean, and how do I "fix" it?</p>
[ { "answer_id": 12132, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "_NT_SYMBOL_PATH" }, { "answer_id": 1493488, "author": "Community", "author_id": -1, "author_profile": "ht...
2008/08/15
[ "https://Stackoverflow.com/questions/12039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
12,051
<p>If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?</p> <p>For example, if I inherit from the Exception class I want to do something like this:</p> <pre><code>class MyExceptionClass : Exception { public MyExceptionClass(string message, string extraInfo) { //This is where it's all falling apart base(message); } } </code></pre> <p>Basically what I want is to be able to pass the string message to the base Exception class.</p>
[ { "answer_id": 12052, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 12, "selected": true, "text": "public class MyExceptionClass : Exception\n{\n public MyExceptionClass(string message, string extrainfo) : base(message)\...
2008/08/15
[ "https://Stackoverflow.com/questions/12051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
12,088
<p>I wonder if anyone uses commercial/free java obfuscators on his own commercial product. I know only about one project that actually had an obfuscating step in the ant build step for releases.</p> <p>Do you obfuscate? And if so, why do you obfuscate?</p> <p>Is it really a way to protect the code or is it just a better feeling for the developers/managers?</p> <p><strong>edit:</strong> Ok, I to be exact about my point: Do you obfuscate to protect your IP (your algorithms, the work you've put into your product)? I won't obfuscate for security reasons, that doesn't feel right. So I'm only talking about protecting your applications code against competitors.</p> <p><a href="https://stackoverflow.com/users/988/staffan">@staffan</a> has a good point:</p> <blockquote> <p>The reason to stay away from chaining code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application.</p> </blockquote>
[ { "answer_id": 12100, "author": "izb", "author_id": 974, "author_profile": "https://Stackoverflow.com/users/974", "pm_score": 4, "selected": false, "text": "public void doSomething()\n{\n /* Generated config class containing static finals: */\n if (Configuration.ISMOTOROLA)\n {\...
2008/08/15
[ "https://Stackoverflow.com/questions/12088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834/" ]
12,095
<p>Our team is creating a new recruitment workflow system to replace an old one. I have been tasked with migrating the old data into the new schema. I have decided to do this by creating a small Windows Forms project as the schema are radically different and straight TSQL scripts are not an adequate solution.</p> <p>The main sealed class 'ImportController' that does the work declares the following delegate event:</p> <pre><code>public delegate void ImportProgressEventHandler(object sender, ImportProgressEventArgs e); public static event ImportProgressEventHandler importProgressEvent; </code></pre> <p>The main window starts a static method in that class using a new thread:</p> <pre><code>Thread dataProcessingThread = new Thread(new ParameterizedThreadStart(ImportController.ImportData)); dataProcessingThread.Name = "Data Importer: Data Processing Thread"; dataProcessingThread.Start(settings); </code></pre> <p>the ImportProgressEvent args carries a string message, a max int value for the progress bar and an current progress int value. The Windows form subcribes to the event:</p> <pre><code>ImportController.importProgressEvent += new ImportController.ImportProgressEventHandler(ImportController_importProgressEvent); </code></pre> <p>And responds to the event in this manner using it's own delegate:</p> <pre><code> private delegate void TaskCompletedUIDelegate(string completedTask, int currentProgress, int progressMax); private void ImportController_importProgressEvent(object sender, ImportProgressEventArgs e) { this.Invoke(new TaskCompletedUIDelegate(this.DisplayCompletedTask), e.CompletedTask, e.CurrentProgress, e.ProgressMax); } </code></pre> <p>Finally the progress bar and listbox are updated:</p> <pre><code>private void DisplayCompletedTask(string completedTask, int currentProgress, int progressMax) { string[] items = completedTask.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in items) { this.lstTasks.Items.Add(item); } if (currentProgress &gt;= 0 &amp;&amp; progressMax &gt; 0 &amp;&amp; currentProgress &lt;= progressMax) { this.ImportProgressBar.Maximum = progressMax; this.ImportProgressBar.Value = currentProgress; } } </code></pre> <p>The thing is the ListBox seems to update very quickly, but the progress bar never moves until the batch is almost complete anyway ??? what gives ?</p>
[ { "answer_id": 12115, "author": "Peteter", "author_id": 1192, "author_profile": "https://Stackoverflow.com/users/1192", "pm_score": 0, "selected": false, "text": "Application.DoEvents();" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2083160/" ]
12,103
<p>When I am running the following statement:</p> <pre><code>@filtered = map {s/&amp;nbsp;//g} @outdata; </code></pre> <p>it is returning an empty list instead of the filtered list that I expected. What I am trying to do is remove every occurrence of <code>&amp;nbsp;</code> from an array of string (which is an XML file).</p> <p>Obviously, I am not understanding something. Can anyone tell me the correct way to do this might be, and why this isn't working for me as is?</p>
[ { "answer_id": 12108, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "@filtered = map {s/&nbsp;//g; $_} @outdata;\n" }, { "answer_id": 13685, "author": "Cebjyre", "author_id": 1...
2008/08/15
[ "https://Stackoverflow.com/questions/12103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/274/" ]
12,135
<p>I'm using an XmlSerializer to deserialize a particular type in mscorelib.dll</p> <pre><code>XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) ); return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) ); </code></pre> <p>This throws a caught <code>FileNotFoundException</code> when the assembly is loaded:</p> <blockquote> <p>"Could not load file or assembly 'mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."</p> </blockquote> <p>FusionLog:</p> <pre><code>=== Pre-bind state information === LOG: User = ### LOG: DisplayName = mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86 (Fully-specified) LOG: Appbase = file:///C:/localdir LOG: Initial PrivatePath = NULL Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\localdir\bin\Debug\appname.vshost.exe.Config LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86 LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.EXE. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.EXE. </code></pre> <p>As far as I know there is no mscorlib.XmlSerializers.DLL, I think the DLL name has bee auto generated by .Net looking for the serializer. </p> <p>You have the option of creating a myApplication.XmlSerializers.DLL when compiling to optimise serializations, so I assume this is part of the framework's checking for it.</p> <p>The problem is that this appears to be causing a delay in loading the application - it seems to hang for a few seconds at this point.</p> <p>Any ideas how to avoid this or speed it up?</p>
[ { "answer_id": 953571, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "XmlRootAttribute rootAttribute = new XmlRootAttribute();\nrootAttribute.ElementName = \"SomeRootName\";\nrootAttribute.IsNulla...
2008/08/15
[ "https://Stackoverflow.com/questions/12135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
12,140
<p>A database application that I'm currently working on, stores all sorts of settings in the database. Most of those settings are there to customize certain business rules, but there's also some other stuff in there.</p> <p>The app contains objects that specifically do a certain task, e.g., a certain complicated calculation. Those non-UI objects are unit-tested, but also need access to lots of those global settings. The way we've implemented this right now, is by giving the objects properties that are filled by the Application Controller at runtime. When testing, we create the objects in the test and fill in values for testing (not from the database).</p> <p>This works better, in any case much better than having all those objects need some global <em>Settings</em> object --- that of course effectively makes unit testing impossible :) Disadvantage can be that you sometimes need to set a dozen of properties, or that you need to let those properties 'percolate' into sub-objects.</p> <p><strong>So the general question is</strong>: how do you provide access to global application settings in your projects, without the need for global variables, while still being able to unit test your code? This must be a problem that's been solved 100's of times...</p> <p>(Note: I'm not too much of an experienced programmer, as you'll have noticed; but I love to learn! And of course, I've already done research into this topic, but I'm really looking for some first-hand experiences)</p>
[ { "answer_id": 12183, "author": "Lars Mæhlum", "author_id": 960, "author_profile": "https://Stackoverflow.com/users/960", "pm_score": 0, "selected": false, "text": "public class MySettings\n{\n public static double Setting1\n { get { return SettingsCache.Instance.GetDouble(\"Se...
2008/08/15
[ "https://Stackoverflow.com/questions/12140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1037/" ]
12,141
<p>For example: Updating all rows of the customer table because you forgot to add the where clause.</p> <ol> <li>What was it like, realizing it and reporting it to your coworkers or customers? </li> <li>What were the lessons learned?</li> </ol>
[ { "answer_id": 12145, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 3, "selected": false, "text": "delete from [table] where [condition]\n" }, { "answer_id": 12149, "author": "Surgical Coder", "author_id": 1276, ...
2008/08/15
[ "https://Stackoverflow.com/questions/12141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/990/" ]
12,144
<p>OK, so I don't want to start a holy-war here, but we're in the process of trying to consolidate the way we handle our application configuration files and we're struggling to make a decision on the best approach to take. At the moment, every application we distribute is using it's own ad-hoc configuration files, whether it's property files (ini style), XML or JSON (internal use only at the moment!).</p> <p>Most of our code is Java at the moment, so we've been looking at <a href="http://commons.apache.org/configuration/" rel="noreferrer">Apache Commons Config</a>, but we've found it to be quite verbose. We've also looked at <a href="http://xmlbeans.apache.org/" rel="noreferrer">XMLBeans</a>, but it seems like a lot of faffing around. I also feel as though I'm being pushed towards XML as a format, but my clients and colleagues are apprehensive about trying something else. I can understand it from the client's perspective, everybody's heard of XML, but at the end of the day, shouldn't be using the right tool for the job?</p> <p>What formats and libraries are people using in production systems these days, is anyone else trying to avoid the <a href="http://www.codinghorror.com/blog/archives/001114.html" rel="noreferrer">angle bracket tax</a>?</p> <p><strong><em>Edit:</strong> really needs to be a cross platform solution: Linux, Windows, Solaris etc. and the choice of library used to interface with configuration files is just as important as the choice of format.</em></p>
[ { "answer_id": 12277, "author": "engtech", "author_id": 175, "author_profile": "https://Stackoverflow.com/users/175", "pm_score": 5, "selected": false, "text": "<user id=\"babooey\" on=\"cpu1\">\n <firstname>Bob</firstname>\n <lastname>Abooey</lastname>\n <department>adv</depart...
2008/08/15
[ "https://Stackoverflow.com/questions/12144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
12,159
<p>I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people have gone about testing those kinds of issues that only show up when two threads interact in a given manner?</p> <p>This seems like a really key problem for programmers today, it would be useful to pool our knowledge on this one imho.</p>
[ { "answer_id": 12223, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 2, "selected": false, "text": "PropertyNotifyChanged" }, { "answer_id": 125487, "author": "Kevin Wong", "author_id": 4792, "author_pr...
2008/08/15
[ "https://Stackoverflow.com/questions/12159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/912/" ]
12,176
<p>Is there any way to include the SVN repository revision number in the version string of a .NET assembly? Something like Major.Minor.SVNRev</p> <p>I've seen mention of doing this with something like CC.NET (although on ASP.NET actually), but is there any way to do it without any extra software? I've done similar things in C/C++ before using build batch scripts, but in was accomplished by reading the version number, then having the script write out a file called "ver.h" everytime with something to the effect of:</p> <pre><code>#define MAJORVER 4 #define MINORVER 23 #define SOURCEVER 965 </code></pre> <p>We would then use these defines to generate the version string.</p> <p>Is something like this possible for .NET?</p>
[ { "answer_id": 653382, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "using System;\nusing Microsoft.Build.Framework;\nusing Microsoft.Build.Utilities;\nusing DotSVN.Common;\nusing DotSVN.Common.E...
2008/08/15
[ "https://Stackoverflow.com/questions/12176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
12,225
<p>I have a database that contains a date and we are using the MaskedEditExtender (MEE) and MaskedEditValidator to make sure the dates are appropriate. However, we want the Admins to be able to go in and change the data (specifically the date) if necessary. </p> <p>How can I have the MEE field pre-populate with the database value when the data is shown on the page? I've tried to use 'bind' in the 'InitialValue' property but it doesn't populate the textbox.</p> <p>Thanks.</p>
[ { "answer_id": 16718, "author": "Keng", "author_id": 730, "author_profile": "https://Stackoverflow.com/users/730", "pm_score": 2, "selected": true, "text": "Mask=\"99/99/9999 99:99:99\"" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
12,271
<p>I have created a template for Visual Studio 2008 and it currently shows up under File->New Project->Visual C#. However, it is only really specific to Visual C#/Windows but I can't work out how to get it to show up under the "Windows" category and not the more general "Visual C#".</p>
[ { "answer_id": 12491, "author": "Aidan Ryan", "author_id": 1042, "author_profile": "https://Stackoverflow.com/users/1042", "pm_score": 4, "selected": true, "text": "<VisualStudioInstallDir>\\Common7\\IDE\\ItemTemplates\\CSharp\\\nMy Documents\\Visual Studio 2008\\Templates\\ProjectTempla...
2008/08/15
[ "https://Stackoverflow.com/questions/12271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214/" ]
12,297
<p>I've got a Repeater that lists all the <code>web.sitemap</code> child pages on an ASP.NET page. Its <code>DataSource</code> is a <code>SiteMapNodeCollection</code>. But, I don't want my registration form page to show up there.</p> <pre><code>Dim Children As SiteMapNodeCollection = SiteMap.CurrentNode.ChildNodes 'remove registration page from collection For Each n As SiteMapNode In SiteMap.CurrentNode.ChildNodes If n.Url = "/Registration.aspx" Then Children.Remove(n) End If Next RepeaterSubordinatePages.DataSource = Children </code></pre> <p>The <code>SiteMapNodeCollection.Remove()</code> method throws a </p> <blockquote> <p>NotSupportedException: "Collection is read-only".</p> </blockquote> <p>How can I remove the node from the collection before DataBinding the Repeater?</p>
[ { "answer_id": 12303, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 1, "selected": false, "text": "//this will now be an enumeration, rather than a read only collection\nDim children = SiteMap.CurrentNode.ChildNodes.Where( _\n ...
2008/08/15
[ "https://Stackoverflow.com/questions/12297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
12,304
<p>This is a problem I have seen other people besides myself having, and I haven't found a good explanation.</p> <p>Let's say you have a maintenance plan with a task to check the database, something like this:</p> <pre><code>USE [MyDb] GO DBCC CHECKDB with no_infomsgs, all_errormsgs </code></pre> <p>If you go look in your logs after the task executes, you might see something like this:</p> <pre><code>08/15/2008 06:00:22,spid55,Unknown,DBCC CHECKDB (mssqlsystemresource) executed by NT AUTHORITY\SYSTEM found 0 errors and repaired 0 errors. Elapsed time: 0 hours 0 minutes 0 seconds. 08/15/2008 06:00:21,spid55,Unknown,DBCC CHECKDB (master) executed by NT AUTHORITY\SYSTEM found 0 errors and repaired 0 errors. Elapsed time: 0 hours 0 minutes 0 seconds. </code></pre> <p>Instead of checking MyDb, it checked master and msssqlsystemresource.</p> <p>Why?</p> <p>My workaround is to create a Sql Server Agent Job with this:</p> <pre><code>dbcc checkdb ('MyDb') with no_infomsgs, all_errormsgs; </code></pre> <p>That always works fine.</p> <pre><code>08/15/2008 04:26:04,spid54,Unknown,DBCC CHECKDB (MyDb) WITH all_errormsgs&lt;c/&gt; no_infomsgs executed by NT AUTHORITY\SYSTEM found 0 errors and repaired 0 errors. Elapsed time: 0 hours 26 minutes 3 seconds. </code></pre>
[ { "answer_id": 12320, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 1, "selected": false, "text": "GO" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
12,306
<p>I'm trying to serialize a Type object in the following way:</p> <pre><code>Type myType = typeof (StringBuilder); var serializer = new XmlSerializer(typeof(Type)); TextWriter writer = new StringWriter(); serializer.Serialize(writer, myType); </code></pre> <p>When I do this, the call to Serialize throws the following exception: </p> <blockquote> <p>"The type System.Text.StringBuilder was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."</p> </blockquote> <p>Is there a way for me to serialize the <code>Type</code> object? Note that I am not trying to serialize the <code>StringBuilder</code> itself, but the <code>Type</code> object containing the metadata about the <code>StringBuilder</code> class.</p>
[ { "answer_id": 12314, "author": "AdamSane", "author_id": 805, "author_profile": "https://Stackoverflow.com/users/805", "pm_score": 1, "selected": false, "text": "public abstract class Type : System.Reflection.MemberInfo\n Member of System\n\nSummary:\nRepresents type declarations: cla...
2008/08/15
[ "https://Stackoverflow.com/questions/12306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767/" ]
12,319
<p>I'm looking to the equivalent of Windows <a href="http://msdn.microsoft.com/fr-fr/library/yeby3zcb.aspx" rel="noreferrer"><code>_wfopen()</code></a> under Mac OS X. Any idea?</p> <p>I need this in order to port a Windows library that uses <code>wchar*</code> for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library.</p>
[ { "answer_id": 13562, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 3, "selected": false, "text": "fopen" }, { "answer_id": 265407, "author": "Vincent Robert", "author_id": 268, "author_profile": "http...
2008/08/15
[ "https://Stackoverflow.com/questions/12319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/268/" ]
12,330
<p>Is there any known way of listing the WMI classes and their properties available for a particular system? Im interested in a vbscript approach, but please suggest anything really :)</p> <p>P.S. Great site.</p>
[ { "answer_id": 78268, "author": "JustinD", "author_id": 12063, "author_profile": "https://Stackoverflow.com/users/12063", "pm_score": 2, "selected": false, "text": "ManagementPath l_Path = new ManagementPath(l_className);\nManagementClass l_Class = new ManagementClass(myScope, l_Manageme...
2008/08/15
[ "https://Stackoverflow.com/questions/12330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
12,332
<p>I am looking for a more technical explanation than the OS calls the function.</p> <p>Is there a website or book?</p>
[ { "answer_id": 12353, "author": "Vincent Robert", "author_id": 268, "author_profile": "https://Stackoverflow.com/users/268", "pm_score": 3, "selected": false, "text": "main()" }, { "answer_id": 33300, "author": "Anders", "author_id": 3501, "author_profile": "https://S...
2008/08/15
[ "https://Stackoverflow.com/questions/12332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
12,348
<p>I'm running PHP 5.2.3 on Windows 2000 Server with IIS 5. I'm trying to get cURL working, so in my <strong>php.ini</strong> file, I have this line:</p> <blockquote> <p>extension_dir ="F:\PHP\ext"</p> </blockquote> <p>And later, I have:</p> <blockquote> <p>extension=php_curl.dll</p> </blockquote> <p>The file <strong>F:\PHP\ext\php_curl.dll</strong> exists, but when I try to run any PHP script, I get this in the error log:</p> <blockquote> <p>PHP Warning: PHP Startup: Unable to load dynamic library 'F:\PHP\ext \php_curl.dll' - The specified module could not be found. in Unknown on line 0 </p> </blockquote>
[ { "answer_id": 12349, "author": "Derek Kurth", "author_id": 1418, "author_profile": "https://Stackoverflow.com/users/1418", "pm_score": 6, "selected": true, "text": "php_curl.dll" }, { "answer_id": 28591600, "author": "elQuique", "author_id": 4580982, "author_profile"...
2008/08/15
[ "https://Stackoverflow.com/questions/12348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1418/" ]
12,368
<p>The .NET garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <code>MyClass</code> to call</p> <pre><code>MyClass.Dispose() </code></pre> <p>and free up all the used space by variables and objects in <code>MyClass</code>?</p>
[ { "answer_id": 12377, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 2, "selected": false, "text": "public class MyClass : IDisposable\n{\n public void Dispose()\n {\n // cleanup here\n }\n}\n" }, { "an...
2008/08/15
[ "https://Stackoverflow.com/questions/12368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1271/" ]
12,374
<p>We’ve found that the unit tests we’ve written for our C#/C++ code have really paid off. But we still have thousands of lines of business logic in stored procedures, which only really get tested in anger when our product is rolled out to a large number of users. </p> <p>What makes this worse is that some of these stored procedures end up being very long, because of the performance hit when passing temporary tables between SPs. This has prevented us from refactoring to make the code simpler.</p> <p>We have made several attempts at building unit tests around some of our key stored procedures (primarily testing the performance), but have found that setting up the test data for these tests is really hard. For example, we end up copying around test databases. In addition to this, the tests end up being really sensitive to change, and even the smallest change to a stored proc. or table requires a large amount of changes to the tests. So after many builds breaking due to these database tests failing intermittently, we’ve just had to pull them out of the build process.</p> <p>So, the main part of my questions is: has anyone ever successfully written unit tests for their stored procedures?</p> <p>The second part of my questions is whether unit testing would be/is easier with linq? </p> <p>I was thinking that rather than having to set up tables of test data, you could simply create a collection of test objects, and test your linq code in a “linq to objects” situation? (I am a totally new to linq so don’t know if this would even work at all)</p>
[ { "answer_id": 25204, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 5, "selected": true, "text": "Public MustInherit Class Repository(Of T As Class)\n Implements IRepository(Of T)\n\n Private mConnectionString As...
2008/08/15
[ "https://Stackoverflow.com/questions/12374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1078/" ]
12,406
<p>From what I've read, <a href="http://blogs.msdn.com/astebner/archive/2008/08/11/8849574.aspx" rel="nofollow noreferrer">VS 2008 SP1 and Team Foundation Server SP1 packages are traditional service packs that require you to first install the original versions before you will be able to install the SP</a>.</p> <p>Is there a way, supported or not, to slipstream the install?</p>
[ { "answer_id": 1707074, "author": "Nagendra", "author_id": 207684, "author_profile": "https://Stackoverflow.com/users/207684", "pm_score": 2, "selected": false, "text": "::Extract the original visual studio 2008 installation to directory VS2k8WithSP1.\nmsiexec.exe /a \"g:\\vs_setup.msi\"...
2008/08/15
[ "https://Stackoverflow.com/questions/12406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
12,476
<p>This is a self-explanatory question:</p> <p>Why does this thing bubble into my try catch's even when nothing is wrong? </p> <p>Why is it showing up in my log, hundreds of times?</p> <p><strong>I know its a newb question, but if this site is gonna get search ranking and draw in newbs we have to ask them</strong></p>
[ { "answer_id": 18507130, "author": "Luke Puplett", "author_id": 107783, "author_profile": "https://Stackoverflow.com/users/107783", "pm_score": 0, "selected": false, "text": "Thread.Abort" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1220/" ]
12,482
<p>I have CruiseControl.NET Version 1.4 set up on my development server. Whenever a developer checks in code, it makes a compile. </p> <p>Now we're at a place where we can start giving our application to the testers. We'd like to use ClickOnce to distribute the application, with the idea being that when a tester goes to test the application, they have the latest build. </p> <p>I can't find a way to make that happen with CruiseControl.NET. We're using MSBUILD to perform the builds.</p>
[ { "answer_id": 12512, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 5, "selected": false, "text": "msbuild /target:publish /p:Configuration=Release /p:Platform=AnyCPU; \"c:\\yourProject.csproj\"\n" }, { "...
2008/08/15
[ "https://Stackoverflow.com/questions/12482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702/" ]
12,489
<p>How do you scan a directory for folders and files in C? It needs to be cross-platform.</p>
[ { "answer_id": 12506, "author": "Clayton", "author_id": 1449, "author_profile": "https://Stackoverflow.com/users/1449", "pm_score": 6, "selected": false, "text": "#define _XOPEN_SOURCE 700\n#include <stdio.h>\n#include <sys/types.h>\n#include <dirent.h>\n\nint main (void)\n{\n DIR *dp;\...
2008/08/15
[ "https://Stackoverflow.com/questions/12489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
12,492
<p>I use emacs to edit my xml files (nxml-mode) and the files were generated by machine don't have any pretty formatting of the tags. </p> <p>I have searched for pretty printing the entire file with indentation and saving it, but wasn't able to find an automatic way.</p> <p>Is there a way? Or atleast some editor on linux which can do it. </p>
[ { "answer_id": 570049, "author": "Christian Berg", "author_id": 5035, "author_profile": "https://Stackoverflow.com/users/5035", "pm_score": 6, "selected": false, "text": "indent-region" }, { "answer_id": 4280824, "author": "bubak", "author_id": 520637, "author_profile...
2008/08/15
[ "https://Stackoverflow.com/questions/12492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448/" ]
12,501
<p>I thought that I had the latest CTP of PowerShell 2 but when I try the command:</p> <p><code>invoke-expression –computername Server01 –command 'get-process PowerShell'</code></p> <p>I get an error message:<br> <strong>A parameter cannot be found that matches parameter name 'computername'.</strong></p> <p>So the question is: How can I tell which version of PowerShell I have installed? And what the latest version is?</p>
[ { "answer_id": 12525, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 2, "selected": false, "text": "$host.version.tostring()" }, { "answer_id": 68933, "author": "Jaykul", "author_id": 8718, "author_profile": "ht...
2008/08/15
[ "https://Stackoverflow.com/questions/12501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
12,516
<p>This morning, I was reading <a href="http://steve.yegge.googlepages.com/when-polymorphism-fails" rel="noreferrer">Steve Yegge's: When Polymorphism Fails</a>, when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.</p> <blockquote> <p>As an example of polymorphism in action, let's look at the classic "eval" interview question, which (as far as I know) was brought to Amazon by Ron Braunstein. The question is quite a rich one, as it manages to probe a wide variety of important skills: OOP design, recursion, binary trees, polymorphism and runtime typing, general coding skills, and (if you want to make it extra hard) parsing theory.</p> <p>At some point, the candidate hopefully realizes that you can represent an arithmetic expression as a binary tree, assuming you're only using binary operators such as "+", "-", "*", "/". The leaf nodes are all numbers, and the internal nodes are all operators. Evaluating the expression means walking the tree. If the candidate doesn't realize this, you can gently lead them to it, or if necessary, just tell them.</p> <p>Even if you tell them, it's still an interesting problem.</p> <p>The first half of the question, which some people (whose names I will protect to my dying breath, but their initials are Willie Lewis) feel is a Job Requirement If You Want To Call Yourself A Developer And Work At Amazon, is actually kinda hard. The question is: how do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree. We may have an ADJ challenge on this question at some point.</p> <p>The second half is: let's say this is a 2-person project, and your partner, who we'll call "Willie", is responsible for transforming the string expression into a tree. You get the easy part: you need to decide what classes Willie is to construct the tree with. You can do it in any language, but make sure you pick one, or Willie will hand you assembly language. If he's feeling ornery, it will be for a processor that is no longer manufactured in production.</p> <p>You'd be amazed at how many candidates boff this one.</p> <p>I won't give away the answer, but a Standard Bad Solution involves the use of a switch or case statment (or just good old-fashioned cascaded-ifs). A Slightly Better Solution involves using a table of function pointers, and the Probably Best Solution involves using polymorphism. I encourage you to work through it sometime. Fun stuff!</p> </blockquote> <p>So, let's try to tackle the problem all three ways. How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using cascaded-if's, a table of function pointers, and/or polymorphism? </p> <p>Feel free to tackle one, two, or all three.</p> <p>[update: title modified to better match what most of the answers have been.]</p>
[ { "answer_id": 12674, "author": "Chris Conway", "author_id": 1412, "author_profile": "https://Stackoverflow.com/users/1412", "pm_score": 2, "selected": false, "text": " +\n / \\\n + 3\n / \\\n1 2\n" }, { "answer_id": 12688, "author": "Herms", "author_id": 1409, ...
2008/08/15
[ "https://Stackoverflow.com/questions/12516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
12,533
<p>Is there a quick one-liner to call datepart in Sql Server and get back the name of the day instead of just the number?</p> <pre><code>select datepart(dw, getdate()); </code></pre> <p>This will return 1-7, with Sunday being 1. I would like 'Sunday' instead of 1.</p>
[ { "answer_id": 12548, "author": "Erick B", "author_id": 1373, "author_profile": "https://Stackoverflow.com/users/1373", "pm_score": 5, "selected": true, "text": "select datename(weekday, getdate());\n" }, { "answer_id": 12549, "author": "Eric Z Beard", "author_id": 1219, ...
2008/08/15
[ "https://Stackoverflow.com/questions/12533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
12,556
<p>It looks interesting and I've played around with it some --- but the development IDE in a web browser seems to be nightmare eventually.</p> <p>Does anyone have experience using it and what are your thoughts?</p>
[ { "answer_id": 16222, "author": "Kieron", "author_id": 588, "author_profile": "https://Stackoverflow.com/users/588", "pm_score": 5, "selected": true, "text": "style" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
12,565
<p>In Ruby, what's the difference between <code>{}</code> and <code>[]</code>?</p> <p><code>{}</code> seems to be used for both code blocks and hashes.</p> <p>Are <code>[]</code> only for arrays?</p> <p>The documention isn't very clear.</p>
[ { "answer_id": 12575, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 3, "selected": false, "text": "{}" }, { "answer_id": 12608, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https:...
2008/08/15
[ "https://Stackoverflow.com/questions/12565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1470/" ]
12,576
<p>What can I do to increase the performance/speed of my PHP scripts without installing software on my servers?</p>
[ { "answer_id": 12584, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 5, "selected": true, "text": "function foo($stuff) {\n ...\n return ...;\n}\n" }, { "answer_id": 24074405, "author": "Dinesh Saini", ...
2008/08/15
[ "https://Stackoverflow.com/questions/12576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
12,591
<p>Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a document’s DTD.</p>
[ { "answer_id": 13040, "author": "Michael Twomey", "author_id": 995, "author_profile": "https://Stackoverflow.com/users/995", "pm_score": 1, "selected": false, "text": "f = StringIO(\"<!ELEMENT b EMPTY>\")\ndtd = etree.DTD(f)\ndtd = etree.DTD(external_id = \"-//OASIS//DTD DocBook XML V4.2...
2008/08/15
[ "https://Stackoverflow.com/questions/12591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207/" ]
12,592
<p>Is it possible to write a <code>doctest</code> unit test that will check that an exception is raised?<br /> For example, if I have a function <code>foo(x)</code> that is supposed to raise an exception if <code>x &lt; 0</code>, how would I write the <code>doctest</code> for that?</p>
[ { "answer_id": 12609, "author": "cnu", "author_id": 1448, "author_profile": "https://Stackoverflow.com/users/1448", "pm_score": 8, "selected": true, "text": " >>> x\n Traceback (most recent call last):\n ...\n NameError: name 'x' is not defined\n" }, { "answer_id": 3378...
2008/08/15
[ "https://Stackoverflow.com/questions/12592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
12,594
<p>Let's say I have a drive such as <strong>C:\</strong>, and I want to find out if it's shared and what it's share name (e.g. <strong>C$</strong>) is.</p> <p>To find out if it's shared, I can use <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharecheck" rel="nofollow noreferrer">NetShareCheck</a>.</p> <p>How do I then map the drive to its share name? I thought that <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharegetinfo" rel="nofollow noreferrer">NetShareGetInfo</a> would do it, but it looks like that takes the share name, not the local drive name, as an input.</p>
[ { "answer_id": 12634, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 0, "selected": false, "text": "SHGetFileInfo with SHGFI_ATTRIBUTES\n" } ]
2008/08/15
[ "https://Stackoverflow.com/questions/12594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179/" ]