qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
270,438
<p>I'm implementing my app as a drag source. When I call DoDragDrop (Win32 call, not MFC) it enters into a modal loop and I don't get repaint messages in my main window until DoDragDrop returns. Unfortunately if I do a drop in the shell (a file) and the filename is already there the shell asks if I want to replace the file. But since me app is blocked because DoDragDrop hasn't returned it isn't repainting and looks 'frozen'. </p> <p>Any clues ?</p>
[ { "answer_id": 9114170, "author": "user1185359", "author_id": 1185359, "author_profile": "https://Stackoverflow.com/users/1185359", "pm_score": 2, "selected": false, "text": "DoDragDrop()" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,444
<p>I'm getting this error:</p> <pre><code>javax.servlet.ServletException: bean not found within scope </code></pre> <p>on a page with this at the top.</p> <pre class="lang-html prettyprint-override"><code>&lt;jsp:useBean id="bean" type="com.example.Bean" scope="request" /&gt; </code></pre> <p>The class exists in the classpath, it worked this morning, and I don't get what not found within scope means.</p> <p>How is this caused and how can I solve it?</p>
[ { "answer_id": 904223, "author": "victor hugo", "author_id": 70616, "author_profile": "https://Stackoverflow.com/users/70616", "pm_score": 1, "selected": false, "text": "<jsp:useBean id=\"givingFormBean\" type=\"some.packg.GivingForm\" scope=\"request\" />\n" }, { "answer_id": 30...
2008/11/06
[ "https://Stackoverflow.com/questions/270444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
270,445
<p>Is there a way to compile multiple java source directories in a single maven project? </p>
[ { "answer_id": 270451, "author": "sal", "author_id": 13753, "author_profile": "https://Stackoverflow.com/users/13753", "pm_score": 6, "selected": false, "text": "<build>\n <sourceDirectory>.</sourceDirectory>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins<...
2008/11/06
[ "https://Stackoverflow.com/questions/270445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753/" ]
270,453
<p>I recently got a notification from a McAfee service (what used to be called HackerSafe) that my website is using SSLv2 and it should be using SSLv3. I don't know anything about the versions of SSL. My site is using IIS 6.0, is there a setting somewhere to turn on SSLv3 or do I need to install something to make this happen? Also, is there any drawbacks to only using SSLv3? Are there browsers that can only use v2?</p>
[ { "answer_id": 288661, "author": "Saul Dolgin", "author_id": 8305, "author_profile": "https://Stackoverflow.com/users/8305", "pm_score": 3, "selected": false, "text": "Windows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHA...
2008/11/06
[ "https://Stackoverflow.com/questions/270453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33731/" ]
270,455
<p>I'm all for language diversity, but Objective C is insane. So I'm curious: is it possible to code iPhone apps with C++ while using the Cocoa API, etc?</p>
[ { "answer_id": 3441001, "author": "Arpad Goretity", "author_id": 415188, "author_profile": "https://Stackoverflow.com/users/415188", "pm_score": 0, "selected": false, "text": "#import \"ObjectiveX.h\"\n\nvoid GUIApplicationMain() { \n    GUIAlert Alert;\n    GUILabel Label;\n    GUISc...
2008/11/06
[ "https://Stackoverflow.com/questions/270455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9476/" ]
270,458
<p>I am building a really basic Cocoa application using WebKit, to display a Flash/Silverlight application within it. Very basic, no intentions for it to be a browser itself.</p> <p>So far I have been able to get it to open basic html links (<code>&lt;a href="..." /&gt;</code>) in a new instance of Safari using </p> <pre><code>[[NSWorkspace sharedWorkspace] openURL:[request URL]]; </code></pre> <p>Now my difficulty is opening a link in a new instance of Safari when <code>window.open()</code> is used in JavaScript. I "think" (and by this, I have been hacking away at the code and am unsure if i actually did or not) I got this kind of working by setting the WebView's <code>policyDelegate</code> and implementing its</p> <pre><code>-webView:decidePolicyForNavigationAction:request:frame:decisionListener: </code></pre> <p>delegate method. However this led to some erratic behavior.</p> <p>So the simple question, what do I need to do so that when <code>window.open()</code> is called, the link is opened in a new instance of Safari.</p> <p>Thanks</p> <p>Big point, I am normally a .NET developer, and have only been working with Cocoa/WebKit for a few days.</p>
[ { "answer_id": 272546, "author": "FireWire", "author_id": 35263, "author_profile": "https://Stackoverflow.com/users/35263", "pm_score": 3, "selected": false, "text": "webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:" }, { "answer_id": 510789, "aut...
2008/11/06
[ "https://Stackoverflow.com/questions/270458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35263/" ]
270,468
<p>Can anyone please let me know the procedure to perform silent installation of SQL Server Express 2005 and the way to specify the installation parameters.</p>
[ { "answer_id": 270521, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 3, "selected": false, "text": "string InstallFile = \"SSCERuntime-ENU-x86.msi\"\nstring LogFile = \"C:\\Install.log\"\n\nProcess proc;\nproc = Proces...
2008/11/06
[ "https://Stackoverflow.com/questions/270468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,479
<p>My solution includes these two projects:</p> <ul> <li>MyNamespace.Web.UI</li> <li>MyNamespace.Web.Core</li> </ul> <p>UI references Core, and Core references Foobar.dll, which exists nowhere except my library. When I build from Visual Studio 2008 Foobar.dll is in the UI project's Bin folder as expected. I have made certain it was not there before the build. </p> <p>But when I build from NAnt, it is not there, which results in a runtime exception. Here's what the NAnt task looks like:</p> <pre><code>&lt;target name="compile" depends="init"&gt; &lt;exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" commandline="${solution.file} /m /t:Clean /p:Configuration=${project.config} /v:q" workingdir="." /&gt; &lt;exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" commandline="${solution.file} /m /t:Rebuild /p:Configuration=${project.config} /v:q" workingdir="." /&gt; &lt;/target&gt; </code></pre> <p>In VS I have tried building, rebuilding, rebuilding all in release mode and debug mode, etc. It's always the same. Foobar.dll is in the Bin folder. Not so with NAnt. I have tried also to remove the /m switch from the NAnt script. Same result.</p> <p>There are several other dlls referenced in Core and not in UI, and they appear in Bin as expected after the NAnt build.</p> <p>My workaround is to reference Foobar.dll in the UI project, but that makes me a little nauseous. Any idea what can cause this?</p> <p>(Incidentally Foobar.dll is actually NHibernate.ProxyGenerators.CastleDynamicProxy.dll)</p>
[ { "answer_id": 34050070, "author": "Hinesh Mandalia", "author_id": 5631656, "author_profile": "https://Stackoverflow.com/users/5631656", "pm_score": 0, "selected": false, "text": "<Reference Include=\"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856...
2008/11/06
[ "https://Stackoverflow.com/questions/270479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29493/" ]
270,488
<p>I am using VC++. Is <code>assert(false)</code> ignored in release mode?</p>
[ { "answer_id": 9836791, "author": "RzR", "author_id": 149841, "author_profile": "https://Stackoverflow.com/users/149841", "pm_score": 1, "selected": false, "text": " #ifdef NDEBUG\n\n # define assert(expr) (__ASSERT_VOID_CAST (0))\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
270,493
<p>I need two divs to look a bit like this: </p> <pre><code> | | ---| LOGO |------------------------ | |_______________| LINKS | | CONTENT | </code></pre> <p>What's the neatest/most elegant way of making them overlap neatly? The logo will have a fixed height and width and will be touching the top edge of the page.</p>
[ { "answer_id": 270501, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "div#logo {\n position: absolute;\n left: 100px; // or whatever\n}\n" }, { "answer_id": 270503, "author": "FlyS...
2008/11/06
[ "https://Stackoverflow.com/questions/270493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,494
<p>I have a form with a textbox and a button. IE is the only browser that will not submit the form when Enter is pressed (works in FF, Opera, Safari, Chrome, etc.). I found this javascript function to try to coax IE into behaving; but no avail:</p> <pre><code>function checkEnter(e){ var characterCode if (e &amp;&amp; e.which) { e = e characterCode = e.which } else { e = event characterCode = e.keyCode } if (characterCode == 13) { document.forms[0].submit() return false } else { return true } } </code></pre> <p>Implementation: </p> <pre><code>searchbox.Attributes("OnKeyUp") = "checkEnter(event)" </code></pre> <p>Any advice?</p> <p><strong>EDIT:</strong> <a href="http://www.codeproject.com/KB/aspnet/EnterKeyToButtonClick.aspx" rel="noreferrer">This page</a> on <a href="http://www.codeproject.com/" rel="noreferrer">CodeProject</a> outlines what Dillie was saying, and it works perfectly.</p>
[ { "answer_id": 270505, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 2, "selected": false, "text": "// Use the following Javascript in your HTML view\n// put it somewhere between <head> and </head>\n\n <script language=...
2008/11/06
[ "https://Stackoverflow.com/questions/270494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
270,510
<p>I am looking to encrypt some data using <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard" rel="noreferrer">Rijndael/AES</a> in <a href="http://en.wikipedia.org/wiki/VBScript" rel="noreferrer">VBScript</a> using a specific key and <a href="http://en.wikipedia.org/wiki/Initialization_vector" rel="noreferrer">IV</a> value. Are there any good function libraries or COM components that would be good to use?</p> <p>I looked at <a href="http://en.wikipedia.org/wiki/CAPICOM" rel="noreferrer">CAPICOM</a>; it allows a passphrase only, and won't allow setting specific key and IV values.</p>
[ { "answer_id": 858525, "author": "Cheeso", "author_id": 48082, "author_profile": "https://Stackoverflow.com/users/48082", "pm_score": 2, "selected": false, "text": "RijndaelManaged" }, { "answer_id": 28129895, "author": "Grnd Xhef", "author_id": 4490604, "author_profi...
2008/11/06
[ "https://Stackoverflow.com/questions/270510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,531
<p>I've got an arbitrary list of .NET assemblies.</p> <p>I need to programmatically check if each DLL was built for x86 (as opposed to x64 or Any CPU). Is this possible?</p>
[ { "answer_id": 270545, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 8, "selected": false, "text": "PE" }, { "answer_id": 270549, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverfl...
2008/11/06
[ "https://Stackoverflow.com/questions/270531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
270,541
<p>What algorithms could i use to determine common characters in a set of strings?</p> <p>To make the example simple, I only care about 2+ characters in a row and if it shows up in 2 or more of the sample. For instance:</p> <ol> <li>0000abcde0000 </li> <li>0000abcd00000 </li> <li>000abc0000000</li> <li>00abc000de000</li> </ol> <p>I'd like to know:</p> <p>00 was used in 1,2,3,4<br> 000 was used in 1,2,3,4<br> 0000 was used in 1,2,3<br> 00000 was used in 2,3<br> ab was used in 1,2,3,4<br> abc was used in 1,2,3,4<br> abcd was used in 1,2<br> bc was used in 1,2,3,4<br> bcd was used in 1,2<br> cd was used in 1,2<br> de was used in 1,4 </p>
[ { "answer_id": 270638, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 2, "selected": false, "text": "abc\nabd\nabde\nacc\nbde\n" }, { "answer_id": 270880, "author": "joel.neely", "author_id": 3525, "author_pro...
2008/11/06
[ "https://Stackoverflow.com/questions/270541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
270,542
<p>I use the Boost Test framework to unit test my C++ code and wondered if it is possible to test if a function will assert? Yes, sounds a bit strange but bear with me! Many of my functions check the input parameters upon entry, asserting if they are invalid, and it would be useful to test for this. For example:</p> <pre><code>void MyFunction(int param) { assert(param &gt; 0); // param cannot be less than 1 ... } </code></pre> <p>I would like to be able to do something like this:</p> <pre><code>BOOST_CHECK_ASSERT(MyFunction(0), true); BOOST_CHECK_ASSERT(MyFunction(-1), true); BOOST_CHECK_ASSERT(MyFunction(1), false); ... </code></pre> <p>You can check for exceptions being thrown using Boost Test so I wondered if there was some assert magic too...</p>
[ { "answer_id": 1150324, "author": "legalize", "author_id": 139855, "author_profile": "https://Stackoverflow.com/users/139855", "pm_score": 3, "selected": false, "text": "catch" }, { "answer_id": 1772832, "author": "Grafoid", "author_id": 215570, "author_profile": "htt...
2008/11/06
[ "https://Stackoverflow.com/questions/270542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
270,561
<p>Developing a website and just trying to get back into the swing of (clever) SQL queries etc, my mind had totally gone tonight!</p> <p>There is a website <a href="http://www.ufindus.com/" rel="nofollow noreferrer">http://www.ufindus.com/</a> which has a textbox allowing you to enter either a place name or a postcode/zipcode. I am trying to do something similiar but I am rubbish at SQL - so how do you construct an SQL statement that could potentially look at 2 columns (i.e. place and postcode) because you can't query both fields for the same value e.g </p> <pre><code>place = 'YORK' AND postcode = 'YORK' </code></pre> <p>or</p> <pre><code>place = 'YO21 5EA' AND postcode = 'YO21 5EA' </code></pre> <p>so do you have to put some logic in to be intelligent enough to detect whether it looks like a place name or a postcode - that just seems too complicated to me!! Any help would be much appreciated.</p>
[ { "answer_id": 270577, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "place = @textboxvalue OR post = @textboxvalue\n" }, { "answer_id": 271547, "author": "Jørn Jensen", "...
2008/11/06
[ "https://Stackoverflow.com/questions/270561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175/" ]
270,592
<pre><code>class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class DropTableQuery: public AbstractQuery { vector&lt; std::pair&lt; string, string&gt; &gt; QueryContent; QueryValidate qv; public: explicit DropTableQuery(const string&amp; qr): AbstractQuery(), qv(qr) {} bool Execute(); }; </code></pre> <p>Is it necessary to call base contructor in derived class constructor?</p>
[ { "answer_id": 270599, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 4, "selected": true, "text": "class MyInterface {\npublic:\n virtual ~MyInterface() {}\n virtual void execute() = 0;\n};\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
270,598
<p>I've got an application that loads .so files as plugins at startup, using <code>dlopen()</code></p> <p>The build environment is running on x86 hardware, but the application is being cross compiled for another platform.</p> <p>It would be great if I could (as part of the automated build process) do a check to make sure that there aren't any unresolved symbols in a combination of the .so files and the application, without having to actually deploy the application.</p> <p>Before I write a script to test symbols using the output of <code>nm</code>, I'm wondering if anyone knows of a utility that already does this?</p> <hr> <p>edit 1: changed the description slightly - I'm not just trying to test symbols in the .so, but rather in a combination of several .so's and the application itself - ie. after the application loaded all of the .so's whether there would still be unresolved symbols.</p> <p>As has been suggested in answers (thanks Martin v. Löwis and tgamblin), <code>nm</code> will easily identify missing symbols in a single file but won't easily identify which of those symbols has been resolved in one of the other loaded modules.</p>
[ { "answer_id": 270632, "author": "Todd Gamblin", "author_id": 9122, "author_profile": "https://Stackoverflow.com/users/9122", "pm_score": 1, "selected": false, "text": " --no-undefined\n Report unresolved symbol references from regular object files.\n This is done even ...
2008/11/06
[ "https://Stackoverflow.com/questions/270598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11694/" ]
270,611
<p>Is it a good idea to store my SQL queries in a global resource file instead of having it in my codebehind? I know stored procedures would be a better solution but I don't have that luxury on this project. </p> <p>I don't want queries all over my pages and thought a central repository would be a better idea.</p>
[ { "answer_id": 270844, "author": "Robert Paulson", "author_id": 14033, "author_profile": "https://Stackoverflow.com/users/14033", "pm_score": 4, "selected": true, "text": "public static class SqlResource\n{\n private static Dictionary<string,SqlQuery> dictionary;\n\n public static ...
2008/11/06
[ "https://Stackoverflow.com/questions/270611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18234/" ]
270,612
<p>I am creating a chat using Ajax requests and I'm trying to get messages div to scroll to the bottom without much luck.</p> <p>I am wrapping everything in this div:</p> <pre><code>#scroll { height:400px; overflow:scroll; } </code></pre> <p>Is there a way to keep it scrolled to the bottom by default using JS?</p> <p>Is there a way to keep it scrolled to the bottom after an ajax request?</p>
[ { "answer_id": 270628, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 12, "selected": true, "text": "var objDiv = document.getElementById(\"your_div\");\nobjDiv.scrollTop = objDiv.scrollHeight;\n" }, { "answer_id": ...
2008/11/06
[ "https://Stackoverflow.com/questions/270612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
270,623
<p>I can use VS08's MFC/ActiveX template to create a C++ ActiveX object that I can load into a HTML page and script with Javascript. But I can't figure out how to create an interface that allows me to call custom methods on my component with Javascript.</p> <p>Could you please tell me how to accomplish that? I have spent over two hours on google with no luck.</p> <p>Thanks.</p>
[ { "answer_id": 301687, "author": "korona", "author_id": 25731, "author_profile": "https://Stackoverflow.com/users/25731", "pm_score": 1, "selected": false, "text": "<html> \n<body> \n<object height=\"0\" width=\"0\" id=\"myControl\" classid=\"CLSID:AC12D6F8-AEB7-4935-B3C9-0E4FB6CF7FB1\" ...
2008/11/06
[ "https://Stackoverflow.com/questions/270623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,630
<p>I am an upper level Software Engineering student currently in a Data Structures and Algorithms class. Our professor wants us to write a program using the List structure found in the C++ STL. I have been trying to use C# more and more, and was wondering if the ArrayList structure in .NET is a good substitute for the STL List implementation. </p>
[ { "answer_id": 270641, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "List<T>" }, { "answer_id": 270642, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "h...
2008/11/06
[ "https://Stackoverflow.com/questions/270630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,648
<p>How do you invoke a tkinter <code>event</code> from a separate object? </p> <p>I'm looking for something like wxWidgets <code>wx.CallAfter</code>. For example, If I create an object, and pass to it my <code>Tk</code> root instance, and then try to call a method of that root window from my object, my app locks up.</p> <p>The best I can come up with is to use the the <code>after</code> method and check the status from my separate object, but that seems wasteful.</p>
[ { "answer_id": 276069, "author": "Bryan Oakley", "author_id": 7432, "author_profile": "https://Stackoverflow.com/users/7432", "pm_score": 6, "selected": true, "text": "event_generate" }, { "answer_id": 36778730, "author": "user110954", "author_id": 2787591, "author_pr...
2008/11/06
[ "https://Stackoverflow.com/questions/270648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16363/" ]
270,651
<p>I recently found a log statement in my projects codebase that says "here i am with search parameter==>===========11/30/2008===1====00:00 AM"</p> <p>what guidelines do you adhere to for writing good log messages in an application?</p>
[ { "answer_id": 270687, "author": "madlep", "author_id": 14160, "author_profile": "https://Stackoverflow.com/users/14160", "pm_score": 3, "selected": false, "text": "LOGGER.debug(\"The variable was \" + myVariable + \" and we are doing \" + foo);\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1129162/" ]
270,658
<p>I'm looking at building basic CMS functionality into our web product and am researching tips and design ideas for versioning content. I'm specifically looking for database schemas in use today.</p> <p>What are you using for content versioning? What patterns apply if you have different types of content that need versions stored? How is question versioning handled on Stack Overflow?</p> <p>Thanks</p>
[ { "answer_id": 270803, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "node node_revision\n---- -------------\nnid* vid*\nvid nid\n... body\n .....
2008/11/06
[ "https://Stackoverflow.com/questions/270658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2656/" ]
270,672
<p>Is there anyway to use unicode strings (most probably in UTF-8, but could be any encoding) in PostScript?</p> <p>So far, i've been using this function to transforms fonts to Latin1 encoding:</p> <pre><code>/latinize { findfont dup length dict begin { 1 index /FID ne {def}{pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end definefont pop }bind def /HelveLat /Helvetica latinize /HelveLatbold /Helvetica-Bold latinize </code></pre> <p>but i really don't like it.</p>
[ { "answer_id": 12524359, "author": "luser droog", "author_id": 733077, "author_profile": "https://Stackoverflow.com/users/733077", "pm_score": 2, "selected": false, "text": "show" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11649/" ]
270,674
<p>I've generated a pdf using iTextSharp and I can preview it very well in ASP.Net but I need to send it directly to printer without a preview. I want the user to click the print button and automatically the document prints.</p> <p>I know that a page can be sent directly to printer using the javascript window.print() but I don't know how to make it for a PDF.</p> <p>Edit: it is not embedded, I generate it like this;</p> <pre><code> ... FileStream stream = new FileStream(Request.PhysicalApplicationPath + "~1.pdf", FileMode.Create); Document pdf = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.GetInstance(pdf, stream); pdf.Open(); pdf.Add(new Paragraph(member.ToString())); pdf.Close(); Response.Redirect("~1.pdf"); ... </code></pre> <p>And here I am.</p>
[ { "answer_id": 270733, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 1, "selected": false, "text": "var x = document.getElementById(\"mypdfembeddobject\"); \nx.click();\nx.setActive();\nx.focus();\nx.print();\n" }, { ...
2008/11/06
[ "https://Stackoverflow.com/questions/270674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130097/" ]
270,677
<p>How do I access specific sections of man pages?</p>
[ { "answer_id": 270694, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 5, "selected": true, "text": "man 3 sysctl\n" }, { "answer_id": 270718, "author": "Adam Rosenfield", "author_id": 9530, "author_pr...
2008/11/06
[ "https://Stackoverflow.com/questions/270677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30924/" ]
270,695
<p>Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB. Is there a way to have an insert statement return a value? I have a sequence set up to number entries as they go into the database, but I need that value to come back after the insert so I can do some manipulation to the set I just entered in the code-behind VB.</p>
[ { "answer_id": 270726, "author": "jishi", "author_id": 33663, "author_profile": "https://Stackoverflow.com/users/33663", "pm_score": 2, "selected": false, "text": "last_insert_id()" }, { "answer_id": 270901, "author": "Mark Stock", "author_id": 19737, "author_profile"...
2008/11/06
[ "https://Stackoverflow.com/questions/270695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12545/" ]
270,703
<p>Our company is looking to integrate invoices into a new system we are developing.</p> <p>We require a solution to create a layout of the invoice and then convert to pdf.</p> <p>We have considered just laying out the invoice in html/css then converting to pdf. We have also considered using SVG->PDf conversion.</p> <p>Both of these solutions integrate well into our existing templating language used for our web application.</p> <p>Historically we have been a Microsoft based business and used Crystal Reports for such a task but we are looking for an open source Linux solution for this project.</p> <p>Does any one have any suggestions of an approach or technology we could use for such a task?</p>
[ { "answer_id": 270723, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "ps2pdf" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35293/" ]
270,708
<p>I have a char array buffer that I am using to store characters that the user will input one by one. My code below works but has a few glitches that I can't figure out:</p> <ol> <li>when I execute a printf to see what's in Buffer, it does fill up but I get garbage characters at the end</li> <li>it won't stop at 8 characters despite being declared as char Buffer[8];</li> </ol> <p>Can somebody please explain to me what is going on and perhaps how I could fix this? Thanks.</p> <pre><code>char Buffer[8]; //holds the byte stream int i=0; if (/* user input event has occurred */) { Buffer[i] = charInput; i++; // Display a response to input printf("Buffer is %s!\n", Buffer); } </code></pre> <p>Output:</p> <pre> tagBuffer is 1┬┬w! tagBuffer is 12┬w! tagBuffer is 123w! tagBuffer is 1234! tagBuffer is 12345! tagBuffer is 123456=! tagBuffer is 1234567! tagBuffer is 12345678!</pre> <p>tagBuffer is 123456789!</p>
[ { "answer_id": 270713, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 6, "selected": true, "text": "\\0" }, { "answer_id": 270719, "author": "Paige Ruten", "author_id": 813, "author_profile": "https...
2008/11/06
[ "https://Stackoverflow.com/questions/270708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
270,724
<p>I'm checking out the Delphi 2009 Trial, but run into problems with the generics stuff right away.</p> <p>The following code does not compile, and I haven't the slightest idea why it's giving me E2015 for the Equals() method:</p> <pre><code>type TPrimaryKey&lt;T&gt; = class(TObject) strict private fValue: T; public constructor Create(AValue: T); function Equals(Obj: TObject): boolean; override; function GetValue: T; end; constructor TPrimaryKey&lt;T&gt;.Create(AValue: T); begin inherited Create; fValue := AValue; end; function TPrimaryKey&lt;T&gt;.Equals(Obj: TObject): boolean; begin Result := (Obj &lt;&gt; nil) and (Obj is TPrimaryKey&lt;T&gt;) and (TPrimaryKey&lt;T&gt;(Obj).GetValue = fValue); end; function TPrimaryKey&lt;T&gt;.GetValue: T; begin Result := fValue; end; </code></pre> <p>Why does the compiler think that fValue and the result of GetValue() can not be compared?</p>
[ { "answer_id": 270789, "author": "Angus Glashier", "author_id": 35063, "author_profile": "https://Stackoverflow.com/users/35063", "pm_score": 2, "selected": false, "text": "TPrimaryKey<T: class> = class(TObject)\n" }, { "answer_id": 270814, "author": "Toon Krijthe", "auth...
2008/11/06
[ "https://Stackoverflow.com/questions/270724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30568/" ]
270,737
<p>In Joel's article for Inc. entitled <a href="http://www.inc.com/magazine/20081101/how-hard-could-it-be-the-unproven-path.html" rel="nofollow noreferrer">How Hard Could It Be?: The Unproven Path</a>, he wrote:</p> <blockquote> <p>...it turns out that Jeff and his programmers were so good that they built a site that could serve 80,000 visitors a day (roughly 755,000 page views)</p> </blockquote> <p>How would I go about figuring out the maximum load my server(s) can handle?</p>
[ { "answer_id": 270742, "author": "Jasper Bekkers", "author_id": 31486, "author_profile": "https://Stackoverflow.com/users/31486", "pm_score": 1, "selected": false, "text": "ab" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
270,745
<p>I have multiple Network Interface Cards on my computer, each with its own IP address.</p> <p>When I use <code>gethostbyname(gethostname())</code> from Python's (built-in) <code>socket</code> module, it will only return one of them. How do I get the others?</p>
[ { "answer_id": 274644, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 7, "selected": true, "text": "netifaces" }, { "answer_id": 1491617, "author": "DamonJW", "author_id": 180219, "author_profile":...
2008/11/06
[ "https://Stackoverflow.com/questions/270745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35305/" ]
270,771
<p>Can anyone suggest me on what data structure to use for a <a href="http://en.wikipedia.org/wiki/Soundex" rel="nofollow noreferrer">soundex algorithm</a> program? The language to be used is Java. If anybody has worked on this before in Java. The program should have these features: be able to read about 50,000 words should be able to read a word and return the related words having the same soundex</p> <p>I don't want the program implementation just few advices on what data structure to use.</p>
[ { "answer_id": 270783, "author": "Edward Kmett", "author_id": 34707, "author_profile": "https://Stackoverflow.com/users/34707", "pm_score": 2, "selected": false, "text": "#!/usr/bin/perl\nuse Text::Soundex;\nuse Data::Dumper;\nopen(DICT,\"</usr/share/dict/linux.words\");\nmy %dictionary ...
2008/11/06
[ "https://Stackoverflow.com/questions/270771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35307/" ]
270,772
<p>The Emacs cperl-mode seems to get confused less than perl-mode, but the Skittles effect makes the thing unusable for me. Does anyone have or know of an example of a .emacs block that causes cperl-mode to use the colorization from perl-mode, ideally in a form readable enough that I can go back and turn back on the default colors one element at a time until I reach something I'm comfortable with?</p> <p>In particular there is a hideously shade of light green used for some builtins that I find quite unreadable, and I prefer my variables to not have the leading <code>$</code> and <code>$$</code> and such tinted red along with the variable name. Most of the rest are merely distracting.</p>
[ { "answer_id": 5903300, "author": "Sam Kington", "author_id": 6832, "author_profile": "https://Stackoverflow.com/users/6832", "pm_score": 2, "selected": false, "text": "(custom-set-faces\n '(cperl-array-face ((t (:weight normal))))\n '(cperl-hash-face ((t (:weight normal))))\n)\n" }, ...
2008/11/06
[ "https://Stackoverflow.com/questions/270772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19202/" ]
270,788
<p>I have a system in which different server processes are handling requests passed as JMS messages from various clients via a JMS broker.</p> <p>I am trying to identify the source of the messages. Is there a way to get the IP or some identifying information about the origin ?</p> <p>Clarification: I already have the client deployed by unknown users, so I'm trying to avoid changing message classes... </p>
[ { "answer_id": 271197, "author": "John M", "author_id": 20734, "author_profile": "https://Stackoverflow.com/users/20734", "pm_score": 0, "selected": false, "text": "// client code\nString myIPString = ...;\nMessage m = session.createTextMessage();\nm.setStringProperty(\"IPOfSender\", myI...
2008/11/06
[ "https://Stackoverflow.com/questions/270788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
270,800
<p>I have several server processes that once in a while respond to messages from the clients and perform read-only transactions.</p> <p>After about a few days that the servers are running, they stop working correctly and when I check it turns out that there's a whole bunch of messages about the connection being closed.</p> <p>When I checked it out, it turned out that hibernate by default works in some sort of development mode where connections are dropped after a few hours, and I started using c3po for connection pooling. </p> <p>However, even with c3po, I get that problem about 24 hours or so after the servers are started.</p> <p>Has anyone encountered that problem and knows how to address it? I'm not familiar enough with the intricacies of configuring hibernate.</p>
[ { "answer_id": 270857, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "autoReconnect=true" }, { "answer_id": 847036, "author": "Community", "author_id": -1, "author_profi...
2008/11/06
[ "https://Stackoverflow.com/questions/270800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
270,811
<pre><code>cmd /C "myshortcut1.lnk" cmd /C "myshortcut2.lnk" </code></pre> <p>Works, but gives me a pop-up DOS window which, when closed, kills my two loaded programs. Same is true for this:</p> <pre><code>start /B cmd /C "1.lnk" start /B cmd /C "2.lnk" start /B cmd /C "3.lnk" start /B cmd /C "4.lnk" </code></pre>
[ { "answer_id": 270857, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "autoReconnect=true" }, { "answer_id": 847036, "author": "Community", "author_id": -1, "author_profi...
2008/11/06
[ "https://Stackoverflow.com/questions/270811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
270,822
<p>I control access to some of my static web resources with some PHP logic. Because directory-based authorization through the webserver is not suitable or easily possible.</p> <p>A combination of things determines whether access is granted or denied. And these rules change from time to time.</p> <p>In the beginning it was a simple regex path match, and a check of one session variable. It's more complicated now as there's a few more variables involved.</p> <p>I'm wondering how to go about refactoring this so it's quick and easy to change the rules. When it was a simple "if this AND this, then deliver, else 403." it was fine to do it in straight PHP. Now the conditions are more complex and there's a couple levels of nesting each with common but slightly different conditions within. This is all easy enough to refactor, but it's not the most intuitive and easy to update.</p> <p>I'm thinking of one of two things.</p> <ol> <li><p>Establish classes for each of the top level of conditions and use a Strategy Factory to pick the right one authorize. Derive them all from a base class containing the common bits and overload whatever's necessary. I think this could still be prone to some shuffling around when some conditions change.</p></li> <li><p>Make a simple engine that iterates a 2d array of ordered rules sort of like firewall rules. Something like: <code>&lt;allow|deny&gt;, &lt;auth_group&gt;, &lt;path_regex&gt;, &lt;other vars&gt;</code></p></li> </ol> <p>I haven't fully thought this one through but it seems like it would be easier to update and also to read as a human.</p> <p>What would you do? Is there an established pattern or library I can use for this?</p> <p>I faced this similar problem in another app some time ago. Where I wanted an easy to update way of chaining rules and outcomes together based on several levels of conditions. This isn't as complicated as that app, but I'd be interested to hear about patterns people use to solve this kind of problem.</p>
[ { "answer_id": 10503977, "author": "Saulo Vallory", "author_id": 219838, "author_profile": "https://Stackoverflow.com/users/219838", "pm_score": 0, "selected": false, "text": "IsSatisfiedBy()" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,825
<p>Has anyone else run into this problem before? I've got a method that calls a generic method with a delegate, inside of a generic class. I've marked the class as Serializable, and it serializes without complaint. But, when I try to deserialize an object of this class, it pegs the CPU and hangs the machine.</p> <p>Code example:</p> <pre><code>public delegate T CombinationFunctionDelegate&lt;T,U,V&gt;(U a, V b); [Serializable] public class SDictionary&lt;TKey, TValue&gt; : Dictionary&lt;TKey, TValue&gt; { public SDictionary() : base() { } protected SDictionary(SerializationInfo info, StreamingContext context) : base(info, context) {} [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); } public List&lt;ListItem&gt; ToListItems() { return Convert(delegate(TKey key, TValue value) { return new ListItem(key.ToString(), value.ToString()); }); } public List&lt;U&gt; Convert&lt;U&gt;(CombinationFunctionDelegate&lt;U, TKey, TValue&gt; converterFunction) { List&lt;U&gt; res = new List&lt;U&gt;(); foreach (TKey key in Keys) res.Add(converterFunction(key, this[key])); return res; } } </code></pre> <p>I can put an instance of this class into ViewState (for example) just fine, but when I try to extract the object from ViewState again, the CPU on the machine spikes and the deserialization call never returns (ie, infinite loop).</p> <p>When I remove the ToListItems() method, everything works wonderfully. Is this really weird, or do I just not understand serialization? =)</p>
[ { "answer_id": 270858, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 0, "selected": false, "text": "public override void GetObjectData(SerializationInfo info, StreamingContext context)\n{\n // deserialize the dictionary first\n ...
2008/11/06
[ "https://Stackoverflow.com/questions/270825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35308/" ]
270,829
<p>So we are sure that we will be taking our product internationally and will eventually need to internationalize it. How much internationalizing would you recommend we do as we go along?</p> <p>I guess in other words, is there any internationalization that is easy now but can be much worse if we let the code base mature and that won't slow us down very much if we choose to start doing it now?</p> <p>Tech used: C#, WPF, WinForms</p>
[ { "answer_id": 55414355, "author": "Robert Jørgensgaard Engdahl", "author_id": 2154774, "author_profile": "https://Stackoverflow.com/users/2154774", "pm_score": 1, "selected": false, "text": "NGettext.Wpf.CompositionRoot.Compose(\"ExampleDomainName\");\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/270829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
270,835
<p>I am trying to provide my own labelFunction for a CategoryAxis programatically but am completely stumped. The regular way is to do it in your MXML file, but I want to do it in my Actionscript file.</p> <p>The regular way of doing it is:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String { return "Some String"; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:CategoryAxis labelFunction="categoryAxis_labelFunc" /&gt; </code></pre> <p>But I want to achieve the same thing in my subclass of CategoryAxis, something like:</p> <pre><code>public class FauxDateAxis extends CategoryAxis { public function FauxDateAxis() { super(); labelFunction = categoryAxis_labelFunc // Doesn't work of course. } private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String { return "Another String"; } } </code></pre>
[ { "answer_id": 271352, "author": "Mitch Haile", "author_id": 28807, "author_profile": "https://Stackoverflow.com/users/28807", "pm_score": 1, "selected": false, "text": "function(item:Object, field:String, index:int, pct:Number)\n" }, { "answer_id": 278855, "author": "Randy S...
2008/11/06
[ "https://Stackoverflow.com/questions/270835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
270,845
<p>I've been trying to come up with a way to write generic repositories that work against various data stores:</p> <pre><code>public interface IRepository { IQueryable&lt;T&gt; GetAll&lt;T&gt;(); void Save&lt;T&gt;(T item); void Delete&lt;T&gt;(T item); } public class MemoryRepository : IRepository {...} public class SqlRepository : IRepository {...} </code></pre> <p>I'd like to work against the same POCO domain classes in each. I'm also considering a similar approach, where each domain class has it's own repository:</p> <pre><code>public interface IRepository&lt;T&gt; { IQueryable&lt;T&gt; GetAll(); void Save(T item); void Delete(T item); } public class MemoryCustomerRepository : IRepository {...} public class SqlCustomerRepository : IRepository {...} </code></pre> <p>My questions: 1)Is the first approach even feasible? 2)Is there any advantage to the second approach. </p>
[ { "answer_id": 271216, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": false, "text": "XmlWriter" }, { "answer_id": 522657, "author": "thinkbeforecoding", "author_id": 47001, "author_profile"...
2008/11/07
[ "https://Stackoverflow.com/questions/270845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,874
<p>I have a DataTrigger defined in my XAML which I want to use in several places. Is it possible to define it as a resource and then share it?</p> <p>Here's my trigger:</p> <pre><code>&lt;TextBlock.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding HasCurrentTest}" Value="True"&gt; &lt;Setter Property="TextBlock.Visibility" Value="Hidden" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/TextBlock.Style&gt; </code></pre> <p>While I can define this in my Window.Resources and give it a key, how do I refer to it in the rest of my XAML?</p>
[ { "answer_id": 270904, "author": "MrSlippers", "author_id": 35290, "author_profile": "https://Stackoverflow.com/users/35290", "pm_score": 1, "selected": false, "text": "<Window.Resources>\n <Style x:Key=\"YourStyleKey\">\n <!-- Your Style -->\n </Style>\n</Window.Resources>\...
2008/11/07
[ "https://Stackoverflow.com/questions/270874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
270,879
<p>I'm starting a new application and looking at using an ORM -- in particular, SQLAlchemy.</p> <p>Say I've got a column 'foo' in my database and I want to increment it. In straight sqlite, this is easy:</p> <pre><code>db = sqlite3.connect('mydata.sqlitedb') cur = db.cursor() cur.execute('update table stuff set foo = foo + 1') </code></pre> <p>I figured out the SQLAlchemy SQL-builder equivalent:</p> <pre><code>engine = sqlalchemy.create_engine('sqlite:///mydata.sqlitedb') md = sqlalchemy.MetaData(engine) table = sqlalchemy.Table('stuff', md, autoload=True) upd = table.update(values={table.c.foo:table.c.foo+1}) engine.execute(upd) </code></pre> <p>This is slightly slower, but there's not much in it.</p> <p>Here's my best guess for a SQLAlchemy ORM approach:</p> <pre><code># snip definition of Stuff class made using declarative_base # snip creation of session object for c in session.query(Stuff): c.foo = c.foo + 1 session.flush() session.commit() </code></pre> <p>This does the right thing, but it takes just under fifty times as long as the other two approaches. I presume that's because it has to bring all the data into memory before it can work with it.</p> <p>Is there any way to generate the efficient SQL using SQLAlchemy's ORM? Or using any other python ORM? Or should I just go back to writing the SQL by hand?</p>
[ { "answer_id": 270891, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 1, "selected": false, "text": "for c in session.query(Stuff).all():\n c.foo = c.foo+1\nsession.commit()\n" }, { "answer_id": 278606, ...
2008/11/07
[ "https://Stackoverflow.com/questions/270879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15154/" ]
270,884
<p>I've been doing some socket programming to transmit information across the wire. I've run into a problem with DataOutputStream.writeUTF(). It seems to allow strings of up to 64k but I have a few situations where I can run over this. Are there any good alternatives that support larger strings or do I need to roll my own?</p>
[ { "answer_id": 270915, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 1, "selected": false, "text": "Writer osw = new OutputStreamWriter(out, \"UTF-8\");\n" }, { "answer_id": 270922, "author": "kasperjj", ...
2008/11/07
[ "https://Stackoverflow.com/questions/270884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269171/" ]
270,895
<p>This fails:</p> <pre><code>my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-$_" =&gt; 1 } @a; </code></pre> <p>with this error:</p> <pre><code>Not enough arguments for map at foo.pl line 4, near "} @a" </code></pre> <p>but this works:</p> <pre><code>my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-" . $_ =&gt; 1 } @a; </code></pre> <p>why?</p>
[ { "answer_id": 270905, "author": "Leonardo Herrera", "author_id": 7841, "author_profile": "https://Stackoverflow.com/users/7841", "pm_score": 5, "selected": true, "text": "my @a = (\"a\", \"b\", \"c\", \"d\", \"e\");\nmy %h = map { +\"prefix-$_\" => 1 } @a;\n" }, { "answer_id": 2...
2008/11/07
[ "https://Stackoverflow.com/questions/270895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14032/" ]
270,917
<p>I know it is a good practice to declare virtual destructors for base classes in C++, but is it always important to declare <code>virtual</code> destructors even for abstract classes that function as interfaces? Please provide some reasons and examples why.</p>
[ { "answer_id": 270925, "author": "Airsource Ltd", "author_id": 18017, "author_profile": "https://Stackoverflow.com/users/18017", "pm_score": 9, "selected": true, "text": "class Interface\n{\n virtual void doSomething() = 0;\n};\n\nclass Derived : public Interface\n{\n Derived();\n ...
2008/11/07
[ "https://Stackoverflow.com/questions/270917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599/" ]
270,918
<p>I would like to create a batch script, to go through 20,000 links in a DB, and weed out all the 404s and such. How would I get the HTTP status code for a remote url?</p> <p>Preferably not using curl, since I dont have it installed. </p>
[ { "answer_id": 270966, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 5, "selected": true, "text": "<?php\n\n$url = parse_url('http://www.example.com/index.html');\n\n$host = $url['host'];\n$port = $url['port'];\n$path = ...
2008/11/07
[ "https://Stackoverflow.com/questions/270918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,919
<p>I am looking for an example of how to do the following in VB.net with Parallel Extensions.</p> <pre><code>Dim T As Thread = New Thread(AddressOf functiontodowork) T1.Start(InputValueforWork) </code></pre> <p>Where I'm getting stuck is on how to pass into the task my parameter InputValueforWork</p> <pre><code>Dim T As Tasks.Task = Tasks.Task.Create(AddressOf functiontodowork) </code></pre> <p>Any suggests and possibly a coding example would be welcome.</p> <p>Andrew</p>
[ { "answer_id": 271266, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 0, "selected": false, "text": "var T = Tasks.Task.Create( () => functionToDoWork(SomeParameter) )\n" }, { "answer_id": 349731, "author": "Mau...
2008/11/07
[ "https://Stackoverflow.com/questions/270919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35331/" ]
270,924
<p>I've been reading a text about an extension to C# and at one point it says that "An attribute decoration X may only be applied to fields of type Y."</p> <p>I haven't been able to find a definition for attribute decoration, and I'm not making much sense out of this by exchanging the two.</p>
[ { "answer_id": 271266, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 0, "selected": false, "text": "var T = Tasks.Task.Create( () => functionToDoWork(SomeParameter) )\n" }, { "answer_id": 349731, "author": "Mau...
2008/11/07
[ "https://Stackoverflow.com/questions/270924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
270,930
<p>As a follow-up to <a href="https://stackoverflow.com/questions/269812/how-to-quickly-get-started-at-using-and-learning-emacs">this question</a>, it's trying to find out how to do something like this which should be easy, that especially stops me from getting more used to using Emacs and instead starting up the editor I'm already familiar with. I use the example here fairly often in editing multiple files.</p> <p>In Ultraedit I'd do Alt+s then p to display a dialog box with the options: Find (includes using regular expressions across multiple lines), Replace with, In Files/Types, Directory, Match Case, Match Whole Word Only, List Changed Files and Search Sub Directories. Usually I'll first use the mouse to click-drag select the text that I want to replace.</p> <p>Using only Emacs itself (on Windows XP), without calling any external utility, how to replace all foo\nbar with bar\nbaz in <code>*.c</code> and <code>*.h</code> files in some folder and all folders beneath it. Maybe Emacs is not the best tool to do this with, but how can it be done easily with a minimal command?</p>
[ { "answer_id": 271013, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 4, "selected": false, "text": "(defun findr-query-replace (from to name dir)\n \"Do `query-replace-regexp' of FROM with TO, on each file found by fin...
2008/11/07
[ "https://Stackoverflow.com/questions/270930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25093/" ]
270,933
<p>I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout.</p> <p>On the client side I use plink to execute the script and stream stdin to a file.</p> <p>This almost works.</p> <p>It seems that the cp command outputs the file name being copied when its executed from inside the script. If I execute '<strong>cp /path/to/file1 .</strong>' in the shell it does it quietly; if I execute it in a script it outputs "file1".</p> <p>How do I prevent this? I've tried piping the output of the cp command to /dev/null and to a dummy text file but with no luck.</p> <p>thanks for any help.</p> <h3>the script</h3> <pre><code>#!/bin/bash cp /path/to/file1 . cp /path/to/file2 . cp /path/to/file3 . tar -cvzf package.tgz file1 file2 file3 cat package.tgz </code></pre> <h3>the output</h3> <pre><code>file1 file2 file3 &lt;&lt;binary data&gt;&gt; </code></pre>
[ { "answer_id": 271345, "author": "bendin", "author_id": 33412, "author_profile": "https://Stackoverflow.com/users/33412", "pm_score": 2, "selected": false, "text": "stderr" }, { "answer_id": 8102364, "author": "bigendian", "author_id": 1013642, "author_profile": "http...
2008/11/07
[ "https://Stackoverflow.com/questions/270933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1851/" ]
270,941
<p>I'm using a large open-source control and I can't seem to find the code that handles a double-click event. Could I perhaps have the debugger break when a double-click occurs or otherwise learn what code is associated with that event?</p>
[ { "answer_id": 271345, "author": "bendin", "author_id": 33412, "author_profile": "https://Stackoverflow.com/users/33412", "pm_score": 2, "selected": false, "text": "stderr" }, { "answer_id": 8102364, "author": "bigendian", "author_id": 1013642, "author_profile": "http...
2008/11/07
[ "https://Stackoverflow.com/questions/270941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22820/" ]
270,947
<p>I write a singleton c++ in the follow way:</p> <pre><code>class A { private: static A* m_pA; A(); virtual ~A(); public: static A* GetInstance(); static void FreeInstance(); void WORK1(); void WORK2(); void WORK3(); } } A* A::GetInstance() { if (m_pA == NULL) m_pA = new A(); return m_pA; } A::~A() { FreeInstance() // Can I write this? are there any potential error? } void A::FreeInstance() { delete m_pA; m_pA = NULL; } </code></pre> <p>Thanks! Evan Teran and sep61.myopenid.com 's answer is right, and really good! My way is wrong, I wish any one writting such code can avoid my silly mistake.</p> <p>My singleton A in my project has a vector of smart pointer, and another thread can also edit this vector, so when the application is closing, it always become unstable even I add lots of CMutex. Multithread error + singleton error wasted me 1 day.<p> //----------------------------------------------------------- A new singleton, you are welcome to edit if you think there is any problem in the following sample:</p> <pre><code>class A { private: static A* m_pA; explicit A(); void A(const A&amp; a); void A(A &amp;a); const A&amp; operator=(const A&amp; a); virtual ~A(); public: static A* GetInstance(); static void FreeInstance(); void WORK1(); void WORK2(); void WORK3(); } } A* A::GetInstance() { if (m_pA == NULL){ static A self; m_pA = &amp;self; } return m_pA; } A::~A() { } </code></pre>
[ { "answer_id": 270957, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 5, "selected": true, "text": "if(m_pA == 0) {\n static A static_instance;\n m_pA = &static_instance;\n}\n" }, { "answer_id": 270973, ...
2008/11/07
[ "https://Stackoverflow.com/questions/270947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
270,948
<p>Are there any tricks for preventing SQL Server from entitizing chars like &amp;, &lt;, and >? I'm trying to output a URL in my XML file but SQL wants to replace any '&amp;' with '<code>&amp;amp;</code>'</p> <p>Take the following query:</p> <pre><code>SELECT 'http://foosite.com/' + RTRIM(li.imageStore) + '/ImageStore.dll?id=' + RTRIM(li.imageID) + '&amp;raw=1&amp;rev=' + RTRIM(li.imageVersion) AS imageUrl FROM ListingImages li FOR XML PATH ('image'), ROOT ('images'), TYPE </code></pre> <p>The output I get is like this (&amp;s are entitized):</p> <pre><code>&lt;images&gt; &lt;image&gt; &lt;imageUrl&gt;http://foosite.com/pics4/ImageStore.dll?id=7E92BA08829F6847&amp;amp;raw=1&amp;amp;rev=0&lt;/imageUrl&gt; &lt;/image&gt; &lt;/images&gt; </code></pre> <p>What I'd like is this (&amp;s are not entitized):</p> <pre><code>&lt;images&gt; &lt;image&gt; &lt;imageUrl&gt;http://foosite.com/pics4/ImageStore.dll?id=7E92BA08829F6847&amp;raw=1&amp;rev=0&lt;/imageUrl&gt; &lt;/image&gt; &lt;/images&gt; </code></pre> <p>How does one prevent SQL server from entitizing the '&amp;'s into '<code>&amp;amp;</code>'?</p>
[ { "answer_id": 271000, "author": "ykaganovich", "author_id": 10026, "author_profile": "https://Stackoverflow.com/users/10026", "pm_score": 5, "selected": true, "text": "&" }, { "answer_id": 8686690, "author": "Janmonn", "author_id": 1124038, "author_profile": "https:/...
2008/11/07
[ "https://Stackoverflow.com/questions/270948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19389/" ]
270,950
<p>What is a doubly linked list's remove method?</p>
[ { "answer_id": 271011, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 2, "selected": false, "text": "public void remove ()\n{\n if (getPreviousNode () != null)\n getPreviousNode ().setNextNode (getNextNode ());\...
2008/11/07
[ "https://Stackoverflow.com/questions/270950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27570/" ]
270,969
<p>I have a migration in Rails that inserts a record into the database. The Category model depends on this record. Since RSpec clears the database before each example, this record is lost and furthermore never seems to be created since RSpec does not seem to generate the database from migrations. What is the best way to create/recreate this record in the database? Would it be using before(:all)?</p>
[ { "answer_id": 271297, "author": "James Baker", "author_id": 9365, "author_profile": "https://Stackoverflow.com/users/9365", "pm_score": 4, "selected": true, "text": "before(:all)" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/270969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34991/" ]
270,984
<p>I'm pretty new to the C++ build flow, and I'm thinking of switching to use partial linking for my libraries instead of creating <code>ar</code> archives. I'm hoping to reduce link time in an inevitable final compilation step that I have, and I figure partial linking some libraries once could save me time over linking everything in that final step.</p> <p>Is what I'm describing possible? I figure it should be something along the lines <code>ld -Ur -o mylib.o [components]</code>. Are there important build considerations that I'm not taking into account?</p>
[ { "answer_id": 270995, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 4, "selected": true, "text": "ar" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/270984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
270,997
<p>I'm looking for an open-source web search library that does not use a search index file. Do you know any?</p> <p>Thanks, Kenneth</p>
[ { "answer_id": 271037, "author": "Will Hartung", "author_id": 13663, "author_profile": "https://Stackoverflow.com/users/13663", "pm_score": 1, "selected": false, "text": "#/bin/sh\narg=`echo $QUERY | sed -e 's/^s=//' -e 's/&.*$//'`\ncd /var/www/httpd\nfind . -type f | xargs egrep -l \"$a...
2008/11/07
[ "https://Stackoverflow.com/questions/270997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16139/" ]
271,007
<p>Lots of people have things that their systems do for them or for their teams. Source control post-commit hooks are a standard example: have an automated build system that checks out the latest source, compiles, tests, and packages it is a back-office hack that most of us probably use.</p> <p>What other cool things have you done?</p>
[ { "answer_id": 543664, "author": "gradbot", "author_id": 17919, "author_profile": "https://Stackoverflow.com/users/17919", "pm_score": 2, "selected": false, "text": "joe.jetfuel.test-example.com" }, { "answer_id": 544809, "author": "James Matta", "author_id": 60483, "...
2008/11/07
[ "https://Stackoverflow.com/questions/271007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6010/" ]
271,015
<p>I need to write a Stored procedure in SQL server whose data returned will be used to generate a XML file.</p> <p>My XML file to be in structure of </p> <pre><code>&lt;root&gt; &lt;ANode&gt;&lt;/ANode&gt; &lt;BNode&gt;&lt;/BNode&gt; &lt;CNode&gt; &lt;C1Node&gt; &lt;C11Node&gt;&lt;/C11Node&gt; &lt;C12Node&gt;&lt;/C12Node&gt; &lt;/C1Node&gt; &lt;C2Node&gt; &lt;C21Node&gt;&lt;/C21Node&gt; &lt;C22Node&gt;&lt;/C22Node&gt; &lt;/C2Node&gt; &lt;C3Node&gt; &lt;C31Node&gt;&lt;/C31Node&gt; &lt;C32Node&gt;&lt;/C32Node&gt; &lt;/C3Node&gt; &lt;/CNode&gt; &lt;/root&gt; </code></pre> <p>My question is, in the stored procedure we can select values for ANode and BNode as a simple SELECT statement like</p> <pre><code>Select ANodeVal,BNodeVal from Table </code></pre> <p>But how to design the stored procedure to get records for the CNode which is a subtree which has 3 or more(dynamic) separate nodes in it for each record in addition to the normal ANode and BNode.</p>
[ { "answer_id": 271202, "author": "Doug L.", "author_id": 19179, "author_profile": "https://Stackoverflow.com/users/19179", "pm_score": 0, "selected": false, "text": "SELECT" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3113/" ]
271,021
<p>I've recently seen occasional problems with stored procedures on a legacy system which displays error messages like this:</p> <blockquote> <p>Server Message: Number 10901, Severity 17: This query requires <em>X</em> auxiliary scan descriptors but currently there are only <em>Y</em> auxiliary scan descriptors available. Either raise the value of the 'number of aux scan descriptors' configuration parameter or try your query later.</p> </blockquote> <p>where <em>X</em> is slightly lower than <em>Y</em>. The Sybase manual usefully tells me that I should redesign my table to use less auxiliary scan descriptors (how?!), or increase the number available on the system. The weird thing is, it's been working fine for years and the only thing that's changed is that we amended the data types of a couple of columns and added an index. Can anyone shed any light on this?</p>
[ { "answer_id": 271660, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "update statistics *table_name*\n" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
271,031
<p>My application needs to store the users email address in a cookie so that I can pre-populate a login form <code>(username == email address)</code>. I set the cookie value in JavaScript. If I read it from JavaScript, I get <code>foo@bar.com</code>. If I look at it in the cookie viewer in Firefox I get <code>foo@bar.com</code>.</p> <p>When I try to read it on the server-side in Java however, I only get <code>foo</code>. </p> <p>Do I need to do some sort of encoding/decoding here? If so, how do I do it in a way that can be decoded by both JavaScript and Java? </p> <p>Thanks in advance! -Michael</p>
[ { "answer_id": 271038, "author": "Glen", "author_id": 269171, "author_profile": "https://Stackoverflow.com/users/269171", "pm_score": 0, "selected": false, "text": "document.cookie = name + \"=\" +escape( value ) \n + ( ( expires ) ? \";expires=\" + expires_date.toGMTString() : \"\" )...
2008/11/07
[ "https://Stackoverflow.com/questions/271031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3700/" ]
271,042
<p>Here's something I know is probably possible but I've never managed to do<br> In VS2005(C++), While debugging, to be able to invoke a function from the code which I'm debugging.<br> This feature is sometimes essential when debugging complex data structures which can't be explored easily using just the normal capabilities of the watch window.<br> The watch window seem to allow writing function calls but every time I try it it gives me one error or another. </p> <p><code>Error: symbol "func" not found</code><br> <code>Error: argument list does not match function</code><br> <code>Error: member function not present</code></p> <p>Did anyone ever succeed in making this work properly? What am I missing here?</p> <p><strong>Edit:</strong> clearly, the function called should be a symbol that exists in the current scope the debugger is in.</p>
[ { "answer_id": 271091, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 5, "selected": true, "text": "The C expression evaluator does not support implicit conversions involving constructor calls." } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
271,043
<p>I'm using jQuery to post a form to a php file, simple script to verify user details.</p> <pre><code>var emailval = $("#email").val(); var invoiceIdval = $("#invoiceId").val(); $.post("includes/verify.php", {invoiceId:invoiceIdval , email:emailval }, function(data) { //stuff here. }); </code></pre> <p>PHP Code:</p> <pre><code>&lt;?php print_r($_POST); ?&gt; </code></pre> <p>I look at the response in firebug, it is an empty array. The array should have at least some value.</p> <p>I can not work out why the <code>$_POST</code> isn't working in the php file. Firebug shows the post to contain the contents posted, email and invoice id, just nothing is actually received in the php file.</p> <p>The form:</p> <pre><code>&lt;form method="post" action="&lt;?=$_SERVER['PHP_SELF']; ?&gt;" enctype="application/x-www-form-urlencoded"&gt; </code></pre> <p>Anyone know what its doing?</p> <p>thanks</p> <hr> <p>found this - <a href="http://www.bradino.com/php/empty-post-array/" rel="nofollow noreferrer">http://www.bradino.com/php/empty-post-array/</a></p> <p>that a sensible route to go?</p>
[ { "answer_id": 271064, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 1, "selected": false, "text": "application/x-www-form-urlencoded\n" }, { "answer_id": 271094, "author": "Owen", "author_id": 4853, ...
2008/11/07
[ "https://Stackoverflow.com/questions/271043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34975/" ]
271,045
<p>I'm new to the MVC framework and wondering how to pass the RSS data from the controller to a view. I know there is a need to convert to an IEnumerable list of some sort. I have seen some examples of creating an anonymous type but can not figure out how to convert an RSS feed to a generic list and pass it to the view. </p> <p>I don't want it to be strongly typed either as there will be multiple calls to various RSS feeds. </p> <p>Any suggestions. </p>
[ { "answer_id": 272576, "author": "Matthew", "author_id": 20162, "author_profile": "https://Stackoverflow.com/users/20162", "pm_score": 4, "selected": true, "text": "using (XmlReader reader = XmlReader.Create(feed))\n{\n SyndicationFeed rssData = SyndicationFeed.Load(reader);\n\n re...
2008/11/07
[ "https://Stackoverflow.com/questions/271045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31148/" ]
271,062
<p>I'm using Emgu.CV which is a C# wrapper for the OpenCV libraries. </p> <p>I changed the Emgu.CV source to invoke from the latest OpenCV library cv110.dll instead of cv100.dll and now I get this error (where ????? is cv110.dll). I have placed the cv110.dll file in all the same locations as the cv100.dll file however this does not help.</p> <p>On a broader scale, what is the folder search order when looking for dlls, and are there anyone other reasons for this error.</p>
[ { "answer_id": 272576, "author": "Matthew", "author_id": 20162, "author_profile": "https://Stackoverflow.com/users/20162", "pm_score": 4, "selected": true, "text": "using (XmlReader reader = XmlReader.Create(feed))\n{\n SyndicationFeed rssData = SyndicationFeed.Load(reader);\n\n re...
2008/11/07
[ "https://Stackoverflow.com/questions/271062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31045/" ]
271,063
<p>I would like to to try Emacs, and want to give it the best chance possible.</p> <p>To do this, it seems like having a good <code>.emacs</code> file is important.</p> <p>I primarily use Mac OS X (so I have looked at Aquamacs), and I mainly do Python programming, so anything specifically for that would be great.</p>
[ { "answer_id": 281944, "author": "Tim Visher", "author_id": 16562, "author_profile": "https://Stackoverflow.com/users/16562", "pm_score": 2, "selected": false, "text": "Caps-lock = Control\nControl = Option\nOption = Inactive\nCommand = Command\n" }, { "answer_id": 12220507, ...
2008/11/07
[ "https://Stackoverflow.com/questions/271063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
271,067
<p>I have the following CSS and HTML snippet being rendered.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>textarea { border:1px solid #999999; width:100%; margin:5px 0; padding:3px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="display: block;" id="rulesformitem" class="formitem"&gt; &lt;label for="rules" id="ruleslabel"&gt;Rules:&lt;/label&gt; &lt;textarea cols="2" rows="10" id="rules"&gt;&lt;/textarea&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Is the problem is that the text area ends up being 8px wider (2px for border + 6px for padding) than the parent. Is there a way to continue to use border and padding but constrain the total size of the <code>textarea</code> to the width of the parent?</p>
[ { "answer_id": 272632, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "https://Stackoverflow.com/users/18914", "pm_score": 7, "selected": false, "text": "textarea\n{\n width:100%;\n}\n.textwrapper\n{\n border:1px solid #999999;\n margin:5px 0;\n padding:3px;\n}" ...
2008/11/07
[ "https://Stackoverflow.com/questions/271067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
271,076
<p>Correct me if I am wrong,</p> <p>int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)<br> long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)</p> <p>What is the difference in C++? Can they be used interchangeably?</p>
[ { "answer_id": 271087, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 8, "selected": true, "text": " OS arch size\nWindows IA-32 4 bytes\nWindows Intel 64 4 bytes\nWindows ...
2008/11/07
[ "https://Stackoverflow.com/questions/271076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25632/" ]
271,077
<p>In my views.py, I'm building a list of two-tuples, where the second item in the tuple is another list, like this:</p> <pre><code>[ Product_Type_1, [ product_1, product_2 ], Product_Type_2, [ product_3, product_4 ]] </code></pre> <p>In plain old Python, I could iteration the list like this:</p> <pre><code>for product_type, products in list: print product_type for product in products: print product </code></pre> <p>I can't seem to do the same thing in my Django template:</p> <pre><code>{% for product_type, products in product_list %} print product_type {% for product in products %} print product {% endfor %} {% endfor %} </code></pre> <p>I get this error from Django:</p> <p><strong>Caught an exception while rendering: zip argument #2 must support iteration</strong></p> <p>Of course, there is some HTML markup in the template, not print statements. Is tuple unpacking not supported in the Django template language? Or am I going about this the wrong way? All I am trying to do is display a simple hierarchy of objects - there are several product types, each with several products (in models.py, Product has a foreign key to Product_type, a simple one-to-many relationship).</p> <p>Obviously, I am quite new to Django, so any input would be appreciated.</p>
[ { "answer_id": 271098, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 2, "selected": false, "text": "{% for product_type in product_type_list %}\n {{ product_type }}\n {% for product in product_type.products.all...
2008/11/07
[ "https://Stackoverflow.com/questions/271077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21245/" ]
271,090
<p>Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server <b>without</b> using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file.</p> <p>The reason it has to be that way is that I would like to backup my files to a server using rsync/ssh running as a cron job. This server mounts my home directory <i>after</i> it authenticates me, so using public key authentication does not work since ~/.ssh isn't available until after the login is successful. expect(1) is out of the question because I would like to run it as a cron job, and since cron jobs don't run under a terminal the combination of expect/ssh just doesn't work. I do not have root access to that server, and it would be difficult to get the admins to make any changes to the way things work there.</p>
[ { "answer_id": 271112, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": -1, "selected": false, "text": "authorized_keys" }, { "answer_id": 363519, "author": "Jay", "author_id": 20840, "author_profile...
2008/11/07
[ "https://Stackoverflow.com/questions/271090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11688/" ]
271,106
<p>I am trying to get this program to give me an out put that when I do an addition, subtraction, multiplication, or division problem it will give me the answer. However, it is not working can anyone help.</p> <pre><code>int main () { int choice; float a, b; float sum; float difference; float product; float quotiont; printf("This program adds, subtracts, multiplies, and divides.\n"); printf("**************\n"); printf("* Calculator *\n"); printf("**************\n"); printf("Enter an expression: "); scanf("%f %f", &amp;a, &amp;b); scanf("%f %f %f %f", &amp;sum, &amp;difference, &amp;product, &amp;quotiont); sum = a + b; difference = a - b; product = a * b; quotiont = a / b; if(a + b) printf("Answer = %f\n", &amp;sum); else if(a - b) printf("Answer = %f\n", &amp;difference); else if(a * b) printf("Answer = %f\n", &amp;product); else if(a / b) printf("Answer = %f\n", &amp;quotiont); else printf("Error"); } </code></pre>
[ { "answer_id": 271146, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": false, "text": "scanf(\"%f %f %f %f\", &sum, &difference, &product, &quotiont); \n" }, { "answer_id": 17675089, "author": "zu...
2008/11/07
[ "https://Stackoverflow.com/questions/271106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
271,109
<p>I have a simple question. Is there a way ( using reflections I suppose ) to iterate all the static values of a class?</p> <p>For instance </p> <pre><code>class Any { static int one = 1; static int two = 2; static int three = 3; public static void main( String [] args ) { for( int i : magicMethod( Any.class ) ){ System.out.println( i ); } } } </code></pre> <p>Output</p> <pre><code> 1 2 3 </code></pre> <p>Thanks.</p>
[ { "answer_id": 271127, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": false, "text": " Field [] constants = Main.class.getFields();\n Object some = new Main();\n for( Field field : constants )...
2008/11/07
[ "https://Stackoverflow.com/questions/271109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
271,115
<p>I'm working on kernel design, and I've got some questions concerning paging.</p> <p>The basic idea that I have so far is this: Each program gets its own (or so it thinks) 4G of memory, minus a section somewhere that I reserve for kernel functions that the program can call. So, the OS needs to figure out some way to load the pages in memory that the program needs to use during its operation.</p> <p>Now, assuming that we had infinite amounts of memory and processor time, I could load/allocate any page the program wrote to or read from as it happened using page faults for pages that didn't exist (or were swapped out) so the OS could quickly allocate them or swap them in. In the real world though, I need to optimize this process, so that we don't have a program constantly consuming all memory that it ever touched.</p> <p>So I guess my question is, how does an OS generally go about this? My initial thought is to create a function that the program calls to set/free pages, which it can then memory manage on its own, but does a program generally do this, or does the compiler assume it has free reign? Also, how does the compiler handle situations where it needs to allocate a fairly large segment of memory? Do I need to provide a function that tries to give it X pages in order?</p> <p>This is obviously not a language specific question, but I'm partial to standard C and good with C++, so I'd like any code examples to be in either that or assembly. (Assembly shouldn't be necessary, I fully intend to make it work with as much C code as possible, and optimize as a last step.)</p> <p>Another thing that should be easier to answer as well: How does one generally handle kernel functions that a program needs to call? Is it OK just to have a set area of memory (I was thinking toward the end of virtual space) that contains most basic functions/process specific memory that the program can call? My thought from there would be to have the kernel functions do something very fancy and swap the pages out (so that programs couldn't see sensitive kernel functions in their own space) when programs needed to do anything major, but I'm not really focusing on security at this point.</p> <p>So I guess I'm more worried about the general design ideas than the specifics. I'd like to make the kernel completely compatible with GCC (somehow) and I need to make sure that it provides everything that a normal program would need.</p> <p>Thanks for any advice.</p>
[ { "answer_id": 271154, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 3, "selected": false, "text": "int" }, { "answer_id": 271229, "author": "CesarB", "author_id": 28258, "author_profile": "https:...
2008/11/07
[ "https://Stackoverflow.com/questions/271115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19521/" ]
271,145
<p>Given a UTC time string like this:</p> <pre><code>2005-11-01T00:00:00-04:00 </code></pre> <p>What is the best way to convert it to a DateTime using a Crystal Reports formula?</p> <p>My best solution is posted below.</p> <p>I hope someone out there can blow me away with a one-liner...</p>
[ { "answer_id": 271147, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 1, "selected": false, "text": "//assume a date stored as a string in this format:\n//2005-11-01T00:00:00-04:00\n//return a DateTime value\nStringVar fie...
2008/11/07
[ "https://Stackoverflow.com/questions/271145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
271,149
<p>how do i check if an item is selected or not in my listbox? so i have a button remove, but i only want that button to execute if an item is selected in the list box. im using asp.net code behind C#. I'd prefer if this validation occurred on the server side.</p> <p>cheers..</p>
[ { "answer_id": 271164, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "protected void removeButton_Click( object sender, EventArgs e )\n{\n if (listBox.SelectedIndex >= 0)\n {\n ...
2008/11/07
[ "https://Stackoverflow.com/questions/271149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
271,150
<p>In adobe Flex datagrid height is equally to fix height . I want to make datagrid height is depend data . </p>
[ { "answer_id": 404639, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 3, "selected": false, "text": "dataGrid.rowCount = yourCollection.length;\n" }, { "answer_id": 891021, "author": "Community", "autho...
2008/11/07
[ "https://Stackoverflow.com/questions/271150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33016/" ]
271,168
<p>Is there a built-in way to know if a given session variable is a serialized object? Say I retrieve a value like $_SESSION['foo'], but I don't know if it was originally a string or if it is a serialized object. Is there some way to check, or once serialized does PHP just see a string as a string as a string? </p>
[ { "answer_id": 271174, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "unserialize()" }, { "answer_id": 271601, "author": "troelskn", "author_id": 18180, "author_profile": "http...
2008/11/07
[ "https://Stackoverflow.com/questions/271168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
271,171
<p>This is a little confusing to explain, so bear with me here...</p> <p>I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the body of the email with predefined variables, to save the user having to type it themselves. They can then edit the message as desired, should it not exactly suit their purposes.</p> <p>There's a number of reasons I want it to go via the user's local mail client, so getting the server to send the email is not an option: it has to be 100% client-side.</p> <p>I already have a mostly-working solution running, and I'll post the details of that as an answer, I'm wondering if there's any better way?</p>
[ { "answer_id": 271172, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 8, "selected": true, "text": "<textarea id=\"myText\">\n Lorem ipsum...\n</textarea>\n<button onclick=\"sendMail(); return false\">Send</button>\n" }, ...
2008/11/07
[ "https://Stackoverflow.com/questions/271171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
271,198
<p>One of the frequent causes of memory leaks in .Net are event handlers which are never removed from their source objects. </p> <p>Will this WCF code cause a memory leak, or will the lambda go out of scope too, allowing both the proxy class and the handler to be GCed?</p> <pre><code>void AMethod() { WCFClient proxy; proxy = new WCFClient(); proxy.RemoteOperationCompleted += (sender, e) =&gt; proxy.Close(); proxy.Open(); proxy.RemoteOperationAsync(); } </code></pre>
[ { "answer_id": 271282, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": true, "text": "proxy" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25201/" ]
271,204
<p>This loop is slower than I would expect, and I'm not sure where yet. See anything?</p> <p>I'm reading an Accces DB, using client-side cursors. When I have 127,000 rows with 20 columns, this loop takes about 10 seconds. The 20 columns are string, int, and date types. All the types get converted to ANSI strings before they are put into the ostringstream buffer.</p> <pre><code>void LoadRecordsetIntoStream(_RecordsetPtr&amp; pRs, ostringstream&amp; ostrm) { ADODB::FieldsPtr pFields = pRs-&gt;Fields; char buf[80]; ::SYSTEMTIME sysTime; _variant_t var; while(!pRs-&gt;EndOfFile) // loop through rows { for (long i = 0L; i &lt; nColumns; i++) // loop through columns { var = pFields-&gt;GetItem(i)-&gt;GetValue(); if (V_VT(&amp;var) == VT_BSTR) { ostrm &lt;&lt; (const char*) (_bstr_t) var; } else if (V_VT(&amp;var) == VT_I4 || V_VT(&amp;var) == VT_UI1 || V_VT(&amp;var) == VT_I2 || V_VT(&amp;var) == VT_BOOL) { ostrm &lt;&lt; itoa(((int)var),buf,10); } else if (V_VT(&amp;var) == VT_DATE) { ::VariantTimeToSystemTime(var,&amp;sysTime); _stprintf(buf, _T("%4d-%02d-%02d %02d:%02d:%02d"), sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond); ostrm &lt;&lt; buf; } } pRs-&gt;MoveNext(); } } </code></pre> <p>EDIT: After more experimentation...</p> <p>I know now that about half the time is used by this line:<br> var = pFields->GetItem(i)->GetValue();</p> <p>If I bypass the Microsoft generated COM wrappers, will my code be faster? My guess is no.</p> <p>The othe half of the time is spent in the statements which convert data and stream it into the ostringstream.</p> <p>I don't know right now as I write this whether it's the conversions or the streaming that is taking more time.</p> <p>Would it be faster if I didn't use ostringstream and instead managed my own buffer, with my own logic to grow the buffer (re-alloc, copy, delete)? Would it be faster if my logic made a pessimistic guesstimate and reserved a lot of space for the ostringstream buffer up front? These might be experiments worth trying.</p> <p>Finally, the conversions themselves. None of the three stand out in my timings as being bad. One answer says that my itoa might be slower than an alternative. Worth checking out.</p>
[ { "answer_id": 271430, "author": "Andreas Magnusson", "author_id": 5811, "author_profile": "https://Stackoverflow.com/users/5811", "pm_score": 0, "selected": false, "text": "#define TIME_CALL(x) \\\ndo { \\\n const DWORD t1 = timeGetTime();\\\n x;\\\n const DWORD t2 = timeGetTime();\\...
2008/11/07
[ "https://Stackoverflow.com/questions/271204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
271,210
<p>I have a build server running CruiseControl.NET. It works well for the 7 projects that are configured to run on that server (let's call it server A).</p> <p>Now I have a new project that I wish to build on a different server (server B), but I want it to appear in the same ccnet dashboard as the existing projects. </p> <p>How do I configure CCNet for this scenario?</p>
[ { "answer_id": 271858, "author": "John Lemp", "author_id": 12915, "author_profile": "https://Stackoverflow.com/users/12915", "pm_score": 4, "selected": true, "text": "dashboard.config" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30183/" ]
271,218
<p>I am trying something very simple, but for some reason it does not work. Basically, I need to rename some nodes in an XML document. Thus, I created an XSLT file to do the transformation.</p> <p>Here is an example of the XML:</p> <p>EDIT: Addresses and Address elements occur at many levels. This is what caused me to have to try and apply an XSLT. The Visual Studio typed dataset feature, which creates typed datasets from XSD files does not permit you to have nested references to the same table. Thus, having Businesses/Business/Addresses and Businesses/Business/Contact/Addresses causes the Load() to fail. This is a known issue, and all they tell you is something like "Don't have nested table references...edit your XSD to stop having that." Unfortunately, this means that we have to apply XSLT to make the XML conform to the "hacked" XSD, since the files are coming from a third party vendor.</p> <p>So, we are very close with the help rendered here. The last couple of things are these:</p> <p>1.) How can I use the namespace reference in the match attribute of the xsl:template in order to specify that I want to rename Businesses/Business/Addresses to BusinessAddresses, but rename Businesses/Business/Contacts/Contact/Addresses to ContactAddresses?</p> <p>2.) How can I stop the XSLT from cluttering every new element with explicit namespace references? It is causing extreme bloat in the output.</p> <p>I created a namespace called "steel", and was having good success with:</p> <pre><code>&lt;xsl:template match="steel:Addresses&gt; &lt;xsl:element name="BusinessAddresses&gt; &lt;/xsl:template&gt; </code></pre> <p>The obvious problem here is that it renames <strong>ALL</strong> of the Addresses elements to BusinessAddresses, even though I want some of them named ContactAddresses, and so on. The needless addition of explicit namespace references to all of the renamed nodes is also troublesome.</p> <p>I tried this sort of thing, but as soon as I add slashes to the match attribute, it is a a syntax error in the XSLT, like so:</p> <pre><code>&lt;xsl:template match="steel:/Businesses/Business/Addresses"&gt; </code></pre> <p>I feel very close, but need some guidance on how to mix both the namespace usage and a way to use the slashes to select <strong>ANY</strong> nodes under specific paths.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;Businesses&gt; &lt;Business&gt; &lt;BusinessName&gt;Steel Stretching&lt;/BusinessName&gt; &lt;Addresses&gt; &lt;Address&gt; &lt;City&gt;Pittsburgh&lt;/City&gt; &lt;/Address&gt; &lt;Address&gt; &lt;City&gt;Philadelphia&lt;/City&gt; &lt;/Address&gt; &lt;/Addresses&gt; &lt;Contacts&gt; &lt;Contact&gt; &lt;FirstName&gt;Paul&lt;/FirstName&gt; &lt;LastName&gt;Jones&lt;/LastName&gt; &lt;Addresses&gt; &lt;Address&gt; &lt;City&gt;Pittsburgh&lt;/City&gt; &lt;/Address&gt; &lt;/Addresses&gt; &lt;/Contact&gt; &lt;/Contacts&gt; &lt;/Business&gt; &lt;Business&gt; &lt;BusinessName&gt;Iron Works&lt;/BusinessName&gt; &lt;Addresses&gt; &lt;Address&gt; &lt;City&gt;Harrisburg&lt;/City&gt; &lt;/Address&gt; &lt;Address&gt; &lt;City&gt;Lancaster&lt;/City&gt; &lt;/Address&gt; &lt;/Addresses&gt; &lt;/Business&gt; &lt;/Businesses&gt; </code></pre> <p>I need to rename Addresses to BusinessAddresses, and I need to rename Address to BusinessAddress, for every instance of Addresses and Address directly under a Business node. I also need to rename Addresses to ContactAddresses, and I need to rename Address to ContactAddress, for every instance of Addresses and Address directly under a Contact Node.</p> <p>I have tried several solutions, but none seem to work. They all end up producing the same XML as the original file.</p> <p>Here is an example of what I have tried:</p> <pre><code> &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@*|*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Addresses"&gt; &lt;BusinessAddresses&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;/BusinessAddresses&gt; &lt;/xsl:template&gt; </code></pre> <p>This has been tried in at least 6 different flavors, complete with stepping through the XSLT debugger in VB.Net. It never executes the template match for Addresses.</p> <p>Why?</p>
[ { "answer_id": 271301, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "xmlns:business" }, { "answer_id": 274416, "author": "Pride Fallon", "author_id": 35458, "author_prof...
2008/11/07
[ "https://Stackoverflow.com/questions/271218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10224/" ]
271,224
<p>Can anyone reccomend a .net control (winforms) that can be used to as a designer to edit xml files / DSL files ??</p>
[ { "answer_id": 271301, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "xmlns:business" }, { "answer_id": 274416, "author": "Pride Fallon", "author_id": 35458, "author_prof...
2008/11/07
[ "https://Stackoverflow.com/questions/271224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
271,238
<p>I'm just concerned about Windows, so there's no need to go into esoterica about Mono compatibility or anything like that.</p> <p>I should also add that the app that I'm writing is WPF, and I'd prefer to avoid taking a dependency on <code>System.Windows.Forms</code> if at all possible.</p>
[ { "answer_id": 271251, "author": "Josh Stodola", "author_id": 54420, "author_profile": "https://Stackoverflow.com/users/54420", "pm_score": 5, "selected": true, "text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Management;\n\nnamespace WMITestCon...
2008/11/07
[ "https://Stackoverflow.com/questions/271238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26628/" ]
271,244
<p>Given a Django.db models class:</p> <pre><code>class P(models.Model): type = models.ForeignKey(Type) # Type is another models.Model class name = models.CharField() </code></pre> <p>where one wishes to create a new P with a specified type, i.e. how does one make "type" to be a default, hidden field (from the user), where type is given likeso:</p> <pre><code>http://x.y/P/new?type=3 </code></pre> <p>So that in the form no "type" field will appear, but when the P is saved, its type will have id 3 (i.e. Type.objects.get(pk=3)).</p> <p>Secondarily, how does one (&amp; is it possible) specify a "default" type in the url, via urls.py, when using generic Django views, viz.</p> <pre><code>urlpatterns = ('django.generic.views.create_update', url(r'^/new$', 'create_object', { 'model': P }, name='new_P'), ) </code></pre> <p>I found that terribly difficult to describe, which may be part of the problem. :) Input is much appreciated!</p>
[ { "answer_id": 271252, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 3, "selected": false, "text": "mydefault = Type.objects.get(pk=3)\n\nclass P(models.Model):\n type = models.ForeignKey(Type, default=mydefault) #...
2008/11/07
[ "https://Stackoverflow.com/questions/271244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
271,254
<p>Pretty self explanatory. I just need to export lists easily to xml format. Are there any tools that accomplish this?</p>
[ { "answer_id": 302472, "author": "jwmiller5", "author_id": 7824, "author_profile": "https://Stackoverflow.com/users/7824", "pm_score": 2, "selected": false, "text": "http://server/_vti_bin/Lists.asmx" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
271,260
<p>I was in need of a way to compress images in .net so i looked into using the .net GZipStream class (or DeflateStream). However i found that decompression was not always successful, sometimes the images would decompress fine and other times i would get a GDI+ error that something is corrupted.</p> <p>After investigating the issue i found that the decompression was not giving back all the bytes it compressed. So if i compressed 2257974 bytes i would sometimes get back only 2257870 bytes (real numbers).</p> <p>The most funny thing is that sometimes it would work. So i created this little test method that compresses only 10 bytes and now i don't get back anything at all.</p> <p>I tried it with both compression classes GZipStream and DeflateStream and i double checked my code for possible errors. I even tried positioning the stream to 0 and flushing all the streams but with no luck.</p> <p>Here is my code:</p> <pre><code> public static void TestCompression() { byte[] test = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; byte[] result = Decompress(Compress(test)); // This will fail, result.Length is 0 Debug.Assert(result.Length == test.Length); } public static byte[] Compress(byte[] data) { var compressedStream = new MemoryStream(); var zipStream = new GZipStream(compressedStream, CompressionMode.Compress); zipStream.Write(data, 0, data.Length); return compressedStream.ToArray(); } public static byte[] Decompress(byte[] data) { var compressedStream = new MemoryStream(data); var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress); var resultStream = new MemoryStream(); var buffer = new byte[4096]; int read; while ((read = zipStream.Read(buffer, 0, buffer.Length)) &gt; 0) { resultStream.Write(buffer, 0, read); } return resultStream.ToArray(); } </code></pre>
[ { "answer_id": 271264, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "Close()" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35371/" ]
271,265
<p>I'm using JMX to save some diagnostic information from a remote process. Looking at the interface in jconsole shows that the return type is <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/openmbean/CompositeData.html" rel="noreferrer">CompositeData</a> (the data actually comes back as <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/openmbean/CompositeDataSupport.html" rel="noreferrer">CompositeDataSupport</a>). I want to output all the key/value pairs that are associated with this object.</p> <p>The problem is that the interface just seems to have a "values()" method with no way of getting the keys. Am I missing something here? Is there some other way to approach this task?</p> <p>Thanks!</p>
[ { "answer_id": 271400, "author": "Tyler Levine", "author_id": 35339, "author_profile": "https://Stackoverflow.com/users/35339", "pm_score": 4, "selected": true, "text": "Set< String > keys = cData.getCompositeType().keySet();\n" }, { "answer_id": 271408, "author": "VonC", ...
2008/11/07
[ "https://Stackoverflow.com/questions/271265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
271,273
<p>I'm trying to take advantage of the constant memory, but I'm having a hard time figuring out how to nest arrays. What I have is an array of data that has counts for internal data but those are different for each entry. So based around the following simplified code I have two problems. First I don't know how to allocate the data pointed to by the members of my data structure. Second, since I can't use cudaGetSymbolAddress for constant memory I'm not sure if I can just pass the global pointer (which you cannot do with plain __device__ memory).</p> <pre><code> struct __align(16)__ data{ int nFiles; int nNames; int* files; int* names; }; __device__ __constant__ data *mydata; __host__ void initMemory(...) { cudaMalloc( (void **) &(mydata), sizeof(data)*dynamicsize ); for(int i=; i lessthan dynamicsize; i++) { cudaMemcpyToSymbol(mydata, &(nFiles[i]), sizeof(int), sizeof(data)*i, cudaMemcpyHostToDevice); //... //Problem 1: Allocate & Set mydata[i].files } } __global__ void myKernel(data *constDataPtr) { //Problem 2: Access constDataPtr[n].files, etc } int main() { //... myKernel grid, threads (mydata); } </code></pre> <p>Thanks for any help offered. :-)</p>
[ { "answer_id": 672941, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "struct data\n{\n int nFiles;\n int nNames;\n int* files;\n int* names;\n}\n" }, { "answer_id": 1261307, ...
2008/11/07
[ "https://Stackoverflow.com/questions/271273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35373/" ]
271,274
<p>I am adding objects into a java Vector using its add(Object) method. In my example, the first 5 objects are identical, followed by 2 instances different from the first five. For some reasons, as soon as I insert the first one that is different, it changes the entire vector to that value!</p> <p>'values' is an iterator containing something like '1','1','1','1','1','2','2'</p> <pre><code> Vector temp = new Vector(); while (values.hasNext()) { temp.add(values.next()); System.out.println(temp.toString()); } </code></pre> <p>It will output something like</p> <blockquote> <p>[1]<br> [1,1]<br> [1,1,1]<br> [1,1,1,1]<br> [1,1,1,1,1]<br> [2,2,2,2,2,2]<br> [2,2,2,2,2,2,2] </p> </blockquote> <p>I tried using a LinkedList, as well as using add(object, index). Same thing happened.</p>
[ { "answer_id": 271293, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": false, "text": "values" }, { "answer_id": 271362, "author": "dlinsin", "author_id": 198, "author_profile": "https://Sta...
2008/11/07
[ "https://Stackoverflow.com/questions/271274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25645/" ]
271,285
<p>My webapp (ASP.NET 2.0) consumes a webservice (asmx on 1.1 framework) on the same machine. After getting XML in return, I pass it to <code>XslCompiledTransform</code> for transform XML to HTML and it works fine.</p> <p>Yesterday I got a <code>System.IO.FileNotFoundException</code> frequently and don't know what causes this kind of problem.</p> <p>First look I thought it's about read/write permission on c:\windows\temp and then I made sure give it full permission for Network Service (also Everybody at last -_-!) but it doesn't help.</p> <p>Any ideas or solutions would be appreciate.</p> <pre><code>-------------------- stack trace -------------------------- Exception: **System.IO.FileNotFoundException** **Could not find file 'C:\WINDOWS\TEMP\sivvt5f6.dll'.** at System.IO.__Error**.WinIOError**(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) at Microsoft.CSharp.CSharpCodeGenerator.FromDomBatch(CompilerParameters options, CodeCompileUnit[] ea) at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] ea) at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromDom(CompilerParameters options, CodeCompileUnit[] compilationUnits) at System.Xml.Xsl.Xslt.Scripts.CompileAssembly(List`1 scriptsForLang) at System.Xml.Xsl.Xslt.Scripts.CompileScripts() at System.Xml.Xsl.Xslt.QilGenerator.Compile(Compiler compiler) at System.Xml.Xsl.Xslt.**Compiler. Compile**(Object stylesheet, XmlResolver xmlResolver, QilExpression&amp; qil) at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.**XslCompiledTransform.Load**(String stylesheetUri, XsltSettings settings, XmlResolver stylesheetResolver) </code></pre>
[ { "answer_id": 271304, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "XslCompiledTransform" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35682/" ]
271,311
<p>Is there some nice documentation for Windows batch scripting I can download and refer to while offline?</p>
[ { "answer_id": 271334, "author": "Paulius", "author_id": 1353085, "author_profile": "https://Stackoverflow.com/users/1353085", "pm_score": 2, "selected": false, "text": "<command> /?\nhelp <command>\n" }, { "answer_id": 2035347, "author": "Peter Mortensen", "author_id": 6...
2008/11/07
[ "https://Stackoverflow.com/questions/271311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14966/" ]
271,318
<p>If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it. </p> <p>My question is should you also always do so within the class? I've always used the Property if there is one, even within the class, but would like to hear some arguments for and against as to which is the most correct and why. </p> <p>Or is it just a matter of coding standards being used on the project?</p>
[ { "answer_id": 271327, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 0, "selected": false, "text": "class Foo {\n public string Value { get; set; }\n\n public void Write() {\n Console.Write(Value);\n }\n}\n" ...
2008/11/07
[ "https://Stackoverflow.com/questions/271318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24395/" ]
271,319
<p>Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed.</p> <p>Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for any alternatives.</p>
[ { "answer_id": 15044689, "author": "nawfal", "author_id": 661933, "author_profile": "https://Stackoverflow.com/users/661933", "pm_score": 6, "selected": true, "text": " no of files cumulative size of files db size\n\nFirebird 2.5 5 6.82...
2008/11/07
[ "https://Stackoverflow.com/questions/271319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11256/" ]
271,329
<p>I have problems with how to design some classes. I have three classes. One superclass, and two subclasses. </p> <p>One subclass (AnimatedCharacter) is made by flash, and is used to display the object on screen. The other (CharacterPhysics) is made by myself to extend the superclass.</p> <p>The problem is that the object I use, is of the type AnimatedCharacter, so I can't just put it in a variable of type CharacterPhysics.</p> <p>What I tried is some sort of Decorator pattern, by giving the object of type CharacterPhysics a reference to the other object. But now I have to override all the methods of the superclass and pass the methodcalls to the reference. Not an ideal situation.</p> <p>Does someone know how to solve this kind of problem?</p> <p><a href="http://www.freeimagehosting.net/uploads/7a95f8352c.png" rel="nofollow noreferrer">alt text http://www.freeimagehosting.net/uploads/7a95f8352c.png</a></p>
[ { "answer_id": 281794, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 1, "selected": false, "text": "AnimatedCharacter" } ]
2008/11/07
[ "https://Stackoverflow.com/questions/271329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20261/" ]
271,337
<p>How do I pick/ delete all the documents from Solr using the boolean NOT notion?</p> <p>i.e. How do I delete all the documents from Solr who's id does NOT start with A59?</p>
[ { "answer_id": 379890, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 7, "selected": true, "text": "-" }, { "answer_id": 12351946, "author": "Rick Tonoli", "author_id": 1514547, "author_profile...
2008/11/07
[ "https://Stackoverflow.com/questions/271337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]