qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
260,615
<p>I am trying this in my Form Load Event</p> <p><pre><code> cmdCancel.Attributes.Add("onClick", "document.forms[0].reset();return false;") </pre></code></p> <p>but it doesn't clear my form. My form is a "ContentPage", part of a masterpage.</p> <p>Am I missing something?</p>
[ { "answer_id": 260630, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": true, "text": " cmdCancel.Attributes.Add(\"onClick\",\"document.getElementById('\" + this.Page.ClientId + \"').reset(); return false;\");\n...
2008/11/04
[ "https://Stackoverflow.com/questions/260615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
260,626
<p>What does "type-safe" mean?</p>
[ { "answer_id": 260640, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 8, "selected": false, "text": "// Fails, Trying to put an integer in a string\nString one = 1;\n// Also fails.\nint foo = \"bar\";\n" }, { "answer_...
2008/11/04
[ "https://Stackoverflow.com/questions/260626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,627
<p>This drop down list, displaying all the files from a folder, one of which will be selected for use. Is there a way to show which file is selected when you load the page? At the moment it says "select a file" every time.</p> <pre><code>&lt;select name="image" type="text" class="box" id="image" value="&lt;?=$image;?&gt;"&gt; &lt;option value='empty'&gt;Select a file&lt;/option&gt; &lt;?php $dirname = "images/"; $images = scandir($dirname); // This is how you sort an array, see http://php.net/sort natsort($images); // There's no need to use a directory handler, just loop through your $images array. foreach ($images as $file) { if (substr($file, -4) == ".gif") { print "&lt;option value='$file'&gt;$file&lt;/option&gt;\n"; } } ?&gt; &lt;/select&gt; </code></pre>
[ { "answer_id": 260640, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 8, "selected": false, "text": "// Fails, Trying to put an integer in a string\nString one = 1;\n// Also fails.\nint foo = \"bar\";\n" }, { "answer_...
2008/11/04
[ "https://Stackoverflow.com/questions/260627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32972/" ]
260,658
<p>Via command line, I usually do this:</p> <pre><code>cp -rRp /path/to/a\_folder/. /path/to/another\_folder </code></pre> <p>This copies just the contents underneath <strong>a_folder</strong> to <strong>another_folder</strong>. In SVN I need to do the same thing, but can't figure it out. I always end up with this:</p> <pre><code>/path/to/another\_folder/a\_folder </code></pre> <p>SVN throws up even when I try this:</p> <pre><code>svn copy file:///path/to/a\_folder/* file:///path/to/another\_folder </code></pre> <p>It says it does not exist.</p> <p><strong>EDIT:</strong></p> <p>This would probably help. The directory structure for my project looks like this:</p> <pre><code>my_project /branches /tags /trunk /vendor /1.1 </code></pre> <p>I need to get the contents of 1.1 under vendor into the trunk without it actually copying the 1.1 folder.</p>
[ { "answer_id": 260706, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 4, "selected": true, "text": "trunk/a_folder/foo\ntrunk/a_folder/bar\ntrunk/new_folder/baz\n" }, { "answer_id": 260737, "author": "Ken Gentle",...
2008/11/04
[ "https://Stackoverflow.com/questions/260658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,663
<p>I started web programming with raw PHP, gradually moving on to its various frameworks, then to Django and Rails. In every framework I've used, pretty much everything I need to do with a database (even involving relatively complex things like many-to-many relationships) could be taken care of by the automatically generated database API without much work. Those few operations that were more complex could be done with straight SQL or by tying together multiple API calls.</p> <p>Now I'm starting to learn Java, and it's confusing me that the language celebrated for being so robust for back-end infrastructure requires so much more code (doesn't that mean harder to maintain?) to do simple things. Example from a tutorial: say you want to search by last name. You write the method in the DAO using Hibernate query language, then you write a method in the Service to call it (couldn't that be automated?), then you call the Service method from the controller. Whereas in any other framework I've worked with, you could call something to the effect of</p> <pre><code>Person.find_by_last_name(request.POST['last_name']) </code></pre> <p>Straight out of the controller - you don't have to write anything custom to do something like that.</p> <p>Is there some kind of code generation I haven't found yet? Something in Eclipse? Just doesn't seem right to me that the language regraded as one of the best choices for complex back-ends is so much harder to work with. Is there something I'm missing?</p>
[ { "answer_id": 260746, "author": "CodingWithSpike", "author_id": 28278, "author_profile": "https://Stackoverflow.com/users/28278", "pm_score": 2, "selected": false, "text": "Controller -> Service -> DAO\n" }, { "answer_id": 261063, "author": "jb.", "author_id": 7918, ...
2008/11/04
[ "https://Stackoverflow.com/questions/260663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,664
<p>I have a PHP app that needs to run bash scripts, and provide a username &amp; password (for remote systems). I need to store these credentials somewhere that is accessible by my PHP (web) app. The logical place is the database (currently MySQL, but will be agnostic). The problem with the "standard" way of hashing and storing the credentials, is that it is not reversible. I <em>have</em> to be able to get the credentials out as unencrypted clear text, to be able to insert the data into bash scripts.</p> <p>Does anyone have any suggestions for a secure way to go about this ?</p> <p>I thought maybe PKI'ing the credentials, and storing the result in the DB. Then use the private key to unencrypt (PHP can do that). Store the scripts to do this outside the web root.</p> <p>Any thoughts much appreciated.</p>
[ { "answer_id": 260709, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 1, "selected": false, "text": "INSERT INTO tbl_passwords SET encoded_pw = ENCODE('r00t', 'my-salt-string');\n" }, { "answer_id": 313187, ...
2008/11/04
[ "https://Stackoverflow.com/questions/260664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,666
<p>Can an abstract class have a constructor?</p> <p>If so, how can it be used and for what purposes?</p>
[ { "answer_id": 260686, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "abstract class Product { \n int value;\n public Product( int val ) {\n value= val;\n }\n abstract public...
2008/11/04
[ "https://Stackoverflow.com/questions/260666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33885/" ]
260,668
<p>I'm curious about people's experiences using AR's to_xml() to build non-entity fields (as in, not an attribute of the model you are serializing, but perhaps, utilizing the attributes in the process) from a controller. </p> <p>to_xml seems to supply a few options for doing this. </p> <p>One is by passing in references to methods on the object being acted on: during the serialization process, these methods are invoked and their results are added to the generated document. I'd like to avoid this path because some of the generated data, while depending on the object's attributes, could be outside of the scope of the model itself -- e.g., building a URL to a particular items "show" action. Plus, it requires too much forethought. I'd like to just be able to change the resultant document by tweaking the to_xml code from the controller. I don't want the hassle of having to declare a method in the object as well. </p> <p>The same goes for overriding to_xml in each object. </p> <p>The other two options seem to fit the bill a little better: one is by passing in procs in the serialization options that generate these fields, and the other is by passing in a block that will yielded to after serialization the objects attributes. These provide the kind of at-the-point-of-invocation customizing that I'm looking for, and in addition, their declarations bind the scope to the controller so that they have access to the same stuff that the controller does, but these methods seem critically limited: AFAICT they contain no reference to the object being serialized. They contain references to the builder object, which, sure I guess you could parse within the block/proc and find the attributes that have already been serialized and use them, but that's a harangue, or at least uneasy and suboptimal. </p> <p>Correct me if I'm wrong here, but what is the point of having procs/blocks available when serializing one or more objects if you have to access to the object itself.</p> <p>Anyway, please tell me how I'm wrong, because it seems like I must be overlooking something here. </p> <p>Oh and yeah, I know that I could write my own view. I'm trying to leverage respond_to and to_xml to achieve minimal extra files/lines. (Though, that is what I resorted to when I couldn't figure out how to do this with AR's serialization.)</p> <p>**EDIT 3.29.09 -- I just submitted a patch for this to Rails. If you're interested, show some support :) <a href="https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2373-record-sensitive-procs-for-to_xml" rel="nofollow noreferrer">https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2373-record-sensitive-procs-for-to_xml</a></p>
[ { "answer_id": 260686, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "abstract class Product { \n int value;\n public Product( int val ) {\n value= val;\n }\n abstract public...
2008/11/04
[ "https://Stackoverflow.com/questions/260668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33866/" ]
260,672
<p>There are some tasks, especially the ones that involve deleting folders as SU, that I do thoughtfully and slowly before I press the Enter key. I think if others saw me do these at the careful pace that I do they would cringe. Are there critical programming tasks that you perform that you believe deserve this thoughtful and careful consideration?</p>
[ { "answer_id": 263428, "author": "Chris Burgess", "author_id": 6624, "author_profile": "https://Stackoverflow.com/users/6624", "pm_score": 0, "selected": false, "text": "select * into myTable_backup from myTable" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,679
<p>If I have a table like:</p> <pre><code>CREATE TABLE FRED ( recordId number(18) primary key, firstName varchar2(50) ); </code></pre> <p>Is there an easy way to clone it's structure (not it's data) into another table of a given name. Basically I want to create table with exactly the same structure, but a different name, so that I can perform some functionality on it. I want to do this in code obviously. Java preferably, but most other languages should be similar.</p>
[ { "answer_id": 260771, "author": "Salamander2007", "author_id": 10629, "author_profile": "https://Stackoverflow.com/users/10629", "pm_score": 5, "selected": true, "text": "select dbms_metadata.get_ddl('TABLE', 'TABLE_NAME', 'SCHEMA_NAME') from dual\n" }, { "answer_id": 62470385, ...
2008/11/04
[ "https://Stackoverflow.com/questions/260679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044/" ]
260,685
<p>I have been using <a href="http://www.plt-scheme.org/" rel="noreferrer">PLT Scheme</a>, but it has some issues. Does anyone know of a better implementation for working through SICP?</p>
[ { "answer_id": 262886, "author": "soegaard", "author_id": 23567, "author_profile": "https://Stackoverflow.com/users/23567", "pm_score": 7, "selected": false, "text": "raco" }, { "answer_id": 39024828, "author": "htanata", "author_id": 4353, "author_profile": "https://...
2008/11/04
[ "https://Stackoverflow.com/questions/260685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25573/" ]
260,701
<p>I'm looking for one line code examples in various languages for getting a valid MD5 result (as a string, not a bytehash or what have you). For instance:</p> <p>PHP: $token = md5($var1 . $var2);</p> <p>I found VB especially troublesome to do in one line.</p>
[ { "answer_id": 260715, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 2, "selected": false, "text": "token = __import__('md5').new(var1 + var2).hexdigest()\n" }, { "answer_id": 260717, "author": "yfeldbl...
2008/11/04
[ "https://Stackoverflow.com/questions/260701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33886/" ]
260,703
<p>Here is some simple Perl to count the number of times a value occurs in an array. This runs without any warnings.</p> <pre><code>use warnings; use strict; my @data = qw(1 1 2 3 4 5 5 5 9); my %histogram; foreach (@data) { $histogram{$_}++; } </code></pre> <p>When the loop body is changed to</p> <pre><code>$histogram{$_} = $histogram{$_} + 1; </code></pre> <p>Perl warns "Use of uninitialized value in addition".</p> <p>What is going on under the hood? Why is the value initialized when supplied as an operand to the ++ operator and uninitialized with the + operator?</p>
[ { "answer_id": 260862, "author": "Axeman", "author_id": 11289, "author_profile": "https://Stackoverflow.com/users/11289", "pm_score": 0, "selected": false, "text": "$histogram{$_}" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25164/" ]
260,716
<p>I'm using a <code>RichTextBox</code> (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys.... For example, I don't want <kbd>Ctrl</kbd>+<kbd>I</kbd> to make the text italic via the RichText method, but to instead run my own method for processing the text.</p> <p>Any ideas?</p>
[ { "answer_id": 260821, "author": "Jim Burger", "author_id": 20164, "author_profile": "https://Stackoverflow.com/users/20164", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Windows.Forms;\n\nnamespace WindowsFormsApplication1\n{\n public partial class Form1 : F...
2008/11/04
[ "https://Stackoverflow.com/questions/260716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
260,723
<p>I have a Tapestry PropertyModel for gender. Right now the dropdown just shows Male and Female because those are the only values in my model. I'd like to add a "Choose an Option" option. Is there a standard way to do this without having to add a fake value to my model? I'd also like it to be smart enough to know that if the field is required, they can't leave it set to "Choose an Option".</p>
[ { "answer_id": 260967, "author": "Brian Deterling", "author_id": 14619, "author_profile": "https://Stackoverflow.com/users/14619", "pm_score": 1, "selected": false, "text": "new LabeledPropertySelectionModel(new GenderModel(), \"Choose an Option\")\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14619/" ]
260,729
<p>Are the two events the same or are there differences that we should take note when coding the keyboard presses?</p>
[ { "answer_id": 262473, "author": "Fry", "author_id": 23553, "author_profile": "https://Stackoverflow.com/users/23553", "pm_score": 1, "selected": false, "text": "ctrlPressed=true" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26087/" ]
260,738
<p>How can I play audio (it would be like a 1 second sound) from a Python script?</p> <p>It would be best if it was platform independent, but firstly it needs to work on a Mac.</p> <p>I know I could just execute the <code>afplay file.mp3</code> command from within Python, but is it possible to do it in raw Python? I would also be better if it didn't rely on external libraries.</p>
[ { "answer_id": 260901, "author": "TML", "author_id": 33918, "author_profile": "https://Stackoverflow.com/users/33918", "pm_score": 6, "selected": false, "text": "pygame.mixer.init()\npygame.mixer.music.load(\"file.mp3\")\npygame.mixer.music.play()\n" }, { "answer_id": 14018627, ...
2008/11/04
[ "https://Stackoverflow.com/questions/260738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
260,742
<p>I've got an embedded Windows Media player in an HTML page, and when the audio gets to the end, it just starts again from the beginning.</p> <p>According to the documentation, there's an <code>autorewind</code> parameter/attribute and also a <code>loop</code>.</p> <p>The problem is, I've set both of those to <code>false</code> (and/or zero) and it doesn't seem to make any difference.</p> <p>Might this be a bug? My client is WMP 10.00.00.4058. Maybe there's some kind of setting on the <em>server</em> which tells files to loop, is that a crazy idea?</p>
[ { "answer_id": 293467, "author": "plan9assembler", "author_id": 1710672, "author_profile": "https://Stackoverflow.com/users/1710672", "pm_score": 0, "selected": false, "text": "<object width=\"320\" height=\"290\"\nclassid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\"\nid=\"mediaplayer1...
2008/11/04
[ "https://Stackoverflow.com/questions/260742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242241/" ]
260,744
<p>An abstract class can only be used as a base class which is extended by some other class, right? The constructor(s) of an abstract class can have the usual access modifiers (public, protected, and private (for internal use)). Which of <code>protected</code> and <code>public</code> is the correct access modifier to use, since the abstract type seems to indicate that technically a public constructor will act very much protected? Should I just use protected on all my constructors?</p>
[ { "answer_id": 260779, "author": "Jordan Stewart", "author_id": 33338, "author_profile": "https://Stackoverflow.com/users/33338", "pm_score": 6, "selected": true, "text": "public class Scratch\n{\n public static abstract class A\n {\n public A( int i ) {}\n }\n\n publi...
2008/11/04
[ "https://Stackoverflow.com/questions/260744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15075/" ]
260,745
<p>I have a menu with an animation going on, but I want to disable the click while the animation is happening.</p> <pre><code>&lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; $("div").click(function() { $(this).animate({height: "200px"}, 2000); return false; }); </code></pre> <p>However, I want to disable all the buttons while the event is happening, AND disable the div that was clicked. </p> <p>I was thinking of adding a class to the div that's clicked and putting the click only on the divs without that class:</p> <pre><code>$("div").not("clicked").click(function() { $(this).animate({height: "200px"}, 2000).addClass("clicked"); return false; }); </code></pre> <p>But this doesn't appear to work (I think it does logically)?</p> <p>Any help appreciated.</p> <p>Cheers,<br /> Steve</p>
[ { "answer_id": 260789, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 5, "selected": true, "text": "$(\"div\").click(function() {\n if (!$(this).parent().children().is(':animated')) {\n $(this).animate({he...
2008/11/04
[ "https://Stackoverflow.com/questions/260745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16124/" ]
260,749
<p>I want to increment a cookie value every time a page is referenced even if the page is loaded from cache. What is the "best" or most concise way to implement this?</p>
[ { "answer_id": 260866, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "var cookieName = \"increment\";\n\nif ($.cookie(cookieName) == null){\n $.cookie(cookieName, 1, { expires: 10 ...
2008/11/04
[ "https://Stackoverflow.com/questions/260749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30099/" ]
260,787
<p>I know that this question has already been asked <a href="https://stackoverflow.com/questions/41207/javascript-interactive-shell-with-completion">HERE</a> but sadly none of the answers suggest a javascript standalone shell that has auto completion. I am reopening this question again, in the hope that some new answers might be found.</p>
[ { "answer_id": 4074233, "author": "intuited", "author_id": 192812, "author_profile": "https://Stackoverflow.com/users/192812", "pm_score": 3, "selected": true, "text": "node-repl" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28486/" ]
260,804
<p>I'm looking for a dbm-like library that I can use in place of Berkeley DB, which I'm currently using. My main reason for switching is the licensing fees for BDB are pretty high (free for open source apps, but my employer does not want to open source this particular app for various reasons).</p> <p>I've looked briefly at qdbm but it doesn't look like it will fill my needs -- lots of keys (several million) and large data items (> 1-5 megabytes). Before I continue my search I figured I'd ask because it seems there are tons of dbm-like libraries out there.</p>
[ { "answer_id": 290551, "author": "geocar", "author_id": 37507, "author_profile": "https://Stackoverflow.com/users/37507", "pm_score": 3, "selected": false, "text": "data_dir/H(key)/" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/260804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
260,817
<p>I wanted to try a little design by contract in my latest C# application and wanted to have syntax akin to:</p> <pre><code>public string Foo() { set { Assert.IsNotNull(value); Assert.IsTrue(value.Contains("bar")); _foo = value; } } </code></pre> <p>I know I can get static methods like this from a unit test framework, but I wanted to know if something like this was already built-in to the language or if there was already some kind of framework floating around. I can write my own Assert functions, just don't want to reinvent the wheel.</p>
[ { "answer_id": 260833, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": false, "text": "using System.Diagnostics\n\nDebug.Assert(value != null);\nDebug.Assert(value == true);\n" }, { "answer_id": 260837, ...
2008/11/04
[ "https://Stackoverflow.com/questions/260817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27613/" ]
260,847
<p>I have written a few MSBuild custom tasks that work well and are use in our CruiseControl.NET build process.</p> <p>I am modifying one, and wish to unit test it by calling the Task's Execute() method. </p> <p>However, if it encounters a line containing </p> <pre><code>Log.LogMessage("some message here"); </code></pre> <p>it throws an InvalidOperationException:</p> <p><em>Task attempted to log before it was initialized. Message was...</em></p> <p>Any suggestions? (In the past I have mostly unit-tested Internal static methods on my custom tasks to avoid such problems.)</p>
[ { "answer_id": 287704, "author": "Tim Bailey", "author_id": 1077232, "author_profile": "https://Stackoverflow.com/users/1077232", "pm_score": 4, "selected": false, "text": "private void LogFormat(string message, params object[] args)\n{\n if (this.BuildEngine != null)\n {\n ...
2008/11/04
[ "https://Stackoverflow.com/questions/260847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30183/" ]
260,857
<p>I have a web application that's branded according to the user that's currently logged in. I'd like to change the favicon of the page to be the logo of the private label, but I'm unable to find any code or any examples of how to do this. Has anybody successfully done this before?</p> <p>I'm picturing having a dozen icons in a folder, and the reference to which favicon.ico file to use is just generated dynamically along with the HTML page. Thoughts?</p>
[ { "answer_id": 260873, "author": "Jeff Sheldon", "author_id": 33910, "author_profile": "https://Stackoverflow.com/users/33910", "pm_score": 4, "selected": false, "text": "<link rel=\"shortcut icon\" type=\"image/ico\" href=\"favicon.ico\">\n" }, { "answer_id": 260876, "author...
2008/11/04
[ "https://Stackoverflow.com/questions/260857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8114/" ]
260,869
<p>I want to convert a BYTE* into an gdi+ Image object.<p> How can I do this?<p> The BYTE* seems a Dib point.<p> I found Image has a method named Image::FromStream() which may help, But I can not find any reference about how to convert a BYTE* into a IStream object. How can I do this? <p> Thanks in advance!</p> <p><strong>Actually, it is hard to believe MS provide a IStream interface, but do not provide any c++ MemoryStream class which implements the interface.</strong></p>
[ { "answer_id": 261189, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 0, "selected": false, "text": "BYTE" }, { "answer_id": 70470651, "author": "SnzFor16Min", "author_id": 10766083, "author_profile": "ht...
2008/11/04
[ "https://Stackoverflow.com/questions/260869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
260,915
<p>I know how to create an array of structs but with a predefined size. However is there a way to create a dynamic array of structs such that the array could get bigger?</p> <p>For example:</p> <pre><code> typedef struct { char *str; } words; main() { words x[100]; // I do not want to use this, I want to dynamic increase the size of the array as data comes in. } </code></pre> <p>Is this possible?</p> <hr> <p>I've researched this: <code>words* array = (words*)malloc(sizeof(words) * 100);</code></p> <p>I want to get rid of the 100 and store the data as it comes in. Thus if 76 fields of data comes in, I want to store 76 and not 100. I'm assuming that I don't know how much data is coming into my program. In the struct I defined above I could create the first "index" as:</p> <pre><code> words* array = (words*)malloc(sizeof(words)); </code></pre> <p>However I want to dynamically add elements to the array after. I hope I described the problem area clearly enough. The major challenge is to dynamically add a second field, at least that is the challenge for the moment.</p> <hr> <p>I've made a little progress however:</p> <pre><code> typedef struct { char *str; } words; // Allocate first string. words x = (words) malloc(sizeof(words)); x[0].str = "john"; // Allocate second string. x=(words*) realloc(x, sizeof(words)); x[1].FirstName = "bob"; // printf second string. printf("%s", x[1].str); --&gt; This is working, it's printing out bob. free(x); // Free up memory. printf("%s", x[1].str); --&gt; Not working since its still printing out BOB even though I freed up memory. What is wrong? </code></pre> <p>I did some error checking and this is what I found. If after I free up memory for x I add the following:</p> <pre><code> x=NULL; </code></pre> <p>then if I try to print x I get an error which is what I want. So is it that the free function is not working, at least on my compiler? I'm using DevC??</p> <hr> <p>Thanks, I understand now due to:</p> <blockquote> <p>FirstName is a pointer to an array of char which is not being allocated by the malloc, only the pointer is being allocated and after you call free, it doesn't erase the memory, it just marks it as available on the heap to be over written later. – MattSmith</p> </blockquote> <h2>Update</h2> <p>I'm trying to modularize and put the creation of my array of structs in a function but nothing seems to work. I'm trying something very simple and I don't know what else to do. It's along the same lines as before, just another function, loaddata that is loading the data and outside the method I need to do some printing. How can I make it work? My code is as follows:</p> <pre><code> # include &lt;stdio.h&gt; # include &lt;stdlib.h&gt; # include &lt;string.h&gt; # include &lt;ctype.h&gt; typedef struct { char *str1; char *str2; } words; void LoadData(words *, int *); main() { words *x; int num; LoadData(&amp;x, &amp;num); printf("%s %s", x[0].str1, x[0].str2); printf("%s %s", x[1].str1, x[1].str2); getch(); }// void LoadData(words *x, int * num) { x = (words*) malloc(sizeof(words)); x[0].str1 = "johnnie\0"; x[0].str2 = "krapson\0"; x = (words*) realloc(x, sizeof(words)*2); x[1].str1 = "bob\0"; x[1].str2 = "marley\0"; *num=*num+1; }// </code></pre> <p>This simple test code is crashing and I have no idea why. Where is the bug?</p>
[ { "answer_id": 260932, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 4, "selected": false, "text": "malloc" }, { "answer_id": 260950, "author": "ob1", "author_id": 3961, "author_profile": "https://Stack...
2008/11/04
[ "https://Stackoverflow.com/questions/260915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31274/" ]
260,945
<p>This should be easy, but I'm having a hard time finding the easiest solution.</p> <p>I need an <code>NSString</code> that is equal to another string concatenated with itself a given number of times.</p> <p>For a better explanation, consider the following python example:</p> <pre><code>&gt;&gt; original = "abc" "abc" &gt;&gt; times = 2 2 &gt;&gt; result = original * times "abcabc" </code></pre> <p>Any hints?</p> <hr> <p>EDIT:</p> <p>I was going to post a solution similar to the one by <a href="https://stackoverflow.com/questions/260945/create-nsstring-by-repeating-another-string-a-given-number-of-times#260969">Mike McMaster's answer</a>, after looking at this implementation from the OmniFrameworks:</p> <pre><code>// returns a string consisting of 'aLenght' spaces + (NSString *)spacesOfLength:(unsigned int)aLength; { static NSMutableString *spaces = nil; static NSLock *spacesLock; static unsigned int spacesLength; if (!spaces) { spaces = [@" " mutableCopy]; spacesLength = [spaces length]; spacesLock = [[NSLock alloc] init]; } if (spacesLength &lt; aLength) { [spacesLock lock]; while (spacesLength &lt; aLength) { [spaces appendString:spaces]; spacesLength += spacesLength; } [spacesLock unlock]; } return [spaces substringToIndex:aLength]; } </code></pre> <p>Code reproduced from the file:</p> <pre><code>Frameworks/OmniFoundation/OpenStepExtensions.subproj/NSString-OFExtensions.m </code></pre> <p>on the OpenExtensions framework from the <a href="http://www.omnigroup.com/developer/" rel="noreferrer">Omni Frameworks</a> by <a href="http://www.omnigroup.com/" rel="noreferrer">The Omni Group</a>.</p>
[ { "answer_id": 260969, "author": "Mike McMaster", "author_id": 544, "author_profile": "https://Stackoverflow.com/users/544", "pm_score": 3, "selected": false, "text": "NSString *original = @\"abc\";\nint times = 2;\n\n// Capacity does not limit the length, it's just an initial capacity\n...
2008/11/04
[ "https://Stackoverflow.com/questions/260945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2954/" ]
260,962
<p>To trim the leading spaces we are using strmove. But we were advised to use strlmove instead of strmove. I have read and used strlcpy and strlcat. Whether strlmove does the similar functionality and what all are its advantages?</p> <p>Edit 1: Thank you Mike B and Chris Young. This is how we use strlcpy.</p> <pre><code>size_t strlcpy(char *dst, const char *src, size_t size) { strncpy(dst, src, size - 1); dst[size - 1] = '\0'; return(strlen(src)); } </code></pre> <p>So I was just thinking of using strlmove() also in the same way. I want to confirm whether any specifications is defined regarding the implementation of strlmove(). I know this is one of the best place i can ask.</p> <p>Edit 2: strlmove() is implemented the same way as strlcpy() and strlcat() using memmove().</p> <pre><code>size_t strlmove(char *dst, const char *src, size_t size) { //Error if the size is 0 //If src length is greater than size; // memmove(dst, src, size-1) and dst[size] = \0; //Otherwise // memmove(dst, src, length(src)); return source len; } </code></pre> <p>Appreciate the help and support provided.</p> <p>Thanks, Mathew Liju</p>
[ { "answer_id": 260972, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 2, "selected": false, "text": "char buf[4096];\nstrncpy(buf, \"Hello\", sizeof buf);\n" }, { "answer_id": 260998, "author": "Michael Burr",...
2008/11/04
[ "https://Stackoverflow.com/questions/260962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18657/" ]
260,986
<p>I have a text file which contains some data. I am trying to search for EA in <strong>ID column only</strong> and prints the whole row. But the code recognize all EA and prints all rows. What code I should add to satisfy the condition? Thanks Again:-)!</p> <p>DATA: <br> Name Age ID <br> ---------------------<br> KRISTE,22,<strong>EA</strong>2008<br> J<strong>EA</strong>N,21,ES4567<br> JAK,45,<strong>EA</strong>2008<br><br> The code prints:<br> KRISTE,22,<strong>EA</strong>2008<br> J<strong>EA</strong>N,21,ES4567<br> JAK,45,<strong>EA</strong>2008<br></p> <p>Desired output:<br> KRIS,22,<strong>EA</strong>2008<br> Kane,45,<strong>EA</strong>2008,<br></p> <pre><code>file='save.txt'; open(F,$file)||die("Could not open $file"); while ($line=&lt;F&gt;){ if ($line=~ m/$EA/i) { my @cells=($f1,$f2,$f3)= split ',',$line; print "&lt;TD&gt;f1&lt;/TD&gt;"; print "&lt;TD&gt;f2&lt;/TD&gt;"; print "&lt;TD&gt;f3&lt;/TD&gt;"; } </code></pre>
[ { "answer_id": 260995, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 2, "selected": false, "text": "file='save.txt';\nopen(F,$file)||die(\"Could not open $file\");\n\nwhile ($line=<F>){\n my @cells=($f1,$f2,$f3)= split ',...
2008/11/04
[ "https://Stackoverflow.com/questions/260986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28607/" ]
260,987
<p>When we submit a job, the following steps are executed sequentially.</p> <p>Then what is the importance of DPRTY?</p>
[ { "answer_id": 370495, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "DPRTY" }, { "answer_id": 55945070, "author": "Rohit Parab", "author_id": 11430782, "author_profile":...
2008/11/04
[ "https://Stackoverflow.com/questions/260987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33392/" ]
261,004
<p>I've got an old classic ASP site that connects to a local sql server 2000 instance. We're moving the db to a new box, and the port is non standard for sql (out of my control). .NET connection strings handle the port number fine by adding it with ,1999 after the server name/IP. The classic ASP connection string isn't working with the same syntax. I checked connectionstrings.com and couldn't find one that worked.</p> <p>Current connection string (set to an Application variable in Global.asa):</p> <pre><code>Driver={SQL Server};Server=xxx.xxx.xxx.xxx;Database=dbname;Uid=dbuser;Pwd=dbpassword </code></pre> <p>I've installed the SQL Native Client and couldn't get that working either (still working on this)</p> <p>Any ideas?</p>
[ { "answer_id": 261077, "author": "Sergey Kornilov", "author_id": 10969, "author_profile": "https://Stackoverflow.com/users/10969", "pm_score": 0, "selected": false, "text": "cst = \"Provider=SQLOLEDB;\" & _ \n \"Data Source=<x.x.x.x>,<port number>;\" & _ \n \"Initial Cata...
2008/11/04
[ "https://Stackoverflow.com/questions/261004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
261,013
<p>I work on a Fedora Linux box.</p> <p>I have a whole host of binaries and libraries that I've installed locally under my home directory.</p> <p>I'd like to set my system up so installing software there functions the same way (for me) as if the root user installed it without a prefix.</p> <p>I can run binaries installed in ~/local/bin just fine by adding that dir to my PATH variable, but what about linking to libraries in ~/local/lib and ~/local/lib64?</p> <p>Is there something akin to LD_LIBRARY_PATH variable but to find the library at compile rather than runtime? I don't want to worry about explicitly passing the path to the compiler via L~/local/lib or through flags in the ./configure script.</p>
[ { "answer_id": 261048, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 1, "selected": false, "text": "LIBRARY_PATH" }, { "answer_id": 261172, "author": "Alnitak", "author_id": 6782, "author_profile": "http...
2008/11/04
[ "https://Stackoverflow.com/questions/261013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109032/" ]
261,015
<p>I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?</p>
[ { "answer_id": 261032, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 6, "selected": false, "text": "src.zip" }, { "answer_id": 5308086, "author": "fouding.zheng", "author_id": 657306, "author_profil...
2008/11/04
[ "https://Stackoverflow.com/questions/261015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
261,045
<p>I just upgraded to Eclipse 3.4 for the second time and I think its for good now. The first time (right when it was released) was too buggy for me to stomach (mainly the PDT 2.0 plug-in); but now it seems to be all worked out.</p> <p>My problem is the Javascript validator. If I define a class in one JS file in my project, then try to use it in another, it tells me that the type is undefined. This is really annoying as some of my scripts are littered with red squigglys.</p> <p>Another problem is that this code:</p> <pre><code>var m_dialogFrame = document.getElementById(m_dialogId); </code></pre> <p>Makes a yellow squiggle saying "Type mismatch: cannot convert from Element to ___m_dialogBody5" I can fix it by adding</p> <pre><code> /** * @type Element */ </code></pre> <p>Before it, but that, also, will be messy.</p> <p>Also, both:</p> <pre><code>new XMLHttpRequest(); </code></pre> <p>And</p> <pre><code>new ActiveXObject("Microsoft.XMLHTTP"); </code></pre> <p>Get red squiggles saying "x cannot be resolved to a type"</p> <p>The last problem is with:</p> <p>if (m_options.width != "auto")</p> <p>Gets a red squiggly because: "The operator != is undefined for the argument type(s) Number, String"</p> <p>How can I fix these issues, or just scrap the entire Javascript validation tool? BTW: it looks frikin awesome if I can get it to work.</p>
[ { "answer_id": 261760, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 3, "selected": false, "text": "Object" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,050
<p>I'm having an issue with a standard ASP.NET page that has a TextBox and a RequiredFieldValidator. The steps to reproduce are quite simple:</p> <ol> <li>Place a TextBox on a page</li> <li>Place a RequiredFieldValidator on the page</li> <li>Point the RequiredFieldValidator at the TextBox</li> <li>Run the app</li> <li>Tab away from the TextBox the RequiredFieldValidator does not show</li> <li>Enter text, then delete the text and THEN tab away, the RequiredFieldValidator does show</li> </ol> <p>The RequiredFieldValidator works fine in both cases after a postback, however it seems the client-side code isn't firing until something is entered into the textbox (and then deleted).</p> <p>Does anyone have a solution to this without hacking away at JavaScript myself?</p>
[ { "answer_id": 261100, "author": "Jim Burger", "author_id": 20164, "author_profile": "https://Stackoverflow.com/users/20164", "pm_score": 3, "selected": true, "text": "protected void Page_Load(object sender, EventArgs e)\n{\n Validate();\n}\n" }, { "answer_id": 261127, "au...
2008/11/04
[ "https://Stackoverflow.com/questions/261050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1462735/" ]
261,062
<p>Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators.</p> <ul> <li>Do you use Bitwise Operators?</li> <li>Why do you use them?</li> <li>What are some example use cases?</li> </ul> <p>Please remember that this question is specifically intended for use of Bitwise Operators in web languages.</p>
[ { "answer_id": 261073, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "&" }, { "answer_id": 261227, "author": "tyler", "author_id": 25303, "author_profile": "https://Stacko...
2008/11/04
[ "https://Stackoverflow.com/questions/261062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11568/" ]
261,080
<p>I would like to have a Java component which has a resize icon on the bottom right of the component so that when I drag that icon, the component will automatically resize with it.</p> <p>By resize icon, I mean the following:</p> <p><img src="https://lh5.ggpht.com/_7dfPdX2BP6o/SQ_sPvvHpTI/AAAAAAAAAKU/vRWKb_pLVvc/s144/resize%20icon.jpg" alt="resize icon in Google Talk"></p> <p>The above image contains the resize icon in the Google Talk messenger's main window. Is there any Java component which provides this facility?</p>
[ { "answer_id": 717579, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "private void buttonMousePressed(java.awt.event.MouseEvent evt) {\n sx = evt.getX();\n sy = evt.getY();\n}\n\npri...
2008/11/04
[ "https://Stackoverflow.com/questions/261080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22550/" ]
261,083
<p>How is it possible to identify that the browser's close button was clicked?</p>
[ { "answer_id": 261111, "author": "andyk", "author_id": 26721, "author_profile": "https://Stackoverflow.com/users/26721", "pm_score": 2, "selected": false, "text": "$(window).unload( function () { alert(\"Bye now!\"); } );\n" }, { "answer_id": 262250, "author": "northsouthwhat...
2008/11/04
[ "https://Stackoverflow.com/questions/261083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,086
<p>I am using a fictional example for this. Say, I have a Widget class like:</p> <pre><code>abstract class Widget { Widget parent; } </code></pre> <p>Now, my other classes would be derived from this Widget class, but suppose I want to put some constraint in the class while defining the derived types such that only a particular "type" of widget can be parent to a particular type of Widget.</p> <p>For example, I have derived two more widgets from the Widget class, WidgetParent and WidgetChild. While defining the child class, I want to define the type of parent as WidgetParent, so that I dont have to type cast the parent every time I use it.</p> <p>Precisely, what I would have liked to do is this:</p> <pre><code>// This does not works! class Widget&lt;PType&gt;: where PType: Widget { PType parent; } class WidgetParent&lt;Widget&gt; { public void Slap(); } class WidgetChild&lt;WidgetParent&gt; { } </code></pre> <p>So that when I want to access the parent of WidgetChild, instead of using it this way:</p> <pre><code>WidgetParent wp = wc.parent as WidgetParent; if(wp != null) { wp.Slap(); } else throw FakeParentException(); </code></pre> <p>I want to use it this way(if I could use generics):</p> <pre><code>wc.parent.Slap(); </code></pre>
[ { "answer_id": 261104, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "class WidgetFactory\n{\n Widget CreateWidget()\n {\n return new Widget();\n }\n}\n" }, { "answer_id"...
2008/11/04
[ "https://Stackoverflow.com/questions/261086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6621/" ]
261,089
<p>how is it advisable to control the cpu utilization during run time ?</p> <p>poll the cpu load and insert sleeps ?</p>
[ { "answer_id": 261123, "author": "artur02", "author_id": 13937, "author_profile": "https://Stackoverflow.com/users/13937", "pm_score": 2, "selected": false, "text": "foreach (Process proc in Process.GetProcesses()) {\n using (PerformanceCounter pcProcess = new PerformanceCounter(\"Pro...
2008/11/04
[ "https://Stackoverflow.com/questions/261089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/195/" ]
261,092
<p>What are all <a href="http://en.wikipedia.org/wiki/Hayes_command_set" rel="nofollow noreferrer">AT</a> commands required for <a href="http://en.wikipedia.org/wiki/General_Packet_Radio_Service" rel="nofollow noreferrer">GPRS</a> communication?</p>
[ { "answer_id": 261144, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 2, "selected": false, "text": "MRESET:\nATZ\n" }, { "answer_id": 742102, "author": "hlovdal", "author_id": 23118, "author_profile": ...
2008/11/04
[ "https://Stackoverflow.com/questions/261092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,098
<p>I am currently using the following javascript to create an expanding menu:</p> <p><a href="http://demo.raibledesigns.com/struts-menu/scripts/menuExpandable.js.src" rel="nofollow noreferrer">http://demo.raibledesigns.com/struts-menu/scripts/menuExpandable.js.src</a></p> <p>Currently, only the hyperlink text is clickable. What is the best way to have the icon next to the text respond to the click?</p>
[ { "answer_id": 263365, "author": "Chris MacDonald", "author_id": 18146, "author_profile": "https://Stackoverflow.com/users/18146", "pm_score": 0, "selected": false, "text": "<a id=\"icon\" href=\"blah\">blah</a>\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,125
<p>I launch a child process in Java as follows:</p> <pre><code>final String[] cmd = {"&lt;childProcessName&gt;"}; Process process = Runtime.getRuntime().exec(cmd); </code></pre> <p>It now runs in the background. All good and fine. </p> <p>If my program now crashes (it <em>is</em> still in dev :-)) the child process still seems to hang around. How can I make it automatically end when the parent Java process dies?</p> <p>If it helps, I'm using Mac OS X 10.5</p>
[ { "answer_id": 261133, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 3, "selected": false, "text": "final String[] cmd = {\"<childProcessName>\"};\nfinal Process process = Runtime.getRuntime().exec(cmd);\nRunnable runna...
2008/11/04
[ "https://Stackoverflow.com/questions/261125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2959/" ]
261,139
<p>There are quite a lot of unittesting frameworks out there for .NET. I found this little feature comparison: <a href="https://xunit.net/docs/comparisons" rel="noreferrer">http://xunit.github.io/docs/comparisons.html</a></p> <p>Now I am to choose the best one for us. But how? Does it matter? Which one is most future proof and has a decent momentum behind it? Should I care about the features? While xUnit seems to be most modern and specifically designed for .NET, NUnit again seems to be the one that is widely accepted. MSTest again is already integrated into Visual Studio ...</p>
[ { "answer_id": 12611700, "author": "Matt Crouch", "author_id": 1670022, "author_profile": "https://Stackoverflow.com/users/1670022", "pm_score": 5, "selected": false, "text": "using Microsoft.VisualStudio.TestTools.UnitTesting;\nusing Assert = Xunit.Assert; // <-- Aliasing the Xunit nam...
2008/11/04
[ "https://Stackoverflow.com/questions/261139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
261,177
<p>[<em>Of course, the question is not restricted to a specific "friend" implementation, feel free though to point out implementation specifics if relevant</em>]</p> <p>Reading through the unanswered questions, I stumbled upon the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="noreferrer"><code>InternalsVisibleTo</code></a> attribute:</p> <blockquote> <p>Specifies that types that are ordinarily visible only within the current assembly are visible to another assembly.</p> </blockquote> <p>The <a href="http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx" rel="noreferrer">C# Programming Guide</a> on <a href="http://msdn.microsoft.com/en-us/library/" rel="noreferrer">MSDN</a> has a section <a href="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx" rel="noreferrer">Friend Assemblies</a> describing how to use the attribute to allow the use of <code>internal</code> methods and types to another assembly.</p> <p>I'm wondering whether it would be a Good Idea to use this to create a "hidden" interface for instrumenting a library for use by the unit testing assembly. It seems to increase coupling massively in both directions (testing code in the production assembly, intimate internal knowledge about the production assembly in testing code), but on the other hand it might help in creating fine-grained tests without cluttering the public interface.</p> <p>What is your experience with using friend declarations when testing? Was it your Silver Bullet, or did it start the Death March? </p>
[ { "answer_id": 261181, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "InternalsVisibleTo" }, { "answer_id": 261217, "author": "Bevan", "author_id": 30280, "author_profile...
2008/11/04
[ "https://Stackoverflow.com/questions/261177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918/" ]
261,190
<p>I am rendering a rails partial and I want to alternate the background color when it renders the partial. I know that is not super clear so here is an example of what I want to do:</p> Row One grey Background Row Two yellow background Row Three grey Background Row Four yellow background <ul> <li>sorry stackoverflow seams to prevent the background colors from being shown but I think this makes my idea clear</li> </ul> <p>This is the view code that I am using </p> <pre><code>&lt;table&gt; &lt;%= render :partial =&gt; 'row' :collection =&gt; @rows %&gt; &lt;/table&gt; </code></pre> <p>the _row.html.erb partial looks like this</p> <pre><code>&lt;tr bgcolor="#AAAAAA"&gt; &lt;td&gt;&lt;%= row.name %&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>The problem is I do not know how to change the background color for every other row. Is there a way to do this?</p>
[ { "answer_id": 261204, "author": "Kristian", "author_id": 23246, "author_profile": "https://Stackoverflow.com/users/23246", "pm_score": 5, "selected": true, "text": "<tr class=\"<%= cycle(\"even\", \"odd\") %>\">\n <td><%= row.name %></td>\n</tr>\n" }, { "answer_id": 14175375, ...
2008/11/04
[ "https://Stackoverflow.com/questions/261190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
261,202
<p>I've written a little web site in my effort to learn vb.net and asp.net, fairly happy with it so rented some space and uploaded it, it was written using asp.net express edition 2008 and sql server express .... I've uploaded it and I've found that it was written in .NET 3.5 and my host only deals with 2.01 ... I've sorted most of that out, and trimmed my web.config file back to basics, but my forms based authentication isn't working </p> <pre><code>&lt;compilation debug="true" strict="false" explicit="true"&gt; &lt;/compilation&gt; &lt;authentication mode="Forms" /&gt; &lt;customErrors mode="Off"/&gt; &lt;/system.web&gt; </code></pre> <p>And it keeps reporting that the sql server does not support remote access ...... not sure what to do next, I don't have to write my own security routines do i ? I have a sql server back end</p> <p>Thanks for your time</p> <p>Chris</p>
[ { "answer_id": 263709, "author": "spacemonkeys", "author_id": 32336, "author_profile": "https://Stackoverflow.com/users/32336", "pm_score": 0, "selected": false, "text": "<?xml version=\"1.0\"?>\n<configuration>\n <appSettings/>\n <connectionStrings>\n <add name=\"DatebaseConnecti...
2008/11/04
[ "https://Stackoverflow.com/questions/261202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32336/" ]
261,215
<p>I need to write the content of a map (key is ID of int, value is of self-defined struct) into a file, and load it from the file later on. Can I do it in MFC with CArchive?</p> <p>Thank you!</p>
[ { "answer_id": 261239, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 1, "selected": false, "text": "struct MapData {\n int m_int;\n std::string m_str;\n\n private: \n friend class boost::serialization::access; \n\...
2008/11/04
[ "https://Stackoverflow.com/questions/261215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26404/" ]
261,219
<p>I'm having a bit of trouble trying to get class variables to work in javascript. </p> <p>I thought that I understood the prototype inheritance model, but obviously not. I assumed that since prototypes will be shared between objects then so will their variables.</p> <p>This is why this bit of code confuses me.</p> <p>What is the correct way to implement class variables?</p> <pre><code>function classA() {}; classA.prototype.shared = 0; a = new classA; //print both values to make sure that they are the same classA.prototype.shared; a.shared; //increment class variable classA.prototype.shared++; //Verify that they are each 1 (Works) classA.prototype.shared; a.shared; //now increment the other reference a.shared++; //Verify that they are each 2 (Doesn't Work) classA.prototype.shared; a.shared; </code></pre> <p>UPDATE: So it seems that everyone is confirming the fact that by incrementing the instance's variable we don't affect the prototype. This is fine, this is what I have documented in my example, but doesn't this seem like an error in the design of the language? Why would this behavior be desirable? I find it weird that when the instance's var is undefined we follow the hidden link to the prototype where we get the value of the var, but we copy it into the instance object. </p> <p>I also understand that this isn't java/c++/ruby/python, it's a different language. I'm just curious as to why this behavior might be good. </p>
[ { "answer_id": 261241, "author": "Chei", "author_id": 11411, "author_profile": "https://Stackoverflow.com/users/11411", "pm_score": 1, "selected": false, "text": "a = new classA" }, { "answer_id": 261243, "author": "Frank Krueger", "author_id": 338, "author_profile": ...
2008/11/04
[ "https://Stackoverflow.com/questions/261219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28486/" ]
261,223
<p>I am creating my application using Django, and am wondering how I can make Django use my CSS file? What settings do I need to do to make Django see the css file?</p> <p>NB: On a local machine</p>
[ { "answer_id": 617130, "author": "Joe", "author_id": 74474, "author_profile": "https://Stackoverflow.com/users/74474", "pm_score": 7, "selected": true, "text": "/site_media/images/foo.gif" }, { "answer_id": 12706373, "author": "jacanterbury", "author_id": 765827, "aut...
2008/11/04
[ "https://Stackoverflow.com/questions/261223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26143/" ]
261,234
<p>Let's say I have an array of lots of values (C++ syntax, sorry):</p> <pre><code>vector&lt;double&gt; x(100000); </code></pre> <p>This array is sorted such that <code>x[n] &gt; x[n-1]</code>.</p> <p>I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface like:</p> <pre><code>void subarray(const double a, const double b, vector&lt;double&gt; &amp;sub) { ... } </code></pre> <p>When this function completes, <code>sub</code> will contain the <code>n</code> values that fell in the range [a, b].</p> <p>Of course a linear search is easy:</p> <pre><code>void subarray(const double a, const double b, vector&lt;double&gt; &amp;sub) { for (size_t i = 0; i &lt; data.size(); i++) { if (a &lt;= data[i] &amp;&amp; data[i] &lt;= b) { sub.push_back(data[i]); } } } </code></pre> <p>However, because <code>data</code> is sorted, I should be able to do this much faster using a binary search. Who wants to take a stab at it? Any language is permitted!</p>
[ { "answer_id": 261250, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 3, "selected": true, "text": "void subarray(const double a, const double b, vector <double> &sub, vector <int> pn) {\n vector <int>::const_...
2008/11/04
[ "https://Stackoverflow.com/questions/261234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
261,237
<p>How do I create an Application Pool on IIS 6.0 using a PowerShell script?</p> <p>This is what I have come up with so far ...</p> <pre><code>$appPool = [wmiclass] "root\MicrosoftIISv2:IIsApplicationPool" </code></pre> <p>Thanks</p>
[ { "answer_id": 263843, "author": "Steven Murawski", "author_id": 1233, "author_profile": "https://Stackoverflow.com/users/1233", "pm_score": 4, "selected": true, "text": "$AppPoolSettings = [wmiclass]'root\\MicrosoftIISv2:IISApplicationPoolSetting'\n$NewPool = $AppPoolSettings.CreateInst...
2008/11/04
[ "https://Stackoverflow.com/questions/261237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10784/" ]
261,271
<p>I'd like to compare two consecutive elements in a std::list while iterating through the list. What is the proper way to access element i+1 while my iterator is at element i? Thanks Cobe</p>
[ { "answer_id": 261277, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "next" }, { "answer_id": 261287, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackov...
2008/11/04
[ "https://Stackoverflow.com/questions/261271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,290
<p>Does MSTest have standalone GUI similar to nUnit that lets me use it and run test without visual studio? What is the official site for MSTest where I can learn more about how to use it?</p>
[ { "answer_id": 74107994, "author": "Iván Kollár", "author_id": 6281186, "author_profile": "https://Stackoverflow.com/users/6281186", "pm_score": 0, "selected": false, "text": "'dotnet test yourassembly.dll -l console -v detailed'\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
261,296
<p>I have a batch file (in windows XP, with command extension activated) with the following line:</p> <pre><code>for /f %%s in ('type version.txt') do set VERSION=%%s </code></pre> <p>On some computer, it works just fine (as illustrated by <a href="https://stackoverflow.com/questions/130116/dos-batch-commands-to-read-first-line-from-text-file">this SO question</a>), but on other <strong>it kills cmd</strong> (the console window just closes)</p> <p>Why ?</p> <hr> <p>Note: the computers seem to have a similar configuration: XpSP2, the user has administrative right, no 'Command processor" defined in HKEY_CURRENT_USER\Software\Microsoft\Command Processor...</p>
[ { "answer_id": 261299, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "for /f %%s in (version.txt) do ...\n" }, { "answer_id": 262599, "author": "Keng", "author_id": 730, "author_...
2008/11/04
[ "https://Stackoverflow.com/questions/261296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6309/" ]
261,311
<p>In C I know about the recursive function but I heard about the re-entrant function.<p>What is that? And whats the difference between them? </p>
[ { "answer_id": 261313, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 5, "selected": true, "text": "strtok()" }, { "answer_id": 314772, "author": "Johannes Schaub - litb", "author_id": 34509, "author_prof...
2008/11/04
[ "https://Stackoverflow.com/questions/261311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
261,316
<p>I have created a report in MS Access report and write some VBA code to retrive data and show the report in MS-Word format. But while generate the report on runtime, the report first show or flash the report design view for few seconds and the report will get generated. </p> <p>I would like to find a solution to avoid this flashing of design view while generate the report. Is it possible in this MS-Access or VBA coding. ??</p> <p>I am posting the lines which i used to call the access report from access form code.</p> <p>DoCmd.OpenReport rst![Argument], acPreview</p> <p>this will generate the report but the design screen is flashing for few seconds while execution. </p> <p>And there is no VBA code has been written in the access report.</p> <p>The actual running is, i have prepare the data in a temp access table and generate the report from the table. </p> <p>The problem here is, while launching the report in preview mode the design screen of the report shows of some few seconds. This looks bad from the users side. </p>
[ { "answer_id": 271239, "author": "David-W-Fenton", "author_id": 9787, "author_profile": "https://Stackoverflow.com/users/9787", "pm_score": 1, "selected": true, "text": " Dim strReport As Report \n strReport = rst!Argument\n If SysCmd(acSysCmdGetObjectState, acReport, strReport...
2008/11/04
[ "https://Stackoverflow.com/questions/261316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18792/" ]
261,336
<p>If I declare a temporary auto deleted character buffer using</p> <pre><code>std::auto_ptr&lt;char&gt; buffer(new char[n]); </code></pre> <p>then the buffer is automatically deleted when the buffer goes out of scope. I would assume that the buffer is deleted using delete.</p> <p>However the buffer was created using new[], and so strictly speaking the buffer should be deleted using delete[].</p> <p>What possibility is there that this mismatch might cause a memory leak?</p>
[ { "answer_id": 261355, "author": "Andreas Magnusson", "author_id": 5811, "author_profile": "https://Stackoverflow.com/users/5811", "pm_score": 3, "selected": false, "text": "std::vector<char>" }, { "answer_id": 262779, "author": "Martin York", "author_id": 14065, "aut...
2008/11/04
[ "https://Stackoverflow.com/questions/261336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/259/" ]
261,338
<p>Talking from a 'best practice' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the latter), but I'm curious to know which you think is best.</p> <pre><code>&lt;?php if($a){ ?&gt; [SOME MARKUP] &lt;?php } else{ ?&gt; [SOME OTHER MARKUP] &lt;?php } ?&gt; </code></pre> <p>Opposed to:</p> <pre><code>&lt;?php unset($out); if($a) $out = '[SOME MARKUP]'; else $out = '[OTHER MARKUP]'; print $out; ?&gt; </code></pre>
[ { "answer_id": 261384, "author": "neu242", "author_id": 13365, "author_profile": "https://Stackoverflow.com/users/13365", "pm_score": 1, "selected": false, "text": "<html><head><title>%title%</title></head><body>\n%mainbody%\nBla bla bla <a href=\"%linkurl%\">%linkname%</a>.\n</body></ht...
2008/11/04
[ "https://Stackoverflow.com/questions/261338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20603/" ]
261,345
<p>How do I get the complete request URL (including query string) in my controller? Is it a matter of concatenating my URL and form parameters or is there a better way.</p> <p>I checked <a href="https://stackoverflow.com/questions/40680/how-do-i-get-the-full-url-of-the-page-i-am-on-in-c">this</a> question, but it seems not to be applicable to MVC. </p> <p>Correct me if I'm wrong.</p> <p>Some more detailed information:</p> <p>My call to my <code>SearchController.AdvancedSearch()</code> originates from a form with about 15 optional parameters. Because of the number of parameters and no possible way (I think) to have optional parameters passed in a clean way, I went for a catchall string that is handled in the controller.</p> <p>Now I want my controller to store its call in a breadcrumb component so that when the crumb is clicked the exact same result can be fetched (with all, but not more, of the arguments included). To do this I need the entire request.URL, <em>including the querystring</em>.</p> <p>In <code>Request.RawURL</code>, <code>request.URL</code> etc this query string is not included. In fact currently I do a plain function.</p> <pre><code>String.Format("{0}/{1}", request.Url, request.form) </code></pre> <p>This gives me some weird results (like submit button values etc), but it works. If there are suggestions on how to make this less of an ugly hack, please do tell.</p> <p>I know where to find the current request, but I can't seem to find a raw URL anywhere though. They are all deprived from the querystring and I need that bit too.</p> <p>My controller updates a collection of URLs in my <code>BreadCrumb</code> component. Therefore it needs the request URL. How do you suggest I take on this problem?</p>
[ { "answer_id": 261411, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 2, "selected": false, "text": "HttpContext.Current.Request\n" }, { "answer_id": 261818, "author": "Jeff Sheldon", "author_id": 3391...
2008/11/04
[ "https://Stackoverflow.com/questions/261345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
261,348
<p>I want to share an object between my servlets and my webservice (JAX-WS) by storing it as a servlet context attribute. But how can I retrieve the servlet context from a web service?</p>
[ { "answer_id": 261349, "author": "Jens Bannmann", "author_id": 7641, "author_profile": "https://Stackoverflow.com/users/7641", "pm_score": 7, "selected": true, "text": "import javax.annotation.Resource;\nimport javax.servlet.ServletContext;\nimport javax.xml.ws.WebServiceContext;\nimport...
2008/11/04
[ "https://Stackoverflow.com/questions/261348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7641/" ]
261,351
<p>I have a web page <code>x.php</code> (in a password protected area of my web site) which has a form and a button which uses the <code>POST</code> method to send the form data and opens <code>x.php#abc</code>. This works pretty well.</p> <p>However, if the users decides to navigate back in Internet Explorer 7, all the fields in the original <code>x.php</code> get cleared and everything must be typed in again. I cannot save the posted information in a session and I am trying to understand how I can get IE7 to behave the way I want.</p> <p>I've searched the web and found answers which suggest that the HTTP header should contain explicit caching information. Currently, I've tried this :</p> <pre><code>session_name("FOO"); session_start(); header("Pragma: public"); header("Expires: Fri, 7 Nov 2008 23:00:00 GMT"); header("Cache-Control: public, max-age=3600, must-revalidate"); header("Last-Modified: Thu, 30 Oct 2008 17:00:00 GMT"); </code></pre> <p>and variations thereof. Without success. Looking at the returned headers with a tool such as <a href="http://www.wireshark.org/" rel="noreferrer">WireShark</a> shows me that Apache is indeed honouring my headers.</p> <p>So my question is: what am I doing wrong?</p>
[ { "answer_id": 261403, "author": "mkoeller", "author_id": 33433, "author_profile": "https://Stackoverflow.com/users/33433", "pm_score": 2, "selected": false, "text": "onload" }, { "answer_id": 261494, "author": "Kent Fredric", "author_id": 15614, "author_profile": "ht...
2008/11/04
[ "https://Stackoverflow.com/questions/261351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4597/" ]
261,362
<p>I've got an HTML "select" element which I'm updating dynamically with code something like this:</p> <pre><code>var selector = document.getElementById('selectorId'); for (var i = 0; i &lt; data.length; ++i) { var opt = document.createElement('option'); opt.value = data[i].id; opt.text = data[i].name; selector.appendChild(opt); } </code></pre> <p>Works fine in Firefox, but IE7 doesn't resize the list box to fit the new data. If the list box is initially empty (which it is in my case), you can hardly see any of the options I've added. Is there a better way to do this? Or a way to patch it up to work in IE?</p>
[ { "answer_id": 261409, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "innerHTML" }, { "answer_id": 261469, "author": "Marko Dumic", "author_id": 5817, "author_profile": "htt...
2008/11/04
[ "https://Stackoverflow.com/questions/261362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3974/" ]
261,368
<p>How do you calculate the number of <code>&lt;td&gt;</code> elements in a particular <code>&lt;tr&gt;</code>?</p> <p>I didn't specify id or name to access directly, we have to use the <code>document.getElementsByTagName</code> concept.</p>
[ { "answer_id": 261383, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 4, "selected": true, "text": "var rowIndex = 0; // rowindex, in this case the first row of your table\nvar table = document.getElementById('mytabl...
2008/11/04
[ "https://Stackoverflow.com/questions/261368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,374
<p>What is the most efficient way to enumerate every cell in every sheet in a workbook?</p> <p>The method below seems to work reasonably for a workbook with ~130,000 cells. On my machine it took ~26 seconds to open the file and ~5 seconds to enumerate the cells . However I'm no Excel expert and wanted to validate this code snippet with the wider community.</p> <pre><code>DateTime timer = DateTime.Now; Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application(); try { exampleFile = new FileInfo(Path.Combine(System.Environment.CurrentDirectory, "Large.xlsx")); excelApplication.Workbooks.Open(exampleFile.FullName, false, false, missing, missing, missing, true, missing, missing, true, missing, missing, missing, missing, missing); Console.WriteLine(string.Format("Took {0} seconds to open file", (DateTime.Now - timer).Seconds.ToString())); timer = DateTime.Now; foreach(Workbook workbook in excelApplication.Workbooks) { foreach(Worksheet sheet in workbook.Sheets) { int i = 0, iRowMax, iColMax; string data = String.Empty; Object[,] rangeData = (System.Object[,]) sheet.UsedRange.Cells.get_Value(missing); if (rangeData != null) { iRowMax = rangeData.GetUpperBound(0); iColMax = rangeData.GetUpperBound(1); for (int iRow = 1; iRow &lt; iRowMax; iRow++) { for(int iCol = 1; iCol &lt; iColMax; iCol++) { data = rangeData[iRow, iCol] != null ? rangeData[iRow, iCol].ToString() : string.Empty; if (i % 100 == 0) { Console.WriteLine(String.Format("Processed {0} cells.", i)); } i++; } } } } workbook.Close(false, missing, missing); } Console.WriteLine(string.Format("Took {0} seconds to parse file", (DateTime.Now - timer).Seconds.ToString())); } finally { excelApplication.Workbooks.Close(); excelApplication.Quit(); } </code></pre> <p><strong>Edit</strong>:</p> <p>Worth stating that I want to use PIA and interop in order to access properties of excel workbooks that are not exposed by API's that work directly with the Excel file.</p>
[ { "answer_id": 261412, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": true, "text": "Worksheet.UsedRange" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5182/" ]
261,375
<p>No doubt I'm missing something really simple here but I just can't see the problem with this query which is producing the following error:</p> <pre><code>SQL query: INSERT INTO ads( ad_id, author, ad_date, category, title, description, condition, price, fullname, telephone, email, status, photo, photothumb ) VALUES ( NULL , 'justal', '1225790938', 'Windsurf Boards', 'test', 'test', 'Excellent', '12', 'test', 'test', 'test', '', '', '' ); MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ad_id', 'author', 'ad_date', 'category', 'title', 'description', 'condition', '' at line 1 </code></pre> <p>Can someone with a fresh pair of eyes spot the problem?</p> <p>Thanks, Al. </p>
[ { "answer_id": 261380, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 3, "selected": true, "text": "INSERT INTO ads( `ad_id`, `author`, `ad_date`, `category`, `title`, `description`, `condition`, `price`, `fullname...
2008/11/04
[ "https://Stackoverflow.com/questions/261375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34019/" ]
261,377
<p>I apologize in advance for the long post...</p> <p>I used to be able to build our VC++ solutions (we're on VS 2008) when we listed the STLPort include and library directories under VS Menu > Tools > Options > VC++ Directories > Directories for Include and Library files. However, we wanted to transition to a build process that totally relies on .vcproj and .sln files. These can be checked into source control unlike VS Options which have to be configured on each development PC separately. We handled the transition for most libraries by adding the Include directories to each Project's Property Pages > Configuration Properties > C/C++ > General > Additional Include Directories, and Library directories to Linker > General > Additional Library Directories.</p> <p>Unfortunately, this approach doesn't work for STLPort. We get LNK2019 and LNK2001 errors during linking:</p> <pre><code>Error 1 error LNK2019: unresolved external symbol "public: virtual bool __thiscall MyClass::myFunction(class stlp_std::basic_istream&lt;char,class stlp_std::char_traits&lt;char&gt; &gt; &amp;,class MyOtherClass &amp;,class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; &amp;)const " (?myFunction@MyClass@@UBE_NAAV?$basic_istream@DV?$char_traits@D@stlp_std@@@stlp_std@@AAVSbprobScenarioData@@AAV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@3@@Z) referenced in function _main MyLibrary.obj Error 5 error LNK2001: unresolved external symbol "public: static void __cdecl MyClass::myFunction(class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; const &amp;,class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; const &amp;,class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; const &amp;,class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; const &amp;,long,enum MyClass::MessageType,int,class stlp_std::basic_string&lt;char,class stlp_std::char_traits&lt;char&gt;,class stlp_std::allocator&lt;char&gt; &gt; const &amp;)" (?myFunction@MyClass@@SAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@000JW4MessageType@1@H0@Z) MyLibrary.lib </code></pre> <p>This happens while linking and executable project to dependencies which are library projects. Curiously, this does not happen while linking the library projects themselves. Any ideas?</p>
[ { "answer_id": 687185, "author": "Aaron", "author_id": 28950, "author_profile": "https://Stackoverflow.com/users/28950", "pm_score": 3, "selected": false, "text": "Error 1 error LNK2019: unresolved external symbol \"public: unsigned char __cdecl TiXmlComment::Accept(bool,class Ti...
2008/11/04
[ "https://Stackoverflow.com/questions/261377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15515/" ]
261,386
<p>I'm new to Flex, and I'm trying to write a simple application. I have a file with an image and I want to display this image on a Graphics. How do I do this? I tried [Embed]-ding it and adding as a child to the component owning the Graphics', but I'm getting a "Type Coercion failed: cannot convert ... to mx.core.IUIComponent" error.</p>
[ { "answer_id": 261768, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 4, "selected": true, "text": "source" }, { "answer_id": 5192958, "author": "Levon", "author_id": 58038, "author_profile": "https://Stack...
2008/11/04
[ "https://Stackoverflow.com/questions/261386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6533/" ]
261,387
<p>I've noticed in many places in Java (C# included), that many "getter" methods are prefixed with "get" while many other aren't. I never noticed any kind of pattern Sun seems to be following. What are some guidelines or rules for using "get" in getter method names?</p>
[ { "answer_id": 261410, "author": "David Arno", "author_id": 7122, "author_profile": "https://Stackoverflow.com/users/7122", "pm_score": 2, "selected": false, "text": "obj.setX(10);\n" }, { "answer_id": 261425, "author": "Jon Skeet", "author_id": 22656, "author_profile...
2008/11/04
[ "https://Stackoverflow.com/questions/261387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30323/" ]
261,405
<p>There are two databases in SQL Server 2005: One called "A" and another one called "A_2". "A" is a variable name to be entered by the user, the "_2" prefix for the second database is always known. (So databases could be "MyDB" and "MyDB_2", etc)<br><br> How to access the other database from within a stored procedure without knowing the actual name and without using the 'exec' statement?</p>
[ { "answer_id": 1024290, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "if object_id('view_Table1') is not null\n drop view view_Table1\n\ndim @cmd nvarchar(max)\n\nset @cmd = 'create view view_...
2008/11/04
[ "https://Stackoverflow.com/questions/261405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34022/" ]
261,407
<p>Currently I have a structure like this:</p> <pre><code>A | +--B | +--C </code></pre> <p>It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in <a href="http://www.hibernate.org/hib_docs/v3/reference/en-US/html/inheritance.html#inheritance-tablepersubclass-discriminator" rel="noreferrer">Section 9.1.3 of the Hibernate manual</a>.</p> <p><strong>Question:</strong> How do I extend the mapping for a structure like this:</p> <pre><code>A | +--B | | | D | +--C </code></pre> <p>Can I <code>&lt;subclass&gt;</code> a <code>&lt;subclass&gt;</code> in the hibernate mapping? What <code>&lt;key&gt;</code>s do I need?</p>
[ { "answer_id": 262654, "author": "shyam", "author_id": 7616, "author_profile": "https://Stackoverflow.com/users/7616", "pm_score": 4, "selected": true, "text": "<hibernate-mapping>\n <class name=\"A\" table=\"A\">\n <id name=\"id\" type=\"long\" column=\"a_id\">\n <generator cla...
2008/11/04
[ "https://Stackoverflow.com/questions/261407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29549/" ]
261,419
<p>It's been a while since I last coded arm assembler and I'm a little rusty on the details. If I call a C function from arm, I only have to worry about saving r0-r3 and lr, right?</p> <p>If the C function uses any other registers, is it responsible for saving those on the stack and restoring them? In other words, the compiler would generate code to do this for C functions. </p> <p>For example if I use r10 in an assembler function, I don't have to push its value on the stack, or to memory, and pop/restore it after a C call, do I?</p> <p>This is for arm-eabi-gcc 4.3.0.</p>
[ { "answer_id": 18215803, "author": "Sven", "author_id": 1080389, "author_profile": "https://Stackoverflow.com/users/1080389", "pm_score": 3, "selected": false, "text": "void foo() {\n asm volatile ( \"nop\" : : : \"r0\", \"r1\", \"r2\", \"r3\", \"r4\", \"r5\", \"r6\", \"r7\", \"r8\", \"...
2008/11/04
[ "https://Stackoverflow.com/questions/261419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596/" ]
261,422
<p>Does anyone know how to tell VS(2008) where to save the obj folder when building the solution? We have it save the bin folder to another path in order to keep the source file folders small (ie. emailable), but can't find any way to tell it to do the same with obj...</p>
[ { "answer_id": 261445, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 7, "selected": true, "text": "BaseIntermediateOutputPath" }, { "answer_id": 3687173, "author": "Dominik Antal", "author_id": 342862, ...
2008/11/04
[ "https://Stackoverflow.com/questions/261422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
261,423
<p>How can we handel key pressed event in asp.net</p>
[ { "answer_id": 261457, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 1, "selected": false, "text": "Enter" }, { "answer_id": 261460, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflo...
2008/11/04
[ "https://Stackoverflow.com/questions/261423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,424
<p>I have a dialog where each entry in a JTree has its corresponding options in a different panel, which is updated when the selection changes. If options for one of the entries is set to an invalid state, when the user attempts to change to a different entry in the tree, I want there to be an error dialog and have the selection not change.</p> <p>I tried doing this with a valueChangeListener on the JTree, but currently then have to have the valueChanged method call "setSelectionRow" to the old selection if there is an error. So that I don't get a StackOverflow, I set a boolean "isError" to true before I do this so that I can ignore the new valueChanged event. Somehow I have the gut feeling this is not the best solution. ;-)</p> <p>How would I go about it instead? Is there a good design pattern for situations like this?</p>
[ { "answer_id": 574109, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": " navTree.addTreeSelectionListener(new TreeSelectionListener() {\n\n boolean treeSelectionListenerEnabled = true;\n\n...
2008/11/04
[ "https://Stackoverflow.com/questions/261424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
261,428
<p>So far I've been using <code>public void run() {}</code> methods to execute my code in Java. When/why might one want to use <code>main()</code> or <code>init()</code> instead of <code>run()</code>?</p>
[ { "answer_id": 261436, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "main()" }, { "answer_id": 261447, "author": "Matthew Schinckel", "author_id": 188, "author_profile":...
2008/11/04
[ "https://Stackoverflow.com/questions/261428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
261,430
<p>I want to detect whether adobe reader is installed using VB6. Also if detected that it's not installed, what would be the best solution?</p>
[ { "answer_id": 553400, "author": "Rob Haupt", "author_id": 65388, "author_profile": "https://Stackoverflow.com/users/65388", "pm_score": 0, "selected": false, "text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,431
<p>I have a variable </p> <pre><code>unsigned char* data = MyFunction(); </code></pre> <p>how to find the length of data?</p>
[ { "answer_id": 261437, "author": "kenny", "author_id": 3225, "author_profile": "https://Stackoverflow.com/users/3225", "pm_score": 3, "selected": false, "text": "string" }, { "answer_id": 261451, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://...
2008/11/04
[ "https://Stackoverflow.com/questions/261431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,449
<p>I'm trying to do the classic Insert/Update scenario where I need to update existing rows in a database or insert them if they are not there.</p> <p>I've found a <a href="https://stackoverflow.com/questions/13540/insert-update-stored-proc-on-sql-server">previous question on the subject</a>, but it deals with stored procedures, which I'm not using. I'd like to just use plain SQL SELECT, INSERT and UPDATE statements, unless there's something better available (the MERGE statement isn't available in SQL Server 2005).</p> <p>I guess my general idea is this:</p> <pre><code>If the row is found update else insert </code></pre> <p>As for checking for a row's existence, how expensive is it to do a SELECT statement before calling an UPDATE or an INSERT? Or is it better to just try an UPDATE, check for the number of rows affected, and then do an INSERT if the rows affected is 0?</p>
[ { "answer_id": 261466, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 4, "selected": true, "text": "UPDATE" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30023/" ]
261,455
<p>After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL.</p> <p>That is:</p> <pre><code>SELECT `id`, `name`, `anotherfield` ... -- vs -- SELECT id, name, anotherfield ... </code></pre>
[ { "answer_id": 261476, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 8, "selected": true, "text": "SELECT `id`, `my name`, `another field` , `field,with,comma` \n" }, { "answer_id": 261484, "author": "Chri...
2008/11/04
[ "https://Stackoverflow.com/questions/261455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
261,463
<p>We have a couple of web servers using load balancer. Machines are running IIS6 on port 81. Externally, site is accessable using port 80. External name and name of the machine are different.</p> <p>We're getting </p> <pre><code>System.ServiceModel.EndpointNotFoundException: The message with To '&lt;url&gt;' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. </code></pre> <p>Relevant part of web.config is:</p> <pre><code> &lt;endpoint binding="ws2007HttpBinding" bindingConfiguration="MyServiceBinding" contract="MyService.IMyService" listenUriMode="Explicit" /&gt; </code></pre> <p>We tried adding listenUri, but that didn't solve our problems.</p> <p>Any ideas?</p>
[ { "answer_id": 482995, "author": "bh213", "author_id": 28912, "author_profile": "https://Stackoverflow.com/users/28912", "pm_score": 4, "selected": true, "text": "[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28912/" ]
261,490
<p>I am building a small system administration web application (think Web-Min, but in RoR) and I need to be able to access system parameters from my Ruby code. For instance, I want to allow the user to change the hostname, time zone, or network config of the server. </p> <p>My current thoughts are to have a separate setuid script (Perl, Ruby, ??) so that I can call it from my RoR code and it will perform the actions. That is quite cumbersome and not very elegant. I'm a Ruby newbie and would like to know if there is a better way to accomplish this type of thing.</p> <p>Thanks!</p>
[ { "answer_id": 261698, "author": "Richard Hurt", "author_id": 21512, "author_profile": "https://Stackoverflow.com/users/21512", "pm_score": 0, "selected": false, "text": "result = %x[uptime]" }, { "answer_id": 261928, "author": "dbr", "author_id": 745, "author_profile...
2008/11/04
[ "https://Stackoverflow.com/questions/261490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21512/" ]
261,500
<p>Most of the documentation available for building Python extension modules uses distutils, but I would like to achieve this by using the appropriate python autoconf &amp; automake macros instead.</p> <p>I'd like to know if there is an open source project out there that does exactly this. Most of the ones I've found end up relying on a setup.py file. Using that approach works, but unfortunately ends up rebuilding the entire source tree any time I make a modification to the module source files.</p>
[ { "answer_id": 13711218, "author": "clarete", "author_id": 1336414, "author_profile": "https://Stackoverflow.com/users/1336414", "pm_score": 4, "selected": false, "text": "src" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9589/" ]
261,512
<p>I'm currently working with Db2 Enterprise Server V 8.2 with FixPak 10</p> <p>And I want to retrieve list of all the open active connections with an instance.</p> <p>In Oracle there is a utility program called &quot;Top Session&quot; which does the similar task. Is there any equivalent in DB2?</p>
[ { "answer_id": 261578, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "LIST APPLICATIONS\n" }, { "answer_id": 265776, "author": "Fuangwith S.", "author_id": 24550, "auth...
2008/11/04
[ "https://Stackoverflow.com/questions/261512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34058/" ]
261,515
<p>I have a large set of files, some of which contain special characters in the filename (e.g. ä,ö,%, and others). I'd like a script file to iterate over these files and rename them removing the special characters. I don't really mind what it does, but it could replace them with underscores for example e.g.</p> <p>Störung%20.doc would be renamed to St_rung_20.doc</p> <p>In order of preference:</p> <ol> <li>A Windiws batch file</li> <li>A Windows script file to run with cscript (vbs)</li> <li>A third party piece of software that can be run from the command-line (i.e. no user interaction required)</li> <li>Another language script file, for which I'd have to install an additional script engine</li> </ol> <p>Background: I'm trying to encrypt these file with GnuPG on Windows but it doesn't seem to handle special characters in filenames with the --encrypt-files option.</p>
[ { "answer_id": 261552, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "chcp 65001" }, { "answer_id": 261553, "author": "Treb", "author_id": 22114, "author_profile": "https:/...
2008/11/04
[ "https://Stackoverflow.com/questions/261515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9625/" ]
261,518
<p>Here's the situation:</p> <p>I have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE).</p> <p>In MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class called MyClassTest, where I create instances of MyClass and test them.</p> <p>My question: how can I link the object file of MyClass, created by building MyDll, to the MyDllUnitTest EXE? I don't want to build MyClass in MyDllUnitTest and I don't want to export the class.</p> <p>I tried using the same <em>Intermediate Directory</em> for both projects (so object files are in the same directory) and using the References feature of VS2005 (right click project --> References --> Add New Reference...), but it didn't work - I still get a linking error (LNK2001).</p> <p><strong>Edit:</strong> I don't want to have the same source file in two projects - consider the face that I have many MyClass/MyClassTest, which means I have to duplicate each MyClass to a different project. I know it is possible to use the same object file in two projects, I've seen it done before but forgot how.</p> <p><strong>Edit:</strong> I've decided to put the files in both projects, so they are compiled twice. It turns out the "Reference" feature works automatically - but only for static lib projects.</p>
[ { "answer_id": 261579, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 3, "selected": true, "text": "extern \"C\" MyClass *CreateMyClass();\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33982/" ]
261,522
<p>What is the command to match brackets in Emacs (the equivalent of the <code>%</code> command in Vim)?</p>
[ { "answer_id": 261545, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 7, "selected": true, "text": "show-paren-mode" }, { "answer_id": 261712, "author": "Chris Conway", "author_id": 1412, "autho...
2008/11/04
[ "https://Stackoverflow.com/questions/261522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24508/" ]
261,525
<p>We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved:</p> <p>In our .csproj files, there are these settings:</p> <ul> <li>&lt;SccProjectName></li> <li>&lt;SccLocalPath></li> <li>&lt;SccAuxPath></li> <li>&lt;SccProvider></li> </ul> <p>Sometimes they are all set to "SAK", sometimes not. It seems things are more likely to work if these say "SAK".</p> <p>In our .sln file, there are settings for many of the projects:</p> <ul> <li>SccLocalPath#</li> <li>SccProjectFilePathRelativizedFromConnection#</li> <li>SccProjectUniqueName#</li> </ul> <p>(The # is a number that identifies each project.) SccLocalPath is a path relative to the solution file. Often it is ".", sometimes it is the folder that the project is in, and sometimes it is ".." or "..\..", and it seems to be bad for it to point to a folder above the solution folder. The relativized one is a path <em>from</em> that folder to the project file. It will be missing entirely if SccLocalPath points to the project's folder. If the SccLocalPath has ".." in it, this path might include folder names that are not the same between branches, which I think causes problems.</p> <p>So, to finally get to the specifics I'd like to know:</p> <ul> <li>What happens when you do "Change source control" and bind projects? How does Visual Studio decide what to put in the project and solution files?</li> <li>What happens when you do "Open from source control"?</li> <li>What's this "connection" folder that SccLocalPath and SccProjectFilePathRelativizedFromConnection refer to? How does Visual Studio/Perforce pick it?</li> <li>Is there some recommended way to make the source control bindings continue to work even when you create a new branch of the solution?</li> </ul> <hr> <p><em>Added June 2012:</em> I don't use Perforce any more, so I can't vouch for it, but have a look at <a href="https://stackoverflow.com/a/11148342/2283">KCD's answer</a> below. Apparently there's <a href="http://forums.perforce.com/index.php?/topic/1585-new-perforce-plugin-for-visual-studio-20121-beta-available-now/" rel="nofollow noreferrer">a new P4 VS plugin</a> under development. Hopefully it should clear up all this mess!</p>
[ { "answer_id": 268578, "author": "Thomas L Holaday", "author_id": 29403, "author_profile": "https://Stackoverflow.com/users/29403", "pm_score": 1, "selected": false, "text": "/Solution\n /library1\n /library2\n /product1\n /product2\n /subsolution\n /sublibrary1\n /subproduct1...
2008/11/04
[ "https://Stackoverflow.com/questions/261525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2283/" ]
261,534
<p>I have an application I am writing in PHP5, using the CodeIgniter framework. I have it running on both Windows (using Xampp) and Ubuntu (using standard Apache, PHP, MySQL stack).</p> <p>I have a form, that takes XML, parses it (using simpleXML) and posts the results into a database.</p> <p>On Windows - no problem, works as intended.</p> <p>On Linux - big problem. It errors out.</p> <p>I have double checked the XML, and it's fine.</p> <p>I removed a large amount of the XML, and it seems that it is OK.</p> <p>I think it's related to the size of the XML string being posted from the form, but am not sure. Again, on Windows it's OK - on Linux, it errors out.</p> <p>The size of the data posted in the form is ~160k (yeah, that's a lot of text, but it's automated - AND it's gonna eventually be about 200k).</p> <p>The error is below.</p> <p>Any help much appreciated.</p> <blockquote> <p>Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/ci/system/application/controllers/system.php:49 Stack trace: #0 /var/www/ci/system/application/controllers/system.php(49): SimpleXMLElement->__construct('') #1 [internal function]: System->add_system() #2 /var/www/ci/system/codeigniter/CodeIgniter.php(233): call_user_func_array(Array, Array) #3 /var/www/ci/index.php(115): require_once('/var/www/ci/sys...') #4 {main} thrown in /var/www/ci/system/application/controllers/system.php on line 49</p> </blockquote> <p>Line 49 looks like this:</p> <p><code>$xml = new SimpleXMLElement($this-&gt;input-&gt;post('form_systemXML'));</code></p> <p>EDIT - FIXED</p> <p>Found the issue. Suhosin is installed on Ubuntu. in the file /etc/php5/apache2/conf.d/suhosin.ini, I enabled the line <code>suhosin.post.max_value_length = 65000</code> and changed the value to 195000. Restarted Apache, and all good. Thanks for the pointers guys.</p>
[ { "answer_id": 261575, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 1, "selected": false, "text": "print_r($_POST);\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34067/" ]
261,535
<p>I'm by no means a sysadmin so please correct me if I'm wrong.</p> <p>I want to run aspnet_regiis.exe -s. This requires the metabase path of my website.</p> <p>How do I find this metabase path?</p>
[ { "answer_id": 18454482, "author": "Slider345", "author_id": 356544, "author_profile": "https://Stackoverflow.com/users/356544", "pm_score": 1, "selected": false, "text": "/W3SVC/<site id>/Root" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
261,536
<p>I'm getting the following error when my win32 (c#) app is calling web services.</p> <pre><code>The request failed with HTTP status 504: Gateway timeout server response timeout. </code></pre> <p>I understand 'I think' that this is because the upstream request does not get a response in a timely fashion.</p> <p>But my question is this? How do I change the <strong>app.config</strong> settings in my win32 application to allow more time to process its data. I assume I require these changes to be made on my app settings as the webservices and IIS hosting the ws are setup with extended times.</p> <p>Look forward to a response and thank you in advance.</p>
[ { "answer_id": 35071350, "author": "dynamiclynk", "author_id": 1427166, "author_profile": "https://Stackoverflow.com/users/1427166", "pm_score": 1, "selected": false, "text": " \"commands\": {\n \"web\": \"Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5090\"\n },\n" ...
2008/11/04
[ "https://Stackoverflow.com/questions/261536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26098/" ]
261,539
<p>I've got a WCF service that uses a LinqToSql DataContext to fetch some information out of a database. The return type of the operation is IEnumerable<code>&lt;DomainObject</code>>, and I have a helper method that converts from the Table-derived LINQ object to a WCF data contract like so:</p> <pre><code>[OperationContract] public IEnumerable&lt;DomainObjectDTO&gt; RetrieveDomainObjects() { var context = CreateDataContext(); return from domainObject in context.DomainObjects select ConvertDomainObject(domainObject); } private DomainObjectDTO ConvertDomainObject(DomainObject obj) { // etc... } </code></pre> <p>This code exhibits a strange behaviour if I pass an invalid connection string to the DataContext. Being unable to find the correct database, presumably the above code throws a SqlException when enumerating the IEnumerable<code>&lt;DomainObjectDTO</code>> when serialization is happening. However, when I run this code in my debugger, I see no first-chance exception on the server side at all! I told the debugger in the Exceptions tab to break on all thrown CLR exceptions, and it simply doesn't. I also don't see the characteristic "First chance exception" message in the Output window.</p> <p>On the client side, I get a CommunicationException with an error message along the lines of "The socket connection terminated unexpectedly". None of the inner exceptions provides any hint as to the underlying cause of the problem.</p> <p>The only way I could figure this out was to rewrite the LINQ code in such a way that the query expression is evaluated inside of the OperationContract method. Incidentally, I get the same result if there is a permissions problem, or if I wrap the DataContext in a using statement, so this is not just isolated to SqlExceptions.</p> <p>Disregarding the inadvisability of making the return type an IEnumerable<code>&lt;T</code>> and only enumerating the query somewhere in the depths of the serializer, is WCF suppressing or somehow preventing exceptions from being thrown in this case? And if so, why?</p>
[ { "answer_id": 261556, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "IErrorHandler" }, { "answer_id": 261587, "author": "Darren", "author_id": 6065, "author_profile":...
2008/11/04
[ "https://Stackoverflow.com/questions/261539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32539/" ]
261,543
<p>Is there a way to drop a validation that was set in Rails plugin (or included module)? Let's say I have some model with module included in it:</p> <pre><code>class User &lt; ActiveRecord::Base include SomeModuleWithValidations # How to cancel validates_presence_of :something here? end module SomeModuleWithValidations def self.included(base) base.class_eval do validates_presence_of :something end end end </code></pre> <p>My only idea so far was to do something like:</p> <pre><code>validates_presence_of :something, :if =&gt; Proc.new{1==2} </code></pre> <p>which would work, I think, but it isn't particulary pretty.</p>
[ { "answer_id": 261713, "author": "Kristian", "author_id": 23246, "author_profile": "https://Stackoverflow.com/users/23246", "pm_score": 1, "selected": false, "text": "def self.validates_presence_of(*args)\n return if args.first == :foo\n super\nend\n" } ]
2008/11/04
[ "https://Stackoverflow.com/questions/261543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26123/" ]
261,547
<p>This query is related to <a href="https://stackoverflow.com/questions/259850/javascript-multiple-client-side-validations-on-same-event">this</a> one I asked yesterday. I have a radio button list on my asp.net page defined as follows: </p> <pre><code>&lt;asp:RadioButtonList ID="rdlSortBy" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" AutoPostBack="True" &gt; &lt;asp:ListItem Selected="True"&gt;Name&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Staff No&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; </code></pre> <p>On the client-side, am doing the following validations:</p> <pre><code>rdlSortBy.Attributes("onclick") = "javascript:return prepareSave() &amp;&amp; prepareSearch();" </code></pre> <p>The problem is that the Javascript validation runs as expected. A message is displayed and I expect to remain on the page until user has saved the changes, instead the page is posted back and effectively I am loosing unsaved changes.</p> <p>What could be going wrong?</p>
[ { "answer_id": 261632, "author": "Adrian Clark", "author_id": 148, "author_profile": "https://Stackoverflow.com/users/148", "pm_score": 1, "selected": false, "text": "OnClick" }, { "answer_id": 271713, "author": "Julius A", "author_id": 13370, "author_profile": "https...
2008/11/04
[ "https://Stackoverflow.com/questions/261547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
261,559
<p>I was wondering how to make a toolbar in MFC that used 24bit or 256 colour bitmaps rather than the horrible 16 colour ones.</p> <p>Can anyone point me in the direction of some simple code?</p> <p>Thanks</p>
[ { "answer_id": 261589, "author": "Stu Mackellar", "author_id": 28591, "author_profile": "https://Stackoverflow.com/users/28591", "pm_score": 5, "selected": true, "text": "HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),\n MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_BITMAP,\n ...
2008/11/04
[ "https://Stackoverflow.com/questions/261559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
261,567
<p>I'm kind of new to C++ and have some questions, this is one of them.</p> <p>Is there ANY reason when you are using a function that takes in one or several parameters, parameters of which you know will always be stored in a variable before the function call, to pass a copy of the variable, rather than a pointer to the variable? </p> <p>I'm talking in terms of performance. Seems to me that it would take a lot more resources to pass a copy of a whole struct than just a pointer(4 bytes).</p>
[ { "answer_id": 261571, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 2, "selected": false, "text": "const" }, { "answer_id": 261598, "author": "Motti", "author_id": 3848, "author_profile": "https://Stack...
2008/11/04
[ "https://Stackoverflow.com/questions/261567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
261,572
<p>I am building a FAQ module for my site and I want to be able to control single elements on the page even though they all have the same class. I believe this comes under siblings which I am not yet familiar with.</p> <p>Basically I want the user to be able to click the question div and then when they click it the answer div within the same div as the question div is set to show (if that makes sense!). Any help would be greatly appreciated.</p> <pre><code>&lt;div class="set"&gt; &lt;div class="question"&gt;What is the airspeed velocity of an unladen swallow?&lt;/div&gt; &lt;div class="answer"&gt;Although a definitive answer would of course require further measurements, published species-wide averages of wing length and body mass, initial Strouhal estimates based on those averages and cross-species comparisons, the Lund wind tunnel study of birds flying at a range of speeds, and revised Strouhal numbers based on that study all lead me to estimate that the average cruising airspeed velocity of an unladen European Swallow is roughly 11 meters per second, or 24 miles an hour. &lt;/div&gt; &lt;/div&gt; &lt;div class="set"&gt; &lt;div class="question"&gt;What is the airspeed velocity of an unladen swallow?&lt;/div&gt; &lt;div class="answer"&gt;Although a definitive answer would of course require further measurements, published species-wide averages of wing length and body mass, initial Strouhal estimates based on those averages and cross-species comparisons, the Lund wind tunnel study of birds flying at a range of speeds, and revised Strouhal numbers based on that study all lead me to estimate that the average cruising airspeed velocity of an unladen European Swallow is roughly 11 meters per second, or 24 miles an hour. &lt;/div&gt; &lt;/div&gt; &lt;div class="set"&gt; &lt;div class="question"&gt;What is the airspeed velocity of an unladen swallow?&lt;/div&gt; &lt;div class="answer"&gt;Although a definitive answer would of course require further measurements, published species-wide averages of wing length and body mass, initial Strouhal estimates based on those averages and cross-species comparisons, the Lund wind tunnel study of birds flying at a range of speeds, and revised Strouhal numbers based on that study all lead me to estimate that the average cruising airspeed velocity of an unladen European Swallow is roughly 11 meters per second, or 24 miles an hour. &lt;/div&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 261596, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 3, "selected": true, "text": "$(document).ready ( function () {\n $('.question').click(function() {\n $(this).next('.answer').show();\n });\n});\n" ...
2008/11/04
[ "https://Stackoverflow.com/questions/261572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
261,573
<p>Is there an efficient algorithm for detecting cycles within a directed graph?</p> <p>I have a directed graph representing a schedule of jobs that need to be executed, a job being a node and a dependency being an edge. I need to detect the error case of a cycle within this graph leading to cyclic dependencies.</p>
[ { "answer_id": 261595, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 9, "selected": true, "text": "O(|E| + |V|)" }, { "answer_id": 261621, "author": "Steve Jessop", "author_id": 13005, "author_profile": "http...
2008/11/04
[ "https://Stackoverflow.com/questions/261573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34080/" ]