qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
31,790
<p>How many ServiceContracts can a WCF service have?</p> <p>Specifically, since a ServiceContract is an attribute to an interface, how many interfaces can I code into one WCF web service? Is it a one-to-one?</p> <p>Does it make sense to separate the contracts across multiple web services?</p>
[ { "answer_id": 31809, "author": "Ubiguchi", "author_id": 2562, "author_profile": "https://Stackoverflow.com/users/2562", "pm_score": 4, "selected": false, "text": "[ServiceBehavior(Namespace = \"DemoService\")]\npublic class DemoService : IDemoService, IDoNothingService\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/31790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/831/" ]
31,794
<p>In .net frameworks 1.1, I use </p> <pre><code>System.Configuration.ConfigurationSettings.AppSettings["name"]; </code></pre> <p>for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this:</p> <pre><code>System.Configuration.ConfigurationManager.AppSettings["name"]; </code></pre> <p>The problem is, ConfigurationManager was not found in the System.Configuration namespace. I've been banging my head against the wall trying to figure out what I'm doing wrong. Anybody got any ideas?</p>
[ { "answer_id": 31838, "author": "Joda", "author_id": 1090, "author_profile": "https://Stackoverflow.com/users/1090", "pm_score": 1, "selected": false, "text": "ConfigurationSettings.AppSettings[\"name\"];\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/31794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2121/" ]
31,799
<p><strong>NOTE: <em>XMLIgnore</em> is NOT the answer!</strong></p> <p>OK, so following on from my question on <a href="https://stackoverflow.com/questions/20084/xml-serialization-and-inherited-types">XML Serialization and Inherited Types</a>, I began integrating that code into my application I am working on, stupidly thinking all will go well..</p> <p>I ran into problems with a couple of classes I have that implement <em>IEnumerable</em> and <em>ICollection&lt;T&gt;</em></p> <p>The problem with these is that when the XMLSerializer comes to serialize these, it views them as an external property, and instead of using the property we would like it to (i.e. the one with our <em>AbstractXmlSerializer</em> ) it comes here and falls over (due to the type mismatch), pretty much putting us back to square one. You cannot decorate these methods with the <strong>XmlIgnore</strong> attribute either, so we cannot stop it that way.</p> <p>My current solution is to remove the interface implementation (in this current application, its no real big deal, just made the code prettier).</p> <p><strong>Do I need to swallow my pride on this one and accept it cant be done?</strong> I know I have kinda pushed and got more out of the XmlSerializer than what was expected of it :)</p> <hr /> <h3>Edit</h3> <p>I should also add, I am currently working in framework 2.</p> <hr /> <h3>Update</h3> <p>I have accepted <a href="https://stackoverflow.com/questions/31799/preventing-xml-serialization-of-ienumerable-and-icollectiont-inherited-types#31810">lomaxx's answer</a>. In my scenario I cannot actually do this, but I do know it will work. Since their have been no other suggestions, I ended up removing the interface implementation from the code.</p>
[ { "answer_id": 31824, "author": "Brian Leahy", "author_id": 580, "author_profile": "https://Stackoverflow.com/users/580", "pm_score": 1, "selected": false, "text": " [XmlArray(\"ProviderPatientLists\")]\n [XmlArrayItem(\"File\")]\n public ProviderPatientList Files\n ...
2008/08/28
[ "https://Stackoverflow.com/questions/31799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
31,818
<p>How can I find out which Service Pack is installed on my copy of SQL Server?</p>
[ { "answer_id": 31820, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 5, "selected": true, "text": "-- SQL Server 2000/2005\nSELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edi...
2008/08/28
[ "https://Stackoverflow.com/questions/31818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3353/" ]
31,849
<p>It seems that it is impossible to capture the keyboard event normally used for copy when running a Flex application in the browser or as an AIR app, presumably because the browser or OS is intercepting it first.</p> <p>Is there a way to tell the browser or OS to let the event through?</p> <p>For example, on an AdvancedDataGrid I have set the keyUp event to handleCaseListKeyUp(event), which calls the following function:</p> <pre><code> private function handleCaseListKeyUp(event:KeyboardEvent):void { var char:String = String.fromCharCode(event.charCode).toUpperCase(); if (event.ctrlKey &amp;&amp; char == "C") { trace("Ctrl-C"); copyCasesToClipboard(); return; } if (!event.ctrlKey &amp;&amp; char == "C") { trace("C"); copyCasesToClipboard(); return; } // Didn't match event to capture, just drop out. trace("charCode: " + event.charCode); trace("char: " + char); trace("keyCode: " + event.keyCode); trace("ctrlKey: " + event.ctrlKey); trace("altKey: " + event.altKey); trace("shiftKey: " + event.shiftKey); } </code></pre> <p>When run, I can never get the release of the "C" key while also pressing the command key (which shows up as KeyboardEvent.ctrlKey). I get the following trace results:</p> <pre><code>charCode: 0 char: keyCode: 17 ctrlKey: false altKey: false shiftKey: false </code></pre> <p>As you can see, the only event I can capture is the release of the command key, the release of the "C" key while holding the command key isn't even sent.</p> <p>Has anyone successfully implemented standard copy and paste keyboard handling?</p> <p>Am I destined to just use the "C" key on it's own (as shown in the code example) or make a copy button available?</p> <p>Or do I need to create the listener manually at a higher level and pass the event down into my modular application's guts?</p>
[ { "answer_id": 48427, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 0, "selected": false, "text": "event.ctrlKey && event.keyCode = Keyboard.C" }, { "answer_id": 426982, "author": "Community", "author_id": -1, ...
2008/08/28
[ "https://Stackoverflow.com/questions/31849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3023/" ]
31,865
<p>I know this might be a no-brainer, but please read on.</p> <p>I also know it's generally not considered a good idea, maybe the worst, to let a browser run and interact with local apps, even in an intranet context.</p> <p>We use Citrix for home-office, and people really like it. Now, they would like the same kind of environment at work, a nice page where every important application/document/folder is nicely arranged and classified in an orderly fashion. These folks are not particularly tech savvy; I don't even consider thinking that they could understand the difference between remote delivered applications and local ones.</p> <p>So, I've been asked if it's possible. Of course, it is, with IE's good ol' ActiveX controls. And I even made a working prototype (that's where it hurts).</p> <p>But now, I doubt. Isn't it madness to allow such 'dangerous' ActiveX controls, even in the '<em>local intranet</em>' zone? People will use the same browser to surf the web, can I fully trust IE? Isn't there a risk that Microsoft would just disable those controls in future updates/versions? What if a website, or any kind of malware, just put another site on the trust list? With that extent of control, you could as well uninstall every protection and just run amok 'till you got hanged by the IT dept.</p> <p>I'm about to confront my superiors with the fact that, even if they saw it is doable, it would be a very bad thing. So I'm desperately in need of good and strong arguments, because "<em>let's don't</em>" won't do it.</p> <p>Of course, if there is nothing to be scared of, that'll be nice too. But I strongly doubt that.</p>
[ { "answer_id": 33689, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 1, "selected": false, "text": "<a href=\"dial#1800-234-567\">Call John Smith</a>\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/31865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452/" ]
31,867
<p>While I've seen rare cases where <em>private</em> inheritance was needed, I've never encountered a case where <em>protected</em> inheritance is needed. Does someone have an example?</p>
[ { "answer_id": 82215, "author": "Antti Kissaniemi", "author_id": 2948, "author_profile": "https://Stackoverflow.com/users/2948", "pm_score": 1, "selected": false, "text": "derivedFunction()" }, { "answer_id": 280453, "author": "Johannes Schaub - litb", "author_id": 34509,...
2008/08/28
[ "https://Stackoverflow.com/questions/31867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2638/" ]
31,868
<p>What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?</p> <p><strong>Following the two initial answers...</strong></p> <ul> <li><p>We definitely need to use the Web Service layer as we will be making these calls from remote client applications.</p></li> <li><p>The WebDAV method would work for us, but we would prefer to be consistent with the web service integration method.</p></li> </ul> <p><Blockquote> There is additionally a web service to upload files, painful but works all the time. </Blockquote></p> <p>Are you referring to the “Copy” service? We have been successful with this service’s <code>CopyIntoItems</code> method. Would this be the recommended way to upload a file to Document Libraries using only the WSS web service API?</p> <p>I have posted our code as a suggested answer.</p>
[ { "answer_id": 34274, "author": "Andy McCluggage", "author_id": 3362, "author_profile": "https://Stackoverflow.com/users/3362", "pm_score": 5, "selected": true, "text": "public static void UploadFile2007(string destinationUrl, byte[] fileData)\n{\n // List of desination Urls, Just one...
2008/08/28
[ "https://Stackoverflow.com/questions/31868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3362/" ]
31,870
<p>What is the best way to include an html entity in XSLT?</p> <pre><code>&lt;xsl:template match="/a/node"&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:text&gt;&amp;nbsp;&lt;/xsl:text&gt; &lt;/xsl:template&gt; </code></pre> <p>this one returns a <strong>XsltParseError</strong></p>
[ { "answer_id": 31873, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 8, "selected": true, "text": "<xsl:text disable-output-escaping=\"yes\"><![CDATA[&nbsp;]]></xsl:text>\n" }, { "answer_id": 31878, "author": "Tom Lok...
2008/08/28
[ "https://Stackoverflow.com/questions/31870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1532/" ]
31,871
<p>Ok, I have a strange exception thrown from my code that's been bothering me for ages.</p> <pre><code>System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall at System.Net.Sockets.Socket.Accept() at System.Net.Sockets.TcpListener.AcceptTcpClient() </code></pre> <p>MSDN isn't terribly helpful on this : <a href="http://msdn.microsoft.com/en-us/library/ms741547(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms741547(VS.85).aspx</a> and I don't even know how to begin troubleshooting this one. It's only thrown 4 or 5 times a day, and never in our test environment. Only in production sites, and on ALL production sites. </p> <p>I've found plenty of posts asking about this exception, but no actual definitive answers on what is causing it, and how to handle or prevent it.</p> <p>The code runs in a separate background thread, the method starts :</p> <pre><code>public virtual void Startup() { TcpListener serverSocket= new TcpListener(new IPEndPoint(bindAddress, port)); serverSocket.Start(); </code></pre> <p>then I run a loop putting all new connections as jobs in a separate thread pool. It gets more complicated because of the app architecture, but basically:</p> <pre><code> while (( socket = serverSocket.AcceptTcpClient()) !=null) //Funny exception here { connectionHandler = new ConnectionHandler(socket, mappingStrategy); pool.AddJob(connectionHandler); } } </code></pre> <p>From there, the <code>pool</code> has it's own threads that take care of each job in it's own thread, separately.</p> <p>My understanding is that AcceptTcpClient() is a blocking call, and that somehow winsock is telling the thread to stop blocking and continue execution.. but why? And what am I supposed to do? Just catch the exception and ignore it? </p> <hr> <p>Well, I do think some other thread is closing the socket, but it's certainly not from my code. What I would like to know is: is this socket closed by the connecting client (on the other side of the socket) or is it closed by my server. Because as it is at this moment, whenever this exception occurs, it shutsdown my listening port, effectively closing my service. If this is done from a remote location, then it's a major problem. </p> <p>Alternatively, could this be simply the IIS server shutting down my application, and thus cancelling all my background threads and blocking methods?</p>
[ { "answer_id": 261393, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "serverSocket.Stop()" }, { "answer_id": 8397129, "author": "Nikolaus Very Permana", "author_id": 961567, "a...
2008/08/28
[ "https://Stackoverflow.com/questions/31871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
31,875
<p>There seem to be many ways to define <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="noreferrer">singletons</a> in Python. Is there a consensus opinion on Stack&nbsp;Overflow?</p>
[ { "answer_id": 31884, "author": "John", "author_id": 2168, "author_profile": "https://Stackoverflow.com/users/2168", "pm_score": 2, "selected": false, "text": "class Singleton:\n __single = None\n def __init__( self ):\n if Singleton.__single:\n raise Singleton.__...
2008/08/28
[ "https://Stackoverflow.com/questions/31875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3363/" ]
31,913
<p>I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it</p> <p>I was looking for a way to separate clearly some softwares internals from their representation in c++</p> <p>I have a generic parameter class (to be later stored in a container) that can contain any kind of value with the the boost::any class</p> <p>I have a base class (roughly) of this kind (of course there is more stuff)</p> <pre><code>class Parameter { public: Parameter() template typename&lt;T&gt; T GetValue() const { return any_cast&lt;T&gt;( _value ); } template typename&lt;T&gt; void SetValue(const T&amp; value) { _value = value; } string GetValueAsString() const = 0; void SetValueFromString(const string&amp; str) const = 0; private: boost::any _value; } </code></pre> <p>There are two levels of derived classes: The first level defines the type and the conversion to/from string (for example ParameterInt or ParameterString) The second level defines the behaviour and the real creators (for example deriving ParameterAnyInt and ParameterLimitedInt from ParameterInt or ParameterFilename from GenericString)</p> <p>Depending on the real type I would like to add external function or classes that operates depending on the specific parameter type without adding virtual methods to the base class and without doing strange casts</p> <p>For example I would like to create the proper gui controls depending on parameter types:</p> <pre><code>Widget* CreateWidget(const Parameter&amp; p) </code></pre> <p>Of course I cannot understand real Parameter type from this unless I use RTTI or implement it my self (with enum and switch case), but this is not the right OOP design solution, you know.</p> <p>The classical solution is the Visitor design pattern <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Visitor_pattern</a></p> <p>The problem with this pattern is that I have to know in advance which derived types will be implemented, so (putting together what is written in wikipedia and my code) we'll have sort of: </p> <pre><code>struct Visitor { virtual void visit(ParameterLimitedInt&amp; wheel) = 0; virtual void visit(ParameterAnyInt&amp; engine) = 0; virtual void visit(ParameterFilename&amp; body) = 0; }; </code></pre> <p>Is there any solution to obtain this behaviour in any other way without need to know in advance all the concrete types and without deriving the original visitor?</p> <hr> <p><strong>Edit:</strong> <a href="https://stackoverflow.com/q/31913">Dr. Pizza's solution seems the closest to what I was thinking</a>, but the problem is still the same and the method is actually relying on dynamic_cast, that I was trying to avoid as a kind of (even if weak) RTTI method</p> <p>Maybe it is better to think to some solution without even citing the visitor Pattern and clean our mind. The purpose is just having the function such:</p> <pre><code>Widget* CreateWidget(const Parameter&amp; p) </code></pre> <p>behave differently for each "concrete" parameter without losing info on its type </p>
[ { "answer_id": 33452, "author": "genix", "author_id": 2714, "author_profile": "https://Stackoverflow.com/users/2714", "pm_score": 0, "selected": false, "text": "class Visitor\n{\npublic:\n template< class T > void visit( const T& param ) const\n {\n assert( false && \"this parameter...
2008/08/28
[ "https://Stackoverflow.com/questions/31913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3373/" ]
31,919
<p>I'm comparing it Java where you can start your application server in debug mode, then attach your IDE to the server. And you can change your code "on the fly" without restarting the server. As long as your changes don't affect any method signatures or fields you can just hit recompile for a class and the application server (servlet container) will reload the class.</p> <p>I suppose this is impossible in ASP.NET since all classes are packed into assemblies and you cannot unload/reload assemblies, can you ?</p> <p>So when you have an .aspx page and an assembly deployed to GAC and your codebehind changes you have to redeploy the assembly and reset IIS. I'm talking about Sharepoint applications in particular and I'm not sure whether you have to do iisreset for private assemblies but I guess you have too.</p> <p>So the best way to debug aspx pages with code behind I guess would be to get rid of the codebehind for the time of active debugging and move into the page, then when it is more or less working move it back to codebehind. (This would be applicable only for application pages in Sharepoint, site pages don't allow inline code )</p> <p>How do you approach debugging of your ASP.NET applications to make it less time consuming?</p>
[ { "answer_id": 31984, "author": "Artem Tikhomirov", "author_id": 2313, "author_profile": "https://Stackoverflow.com/users/2313", "pm_score": 2, "selected": false, "text": "<system.web>\n ...\n <trust level=\"WSS_Medium\" originUrl=\"\" />\n ...\n</system.web>\n" }, { "an...
2008/08/28
[ "https://Stackoverflow.com/questions/31919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
31,931
<p>I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.</p> <p>It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way. </p> <p>What's the simplest way of doing this?</p> <p>[Edit: Just to avoid confusion in an answer below, this is a <strong>JavaScript</strong> question, not a Java one.]</p>
[ { "answer_id": 31938, "author": "liammclennan", "author_id": 2785, "author_profile": "https://Stackoverflow.com/users/2785", "pm_score": 3, "selected": false, "text": "var today = new Date();\nvar yesterday = new Date().setDate(today.getDate() -1);\n" }, { "answer_id": 31939, ...
2008/08/28
[ "https://Stackoverflow.com/questions/31931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/916/" ]
31,935
<p>I'm sure this is easy but I can't figure it out:</p> <p>I have an ASP.NET page with some UpdatePanels on it. I want the page to <em>completely</em> load with some 'Please wait' text in the UpdatePanels. Then once the page is <em>completely loaded</em> I want to call a code-behind function to update the UpdatePanel.</p> <p>Any ideas as to what combination of Javascript and code-behind I need to implement this idea?</p> <p>SAL</p> <p>PS: I've tried putting my function call in the Page_Load but then code is run <em>before</em> the page is delivered and, as the function I want to run takes some time, the page simply takes too long to load up.</p>
[ { "answer_id": 33161, "author": "SAL", "author_id": 3099, "author_profile": "https://Stackoverflow.com/users/3099", "pm_score": 3, "selected": false, "text": " <%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\" Inherits=\"AJAXPostLoadCall._Default\" %>\n\...
2008/08/28
[ "https://Stackoverflow.com/questions/31935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3099/" ]
32,000
<p>I'm basically trying to figure out the simplest way to perform your basic insert operation in C#.NET using the SqlClient namespace. </p> <p>I'm using <code>SqlConnection</code> for my db link, I've already had success executing some reads, and I want to know the simplest way to insert data. I'm finding what seem to be pretty verbose methods when I google.</p>
[ { "answer_id": 32005, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": true, "text": "using (var conn = new SqlConnection(yourConnectionString))\n{\n var cmd = new SqlCommand(\"insert into Foo values (@bar...
2008/08/28
[ "https://Stackoverflow.com/questions/32000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1344/" ]
32,001
<p>I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. </p> <p>If, however, before X seconds has elapsed, I decide that the event should occur after Y seconds instead, then I want to be able to tell the timer to reset its time so that the event occurs in Y seconds. E.g. the timer should be able to do something like:</p> <pre><code>Timer timer = new Timer(); timer.schedule(timerTask, 5000); //Timer starts in 5000 ms (X) //At some point between 0 and 5000 ms... setNewTime(timer, 8000); //timerTask will fire in 8000ms from NOW (Y). </code></pre> <p>I don't see a way to do this using the utils timer, as if you call cancel() you cannot schedule it again.</p> <p>The only way I've come close to replicating this behavior is by using javax.swing.Timer and involves stopping the origional timer, and creating a new one. i.e.: </p> <pre><code>timer.stop(); timer = new Timer(8000, ActionListener); timer.start(); </code></pre> <p>Is there an easier way??</p>
[ { "answer_id": 32047, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 1, "selected": false, "text": "Timer/TimerTask" }, { "answer_id": 32057, "author": "C. K. Young", "author_id": 13, "author_profile": "https:...
2008/08/28
[ "https://Stackoverflow.com/questions/32001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142/" ]
32,003
<p>Im searching a tool which allows me to specify some folders as "bookmarks" and than access them on the commandline (on Windows XP) via a keyword. Something like:</p> <pre><code>C:\&gt; go home D:\profiles\user\home\&gt; go svn-project1 D:\projects\project1\svn\branch\src\&gt; </code></pre> <p>I'm currently using a bunch of batch files, but editing them by hand is a daunting task. On Linux there is <a href="http://www.skamphausen.de/software/cdargs/" rel="noreferrer">cdargs</a> or <a href="http://kore-nordmann.de/blog/shell_bookmarks.html" rel="noreferrer">shell bookmarks</a> but I haven't found something on windows.</p> <hr> <p>Thanks for the Powershell suggestion, but I'm not allowed to install it on my box at work, so it should be a "classic" cmd.exe solution.</p>
[ { "answer_id": 32007, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "$vids=\"C:\\Users\\mabster\\Videos\"\n" }, { "answer_id": 32012, "author": "Espo", "author_id": 2257, ...
2008/08/28
[ "https://Stackoverflow.com/questions/32003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1462/" ]
32,010
<p><a href="http://twitter.com/codinghorror/statuses/901272685" rel="nofollow noreferrer">Source</a></p> <blockquote> <p>RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely measurable)</p> </blockquote> <p>Assuming that this applies to PHP, Python, Perl, Ruby etc as well as C# (which is what I assume Jeff was using), how much of a slowdown is it and will I incur a similar penalty with <code>/[a-zA-z]/</code> as I will with <code>/[a-z]/i</code> ?</p>
[ { "answer_id": 32021, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 5, "selected": true, "text": "RegexOptions.IgnoreCase" }, { "answer_id": 32135, "author": "Nathan Fellman", "author_id": 1084, "author_pro...
2008/08/28
[ "https://Stackoverflow.com/questions/32010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
32,027
<p>I'm new to NAnt but have some experience with Ant and CruiseControl.</p> <p>What I want to do is have my SVN project include all tools needed (like NUnit and Mocks etc) so I can check out onto a fresh machine and build. This strategy is outlined by J.P Boodhoo <a href="http://blog.jpboodhoo.com/NAntStarterSeries.aspx" rel="noreferrer">here.</a></p> <p>So far so good if I only want to run on Windows, but I want to be able to check out onto Linux and build/test/run against Mono too. I want no dependencies external to the SVN project. I don't mind having two sets of tools in the project but want only one NAnt build file</p> <p>This must be possible - but how? what are the tricks / 'traps for young players' </p>
[ { "answer_id": 32317, "author": "RobertTheGrey", "author_id": 1107, "author_profile": "https://Stackoverflow.com/users/1107", "pm_score": 4, "selected": true, "text": "$ export MONO_NO_UNLOAD=1\n$ make clean\n$ make\n$ mono bin/NAnt.exe clean build\n" }, { "answer_id": 46075, ...
2008/08/28
[ "https://Stackoverflow.com/questions/32027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3024/" ]
32,034
<p>After reading the Head First Design Patterns book and using a number of other design patterns, I'm trying to understand the Observer pattern. Isn't this already implemented using Events in the .NET Framework?</p>
[ { "answer_id": 100921, "author": "Hace", "author_id": 18703, "author_profile": "https://Stackoverflow.com/users/18703", "pm_score": 2, "selected": false, "text": "public void NotifyObservers()\n{\n foreach(Product product in ProductList)\n {\n if (product is IProductObserver...
2008/08/28
[ "https://Stackoverflow.com/questions/32034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993/" ]
32,041
<p>Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations.</p> <p>It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performance. It would be nice if the compiler would simply make the debug statements vanish.</p>
[ { "answer_id": 32067, "author": "izb", "author_id": 974, "author_profile": "https://Stackoverflow.com/users/974", "pm_score": 3, "selected": false, "text": "public abstract class Config\n{\n public static final boolean ENABLELOGGING = true;\n}\n" }, { "answer_id": 32122, "...
2008/08/28
[ "https://Stackoverflow.com/questions/32041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1772/" ]
32,044
<p>I have a tree structure in memory that I would like to render in HTML using a Django template. </p> <pre><code>class Node(): name = "node name" children = [] </code></pre> <p>There will be some object <code>root</code> that is a <code>Node</code>, and <code>children</code> is a list of <code>Node</code>s. <code>root</code> will be passed in the content of the template.</p> <p>I have found <a href="http://blog.elsdoerfer.name/2008/01/22/recursion-in-django-templates/" rel="noreferrer">this</a> one discussion of how this might be achieved, but the poster suggests this might not be good in a production environment.</p> <p>Does anybody know of a better way?</p>
[ { "answer_id": 32125, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 6, "selected": true, "text": "<li>" }, { "answer_id": 11644588, "author": "Rohan", "author_id": 229410, "author_profile": "https...
2008/08/28
[ "https://Stackoverflow.com/questions/32044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154/" ]
32,058
<p>I have a simple web service operation like this one:</p> <pre><code> [WebMethod] public string HelloWorld() { throw new Exception("HelloWorldException"); return "Hello World"; } </code></pre> <p>And then I have a client application that consumes the web service and then calls the operation. Obviously it will throw an exception :-)</p> <pre><code> try { hwservicens.Service1 service1 = new hwservicens.Service1(); service1.HelloWorld(); } catch(Exception e) { Console.WriteLine(e.ToString()); } </code></pre> <p>In my catch-block, what I would like to do is extract the Message of the actual exception to use it in my code. The exception caught is a <code>SoapException</code>, which is fine, but it's <code>Message</code> property is like this...</p> <pre><code>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.Exception: HelloWorldException at WebService1.Service1.HelloWorld() in C:\svnroot\Vordur\WebService1\Service1.asmx.cs:line 27 --- End of inner exception stack trace --- </code></pre> <p>...and the <code>InnerException</code> is <code>null</code>.</p> <p>What I would like to do is extract the <code>Message</code> property of the <code>InnerException</code> (the <code>HelloWorldException</code> text in my sample), can anyone help with that? If you can avoid it, please don't suggest parsing the <code>Message</code> property of the <code>SoapException</code>.</p>
[ { "answer_id": 32508, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 4, "selected": true, "text": "[WebMethod]\npublic ResponseClass HelloWorld()\n{\n ResponseClass c = new ResponseClass();\n try \n {\n throw new Exce...
2008/08/28
[ "https://Stackoverflow.com/questions/32058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3379/" ]
32,059
<p>Let's say I have four tables: <code>PAGE</code>, <code>USER</code>, <code>TAG</code>, and <code>PAGE-TAG</code>:</p> <pre><code>Table | Fields ------------------------------------------ PAGE | ID, CONTENT TAG | ID, NAME USER | ID, NAME PAGE-TAG | ID, PAGE-ID, TAG-ID, USER-ID </code></pre> <p>And let's say I have four pages:</p> <pre><code>PAGE#1 'Content page 1' tagged with tag#1 by user1, tagged with tag#1 by user2 PAGE#2 'Content page 2' tagged with tag#3 by user2, tagged by tag#1 by user2, tagged by tag#8 by user1 PAGE#3 'Content page 3' tagged with tag#7 by user#1 PAGE#4 'Content page 4' tagged with tag#1 by user1, tagged with tag#8 by user1 </code></pre> <p>I expect my query to look something like this: </p> <pre><code>select page.content ? from page, page-tag where page.id = page-tag.pag-id and page-tag.tag-id in (1, 3, 8) order by ? desc </code></pre> <p>I would like to get output like this:</p> <pre><code>Content page 2, 3 Content page 4, 2 Content page 1, 1 </code></pre> <hr> <p>Quoting Neall </p> <blockquote> <p>Your question is a bit confusing. Do you want to get the number of times each page has been tagged? </p> </blockquote> <p>No</p> <blockquote> <p>The number of times each page has gotten each tag? </p> </blockquote> <p>No</p> <blockquote> <p>The number of unique users that have tagged a page? </p> </blockquote> <p>No </p> <blockquote> <p>The number of unique users that have tagged each page with each tag?</p> </blockquote> <p>No</p> <p>I want to know how many of the passed tags appear in a particular page, not just if any of the tags appear. </p> <p>SQL IN works like an boolean operator OR. If a page was tagged with any value within the IN Clause then it returns true. I would like to know how many of the values inside of the IN clause return true. </p> <p>Below i show, the output i expect: </p> <pre><code>page 1 | in (1,2) -&gt; 1 page 1 | in (1,2,3) -&gt; 1 page 1 | in (1) -&gt; 1 page 1 | in (1,3,8) -&gt; 1 page 2 | in (1,2) -&gt; 1 page 2 | in (1,2,3) -&gt; 2 page 2 | in (1) -&gt; 1 page 2 | in (1,3,8) -&gt; 3 page 4 | in (1,2,3) -&gt; 1 page 4 | in (1,2,3) -&gt; 1 page 4 | in (1) -&gt; 1 page 4 | in (1,3,8) -&gt; 2 </code></pre> <p>This will be the content of the page-tag table i mentioned before: </p> <pre><code> id page-id tag-id user-id 1 1 1 1 2 1 1 2 3 2 3 2 4 2 1 2 5 2 8 1 6 3 7 1 7 4 1 1 8 4 8 1 </code></pre> <p><strong>@Kristof</strong> does not exactly what i am searching for but thanks anyway. </p> <p><strong>@Daren</strong> If i execute you code i get the next error: </p> <pre><code>#1054 - Unknown column 'page-tag.tag-id' in 'having clause' </code></pre> <p><strong>@Eduardo Molteni</strong> Your answer does not give the output in the question but: </p> <pre><code>Content page 2 8 Content page 4 8 content page 2 3 content page 1 1 content page 1 1 content page 2 1 cotnent page 4 1 </code></pre> <p><strong>@Keith</strong> I am using plain SQL not T-SQL and i am not familiar with T-SQL, so i do not know how your query translate to plain SQL.</p> <p>Any more ideas?</p>
[ { "answer_id": 32070, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 2, "selected": false, "text": "select page.content, count(page-tag.tag-id) as tagcount\nfrom page inner join page-tag on page-tag.page-id = page.id\ngr...
2008/08/28
[ "https://Stackoverflow.com/questions/32059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
32,085
<p>In XLST how would you find out the length of a node-set?</p>
[ { "answer_id": 32092, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 5, "selected": true, "text": "<xsl:variable name=\"length\" select=\"count(nodeset)\"/>\n" }, { "answer_id": 32217, "author": "samjudson", "aut...
2008/08/28
[ "https://Stackoverflow.com/questions/32085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
32,087
<p>I want to know what are the options to do some scripting jobs in windows platform. I need functionality like file manipulations, registry editing etc. Can files be edited using scripting tools? What other functionality does windows scripting tools offer? Can everything that can be done using the Windows GUI be done using a scripting language?</p>
[ { "answer_id": 55769598, "author": "Zhiyuan-Amos", "author_id": 8828382, "author_profile": "https://Stackoverflow.com/users/8828382", "pm_score": 0, "selected": false, "text": "(Get-Content c:\\temp\\test.txt).replace('[MYID]', 'MyValue') | Set-Content c:\\temp\\test.txt" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
32,100
<p>What is the simplest SQL query to find the second largest integer value in a specific column? </p> <p>There are maybe duplicate values in the column.</p>
[ { "answer_id": 32108, "author": "Magnar", "author_id": 1123, "author_profile": "https://Stackoverflow.com/users/1123", "pm_score": 3, "selected": false, "text": "SELECT DISTINCT value \nFROM Table \nORDER BY value DESC \nLIMIT 2\n" }, { "answer_id": 32109, "author": "dguaragl...
2008/08/28
[ "https://Stackoverflow.com/questions/32100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
32,145
<p>I'm going to try something with the format of this question and I'm very open to suggestions about a better way to handle it.</p> <p>I didn't want to just dump a bunch of code in the question so I've posted the code for the class on <code>refactormycode</code>.</p> <p><strong><a href="http://www.refactormycode.com/codes/461-base-class-for-easy-class-property-handling" rel="nofollow noreferrer">base class for easy class property handling</a></strong></p> <p>My thought was that people can either post code snippets here or make changes on <code>refactormycode</code> and post links back to their refactorings. I'll make upvotes and accept an answer (assuming there's a clear "winner") based on that.</p> <p>At any rate, on to the class itself:</p> <p>I see a lot of debate about getter/setter class methods and is it better to just access simple property variables directly or should every class have explicit get/set methods defined, blah blah blah. I like the idea of having explicit methods in case you have to add more logic later. Then you don't have to modify any code that uses the class. However I hate having a million functions that look like this:</p> <pre><code>public function getFirstName() { return $this-&gt;firstName; } public function setFirstName($firstName) { return $this-&gt;firstName; } </code></pre> <p>Now I'm sure I'm not the first person to do this (I'm hoping that there's a better way of doing it that someone can suggest to me).</p> <p>Basically, the PropertyHandler class has a __call magic method. Any methods that come through __call that start with "get" or "set" are then routed to functions that set or retrieve values into an associative array. The key into the array is the name of the calling method after getting or setting. So, if the method coming into __call is "getFirstName", the array key is "FirstName".</p> <p>I liked using __call because it will automatically take care of the case where the subclass already has a "getFirstName" method defined. My impression (and I may be wrong) is that the __get &amp; __set magic methods don't do that.</p> <p>So here's an example of how it would work:</p> <pre><code>class PropTest extends PropertyHandler { public function __construct() { parent::__construct(); } } $props = new PropTest(); $props-&gt;setFirstName("Mark"); echo $props-&gt;getFirstName(); </code></pre> <p>Notice that PropTest doesn't actually have "setFirstName" or "getFirstName" methods and neither does PropertyHandler. All that's doing is manipulating array values.</p> <p>The other case would be where your subclass is already extending something else. Since you can't have true multiple inheritances in PHP, you can make your subclass have a PropertyHandler instance as a private variable. You have to add one more function but then things behave in exactly the same way.</p> <pre><code>class PropTest2 { private $props; public function __construct() { $this-&gt;props = new PropertyHandler(); } public function __call($method, $arguments) { return $this-&gt;props-&gt;__call($method, $arguments); } } $props2 = new PropTest2(); $props2-&gt;setFirstName('Mark'); echo $props2-&gt;getFirstName(); </code></pre> <p>Notice how the subclass has a __call method that just passes everything along to the PropertyHandler __call method.</p> <hr> <p>Another good argument against handling getters and setters this way is that it makes it really hard to document.</p> <p>In fact, it's basically impossible to use any sort of document generation tool since the explicit methods to be don't documented don't exist.</p> <p>I've pretty much abandoned this approach for now. It was an interesting learning exercise but I think it sacrifices too much clarity.</p>
[ { "answer_id": 32191, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 3, "selected": false, "text": "class test {\n protected $x='';\n protected $y='';\n\n function set_y ($y) {\n print \"specific function set_y\\n\"...
2008/08/28
[ "https://Stackoverflow.com/questions/32145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
32,149
<p>Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as <code>"GEORGE BURDELL"</code> or <code>"george burdell"</code> and turns it into <code>"George Burdell"</code>.</p> <p>I have a simple one that handles the simple cases. The ideal would be to have something that can handle things such as <code>"O'REILLY"</code> and turn it into <code>"O'Reilly"</code>, but I know that is tougher.</p> <p>I am mainly focused on the English language if that simplifies things.</p> <hr> <p><strong>UPDATE:</strong> I'm using C# as the language, but I can convert from almost anything (assuming like functionality exists).</p> <p>I agree that the McDonald's scneario is a tough one. I meant to mention that along with my O'Reilly example, but did not in the original post.</p>
[ { "answer_id": 32189, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "/\\w+/\n" }, { "answer_id": 32236, "author": "JimmyJ", "author_id": 2083, "author_profile": "https...
2008/08/28
[ "https://Stackoverflow.com/questions/32149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3203/" ]
32,151
<p>Is there a way to export a simple HTML page to Word (.doc format, not .docx) without having Microsoft Word installed?</p>
[ { "answer_id": 32176, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 5, "selected": true, "text": "application/msword" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3396/" ]
32,168
<p>A question related to <a href="https://stackoverflow.com/questions/28002">Regular cast vs. static_cast vs. dynamic_cast</a>:</p> <p>What cast syntax style do you prefer in C++?</p> <ul> <li>C-style cast syntax: <code>(int)foo</code></li> <li>C++-style cast syntax: <code>static_cast&lt;int&gt;(foo)</code></li> <li>constructor syntax: <code>int(foo)</code></li> </ul> <p>They may not translate to exactly the same instructions (do they?) but their effect should be the same (right?).</p> <p>If you're just casting between the built-in numeric types, I find C++-style cast syntax too verbose. As a former Java coder I tend to use C-style cast syntax instead, but my local C++ guru insists on using constructor syntax.</p> <p>What do you think?</p>
[ { "answer_id": 32224, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "void f(auto_ptr<int> x);\n\nf(static_cast<auto_ptr<int> >(new int(5))); // GOOD\nf(auto_ptr<int>(new int(5)); ...
2008/08/28
[ "https://Stackoverflow.com/questions/32168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2686/" ]
32,173
<p>I'm trying to disable a bunch of controls with JavaScript (so that they post back values). All the controls work fine except for my radio buttons as they lose their value. In the below code which is called via a recursive function to disable all child controls the Second else (else if (control is <code>RadioButton</code>)) is never hit and the RadioButton control is identified as a <code>Checkbox</code> control.</p> <pre><code> private static void DisableControl(WebControl control) { if (control is CheckBox) { ((CheckBox)control).InputAttributes.Add("disabled", "disabled"); } else if (control is RadioButton) { } else if (control is ImageButton) { ((ImageButton)control).Enabled = false; } else { control.Attributes.Add("readonly", "readonly"); } } </code></pre> <p>Two Questions:<br> 1. How do I identify which control is a radiobutton? <br> 2. How do I disable it so that it posts back its value?</p>
[ { "answer_id": 32473, "author": "Nicholas", "author_id": 2808, "author_profile": "https://Stackoverflow.com/users/2808", "pm_score": 3, "selected": true, "text": " private static void DisableControl(WebControl control)\n {\n Type controlType = control.GetType();\n\n i...
2008/08/28
[ "https://Stackoverflow.com/questions/32173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2808/" ]
32,175
<p>I'm trying to install a .NET service I wrote. As recommended by MSDN, I'm using InstallUtil. But I have missed how I can set the default service user on the command-line or even in the service itself. Now, when InstallUtil is run, it will display a dialog asking the user for the credentials for a user. I'm trying to integrate the service installation into a larger install and need the service installation to remain silent.</p>
[ { "answer_id": 50661256, "author": "D. Lockett", "author_id": 7716585, "author_profile": "https://Stackoverflow.com/users/7716585", "pm_score": 0, "selected": false, "text": "/username" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494/" ]
32,231
<p>Are there any rapid Database protoyping tools that don't require me to declare a database schema, but rather create it based on the way I'm using my entities.</p> <p>For example, assuming an empty database (pseudo code):</p> <pre><code>user1 = new User() // Creates the user table with a single id column user1.firstName = "Allain" // alters the table to have a firstName column as varchar(255) user2 = new User() // Reuses the table user2.firstName = "Bob" user2.lastName = "Loblaw" // Alters the table to have a last name column </code></pre> <p>Since there are logical assumptions that can be made when dynamically creating the schema, and you could always override its choices by using your DB tools to tweak it later.</p> <p>Also, you could generate your schema by unit testing it this way.</p> <p>And obviously this is only for prototyping.</p> <p>Is there anything like this out there?</p>
[ { "answer_id": 32463, "author": "Ed.T", "author_id": 3014, "author_profile": "https://Stackoverflow.com/users/3014", "pm_score": 1, "selected": false, "text": "class User {\n\n String userName\n String firstName\n String lastName\n Date dateCreated\n Date lastUpdated\n\n ...
2008/08/28
[ "https://Stackoverflow.com/questions/32231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
32,241
<p><a href="https://stackoverflow.com/questions/32149/does-anyone-have-a-good-proper-case-algorithm">Using this question</a> as the base is there an alogrithm or coding example to change some text to Pascal or Camel casing.</p> <p>For example:</p> <pre><code>mynameisfred </code></pre> <p>becomes</p> <pre><code>Camel: myNameIsFred Pascal: MyNameIsFred </code></pre>
[ { "answer_id": 32429, "author": "ljs", "author_id": 3394, "author_profile": "https://Stackoverflow.com/users/3394", "pm_score": 3, "selected": true, "text": "camelCase(\"hithisisatest\");\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075/" ]
32,243
<p>The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. </p> <p>Even though <code>imagesavealpha</code> is set, something isn't quite right.</p> <p>What's the best way to preserve the transparency in the resampled image?</p> <pre><code>$uploadTempFile = $myField[ 'tmp_name' ] list( $uploadWidth, $uploadHeight, $uploadType ) = getimagesize( $uploadTempFile ); $srcImage = imagecreatefrompng( $uploadTempFile ); imagesavealpha( $targetImage, true ); $targetImage = imagecreatetruecolor( 128, 128 ); imagecopyresampled( $targetImage, $srcImage, 0, 0, 0, 0, 128, 128, $uploadWidth, $uploadHeight ); imagepng( $targetImage, 'out.png', 9 ); </code></pre>
[ { "answer_id": 32270, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 4, "selected": false, "text": "$srcImage = imagecreatefrompng($uploadTempFile);\nimagealphablending($srcImage, false);\nimagesavealpha($srcImage, tru...
2008/08/28
[ "https://Stackoverflow.com/questions/32243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820/" ]
32,260
<p>Instead of relying on my host to send an email, I was thinking of sending the email messages using my <strong>Gmail</strong> account. The emails are personalized emails to the bands I play on my show. </p> <p>Is it possible to do it?</p>
[ { "answer_id": 32336, "author": "Domenic", "author_id": 3191, "author_profile": "https://Stackoverflow.com/users/3191", "pm_score": 11, "selected": true, "text": "System.Net.Mail" }, { "answer_id": 489594, "author": "Donny V.", "author_id": 1231, "author_profile": "ht...
2008/08/28
[ "https://Stackoverflow.com/questions/32260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2535/" ]
32,280
<p>I am in the middle of reading the excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0132350882" rel="noreferrer" rel="nofollow noreferrer">Clean Code</a></p> <p>One discussion is regarding passing nulls into a method.</p> <pre><code>public class MetricsCalculator { public double xProjection(Point p1, Point p2) { return (p2.x - p1.x) * 1.5; } } ... calculator.xProjection(null, new Point(12,13)); </code></pre> <p>It represents different ways of handling this:</p> <pre><code>public double xProjection(Point p1, Point p2) { if (p1 == null || p2 == null) { throw new IllegalArgumentException("Invalid argument for xProjection"); } return (p2.x - p1.x) * 1.5; } public double xProjection(Point p1, Point p2) { assert p1 != null : "p1 should not be null"; assert p2 != null : "p2 should not be null"; return (p2.x - p1.x) * 1.5; } </code></pre> <p>I prefer the <a href="http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html" rel="noreferrer">assertions</a> approach, but I don't like the fact that assertions are turned off by default.</p> <p>The book finally states:</p> <blockquote> <p>In most programming languages there is no good way to deal with a null that is passed by a caller accidentally. Because this is the case, the rational approach is to forbid passing null by default.</p> </blockquote> <p>It doesn't really go into how you would enforce this restriction?</p> <p>Do any of you have strong opinions either way.</p>
[ { "answer_id": 32304, "author": "Chris Karcher", "author_id": 2773, "author_profile": "https://Stackoverflow.com/users/2773", "pm_score": 2, "selected": false, "text": "if (p1 == null || p2 == null) {\n throw new IllegalArgumentException(\"Invalid argument for xProjection\");\n}\n" ...
2008/08/28
[ "https://Stackoverflow.com/questions/32280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3295/" ]
32,282
<p>How can I test the same regex against different regular expression engines?</p>
[ { "answer_id": 32354, "author": "Sébastien RoccaSerra", "author_id": 2797, "author_profile": "https://Stackoverflow.com/users/2797", "pm_score": 3, "selected": false, "text": "re-builder" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2820/" ]
32,332
<p>This isn't a design question, really, though it may seem like it. (Well, okay, it's kind of a design question). What I'm wondering is why the C++ <code>std::fstream</code> classes don't take a <code>std::string</code> in their constructor or open methods. Everyone loves code examples so:</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; int main() { std::string filename = "testfile"; std::ifstream fin; fin.open(filename.c_str()); // Works just fine. fin.close(); //fin.open(filename); // Error: no such method. //fin.close(); } </code></pre> <p>This gets me all the time when working with files. Surely the C++ library would use <code>std::string</code> wherever possible?</p>
[ { "answer_id": 32368, "author": "Christopher", "author_id": 3186, "author_profile": "https://Stackoverflow.com/users/3186", "pm_score": 4, "selected": false, "text": "std::string" }, { "answer_id": 37542, "author": "wilhelmtell", "author_id": 456, "author_profile": "h...
2008/08/28
[ "https://Stackoverflow.com/questions/32332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
32,333
<p>Here's a perfect example of the problem: <a href="http://blog.teksol.info/2009/03/27/argumenterror-on-number-sum-when-using-classifier-bayes.html" rel="nofollow noreferrer">Classifier gem breaks Rails</a>.</p> <p>** Original question: **</p> <p>One thing that concerns me as a security professional is that Ruby doesn't have a parallel of Java's package-privacy. That is, this isn't valid Ruby:</p> <pre><code>public module Foo public module Bar # factory method for new Bar implementations def self.new(...) SimpleBarImplementation.new(...) end def baz raise NotImplementedError.new('Implementing Classes MUST redefine #baz') end end private class SimpleBarImplementation include Bar def baz ... end end end </code></pre> <p>It'd be really nice to be able to prevent monkey-patching of Foo::BarImpl. That way, people who rely on the library know that nobody has messed with it. Imagine if somebody changed the implementation of MD5 or SHA1 on you! I can call <code>freeze</code> on these classes, but I have to do it on a class-by-class basis, and other scripts might modify them before I finish securing my application if I'm not <strong>very</strong> careful about load order.</p> <p>Java provides lots of other tools for defensive programming, many of which are not possible in Ruby. (See Josh Bloch's book for a good list.) Is this really a concern? Should I just stop complaining and use Ruby for lightweight things and not hope for "enterprise-ready" solutions?</p> <p>(And no, core classes are not frozen by default in Ruby. See below:)</p> <pre><code>require 'md5' # =&gt; true MD5.frozen? # =&gt; false </code></pre>
[ { "answer_id": 33611, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 3, "selected": false, "text": "require 'awesome'\n# Do something awesome.\n" }, { "answer_id": 33900, "author": "James A. Rosen", "aut...
2008/08/28
[ "https://Stackoverflow.com/questions/32333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
32,338
<p>I just saw <a href="http://www.codeplex.com/CloneDetectiveVS" rel="nofollow noreferrer">Clone Detective</a> linked on YCombinator news, and the idea heavily appeals to me. It seems like it would be useful for many languages, not just C#, but I haven't seen anything similar elsewhere.</p> <p>Edit: For those who don't want to follow the link, Clone Detective scans the codebase for duplicate code that may warrant refactoring to minimize duplication.</p>
[ { "answer_id": 33611, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 3, "selected": false, "text": "require 'awesome'\n# Do something awesome.\n" }, { "answer_id": 33900, "author": "James A. Rosen", "aut...
2008/08/28
[ "https://Stackoverflow.com/questions/32338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3326/" ]
32,341
<p>I may just be missing this functionality, but does anyone know if there is a widget available:</p> <p>I need to list the subject for all the entries that are associated with a given tag.</p> <p>For example: I have 5 articles tagged with "Tutorial", I'd like to see a list as follows:</p> <ul> <li>Tutorial 1: Installing the app</li> <li>Tutorial 2: Customizing</li> <li>Tutorial 3: Advanced edits</li> <li>Tutorial 4: User managment</li> </ul> <p>Does functionality like this exists in wordpress allready?</p>
[ { "answer_id": 33611, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 3, "selected": false, "text": "require 'awesome'\n# Do something awesome.\n" }, { "answer_id": 33900, "author": "James A. Rosen", "aut...
2008/08/28
[ "https://Stackoverflow.com/questions/32341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2490/" ]
32,343
<p>Let's say I had a program in C# that did something computationally expensive, like encoding a list of WAV files into MP3s. Ordinarily I would encode the files one at a time, but let's say I wanted the program to figure out how many CPU cores I had and spin up an encoding thread on each core. So, when I run the program on a quad core CPU, the program figures out it's a quad core CPU, figures out there are four cores to work with, then spawns four threads for the encoding, each of which is running on its own separate CPU. How would I do this?</p> <p>And would this be any different if the cores were spread out across multiple physical CPUs? As in, if I had a machine with two quad core CPUs on it, are there any special considerations or are the eight cores across the two dies considered equal in Windows?</p>
[ { "answer_id": 32352, "author": "wvdschel", "author_id": 2018, "author_profile": "https://Stackoverflow.com/users/2018", "pm_score": 2, "selected": false, "text": "Environment.ProcessorCount" }, { "answer_id": 568002, "author": "Joe Erickson", "author_id": 56710, "aut...
2008/08/28
[ "https://Stackoverflow.com/questions/32343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
32,366
<p>I just started thinking about creating/customizing a web crawler today, and know very little about web crawler/robot etiquette. A majority of the writings on etiquette I've found seem old and awkward, so I'd like to get some current (and practical) insights from the web developer community.</p> <p>I want to use a crawler to walk over "the web" for a super simple purpose - "does the markup of site XYZ meet condition ABC?".</p> <p>This raises a lot of questions for me, but I think the two main questions I need to get out of the way first are:</p> <ul> <li>It feels a little "iffy" from the get go -- is this sort of thing acceptable?</li> <li>What specific considerations should the crawler take to not upset people?</li> </ul>
[ { "answer_id": 32452, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": false, "text": "no-cache" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326/" ]
32,369
<p>One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes people get a little too jumpy.</p> <p>Case in point: One of our state customers recently found out that the browser provides the handy feature to save your password. We all know that it has been there for a while and is completely optional and is up to the end user to decide whether or not it is a smart decision to use or not. However, there is a bit of an uproar at the moment and we are being demanded to find a way to disable that functionality for our site.</p> <p><strong>Question</strong>: Is there a way for a site to tell the browser not to offer to remember passwords? I've been around web development a long time but don't know that I have come across that before.</p> <p>Any help is appreciated.</p>
[ { "answer_id": 32386, "author": "Markus Olsson", "author_id": 2114, "author_profile": "https://Stackoverflow.com/users/2114", "pm_score": 9, "selected": true, "text": "<form id=\"loginForm\" action=\"login.cgi\" method=\"post\" autocomplete=\"off\">\n" }, { "answer_id": 32388, ...
2008/08/28
[ "https://Stackoverflow.com/questions/32369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3262/" ]
32,397
<p>On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine. </p>
[ { "answer_id": 32399, "author": "Tall Jeff", "author_id": 1553, "author_profile": "https://Stackoverflow.com/users/1553", "pm_score": 5, "selected": true, "text": "t = (time of entry post) - (Dec 8, 2005)\nx = upvotes - downvotes\n\ny = {1 if x > 0, 0 if x = 0, -1 if x < 0)\nz = {1 if x ...
2008/08/28
[ "https://Stackoverflow.com/questions/32397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1942/" ]
32,404
<p>I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which provides a higher level interface for operations on these objects, and the other programs to access the objects through that service.</p> <p>I am currently aiming for Python and the Django framework as the technologies to implement that service with. I'm pretty sure I figure how to daemonize the Python program in Linux. However, it is an optional spec item that the system should support Windows. I have little experience with Windows programming and no experience at all with Windows services.</p> <p><strong>Is it possible to run a Python programs as a Windows service (i. e. run it automatically without user login)?</strong> I won't necessarily have to implement this part, but I need a rough idea how it would be done in order to decide whether to design along these lines.</p> <p><i>Edit: Thanks for all the answers so far, they are quite comprehensive. I would like to know one more thing: <b>How is Windows aware of my service? Can I manage it with the native Windows utilities?</b> <strong>What is the equivalent of putting a start/stop script in /etc/init.d?</i></strong></p>
[ { "answer_id": 32440, "author": "Ricardo Reyes", "author_id": 3399, "author_profile": "https://Stackoverflow.com/users/3399", "pm_score": 9, "selected": true, "text": "import win32serviceutil\nimport win32service\nimport win32event\nimport servicemanager\nimport socket\n\n\nclass AppServ...
2008/08/28
[ "https://Stackoverflow.com/questions/32404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077/" ]
32,412
<p>I've been tasked with the the maintenance of a nonprofit website that recently fell victim to a SQL injection attack. Someone exploited a form on the site to add text to every available text-like field in the database (varchar, nvarchar, etc.) which, when rendered as HTML, includes and executes a JavaScript file. </p> <p>A Google search of the URL indicates that it's from email spammers based out of Romania or China, but that's not what's important right now.</p> <p>I went through and manually removed the information from the the text fields that render on most visible and popular pages on the site but I'm curious as to what would be the best programmatic way of removing the text from the other text fields on the site. </p> <p>Obviously there's more that needs to be done (hardening the site against SQL injections, using something like markdown instead of storing HTML, etc.) and I am working on those but for the time being what I really need is a good way to go in and programmatically remove the injected text. I know what the exact text is, it's the same every time, and it's always appended to the end of any text field. I can't afford to strip out all HTML in the database at this time and I don't know when this happened exactly so I can't just roll back to a backup. Also, the site is on shared hosting and I cannot connect to the database directly with SQL Server tools. I can execute queries against it though, so if there's any way of constructing a SQL update statement to the effect of "hey find all the text fields in all of the tables in the entire database and do this to clean them" that would be the best. </p>
[ { "answer_id": 32422, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 0, "selected": false, "text": "DECLARE @T VARCHAR(255),@C VARCHAR(4000) \nDECLARE Table_Cursor CURSOR FOR \nSELECT a.name,b.name FROM sysobjects a,syscolum...
2008/08/28
[ "https://Stackoverflow.com/questions/32412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
32,414
<p>We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. That being said, one issue we are running into is that after we push out an update with new JavaScript files, the client browsers still use the cached version of the file and they do not see the update. Obviously, on a support call, we can simply inform them to do a <kbd>ctrl</kbd><kbd>F5</kbd> refresh to ensure that they get the up-to-date files from the server, but it would be preferable to handle this before that time.</p> <p>Our current thought is to simply attach a version number onto the name of the JavaScript files and then when changes are made, increment the version on the script and update all references. This definitely gets the job done, but updating the references on each release could get cumbersome.</p> <p>As I'm sure we're not the first ones to deal with this, I figured I would throw it out to the community. How are you ensuring clients update their cache when you update your code? If you're using the method described above, are you using a process that simplifies the change?</p>
[ { "answer_id": 32427, "author": "Huppie", "author_id": 1830, "author_profile": "https://Stackoverflow.com/users/1830", "pm_score": 10, "selected": true, "text": "?<version>" }, { "answer_id": 83853, "author": "Richard Turner", "author_id": 12559, "author_profile": "ht...
2008/08/28
[ "https://Stackoverflow.com/questions/32414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2176/" ]
32,428
<p>I've created an assembly and referenced it in my Reporting Services report. I've tested the report locally (works), and I then uploaded the report to a report server (doesn't work).</p> <p>Here is the error that is thrown by the custom code I've written.</p> <blockquote> <p>System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.CheckNReturnSO(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark&amp; stackMark, Int32 unrestrictedOverride, Int32 create) at System.Security.CodeAccessSecurityEngine.Assert(CodeAccessPermission cap, StackCrawlMark&amp; stackMark) at System.Security.CodeAccessPermission.Assert() at [Snipped Method Name] at ReportExprHostImpl.CustomCodeProxy.[Snipped Method Name] The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer</p> </blockquote> <p>This project is something I inherited, and I'm not intimately familiar with it. Although I do have the code (now), so I can at least work with it :)</p> <p>I believe the code that is failing is this:</p> <pre><code> Dim fio As System.Security.Permissions.FileIOPermission = New System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted) fio.Assert() </code></pre> <p>However, this kind of stuff is everywhere too:</p> <pre><code>Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hhash As Integer, ByVal pbData As String, ByVal dwDataLen As Integer, ByVal dwFlags As Integer) As Integer </code></pre> <p>I can see either of these being things that Reporting Services would not accommodate out of the box.</p>
[ { "answer_id": 37379, "author": "Ian Robinson", "author_id": 326, "author_profile": "https://Stackoverflow.com/users/326", "pm_score": 4, "selected": true, "text": " <CodeGroup\n class=\"UnionCodeGroup\"\n version=\"1\"\n ...
2008/08/28
[ "https://Stackoverflow.com/questions/32428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326/" ]
32,433
<p>This query works great:</p> <pre><code>var pageObject = (from op in db.ObjectPermissions join pg in db.Pages on op.ObjectPermissionName equals page.PageName where pg.PageID == page.PageID select op) .SingleOrDefault(); </code></pre> <p>I get a new type with my 'op' fields. Now I want to retrieve my 'pg' fields as well, but</p> <pre><code>select op, pg).SingleOrDefault(); </code></pre> <p>doesn't work.</p> <p>How can I select everything from both tables so that they appear in my new pageObject type?</p>
[ { "answer_id": 32445, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": " select new { op, pg }\n" }, { "answer_id": 32449, "author": "aku", "author_id": 1196, "author_pro...
2008/08/28
[ "https://Stackoverflow.com/questions/32433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
32,448
<p>The product-group I work for is currently using gcc 3.4.6 (we know it is ancient) for a large low-level c-code base, and want to upgrade to a later version. We have seen performance benefits testing different versions of gcc 4.x on all hardware platforms we tested it on. We are however <em>very</em> scared of c-compiler bugs (for a good reason historically), and wonder if anyone has insight to which version we should upgrade to.</p> <p>Are people using 4.3.2 for large code-bases and feel that it works fine?</p>
[ { "answer_id": 14654717, "author": "vonbrand", "author_id": 1839777, "author_profile": "https://Stackoverflow.com/users/1839777", "pm_score": 1, "selected": false, "text": "-Wall" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1524/" ]
32,458
<p>I have a coworker who writes unit tests for objects which fill their fields with random data. His reason is that it gives a wider range of testing, since it will test a lot of different values, whereas a normal test only uses a single static value.</p> <p>I've given him a number of different reasons against this, the main ones being:</p> <ul> <li>random values means the test isn't truly repeatable (which also means that if the test can randomly fail, it can do so on the build server and break the build)</li> <li>if it's a random value and the test fails, we need to a) fix the object and b) force ourselves to test for that value every time, so we know it works, but since it's random we don't know what the value was</li> </ul> <p>Another coworker added:</p> <ul> <li>If I am testing an exception, random values will not ensure that the test ends up in the expected state</li> <li>random data is used for flushing out a system and load testing, not for unit tests</li> </ul> <p>Can anyone else add additional reasons I can give him to get him to stop doing this?</p> <p>(Or alternately, is this an acceptable method of writing unit tests, and I and my other coworker are wrong?)</p>
[ { "answer_id": 71762174, "author": "armandino", "author_id": 45112, "author_profile": "https://Stackoverflow.com/users/45112", "pm_score": 2, "selected": false, "text": "Person person = Instancio.create(Person.class);\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/517/" ]
32,460
<p>Here's the situation: I need to bind a WPF <code>FixedPage</code> against a <code>DataRow</code>. Bindings don't work against <code>DataRows</code>; they work against <code>DataRowViews</code>. I need to do this in the most generic way possible, as I know nothing about and have no control over what is in the <code>DataRow</code>. </p> <p>What I need is to be able to get a <code>DataRowView</code> for a given <code>DataRow</code>. I can't use the <code>Find()</code> method on the <code>DefaultView</code> because that takes a key, and there is no guarantee the table will have a primary key set.</p> <p>Does anybody have a suggestion as to the best way to go around this? </p>
[ { "answer_id": 32483, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "row.Table.DefaultView[row.Table.Rows.IndexOf(row)]\n" }, { "answer_id": 6989851, "author": "Joel Barsotti", "au...
2008/08/28
[ "https://Stackoverflow.com/questions/32460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
32,462
<p>So I've got a hobby site I'm working on. I've got items that are tagged and I want to associate those items with photos from Flickr. Even with restrictive searches, I might get results numbering in the thousands.</p> <p>Requirements:</p> <ol> <li>I want to display between 10-20 pictures but I want to randomize the photos each time. </li> <li>I don't want to hit Flickr every time a page request is made. </li> <li>Not every Flickr photo with the same tags as my item will be relevant.</li> </ol> <p>How should I store that number of results and how would I determine which ones are relevant?</p>
[ { "answer_id": 32483, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "row.Table.DefaultView[row.Table.Rows.IndexOf(row)]\n" }, { "answer_id": 6989851, "author": "Joel Barsotti", "au...
2008/08/28
[ "https://Stackoverflow.com/questions/32462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2863/" ]
32,529
<p>I want to limit my users to a directory and its sub directories but the "Parent Directory" button allows them to browse to an arbitrary directory.</p> <p>How should I go about doing that?</p>
[ { "answer_id": 32658, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 5, "selected": false, "text": "class DirectoryRestrictedFileSystemView extends FileSystemView\n{\n private final File[] rootDirectories;\n\n Di...
2008/08/28
[ "https://Stackoverflow.com/questions/32529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
32,537
<p>For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?</p> <p>Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown apps, but also have a way to run small snippets of code in a console.</p>
[ { "answer_id": 32686, "author": "Joseph Pecoraro", "author_id": 792, "author_profile": "https://Stackoverflow.com/users/792", "pm_score": 3, "selected": true, "text": "irb" }, { "answer_id": 36446, "author": "asussex", "author_id": 3796, "author_profile": "https://Sta...
2008/08/28
[ "https://Stackoverflow.com/questions/32537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2001/" ]
32,540
<p>How is your javaScript code organized? Does it follow patterns like MVC, or something else? </p> <p>I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com" rel="noreferrer">jQuery</a>, however, the logic on the page is growing to a point where some organization, or dare I say it, "architecture" is needed. My first approach is "MVC-ish":</p> <ul> <li>The 'model' is a JSON tree that gets extended with helpers</li> <li>The view is the DOM plus classes that tweak it</li> <li>The controller is the object where I connect events handling and kick off view or model manipulation</li> </ul> <p>I'm very interested, however, in how other people have built more substantial javaScript apps. I'm not interested in GWT, or other server-oriented approaches... just in the approach of "javaScript + &lt;generic web service-y thingy here&gt;"</p> <p>Note: earlier I said javaScript "is not really OO, not really functional". This, I think, distracted everyone. Let's put it this way, because javaScript is unique in many ways, and I'm coming from a strongly-typed background, I don't want to force paradigms I know but were developed in very different languages.</p>
[ { "answer_id": 32594, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 4, "selected": true, "text": "var Vehicle = jQuery.Class.create({ \n init: function(name) { this.name = name; } \n});\n\nvar Car = Vehicle.extend({ ...
2008/08/28
[ "https://Stackoverflow.com/questions/32540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3436/" ]
32,541
<p>Anybody have a good example how to deep clone a WPF object, preserving databindings?</p> <hr> <p>The marked answer is the first part.</p> <p>The second part is that you have to create an ExpressionConverter and inject it into the serialization process. Details for this are here:<br> <a href="http://www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx?fid=1428301&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;select=2801571" rel="noreferrer">http://www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx?fid=1428301&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;select=2801571</a></p>
[ { "answer_id": 32575, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 0, "selected": false, "text": " public static T DeepClone<T>(T from)\n {\n using (MemoryStream s = new MemoryStream())\n {\n B...
2008/08/28
[ "https://Stackoverflow.com/questions/32541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
32,570
<p>Is there some way I can use URLs like: </p> <p><em><a href="http://www.blog.com/team-spirit/" rel="nofollow noreferrer">http://www.blog.com/team-spirit/</a></em></p> <p>instead of</p> <p><em><a href="http://www.blog.com/?p=122" rel="nofollow noreferrer">http://www.blog.com/?p=122</a></em></p> <p>in a Windows hosted PHP server?</p>
[ { "answer_id": 73370706, "author": "Alamin Sarkar", "author_id": 19773925, "author_profile": "https://Stackoverflow.com/users/19773925", "pm_score": 0, "selected": false, "text": "# any file that exists just return it \nRewriteCond %{REQUEST_FILENAME} -f \nRewriteRule ^(.*) $1 [L]\n" ...
2008/08/28
[ "https://Stackoverflow.com/questions/32570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
32,586
<p>Is there an easy way to discover a File's creation time with Java? The File class only has a method to get the "last modified" time. According to some resources I found on Google, the File class doesn't provide a getCreationTime() method because not all file systems support the idea of a creation time.</p> <p>The only working solution I found involes shelling out the the command line and executing the "dir" command, which looks like it outputs the file's creation time. I guess this works, I only need to support Windows, but it seems very error prone to me.</p> <p>Are there any third party libraries that provide the info I need?</p> <p><strong>Update:</strong> In the end, I don't think it's worth it for me to buy the third party library, but their API does seem pretty good so it's probably a good choice for anyone else that has this problem. </p>
[ { "answer_id": 3350512, "author": "LiuYan 刘研", "author_id": 404192, "author_profile": "https://Stackoverflow.com/users/404192", "pm_score": 3, "selected": false, "text": "// Get/Set windows file CreationTime/LastWriteTime/LastAccessTime\n// Test with jna-3.2.7\n// [http://maclife.net/wik...
2008/08/28
[ "https://Stackoverflow.com/questions/32586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1471/" ]
32,598
<p>If you have Subversion installed on your development machine and you don't work in a team, is there any reason why you should use the <em>svn</em> protocol instead of <em>file</em>?</p>
[ { "answer_id": 229642, "author": "Peter Wone", "author_id": 1715673, "author_profile": "https://Stackoverflow.com/users/1715673", "pm_score": 0, "selected": false, "text": "file" }, { "answer_id": 44699067, "author": "bahrep", "author_id": 761095, "author_profile": "h...
2008/08/28
[ "https://Stackoverflow.com/questions/32598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1670/" ]
32,607
<p>I'd like to rollback a change I made recently in TFS. In Subversion, this was pretty straightforward. However, it seems to be an incredible headache in TFS:</p> <h3>Option 1: Get Prior Version</h3> <ol> <li>Manually get prior version of each file</li> <li>Check out for edit</li> <li>Fail - the checkout (in VS2008) forces me to get the latest version</li> </ol> <h3>Option 2: Get TFS Power Tools</h3> <ol> <li>Download Team Foundation Power Tools</li> <li>Issue rollback command from cmd line</li> <li>Fail - it won't work if there are any other pending changes</li> </ol> <h3>Option 3: Manually Undo Changes</h3> <ol> <li>manually undo my changes, then commit a new changeset</li> </ol> <h3>Question</h3> <p>How do I rollback to a previous changeset in TFS?</p>
[ { "answer_id": 5355837, "author": "Kevin Lo", "author_id": 199043, "author_profile": "https://Stackoverflow.com/users/199043", "pm_score": 4, "selected": false, "text": "TF - Team Foundation Version Control Tool, Version 10.0.30319.1\nCopyright (c) Microsoft Corporation. All rights rese...
2008/08/28
[ "https://Stackoverflow.com/questions/32607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1338/" ]
32,621
<p>I'm trying to find the latitude and longitude of the corners of my map while in birdseye view. I want to be able to plot pins on the map, but I have hundreds of thousands of addresses that I want to be able to limit to the ones that need to show on the map.</p> <p>In normal view, VEMap.GetMapView().TopLeftLatLong and .BottomRightLatLong return the coordinates I need; but in Birdseye view they return blank (or encrypted values). The SDK recommends using VEBirdseyeScene.GetBoundingRectangle(), but this returns bounds of up to two miles from the center of my scene which in major cities still returns way too many addresses.</p> <p>In previous versions of the VE Control, there was an undocumented VEDecoder object I could use to decrypt the LatLong values for the birdseye scenes, but this object seems to have disappeared (probably been renamed). How can I decode these values in version 6.1?</p>
[ { "answer_id": 33238, "author": "MartinHN", "author_id": 2972, "author_profile": "https://Stackoverflow.com/users/2972", "pm_score": 0, "selected": false, "text": "function GetInfo() \n{\n alert('The latitude,longitude at the center of the map is: '+map.GetCenter()); \n}...
2008/08/28
[ "https://Stackoverflow.com/questions/32621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3420/" ]
32,633
<p>I can easily set breakpoints in embedded JS functions, but I don't see any way of accessing external JS scripts via Firebug unless I happen to enter them during a debug session. Is there a way to do this without having to 'explore' my way into the script?</p> <p>@Jason: This is a good point, but in my case I do not have easy access to the script. I am specifically talking about the client scripts which are invoked by the ASP.Net Validators that I would like to debug. I can access them during a debug session through entering the function calls, but I could not find a way to access them directly.</p>
[ { "answer_id": 32711, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 5, "selected": false, "text": "debugger;" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
32,637
<p>I am consuming the Twitter API and want to convert all URLs to hyperlinks. </p> <p>What is the most effective way you've come up with to do this?</p> <p>from</p> <pre><code>string myString = "This is my tweet check it out http://tinyurl.com/blah"; </code></pre> <p>to</p> <pre><code>This is my tweet check it out &lt;a href="http://tinyurl.com/blah"&gt;http://tinyurl.com/&gt;blah&lt;/a&gt; </code></pre>
[ { "answer_id": 32648, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 6, "selected": true, "text": "Regex r = new Regex(@\"(https?://[^\\s]+)\");\nmyString = r.Replace(myString, \"<a href=\\\"$1\\\">$1</a>\");\n" }, { ...
2008/08/28
[ "https://Stackoverflow.com/questions/32637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2347826/" ]
32,640
<p>So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return "GET".</p> <p>I've seen some examples/helpers out on the nets, but some are dated. Figured this would be a good place to keep the latest and greatest.</p> <p>I'm using latest version of rhino mocks</p>
[ { "answer_id": 32672, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 7, "selected": true, "text": "var request = new Mock<HttpRequestBase>();\nrequest.Expect(r => r.HttpMethod).Returns(\"GET\");\nvar mockHttpContext = new Mock<...
2008/08/28
[ "https://Stackoverflow.com/questions/32640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
32,649
<p>When making changes using <code>SubmitChanges()</code>, LINQ sometimes dies with a <code>ChangeConflictException</code> exception with the error message <code>Row not found or changed</code>, without any indication of either the row that has the conflict or the fields with changes that are in conflict, when another user has changed some data in that row.</p> <p>Is there any way to determine which row has a conflict and which fields they occur in, and also is there a way of getting LINQ to ignore the issue and simply commit the data regardless?</p> <p>Additionally, does anybody know whether this exception occurs when <em>any</em> data in the row has changed, or only when data has been changed in a field that LINQ is attempting to alter?</p>
[ { "answer_id": 32705, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 6, "selected": true, "text": "try\n{\n db.SubmitChanges(ConflictMode.ContinueOnConflict);\n}\ncatch (ChangeConflictException e)\n{\n Console.Wr...
2008/08/28
[ "https://Stackoverflow.com/questions/32649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3394/" ]
32,664
<p>Can anyone tell me if there is a way with generics to limit a generic type argument <code>T</code> to only:</p> <ul> <li><code>Int16</code></li> <li><code>Int32</code></li> <li><code>Int64</code></li> <li><code>UInt16</code></li> <li><code>UInt32</code></li> <li><code>UInt64</code></li> </ul> <p>I'm aware of the <code>where</code> keyword, but can't find an interface for <strong>only</strong> these types,</p> <p>Something like:</p> <pre><code>static bool IntegerFunction&lt;T&gt;(T value) where T : INumeric </code></pre>
[ { "answer_id": 32687, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 7, "selected": false, "text": "static bool GenericFunction<T>(T value) \n where T : operators( +, -, /, * )\n" }, { "answer_id": 32690, "author":...
2008/08/28
[ "https://Stackoverflow.com/questions/32664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736/" ]
32,668
<p>I don't edit CSS very often, and almost every time I need to go and google the <a href="http://www.w3.org/TR/REC-CSS2/box.html" rel="noreferrer">CSS box model</a> to check whether <code>padding</code> is inside the <code>border</code> and <code>margin</code> outside, or vice versa. (Just checked again and <code>padding</code> is inside).</p> <p>Does anyone have a good way of remembering this? A little mnemonic, a good explanation as to why the names are that way round ...</p>
[ { "answer_id": 32696, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": false, "text": "body" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3189/" ]
32,694
<p>I'm trying to use <strong>NIS</strong> for authentication on a st of machines. I had to change one of the user ID numbers for a user account on the NIS server (I changed the userid for <code>username</code> from 500 to 509 to avoid a conflict with a local user account with id 500 on the clients). The problem is that it has not updated properly on the client. </p> <p>In particular, if I do <code>ypcat passwd | grep username</code>, I get the up-to-date info:</p> <pre><code>username:*hidden*:509:509:User Name:/home/username:/bin/bash </code></pre> <p>But if I do, <code>ypmatch username passwd</code>, it says:</p> <pre><code>username:*hidden*:500:500:User Name:/home/username:/bin/bash </code></pre> <p>This means that when the user logs onto one of the clients, it has the wrong userid, which causes all sorts of problems. I've done <code>"cd /var/yp; make"</code> on the server, and <code>"service ypbind restart"</code> on the client, but that hasn't fixed the problem. Does anybody know what would be causing this and how I can somehow force a refresh on the client? (I'm running Fedora 8 on both client and server).</p>
[ { "answer_id": 32770, "author": "Lorin Hochstein", "author_id": 742, "author_profile": "https://Stackoverflow.com/users/742", "pm_score": 1, "selected": false, "text": "\"service ypserv restart\"" }, { "answer_id": 12900738, "author": "Bradley Kreider", "author_id": 26890...
2008/08/28
[ "https://Stackoverflow.com/questions/32694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
32,709
<p>Haven't fired up reflector to look at the difference but would one expect to see the exact same compiled code when comparing <code>Func&lt;T, bool&gt;</code> vs. <code>Predicate&lt;T&gt;</code> </p> <p>I would imagine there is no difference as both take a generic parameter and return bool?</p>
[ { "answer_id": 36872, "author": "ljs", "author_id": 3394, "author_profile": "https://Stackoverflow.com/users/3394", "pm_score": 4, "selected": false, "text": "class A {\n static void Main() {\n Func<int, bool> func = i => i > 100;\n Predicate<int> pred = i => i > 100;\n\n Test<...
2008/08/28
[ "https://Stackoverflow.com/questions/32709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993/" ]
32,715
<p>When using the app_offline.htm feature of ASP.NET, it only allows html, but no images. Is there a way to get images to display <strong>without having to point them to a different url on another site</strong>?</p>
[ { "answer_id": 32866, "author": "Ryan Sampson", "author_id": 1375, "author_profile": "https://Stackoverflow.com/users/1375", "pm_score": 2, "selected": false, "text": " public void Application_Start(object sender, EventArgs e)\n {\n Application[\"OfflineMessage\"] = \"This website is...
2008/08/28
[ "https://Stackoverflow.com/questions/32715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/820/" ]
32,717
<p>I just finished setting up an out-of-place build system for our existing C++ code using inherited property sheets, a feature that seems to be specific to the Visual C++ product. Building out-of-place requires that many of the project settings be changed, and the inherited property sheets allowed me to change all the necessary settings just by attaching a property sheet to the project. I am migrating our team from C++/MFC for UI to C# and WPF, but I need to provide the same out-of-place build functionality, hopefully with the same convenience. I cannot seem to find a way to do this with C# projects - I first looked to see if I could reference an MsBuild targets file, but could not find a way to do this. I know I could just use MsBuild for the whole thing, but that seems more complicated than necessary. Is there a way I can define a macro for a directory and use it in the output path, for example?</p>
[ { "answer_id": 188237, "author": "akmad", "author_id": 1314, "author_profile": "https://Stackoverflow.com/users/1314", "pm_score": 3, "selected": true, "text": "Target" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
32,744
<p>For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...</p> <p>The way I understand it, outgoing mail has to make three trips:</p> <ol> <li>Client (gmail user using Thunderbird) to a server (Gmail)</li> <li>First server (Gmail) to second server (Hotmail)</li> <li>Second server (Hotmail) to second client (hotmail user using OS X Mail)</li> </ol> <p>As I understand it, step one uses SMTP for the client to communicate. The client authenticates itself somehow (say, with USER and PASS), and then sends a message to the gmail server.</p> <p>However, I don't understand how gmail server transfers the message to the hotmail server.</p> <p>For step three, I'm pretty sure, the hotmail server uses POP to send the message to the hotmail client (using authentication, again).</p> <p>So, the big question is: <strong>when I click send Mail sends my message to my gmail server, how does my gmail server forward the message to, say, a hotmail server so my friend can recieve it?</strong></p> <p>Thank you so much!</p> <p>~Jason</p> <hr> <p>Thanks, that's been helpful so far.</p> <p>As I understand it, the first client sends the message to the first server using SMTP, often to an address such as smtp.mail.SOMESERVER.com on port 25 (usually).</p> <p>Then, SOMESERVER uses SMTP again to send the message to RECEIVESERVER.com on port 25 (not smtp.mail.RECEIVESERVER.com or anything fancy).</p> <p>Then, when the recipient asks RECEIVESERVER for its mail, using POP, s/he recieves the message... right?</p> <p>Thanks again (especially to dr-jan),</p> <p>Jason</p>
[ { "answer_id": 32776, "author": "dr-jan", "author_id": 2599, "author_profile": "https://Stackoverflow.com/users/2599", "pm_score": 5, "selected": true, "text": "nslookup\n> set type=mx\n> stackoverflow.com\nServer: 158.155.25.16\nAddress: 158.155.25.16#53\n\nNon-authoritat...
2008/08/28
[ "https://Stackoverflow.com/questions/32744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
32,747
<p>How do I get today's date in C# in mm/dd/yyyy format?</p> <p>I need to set a string variable to today's date (preferably without the year), but there's got to be a better way than building it month-/-day one piece at a time.</p> <p>BTW: I'm in the US so M/dd would be correct, e.g. September 11th is 9/11.</p> <p><em>Note: an answer from kronoz came in that discussed internationalization, and I thought it was awesome enough to mention since I can't make it an 'accepted' answer as well.</em></p> <p><a href="https://stackoverflow.com/questions/32747/how-do-i-get-todays-date-in-c-in-8282008-format#32819" title="kronoz&#39;s answer">kronoz's answer</a></p>
[ { "answer_id": 32749, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "DateTime.Now.ToString(\"M/d/yyyy\");\n" }, { "answer_id": 32751, "author": "Corin Blaikie", "author_id":...
2008/08/28
[ "https://Stackoverflow.com/questions/32747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
32,750
<p>I have a <code>byte[]</code> array, the contents of which represent a TIFF file (as in, if I write out these bytes directly to a file using the <code>BinaryWriter</code> object, it forms a perfectly valid TIFF file) and I'm trying to turn it into a System.Drawing.Image object so that I can use it for later manipulation (feeding into a multipage TIFF object)</p> <p>The problem I'm having is that the commonly accepted code for this task:</p> <pre><code> public Image byteArrayToImage(byte[] byteArrayIn) { MemoryStream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms, true); return returnImage; } </code></pre> <p>doesn't work for me. The second line of the above method where it calls the <code>Image.FromStream</code> method dies at runtime, saying</p> <pre><code>Parameter Not Valid </code></pre> <p>I believe that the method is choking on the fact that this is a TIFF file but I cannot figure out how to make the <code>FromStream</code> method accept this fact.</p> <p>How do I turn a byte array of a TIFF image into an Image object?</p> <p>Also, like I said the end goal of this is to have a byte array representing a multipage TIFF file, which contains the TIFF files for which I have byte array objects of right now. If there's a much better way to go about doing this, I'm all for it.</p>
[ { "answer_id": 32841, "author": "Tim", "author_id": 1970, "author_profile": "https://Stackoverflow.com/users/1970", "pm_score": 3, "selected": true, "text": "MemoryStream ms = new MemoryStream(byteArrayIn);\n" }, { "answer_id": 33101, "author": "Tom Kidd", "author_id": 25...
2008/08/28
[ "https://Stackoverflow.com/questions/32750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
32,777
<p>I've found a few (unfortunately, they are bookmarked at home and I'm at work, so no links), but I was wondering if anyone had any opinions about any of them (love it, hate it, whatever) so I could make a good decision. I think I'm going to use Cygwin for my Unix commands on Windows, but I'm not sure how well that's going to work, so I would love for alternatives and I'm sure there are people out there interested in this who aren't running Cygwin.</p>
[ { "answer_id": 99843, "author": "bk1e", "author_id": 8090, "author_profile": "https://Stackoverflow.com/users/8090", "pm_score": 2, "selected": false, "text": "fork()" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
32,790
<p>For various reasons calling <code>System.exit</code> is frowned upon when writing <strong>Java Applications</strong>, so how can I notify the calling process that not everything is going according to plan?</p> <p><strong>Edit:</strong> The 1 is a <code>standin</code> for any non-zero exit code.</p>
[ { "answer_id": 32817, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 1, "selected": false, "text": "Exception at thread 'main': FileNotFoundException \"The file 'foo' doesn't exist\"\n" }, { "answer_id": 33007, "au...
2008/08/28
[ "https://Stackoverflow.com/questions/32790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
32,803
<p>This question comes on the heels of the question asked <a href="https://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marke">here</a>.</p> <p>The email that comes from our web server comes from an IP address that is different than that for the Exchange server. Is this okay if the SPF and Domain keys are setup properly?</p>
[ { "answer_id": 32817, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 1, "selected": false, "text": "Exception at thread 'main': FileNotFoundException \"The file 'foo' doesn't exist\"\n" }, { "answer_id": 33007, "au...
2008/08/28
[ "https://Stackoverflow.com/questions/32803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2535/" ]
32,814
<p>I'm using an older version of ASP.NET AJAX due to runtime limitations, Placing a ASP.NET Validator inside of an update panel does not work. Is there a trick to make these work, or do I need to use the ValidatorCallOut control that comes with the AJAX toolkit?</p>
[ { "answer_id": 107824, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": -1, "selected": false, "text": "Page_ClientValidate(\"validationGroupName\");\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
32,824
<p>While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object.</p> <p>My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCacheability method everything works like a charm and the server sends along the e-tag header. If I set it to private the e-tag header will be suppressed.</p> <p>Maybe I just haven't looked hard enough but I haven't seen anything in the HTTP/1.1 spec that would justify this behavior. Why wouldn't you want to send E-Tag to browsers while still prohibiting proxies from storing the data?</p> <pre><code>using System; using System.Web; public class Handler : IHttpHandler { public void ProcessRequest (HttpContext ctx) { ctx.Response.Cache.SetCacheability(HttpCacheability.Private); ctx.Response.Cache.SetETag("\"static\""); ctx.Response.ContentType = "text/plain"; ctx.Response.Write("Hello World"); } public bool IsReusable { get { return true; } } } </code></pre> <p>Will return</p> <pre> Cache-Control: private Content-Type: text/plain; charset=utf-8 Content-Length: 11 </pre> <p>But if we change it to public it'll return</p> <pre> Cache-Control: public Content-Type: text/plain; charset=utf-8 Content-Length: 11 Etag: "static" </pre> <p>I've run this on the ASP.NET development server and IIS6 so far with the same results. Also I'm unable to explicitly set the ETag using</p> <pre><code>Response.AppendHeader("ETag", "static") </code></pre> <p><strong>Update</strong>: It's possible to append the ETag header manually when running in IIS7, I suspect this is caused by the tight integration between ASP.NET and the IIS7 pipeline.</p> <p><strong>Clarification</strong>: It's a long question but the core question is this: <strong>why does ASP.NET do this, how can I get around it and should I?</strong></p> <p><strong>Update</strong>: I'm going to accept <a href="https://stackoverflow.com/questions/32824/why-does-httpcacheabilityprivate-suppress-etags#34004">Tony's answer</a> since it's essentially correct (go Tony!). I found that if you want to emulate the HttpCacheability.Private fully you can set the cacheability to ServerAndPrivate but you also have call cache.<a href="http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.setomitvarystar.aspx" rel="nofollow noreferrer">SetOmitVaryStar</a>(true) otherwise the cache will add the <strong>Vary: *</strong> header to the output and you don't want that. I'll edit that into the answer when I get edit permissions (or if you see this Tony perhaps you could edit your answer to include that call?)</p>
[ { "answer_id": 33555, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 2, "selected": false, "text": "System.Web.HttpCachePolicy.UpdateCachedHeaders()" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2114/" ]
32,871
<p>I have a swf with loads text into a Sprite that resizes based on the content put into - I'd like though for the ones that are longer than the page to have the browser use its native scroll bars rather than handle it in actionscript (very much like <a href="http://www.nike.com/nikeskateboarding/v3/" rel="noreferrer">http://www.nike.com/nikeskateboarding/v3/</a>...)</p> <p>I did have a look at the stuff nike did but just wasn't able to pull it off. Any idea's?</p>
[ { "answer_id": 34523, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 3, "selected": false, "text": "function resizeFlash( h ) {\n // \"flash-node-id\" is the ID of the embedded Flash movie\n document.getElementById(\"flash...
2008/08/28
[ "https://Stackoverflow.com/questions/32871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
32,877
<p>I've got a problem where incoming SOAP messages from one particular client are being marked as invalid and rejected by our XML firewall device. It appears extra payload data is being inserted by Visual Studio; we're thinking the extra data may be causing a problem b/c we're seeing "VsDebuggerCausalityData" in these messages but not in others sent from a different client who is not having a problem. It's a starting point, anyway.</p> <p>The question I have is how can the client remove this extra data and still run from VS? Why is VS putting it in there at all?</p> <p>Thanks.</p>
[ { "answer_id": 33312, "author": "Darryl Braaten", "author_id": 1834, "author_profile": "https://Stackoverflow.com/users/1834", "pm_score": 5, "selected": true, "text": "<configuration>\n <system.diagnostics>\n <switches>\n <add name=\"Remote.Disable\" value=\"1\" />\n </swit...
2008/08/28
[ "https://Stackoverflow.com/questions/32877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1683/" ]
32,897
<p>This question would probably apply equally as well to other languages with C-like multi-line comments. Here's the problem I'm encountering. I'm working with Java code in Eclipse, and I wanted to comment out a block of code. However, there is a string that contains the character sequence "*/", and Eclipse thinks that the comment should end there, even though it is inside a string. It gives me tons of errors and fails to build.</p> <pre><code>/* ... some Java code ... ... "... */ ..." ... ... more Java code ... */ </code></pre> <p>Does the Java specification match with Eclipse's interpretation of my multi-line comment? I would like to think that Java and/or Eclipse would account for this sort of thing.</p>
[ { "answer_id": 32927, "author": "joev", "author_id": 3449, "author_profile": "https://Stackoverflow.com/users/3449", "pm_score": 0, "selected": false, "text": "public class Test {\n public static final void main(String[] args) throws Exception {\n String s = \"This is the original st...
2008/08/28
[ "https://Stackoverflow.com/questions/32897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
32,899
<p>I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this:</p> <pre><code>import unittest l = [[&quot;foo&quot;, &quot;a&quot;, &quot;a&quot;,], [&quot;bar&quot;, &quot;a&quot;, &quot;b&quot;], [&quot;lee&quot;, &quot;b&quot;, &quot;b&quot;]] class TestSequence(unittest.TestCase): def testsample(self): for name, a,b in l: print &quot;test&quot;, name self.assertEqual(a,b) if __name__ == '__main__': unittest.main() </code></pre> <p>The downside of this is that it handles all data in one test. I would like to generate one test for each item on the fly. Any suggestions?</p>
[ { "answer_id": 32939, "author": "Dmitry Mukhin", "author_id": 3448, "author_profile": "https://Stackoverflow.com/users/3448", "pm_score": 9, "selected": true, "text": "from parameterized import parameterized\n\nclass TestSequence(unittest.TestCase):\n @parameterized.expand([\n ...
2008/08/28
[ "https://Stackoverflow.com/questions/32899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/720/" ]
32,937
<p>In C# is there a shorthand way to write this:</p> <pre><code>public static bool IsAllowed(int userID) { return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...); } </code></pre> <p>Like:</p> <pre><code>public static bool IsAllowed(int userID) { return (userID in Personnel.JohnDoe, Personnel.JaneDoe ...); } </code></pre> <p>I know I could also use switch, but there are probably 50 or so functions like this I have to write (porting a classic ASP site over to ASP.NET) so I'd like to keep them as short as possible.</p>
[ { "answer_id": 32942, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 2, "selected": false, "text": "List<int> allowedIDs = ...;\n\npublic bool IsAllowed(int userID)\n{\n return allowedIDs.Contains(userID);\n}\n" }, ...
2008/08/28
[ "https://Stackoverflow.com/questions/32937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1302/" ]
32,986
<p>I know that if you have a loop that modifies the count of the items in the loop, using the NSEnumerator on a set is the best way to make sure your code blows up, however I would like to understand the performance tradeoffs between the NSEnumerator class and just an old school for loop</p>
[ { "answer_id": 33035, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "NSFastEnumeration" }, { "answer_id": 33256, "author": "Chris Hanson", "author_id": 714, "author_profile": "...
2008/08/28
[ "https://Stackoverflow.com/questions/32986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3484/" ]
32,991
<p>The leaving your wireless network open question reminded me of this.</p> <p>I typically share the root drive on my machines across my network, and tie login authorization to the machines NT ID, so there is at least some form of protection.</p> <p>My question, how easy is it to gain access to these drives for ill good? Is the authorization enough, or should I lock things down more?</p>
[ { "answer_id": 32997, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 0, "selected": false, "text": "\\\\yourmachine\\c$\n" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/32991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
33,048
<p>Suppose you have an ActiveRecord::Observer in one of your Ruby on Rails applications - how do you test this observer with rSpec?</p>
[ { "answer_id": 33869, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 4, "selected": false, "text": "should_receive" }, { "answer_id": 130114, "author": "Pete", "author_id": 13472, "author_profile": "ht...
2008/08/28
[ "https://Stackoverflow.com/questions/33048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2569/" ]
33,055
<p>I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?</p>
[ { "answer_id": 33064, "author": "Nicolai Reuschling", "author_id": 2569, "author_profile": "https://Stackoverflow.com/users/2569", "pm_score": 8, "selected": true, "text": "svnadmin dump repositorypath | gzip > backupname.svn.gz\n" }, { "answer_id": 33068, "author": "RobotCal...
2008/08/28
[ "https://Stackoverflow.com/questions/33055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3396/" ]
33,063
<p>I have a big string (let's call it a CSV file, though it isn't actually one, it'll just be easier for now) that I have to parse in C# code.<br> The first step of the parsing process splits the file into individual lines by just using a <code>StreamReader</code> object and calling <code>ReadLine</code> until it's through the file. However, any given line might contain a quoted (in single quotes) literal with embedded newlines. I need to find those newlines and convert them temporarily into some other kind of token or escape sequence until I've split the file into an array of lines..then I can change them back. </p> <p>Example input data: </p> <pre><code>1,2,10,99,'Some text without a newline', true, false, 90 2,1,11,98,'This text has an embedded newline and continues here', true, true, 90 </code></pre> <p>I could write all of the C# code needed to do this by using <code>string.IndexOf</code> to find the quoted sections and look within them for newlines, but I'm thinking a Regex might be a better choice (i.e. <a href="http://regex.info/blog/2006-09-15/247" rel="nofollow noreferrer">now I have two problems</a>)</p>
[ { "answer_id": 33074, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "content = Regex.Replace(content, \"'([^']*)\\n([^']*)'\", \"'\\1TOKEN\\2'\");\n" }, { "answer_id": 33172, "author...
2008/08/28
[ "https://Stackoverflow.com/questions/33063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187/" ]
33,073
<p>How do I make <code>diff</code> ignore temporary files like <code>foo.c~</code>? Is there a configuration file that will make ignoring temporaries the default?</p> <p>More generally: what's the best way to generate a "clean" patch off a tarball? I do this rarely enough (submitting a bug fix to an OSS project by email) that I always struggle with it...</p> <p>EDIT: OK, the short answer is</p> <pre><code>diff -ruN -x *~ ... </code></pre> <p>Is there a better answer? E.g., can this go in a configuration file?</p>
[ { "answer_id": 33098, "author": "Fernando Barrocal", "author_id": 2274, "author_profile": "https://Stackoverflow.com/users/2274", "pm_score": 0, "selected": false, "text": "#!/bin/bash\nolddir=\"/tmp/old\"\nnewdir=\"/tmp/new\"\n\npushd $newdir\nfor files in $(find . -name \\*.c)\ndo\n d...
2008/08/28
[ "https://Stackoverflow.com/questions/33073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
33,080
<p>In a web application, I have a page that contains a DIV that has an auto-width depending on the width of the browser window.</p> <p>I need an auto-height for the object. The DIV starts about 300px from the top screen, and its height should make it stretch to the bottom of the browser screen. I have a max height for the container DIV, so there would have to be minimum-height for the div. I believe I can just restrict that in CSS, and use Javascript to handle the resizing of the DIV.</p> <p>My javascript isn't nearly as good as it should be. Is there an easy script I could write that would do this for me?</p> <p>Edit: The DIV houses a control that does it's own overflow handling (implements its own scroll bar).</p>
[ { "answer_id": 33096, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 3, "selected": false, "text": "div {\n position: absolute;\n top: 300px;\n bottom: 0px;\n left: 30px;\n right: 30px;\n}\n" }, { "answer...
2008/08/28
[ "https://Stackoverflow.com/questions/33080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1226/" ]
33,089
<p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application. It keeps redirecting to a Login.aspx page at the root of my application that does not exist. My login page is within a folder.</p>
[ { "answer_id": 33092, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 1, "selected": false, "text": "<?xml version=\"1.0\"?>\n<configuration>\n <system.web>\n ...\n <!--\n The <authentication> sec...
2008/08/28
[ "https://Stackoverflow.com/questions/33089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
33,103
<p>I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item?</p>
[ { "answer_id": 33130, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 4, "selected": true, "text": "onpaste" } ]
2008/08/28
[ "https://Stackoverflow.com/questions/33103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450/" ]
33,115
<p>Does C# have the notion of private / protected inheritance, and if not, why?</p> <p><strong>C++</strong></p> <pre> <code> class Foo : private Bar { public: ... }; </code> </pre> <p><strong>C#</strong></p> <pre> <code> public abstract NServlet class : private System.Web.UI.Page { // error "type expected" } </code> </pre> <p>I am implementing a "servlet like" concept in an .aspx page and I don't want the concrete class to have the ability to see the internals of the System.Web.UI.Page base.</p>
[ { "answer_id": 33182, "author": "Chris Karcher", "author_id": 2773, "author_profile": "https://Stackoverflow.com/users/2773", "pm_score": 2, "selected": false, "text": "class Base\n{\n public void F() {}\n}\nclass Derived : Base\n{\n new private void F() {}\n}\n\nBase o = new Derived...
2008/08/28
[ "https://Stackoverflow.com/questions/33115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
33,150
<p>I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.</p> <p>in vb.net: <code>Parent.FindControl(TargetControlName)</code></p> <p>I would like to pass a method to the control in the ASPX markup. </p> <p>for example: <code>&lt;c:MyCustomerControl runat=server InitializeStuffCallback="InitializeStuff"&gt;</code></p> <p>So, I tried using reflection to access the given method name from the Parent.</p> <p>Something like (in VB)</p> <pre class="lang-vb prettyprint-override"><code>Dim pageType As Type = Page.GetType Dim CallbackMethodInfo As MethodInfo = pageType.GetMethod( "MethodName" ) 'Also tried sender.Parent.GetType.GetMethod("MethodName") sender.Parent.Parent.GetType.GetMethod("MethodName") </code></pre> <p>The method isn't found, because it just isn't apart of the Page. Where should I be looking? I'm fairly sure this is possible because I've seen other controls do similar.</p> <hr> <p>I forgot to mention, my work-around is to give the control events and attaching to them in the Code-behind.</p>
[ { "answer_id": 33179, "author": "Jesse Dearing", "author_id": 1804, "author_profile": "https://Stackoverflow.com/users/1804", "pm_score": 3, "selected": true, "text": "Browsable" }, { "answer_id": 33187, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": ...
2008/08/28
[ "https://Stackoverflow.com/questions/33150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2017/" ]