qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
233,141
<p>I have a comma separated list of strings like the one below.</p> <pre><code>a,b ,c ,d, , , , ,e, f,g,h . </code></pre> <p>I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be</p> <pre><code>a,b ,c ,d,NA,NA,NA,NA,e, f,g,h . </code></pre> <p>I tried using ",\s+," to search but it skips the alternate empty strings and results in</p> <pre><code>a,b ,c ,d,NA, ,NA, ,e, f,g,h . </code></pre> <p>What's the correct regex to use here ?</p>
[ { "answer_id": 233160, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "(?<=,)\\s+(?=,)" }, { "answer_id": 233227, "author": "MrM", "author_id": 319803, "author_profile": "https:...
2008/10/24
[ "https://Stackoverflow.com/questions/233141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24424/" ]
233,148
<p>I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers?</p> <p>If so, is this still the case as I begin to move away from learning C into Objective-C and <a href="http://en.wikipedia.org/wiki/Cocoa_%28API%29" rel="noreferrer">Cocoa</a> on Macs?</p> <p>Which is the preferred coding style for array access, in both C and Objective-C? Which is considered (by professionals of their respective languages) more legible, more "correct" (for lack of a better term)?</p>
[ { "answer_id": 233166, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 7, "selected": true, "text": "int i;\nint a[20];\n\n// Init all values to zero\nmemset(a, 0, sizeof(a));\nfor (i = 0; i < 20; i++) {\n printf(\"Value of...
2008/10/24
[ "https://Stackoverflow.com/questions/233148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
233,171
<p>What is the best way to do GUIs in <a href="http://en.wikipedia.org/wiki/Clojure" rel="noreferrer">Clojure</a>?</p> <p>Is there an example of some functional <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" rel="noreferrer">Swing</a> or <a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" rel="noreferrer">SWT</a> wrapper? Or some integration with <a href="http://en.wikipedia.org/wiki/JavaFX" rel="noreferrer">JavaFX</a> declarative GUI description which could be easily wrapped to <a href="http://en.wikipedia.org/wiki/S-expression" rel="noreferrer">s-expressions</a> using some macrology?</p> <p>Any tutorials?</p>
[ { "answer_id": 233271, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 4, "selected": false, "text": "(import '(javax.swing JFrame JButton JOptionPane)) ;'\n(import '(java.awt.event ActionListener)) ;'\n\n(let [frame (JFr...
2008/10/24
[ "https://Stackoverflow.com/questions/233171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31141/" ]
233,188
<p>I have a web page that uses a scrolling div to display table information. When the window is resized (and also on page load), the display is centered and the div's scrollbar positioned to the right of the page by setting its width. For some reason, the behaviour is different under firefox than IE. IE positions/sizes the div as expected, but firefox seems to make it too wide, such that the scrollbar begins to disappear when the window client width reaches about 800px. I'm using the following methods to set the position and size: </p> <pre><code>function getWindowWidth() { var windowWidth = 0; if (typeof(window.innerWidth) == 'number') { windowWidth=window.innerWidth; } else { if (document.documentElement &amp;&amp; document.documentElement.clientWidth) { windowWidth=document.documentElement.clientWidth ; } else { if (document.body &amp;&amp; document.body.clientWidth) { windowWidth=document.body.clientWidth; } } } return windowWidth; } function findLPos(obj) { var curleft = 0; if (obj.offsetParent) { curleft = obj.offsetLeft while (obj = obj.offsetParent) { curleft += obj.offsetLeft } } return curleft; } var bdydiv; var coldiv; document.body.style.overflow="hidden"; window.onload=resizeDivs; window.onresize=resizeDivs; function resizeDivs(){ bdydiv=document.getElementById('bdydiv'); coldiv=document.getElementById('coldiv'); var winWdth=getWindowWidth(); var rghtMarg = 0; var colHdrTbl=document.getElementById('colHdrTbl'); rghtMarg = parseInt((winWdth - 766) / 2) - 8; rghtMarg = (rghtMarg &gt; 0 ? rghtMarg : 0); coldiv.style.paddingLeft = rghtMarg + "px"; bdydiv.style.paddingLeft = rghtMarg + "px"; var bdydivLft=findLPos(bdydiv); if ((winWdth - bdydivLft) &gt;= 1){ bdydiv.style.width = winWdth - bdydivLft; coldiv.style.width = bdydiv.style.width; } syncScroll(); } function syncScroll(){ if(coldiv.scrollLeft&gt;=0){ coldiv.scrollLeft=bdydiv.scrollLeft; } } </code></pre> <p>Note that I've cut out other code which sets height, and other non-relevant parts. The full page can be seen <a href="http://site1.funddata.com/mozilladivresize.html" rel="nofollow noreferrer">here</a>. If you go to the link in both IE and firefox, resize width until "800" is displayed in the green box top-right, and resize height until the scrollbar at the right is enabled, you can see the problem. If you then resize the IE width, the scrollbar stays, but if you resize the firefox width wider, the scrollbar begins to disappear. I'm at a loss as to why this is happening....</p> <p>Note that AFAIK, getWindowWidth() should be cross-browser-compatible, but I'm not so sure about findLPos().... perhaps there's an extra object in Firefox's DOM or something, which is changing the result??</p>
[ { "answer_id": 233204, "author": "Bob Somers", "author_id": 1384, "author_profile": "https://Stackoverflow.com/users/1384", "pm_score": 0, "selected": false, "text": "windowWidth = document.documentElement.clientWidth;\n" }, { "answer_id": 233577, "author": "roenving", "a...
2008/10/24
[ "https://Stackoverflow.com/questions/233188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11820/" ]
233,192
<p><em>What options are there to detect web-crawlers that do not want to be detected?</em></p> <p>(I know that listing detection techniques will allow the smart stealth-crawler programmer to make a better spider, but I do not think that we will ever be able to block smart stealth-crawlers anyway, only the ones that make mistakes.)</p> <p>I'm not talking about the nice crawlers such as Googlebot and Yahoo! Slurp. I consider a bot nice if it:</p> <ol> <li>identifies itself as a bot in the user agent string</li> <li>reads <code>robots.txt</code> (and obeys it)</li> </ol> <p>I'm talking about the <em>bad</em> crawlers, hiding behind common user agents, using my bandwidth and never giving me anything in return.</p> <p>There are some trapdoors that can be constructed <em>updated list (thanks Chris, gs)</em>:</p> <ol> <li>Adding a directory only listed (marked as disallow) in the <code>robots.txt</code>,</li> <li>Adding invisible links (possibly marked as rel=&quot;nofollow&quot;?), <ul> <li>style=&quot;display: none;&quot; on link or parent container</li> <li>placed underneath another element with higher z-index</li> </ul> </li> <li>detect who doesn't understand CaPiTaLiSaTioN,</li> <li>detect who tries to post replies but always fail the Captcha.</li> <li>detect GET requests to POST-only resources</li> <li>detect interval between requests</li> <li>detect order of pages requested</li> <li>detect who (consistently) requests HTTPS resources over HTTP</li> <li>detect who does not request image file (this in combination with a list of user-agents of known image capable browsers works surprisingly nice)</li> </ol> <p>Some traps would be triggered by both 'good' and 'bad' bots. you could combine those with a whitelist:</p> <ol> <li>It trigger a trap</li> <li>It request <code>robots.txt</code>?</li> <li>It doest not trigger another trap because it obeyed <code>robots.txt</code></li> </ol> <p><em>One other important thing here is:</em> Please consider blind people using a screen readers: give people a way to contact you, or solve a (non-image) Captcha to continue browsing.</p> <p><strong>What methods are there to automatically detect the web crawlers trying to mask themselves as normal human visitors.</strong></p> <p>The question is not: <em>How do I catch every crawler.</em> The question is: <em>How can I maximize the chance of detecting a crawler.</em></p> <p>Some spiders are really good, and actually parse and understand HTML, xhtml, CSS JavaScript, VBScript etc... I have no illusions: I won't be able to beat them.</p> <p>You would however be surprised how stupid some crawlers are. With the best example of stupidity (in my opinion) being: cast all URLs to lower case before requesting them.</p> <p>And then there is a whole bunch of crawlers that are just 'not good enough' to avoid the various trapdoors.</p>
[ { "answer_id": 233541, "author": "Georg Schölly", "author_id": 24587, "author_profile": "https://Stackoverflow.com/users/24587", "pm_score": 3, "selected": false, "text": "<a href=\"iamabot.script\" style=\"display:none;\">Don't click me!</a>\n" }, { "answer_id": 310343, "aut...
2008/10/24
[ "https://Stackoverflow.com/questions/233192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22674/" ]
233,199
<p>I am trying to get data from my server, used RemoteObject to accomplish it. When I run the application on my localhost it works great but when iam using it on my server i get a Channel.Security.Error(Security Error accessing URL).</p> <p>On the server side logs there is a mention about cross domain . 77.127.194.4 - - [23/Oct/2008 21:15:11] "GET /crossdomain.xml HTTP/1.1" 501</p> <p>Any one encountered the same problem ? any idea ?</p>
[ { "answer_id": 233541, "author": "Georg Schölly", "author_id": 24587, "author_profile": "https://Stackoverflow.com/users/24587", "pm_score": 3, "selected": false, "text": "<a href=\"iamabot.script\" style=\"display:none;\">Don't click me!</a>\n" }, { "answer_id": 310343, "aut...
2008/10/24
[ "https://Stackoverflow.com/questions/233199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20955/" ]
233,207
<p>Should I always wrap external resource calls in a try-catch? (ie. calls to a database or file system) Is there a best practice for error handling when calling external resources?</p>
[ { "answer_id": 233248, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "try/finally" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
233,216
<p>I have an abstract generic class <code>BLL&lt;T&gt; where T : BusinessObject</code>. I need to open an assembly that contains a set of concrete BLL classes, and return the tuples (businessObjectType, concreteBLLType) inside a Dictionary. There is the part of the method I could do until now, but I'm having problems to discover T.</p> <pre><code>protected override Dictionary&lt;Type, Type&gt; DefineBLLs() { string bllsAssembly = ConfigurationManager.AppSettings["BLLsAssembly"]; Type[] types = LoadAssembly(bllsAssembly); Dictionary&lt;Type, Type&gt; bllsTypes = new Dictionary&lt;Type, Type&gt;(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(BLL&lt;&gt;))) /* how to know T in the situation below? */ bllsTypes.Add(??businessObjectType (T)??, type); } return bllsTypes; } </code></pre>
[ { "answer_id": 233236, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "using System;\nusing System.Reflection;\n\npublic abstract class Base<T>\n{\n}\n\npublic class Concrete : Base<string>\n{...
2008/10/24
[ "https://Stackoverflow.com/questions/233216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
233,217
<p>I'm writing a C Shell program that will be doing <code>su</code> or <code>sudo</code> or <code>ssh</code>. They all want their passwords in console input (the TTY) rather than stdin or the command line.</p> <p>Does anybody know a solution?</p> <p>Setting up password-less <code>sudo</code> is not an option.</p> <p><a href="/questions/tagged/expect" class="post-tag" title="show questions tagged &#39;expect&#39;" rel="tag">expect</a> could be an option, but it's not present on my stripped-down system.</p>
[ { "answer_id": 233224, "author": "Marko", "author_id": 31141, "author_profile": "https://Stackoverflow.com/users/31141", "pm_score": 3, "selected": false, "text": "expect" }, { "answer_id": 351916, "author": "mlambie", "author_id": 17453, "author_profile": "https://St...
2008/10/24
[ "https://Stackoverflow.com/questions/233217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23420/" ]
233,222
<p>I have 3 divs where only one is visible by default, they each contain information about a product. Below this divs is a list of 3 images which are images of the products. By default of course the 1st list item is selected and has <code>class="selected"</code>. When a different product image is clicks then <code>class="selected"</code> moves to that list item and the div above it changes to hidden and the div containing the other product information needs to appear.</p> <p>I have searched all over the place for a plugin which can do what I want, they are all limited in some way which stops me doing from doing it.</p>
[ { "answer_id": 233252, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 2, "selected": false, "text": "<img id=\"img1\" src=\"1.jpg\" desc=\"d1\" class=\"selected prodImg\" />\n<img id=\"img2\" src=\"2.jpg\" desc=\"d2\" cl...
2008/10/24
[ "https://Stackoverflow.com/questions/233222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
233,243
<p>That was an interview question that I was unable to answer:</p> <p>How to check that a string is a palindrome using regular expressions?</p> <p>p.s. There is already a question "<a href="https://stackoverflow.com/questions/52002/how-to-check-if-the-given-string-is-palindrome">How to check if the given string is palindrome?</a>" and it gives a lot of answers in different languages, but no answer that uses regular expressions.</p>
[ { "answer_id": 233275, "author": "FOR", "author_id": 27826, "author_profile": "https://Stackoverflow.com/users/27826", "pm_score": 4, "selected": false, "text": "\\(.\\)\\(.\\)\\2\\1\n" }, { "answer_id": 233294, "author": "Dan", "author_id": 8040, "author_profile": "h...
2008/10/24
[ "https://Stackoverflow.com/questions/233243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26276/" ]
233,251
<p>Since many years a GUI-standard are the menu-bars of applications with menus popping up, if you click or hover an entry in the menu-bar. Some websites implement this feature too, but they are using Javascript, as far as I can see. For different reasons Javascript can be a problem, so the question: Is this possible to implement without Javascript, only using HTML and CSS?</p>
[ { "answer_id": 233266, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "a:link {\n color: blue;\n}\n\na:hover {\n color: red;\n}\n" }, { "answer_id": 233269, "author": "Jeff Fr...
2008/10/24
[ "https://Stackoverflow.com/questions/233251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
233,255
<p>I am working on a project to enhance our production debugging capabilities. Our goal is to reliably produce a minidump on any unhandled exception, whether the exception is managed or unmanaged, and whether it occurs on a managed or unmanaged thread.</p> <p>We use the excellent <a href="http://www.debuginfo.com/tools/clrdump.html" rel="noreferrer">ClrDump</a> library for this currently, but it does not quite provide the exact features we need, and I'd like to understand the mechanisms behind exception filtering, so I set out to try this for myself.</p> <p>I started out by following this blog article to install an SEH handler myself: <a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/12.aspx" rel="noreferrer">http://blogs.microsoft.co.il/blogs/sasha/archive/2007/12.aspx</a>. This technique works for console applications, but when I try the same thing from a WinForms application, my filter is not called for any variety of unmanaged exceptions.</p> <p>What can ClrDump be doing that I'm not doing? ClrDump produces dumps in all cases, so its exception filter must still be called...</p> <p>Note: I'm aware of ADPlus's capabilities, and we've also considered using the AeDebug registry keys... These are also possibilities, but also have their tradeoffs.</p> <p>Thanks, Dave</p> <pre><code>// Code adapted from &lt;http://blogs.microsoft.co.il/blogs/sasha/archive/2007/12.aspx&gt; LONG WINAPI MyExceptionFilter(__in struct _EXCEPTION_POINTERS *ExceptionInfo) { printf("Native exception filter: %X\n",ExceptionInfo-&gt;ExceptionRecord-&gt;ExceptionCode); Beep(1000,1000); Sleep(500); Beep(1000,1000); if(oldFilter_ == NULL) { return EXCEPTION_CONTINUE_SEARCH; } LONG ret = oldFilter_(ExceptionInfo); printf("Other handler returned %d\n",ret); return ret; } #pragma managed namespace SEHInstaller { public ref class SEHInstall { public: static void InstallHandler() { oldFilter_ = SetUnhandledExceptionFilter(MyExceptionFilter); printf("Installed handler old=%x\n",oldFilter_); } }; } </code></pre>
[ { "answer_id": 238357, "author": "HTTP 410", "author_id": 13118, "author_profile": "https://Stackoverflow.com/users/13118", "pm_score": 4, "selected": true, "text": "Application.ThreadException += new Threading.ThreadExceptionHandler(CatchFormsExceptions);\n" }, { "answer_id": 14...
2008/10/24
[ "https://Stackoverflow.com/questions/233255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6996/" ]
233,259
<p>I'm looking for ActiveX components that can easily: </p> <ul> <li>get and send emails via SMTP and POP3</li> <li>strip out and save attachments.</li> <li>Convert RTF (Outlook emails) to HTML</li> <li>Sanitize HTML.</li> </ul> <p>What components would you recommend? What components do you use?</p>
[ { "answer_id": 422437, "author": "LarryF", "author_id": 18518, "author_profile": "https://Stackoverflow.com/users/18518", "pm_score": 1, "selected": false, "text": "\n Content-Type: application/octet-stream\n Content-Transfer-Encoding: base64" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1726/" ]
233,261
<p>The strongly typed <code>SearchViewData</code> has a field called Colors that in it's turn is a <code>ColorViewData</code>. In my <code>/Colors.mvc/search</code> I populate this <code>viewData.Model.Colors</code> based on the given search criteria. Then, based on several factors, I render one of a set of user controls that are able to render itself with a <code>ColorViewData</code>.<br> So I will end up with:</p> <pre><code>&lt;%Html.RenderPartial("~/Views/Color/_ColorList.ascx", ViewData.Model.Colors);%&gt; </code></pre> <p>This used to work just fine, but since the upgrade to the beta1, my user control always ends up with <code>viewdata = null;</code></p> <p>Suggestions?</p>
[ { "answer_id": 233335, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 0, "selected": false, "text": "<% Html.RenderPartial(\"xxx\", new ViewDataDictionary(ViewData.Model.Colors)); %>\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
233,264
<p>I have an ASP.NET application. Basically the delivery process is this one :</p> <ul> <li>Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script.</li> <li>The zip and nant files are copied to the client's computer</li> <li>the Nant script replaces the current website files with the file contained in the zip file.</li> </ul> <p>My problem is that with this process I have an Unauthorized access error when I try to open the website. It seems that the files need to have a permission set for the user "<strong>IIS_WPG</strong>".</p> <p>I don't have the power to change IIS configuration so I have to manually change the permissions of each file. And each time I replace the files the permissions are removed and I need to set them again.</p> <p>So I have two questions :</p> <ul> <li>Can I change files permissions with Nant ? How to do it ?</li> <li>Is it possible to avoid this problem ? (developers don't have this user on their computers)</li> </ul>
[ { "answer_id": 233299, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 3, "selected": true, "text": "<exec program=\"cacls\">\n <arg value=\"*\" />\n <arg value=\"/G IIS_WPG:F\" />\n</exec>\n" }, { "answer_i...
2008/10/24
[ "https://Stackoverflow.com/questions/233264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28544/" ]
233,283
<p>I'm starting a Wordpress Blog that will have adult content on it, so I'll need a first-time-only splash page in Wordpress. The first-time-only issue, I can fix with a cookie (although I am aware that not everyone has cookies enabled) </p> <p>What I could do is, create a script that loads another page if a cookie isn't present. Or I could make the splash page be my home page, and if the cookie is present, redirect. </p> <p>But that's not really what I'm looking for. I don't want to hassle with pages. In stead I'm looking for a lightbox-y solution, that darkens the background (the home page) and shows a panel with the choice to stay or leave. </p> <p>I haven't got a clue on how to start this. I am familiar with PHP, Javascript and CSS, so I'm not even asking for code. I just want a web programmer's view on this, and some help on how to create the splash-page the way I would like it. Or is it a stupid idea?</p>
[ { "answer_id": 9507418, "author": "Trey Copeland", "author_id": 1830549, "author_profile": "https://Stackoverflow.com/users/1830549", "pm_score": 1, "selected": false, "text": "#inline_content" }, { "answer_id": 12272564, "author": "Bojana Šekeljić", "author_id": 1647537,...
2008/10/24
[ "https://Stackoverflow.com/questions/233283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31145/" ]
233,284
<p>I have created a .NET DLL which makes some methods COM visible.</p> <p>One method is problematic. It looks like this:</p> <pre><code>bool Foo(byte[] a, ref byte[] b, string c, ref string d) </code></pre> <p>VB6 gives a compile error when I attempt to call the method:</p> <blockquote> <p>Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic.</p> </blockquote> <p>I read that array parameters must be passed by reference, so I altered the first parameter in the signature:</p> <pre><code>bool Foo(ref byte[] a, ref byte[] b, string c, ref string d) </code></pre> <p>VB6 still gives the same compile error.</p> <p>How might I alter the signature to be compatible with VB6?</p>
[ { "answer_id": 233451, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "[ComVisible(true)]\nbool Foo([In] ref byte[] a, [In] ref byte[] b, string c, ref string d)\n" }, { "answer_id": 23...
2008/10/24
[ "https://Stackoverflow.com/questions/233284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/329888/" ]
233,288
<p><strong>I have class A:</strong></p> <pre><code>public class ClassA&lt;T&gt; </code></pre> <p><strong>Class B derives from A:</strong></p> <pre><code>public class ClassB : ClassA&lt;ClassB&gt; </code></pre> <p><strong>Class C derives from class B:</strong></p> <pre><code>public class ClassC : ClassB </code></pre> <p><strong>Now I have a generic method with constraints</strong></p> <pre><code>public static T Method&lt;T&gt;() where T : ClassA&lt;T&gt; </code></pre> <p>OK, now I want to call:</p> <pre><code>ClassC c = Method&lt;ClassC&gt;(); </code></pre> <p>but I get the compile error saying: <code>Type argument 'ClassC' does not inherit from or implement the constraint type 'ClassA&lt;ClassC&gt;.</code></p> <p>Yet, the compiler will allow:</p> <pre><code>ClassB b = Method&lt;ClassB&gt;(); </code></pre> <p>My understanding is that this fails because <code>ClassC</code> inherits <code>ClassA&lt;ClassB&gt;</code> instead of <code>ClassA&lt;ClassC&gt;</code></p> <p><strong>My real question is, is it possible to create a class deriving from <code>ClassB</code> that can be used in some way with the generic method?</strong></p> <p>This may seem like generics are overused and I would agree. I am trying to create business layer objects deriving from the subsonic data objects in a separate project.</p> <p>Note: I have put the &lt; T > with extra spaces otherwise they get stripped from the question.</p>
[ { "answer_id": 233303, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "public static T Method<T,U>() where T : ClassA<U> where U : T\n" }, { "answer_id": 233425, "author": "Tamas C...
2008/10/24
[ "https://Stackoverflow.com/questions/233288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24681/" ]
233,320
<p>I'm running Python 2.6 on Unix and when I run the interactive prompt (<a href="http://en.wikipedia.org/wiki/SQLite" rel="noreferrer">SQLite</a> is supposed to be preinstalled) I get:</p> <pre><code>[root@idev htdocs]# python Python 2.6 (r26:66714, Oct 23 2008, 16:25:34) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import sqlite Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: No module named sqlite &gt;&gt;&gt; </code></pre> <p>How do I resolve this?</p>
[ { "answer_id": 233336, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": false, "text": "import sqlite3\n" }, { "answer_id": 233865, "author": "razong", "author_id": 29885, "author_profile": "htt...
2008/10/24
[ "https://Stackoverflow.com/questions/233320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3404/" ]
233,328
<p>I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?</p>
[ { "answer_id": 233339, "author": "John Carter", "author_id": 8331, "author_profile": "https://Stackoverflow.com/users/8331", "pm_score": 10, "selected": true, "text": "set print elements 0\n" }, { "answer_id": 253120, "author": "Community", "author_id": -1, "author_pr...
2008/10/24
[ "https://Stackoverflow.com/questions/233328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331/" ]
233,358
<p>A quick question about elf file headers, I can't seem to find anything useful on how to add/change fields in the elf header. I'd like to be able to change the magic numbers and to add a build date to the header, and probably a few other things. </p> <p>As I understand it the linker creates the header information, but I don't see anything in the LD script that refers to it (though i'm new to ld scripts).</p> <p>I'm using gcc and building for ARM.</p> <p>thanks!</p> <p>Updates:</p> <ul> <li>ok maybe my first question should be: is it possible to create/edit the header file at link time?</li> </ul>
[ { "answer_id": 47084888, "author": "maxschlepzig", "author_id": 427158, "author_profile": "https://Stackoverflow.com/users/427158", "pm_score": 2, "selected": false, "text": "info.c" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/76121/" ]
233,360
<p>How useful, if at all, is for the testers on a product team to know about the internal code details of a product. This does not mean they need to know every line of code but a good idea of how the code is structured, what is the object model, how the various modules are inter-linked, what are the inter-dependencies between various features etc.? This can argubaly help them in finding related issues or defects once they hit one. On the other side, this can potentially 'bias' their "user-centric" approach towards evaluating and certifying the product and can effect the testing results in the end.</p> <p>I have not heard of any specific model for such interaction. (Lets assume a product that users, potentially non-technical consume, and not a framework or API that the testers are testing - in the latter case the testers may need to understand the code to test that because the user is another programmer). </p>
[ { "answer_id": 233498, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 1, "selected": false, "text": "long long int increment(long long int l) {\n if (l == 475636294934LL) return 3;\n return l + 1;\n}\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1065163/" ]
233,379
<p>We have a WinForms application which runs on a touch-screen on a bit of industrial equipment. For historical reasons which are not up for changing today, the displayed form has a normal Windows title bar. </p> <p>We would like to stop people using the mouse (i.e. touchscreen) from moving the window by dragging the title bar. We don't care if there's some other way to move the window using the keyboard.</p> <p>What's the most elegant way to achieve this? I can think of trying to subvert mouse messages if there's a mouse-down on the titlebar (though NC hit-testing doesn't at first glance seem completely obvious in Winforms), and I can think of responding to Move messages in some way which restores the window position.</p> <p>But both of these seem clunky, and I have a feeling I am missing something elegant and obvious.</p>
[ { "answer_id": 233514, "author": "Will Dean", "author_id": 987, "author_profile": "https://Stackoverflow.com/users/987", "pm_score": 2, "selected": false, "text": " protected override void WndProc(ref Message msg)\n {\n const int WM_NCLBUTTONDOWN = 0xa1;\n\n switch (msg.Msg)...
2008/10/24
[ "https://Stackoverflow.com/questions/233379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987/" ]
233,382
<p>I have to override Add method of "Controls" property of myControl that is extended from a Panel control of windows. For that i extended ControlCollection class into MyControlCollection where i overriden its Add method. Now i declared a Controls property of MyControlCollection type to hide panel's Controls property. When i am accessing this.Controls.Add(control), it refers to overriden Add method. But if i drags and drops a control on myControl the behaviour is of base type's Add method. Can any body suggest the cause and remedy for this problem? Thanks in advance.</p>
[ { "answer_id": 233398, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "ControlCollection" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31159/" ]
233,411
<p>Is it possible to enable a second monitor programatically and extend the Windows Desktop onto it in C#? It needs to do the equivalent of turning on the checkbox in the image below.</p> <p><img src="https://i.stack.imgur.com/ss2sE.png" alt="alt text"></p>
[ { "answer_id": 233826, "author": "Pop Catalin", "author_id": 4685, "author_profile": "https://Stackoverflow.com/users/4685", "pm_score": 5, "selected": true, "text": "DISPLAY_DEVICE_ATTACHED_TO_DESKTOP" }, { "answer_id": 507370, "author": "Community", "author_id": -1, ...
2008/10/24
[ "https://Stackoverflow.com/questions/233411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4500/" ]
233,421
<p>Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with:</p> <pre><code>git daemon </code></pre> <p>Is there a native Windows option, short of sharing folders, to host a Git service?</p> <p>EDIT: I am currently using the cygwin install of git to store and work with git repositories in Windows, but I would like to take the next step of hosting a repository with a service that can provide access to others.</p>
[ { "answer_id": 2275844, "author": "Derek Greer", "author_id": 1219618, "author_profile": "https://Stackoverflow.com/users/1219618", "pm_score": 7, "selected": true, "text": "#!/bin/bash\n\n/usr/bin/git daemon --reuseaddr --base-path=/git --export-all --verbose --enable=receive-pack\n" ...
2008/10/24
[ "https://Stackoverflow.com/questions/233421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29156/" ]
233,434
<p>I am trying to make our SQL Server Integration Services packages as portable as possible and the one thing that is preventing that is that the path to the config is always an absolute path, which makes testing and deployment a headache. Are there any suggestions for making this more manageble?</p> <p>Another issue is when another developer gets the package out of source control the path is specific to the developers machine.</p>
[ { "answer_id": 233528, "author": "Malik Daud Ahmad Khokhar", "author_id": 1688440, "author_profile": "https://Stackoverflow.com/users/1688440", "pm_score": 5, "selected": true, "text": "dtexec /File Package.dtsx /Conf configuration.dtsConfig\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12915/" ]
233,441
<p>On the SVN server, there is a file called <code>config.conf</code>. I have a local version called the same thing (in the same place). <strong>How can I make sure that my local config does not get overwritten, nor checked in?</strong> </p> <p>While I'm here, is the answer different for a directory?</p> <p>I'm using Tortoise SVN, but command line answers are cool.</p> <p>Thanks!</p> <p>[Sorry if this basic question has been asked before... I looked but didn't find it.]</p>
[ { "answer_id": 233460, "author": "Ryan", "author_id": 17917, "author_profile": "https://Stackoverflow.com/users/17917", "pm_score": 3, "selected": true, "text": "mv config.conf config.conf.theirs && mv config.conf.mine config.conf" }, { "answer_id": 233573, "author": "Matthew...
2008/10/24
[ "https://Stackoverflow.com/questions/233441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
233,443
<p>I need to display a small (15x15 pixel) animation in a Flex app. I have it FLV format, but it could be converted to somthing else. I'd prefer to have the file embedded in the app (it's only 8k in size). I've seen posts about displaying animated GIFs using third-party code which would be OK, but is there a way to do this with the native Flex libs. I also realize that FLVs can be displayed in Video objects but only if they are external files.</p>
[ { "answer_id": 235296, "author": "Chetan S", "author_id": 31284, "author_profile": "https://Stackoverflow.com/users/31284", "pm_score": 1, "selected": false, "text": "Image" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15899/" ]
233,446
<p>I'm trying to write a small app that monitors how much power is left in a notebook battery and I'd like to know which Win32 function I could use to accomplish that.</p>
[ { "answer_id": 29435614, "author": "Bruno STEUX", "author_id": 3778294, "author_profile": "https://Stackoverflow.com/users/3778294", "pm_score": 2, "selected": false, "text": "int getBatteryLevel()\n{\n SYSTEM_POWER_STATUS status;\n GetSystemPowerStatus(&status);\n return status...
2008/10/24
[ "https://Stackoverflow.com/questions/233446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9458/" ]
233,455
<p>I am making a program in C# to connect to a webcam and do some image manipulation with it.</p> <p>I have a working application that uses win32 api (avicap32.dll) to connect to the webcam and send messages to it that sends it to the clipboard. The problem is that, while accessible from paint, reading it from the program results in null pointers.</p> <p>This is the code I use to connect the webcam:</p> <pre><code>mCapHwnd = capCreateCaptureWindowA(&quot;WebCap&quot;, 0, 0, 0, 320, 240, 1024, 0); SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0); SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0); </code></pre> <p>And this is what I use to copy the image to the clipboard:</p> <pre><code>SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0); SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0); tempObj = Clipboard.GetDataObject(); tempImg = (System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap); </code></pre> <p>There's some error checking which I have removed from the code to make it shorter.</p>
[ { "answer_id": 234423, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 5, "selected": true, "text": "using (var cv = new OpenCVDotNet.CVCapture(0))\n{\n var image = cv.CreateCompatibleImage();\n // ...\n cv.Release();...
2008/10/24
[ "https://Stackoverflow.com/questions/233455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31151/" ]
233,467
<p>I know that most links should be left up to the end-user to decide how to open, but we can't deny that there are times you almost 'have to' force into a new window (for example to maintain data in a form on the current page).</p> <p>What I'd like to know is what the consensus is on the 'best' way to open a link in a new browser window.</p> <p>I know that <code>&lt;a href="url" target="_blank"&gt;</code> is out. I also know that <code>&lt;a href="#" onclick="window.open(url);"&gt;</code> isn't ideal for a variety of reasons. I've also tried to completely replace anchors with something like <code>&lt;span onclick="window.open(url);"&gt;</code> and then style the SPAN to look like a link.</p> <p>One solution I'm leaning towards is <code>&lt;a href="url" rel="external"&gt;</code> and using JavaScript to set all targets to '_blank' on those anchors marked 'external'.</p> <p>Are there any other ideas? What's better? I'm looking for the most XHTML-compliant and easiest way to do this.</p> <p>UPDATE: I say target="_blank" is a no no, because I've read in <a href="http://www.sitepoint.com/article/standards-compliant-world/3/" rel="noreferrer">several places</a> that the target attribute is going to be phased out of XHTML.</p>
[ { "answer_id": 233477, "author": "Luk", "author_id": 5789, "author_profile": "https://Stackoverflow.com/users/5789", "pm_score": 4, "selected": false, "text": "target=\"_blank\"" }, { "answer_id": 233495, "author": "Mark S. Rasmussen", "author_id": 12469, "author_prof...
2008/10/24
[ "https://Stackoverflow.com/questions/233467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22303/" ]
233,468
<p>I have a number of custom controls that I am trying to enable designer support for. The signature looks something like the following:</p> <pre><code>[ToolboxData("&lt;{0}:MyDropDownList runat=\"server\" CustomProp="123"&gt;&lt;/{0}:MyDropDownList&gt;")] public class MyDropDownList: DropDownList { ... code here } </code></pre> <p>This works fine, but when I drag a control onto the page from the toolbox, the TagPrefix that gets added is "cc1":</p> <pre><code>&lt;%@ Register Assembly="DBMClientPortal.Controls" Namespace="DBMClientPortal.Controls" TagPrefix="cc1" %&gt; </code></pre> <p>Obviously it is somewhat irrelevant what that TagPrefix is... it works as it stands, but I figured I <em>must</em> be able to change it somehow and curiosity got the better of me...</p> <p>Anyone know how to define what the TagPrefix will be set to when dragging a custom control onto a page in visual studio?</p> <p>Thanks, Max</p>
[ { "answer_id": 233484, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 4, "selected": true, "text": "[assembly:TagPrefix(\"MyControls\",\"RequiredTextBox\")]\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29662/" ]
233,475
<p>I'm writing tests for a business method that invokes some DAO classes to perform operations over a database.</p> <p>This method, firstly retrieves a JDBC connection from a DataSource object, The same connection is passed to all DAO instances, so I can use it to control the transaction. So, if everything works properly, I must invoke commit() over the connection object.</p> <p>I would like to test if the commit() is invoked, so I've thought to create an expectation (I'm using JMock) that checks that. But since the Connection class isn't a direct neighbour from my Business class, I don't know how to do this.</p> <p>Someone knows how to overcome this? There is some JMock facility for this, or some alternative design that allows to overcome this?</p> <p>Thanks</p>
[ { "answer_id": 233492, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "DataSource" }, { "answer_id": 233499, "author": "matt b", "author_id": 4249, "author_profile": "https...
2008/10/24
[ "https://Stackoverflow.com/questions/233475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9025/" ]
233,490
<p>I need to access a network resource on which only a given Domain Account has access. I am using the LogonUser call, but get a "User does not have required priviliege" exception, as the web application is running with the asp.net account and it does not have adequate permissions to make this call.</p> <p>Is there a way to get around it? Changing the identity or permissions of the ASP.Net account is not an option as this is a production machine with many projects running. Is there a better way to achieve this?</p> <p>Using Asp.Net 2.0, Forms Authentication.</p> <p>Kind Regards.</p>
[ { "answer_id": 233538, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 1, "selected": false, "text": "<identity impersonate=\"true\" userName=\"\"/>\n" }, { "answer_id": 1327185, "author": "Community", ...
2008/10/24
[ "https://Stackoverflow.com/questions/233490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
233,491
<p>Specifically, I currently have a JPanel with a TitledBorder. I want to customize the look of the border. In my app's current state, the title is drawn, but not the line border itself.</p> <p>If I bind an imagePainter to the panelBorder method for Panel objects, I can put a custom image around panels -- however it only shows up on those panels that I haven't explicitly set the border on in the code. Here's what that code looks like:</p> <pre><code>&lt;style id="PanelStyle"&gt; &lt;state&gt; &lt;imagePainter method="panelBorder" path="images/thick border.png" sourceInsets="3 3 3 3" /&gt; &lt;/state&gt; &lt;/style&gt; &lt;bind style="PanelStyle" type="region" key="Panel" /&gt; </code></pre> <p>How can I do the opposite -- that is, make this custom image only show up on panels I've applied a TitledBorder to?</p> <p>I have also tried using a named panel:</p> <pre><code>panel.setName("MyPanel") </code></pre> <p>and a name binding:</p> <pre><code>&lt;bind style="PanelStyle" type="name" key="MyPanel"&gt; </code></pre> <p>This allows me to change the style of only particular panels, which is good. However, it does not solve the original problem: I still can't customize my panel's NamedBorder.</p> <p>If I specify a NamedBorder, my PanelBorder painter is ignored, and just the name is printed. If I take away my NamedBorder, I <i>can</i> use my custom border graphic, but then I have to poke and prod my layout to get a JLabel in the same place that the title was previously, which is undesirable.</p> <p>Further research has uncovered that the reason there is no rendered line is that TitledBorder's constructor takes an argument of another Border, which it renders in addition to the title. I was not passing this argument, and the default depends on your selected L&amp;F. Back when I was using the System L&amp;F, the default was a LineBorder. Apparently Synth's default is an EmptyBorder. Explicitly specifying the LineBorder gets me the line back, which solves most of my problem.</p> <p>The rest of my problem involves using a custom graphic for the LineBorder. For now I'm getting by rendering my custom graphic as a second PanelBackground image -- it gets composited on top of the actual background and achieves the desired visual effect, though it's not the ideal implementation.</p>
[ { "answer_id": 279305, "author": "SpooneyDinosaur", "author_id": 22386, "author_profile": "https://Stackoverflow.com/users/22386", "pm_score": 1, "selected": false, "text": "<bind style=\"PanelStyle\" type=\"name\" key=\"mySpecialPanel\" />\n" }, { "answer_id": 1118556, "auth...
2008/10/24
[ "https://Stackoverflow.com/questions/233491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7161/" ]
233,501
<p>For the purposes of this question, the code base is an ASP.NET website that has multiple pages written in both C# and Visual Basic .NET. The primary language is C# and the Visual Basic .NET webpages where forked into the project as the same functionality is needed. </p> <p>Should the time be taken to actually rewrite these pages, including going through the testing and debugging cycle again, or would the be considered acceptable as is?</p>
[ { "answer_id": 239817, "author": "Scriptmonkey", "author_id": 31767, "author_profile": "https://Stackoverflow.com/users/31767", "pm_score": 1, "selected": false, "text": "<configuration>\n<system.web>\n <compilation>\n <codeSubDirectories>\n <add directoryName=\"VB_C...
2008/10/24
[ "https://Stackoverflow.com/questions/233501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
233,504
<p>I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print results.</p> <p>Here's the code I have so far. It saves the raw image (byteArray) to a JPEG file, but it ignores the X/Ydensity information I specify via IIOMetadata. Any advice what I'm doing wrong? </p> <p>Any other solution (third-party library, etc) would be welcome too. </p> <pre><code>import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.io.File; import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageTypeSpecifier; import javax.imageio.metadata.IIOMetadata; import javax.imageio.plugins.jpeg.JPEGImageWriteParam; import javax.imageio.stream.ImageOutputStream import org.w3c.dom.Element; import com.sun.imageio.plugins.jpeg.JPEGImageWriter; public boolean saveJpeg(int[] byteArray, int width, int height, int dpi, String file) { BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); WritableRaster wr = bufferedImage.getRaster(); wr.setPixels(0, 0, width, height, byteArray); try { // Image writer JPEGImageWriter imageWriter = (JPEGImageWriter) ImageIO.getImageWritersBySuffix("jpeg").next(); ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); imageWriter.setOutput(ios); // Compression JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); jpegParams.setCompressionQuality(0.85f); // Metadata (dpi) IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); Element tree = (Element)data.getAsTree("javax_imageio_jpeg_image_1.0"); Element jfif = (Element)tree.getElementsByTagName("app0JFIF").item(0); jfif.setAttribute("Xdensity", Integer.toString(dpi)); jfif.setAttribute("Ydensity", Integer.toString(dpi)); jfif.setAttribute("resUnits", "1"); // density is dots per inch // Write and clean up imageWriter.write(data, new IIOImage(bufferedImage, null, null), jpegParams); ios.close(); imageWriter.dispose(); } catch (Exception e) { return false; } return true; } </code></pre> <p>Thanks!</p>
[ { "answer_id": 1276894, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "data.setFromTree(\"javax_imageio_jpeg_image_1.0\", tree);\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31155/" ]
233,507
<p>Is it possible to log out user from a web site if he is using basic authentication?</p> <p>Killing session is not enough, since, once user is authenticated, each request contains login info, so user is automatically logged in next time he/she access the site using the same credentials.</p> <p>The only solution so far is to close browser, but that's not acceptable from the usability standpoint.</p>
[ { "answer_id": 14329930, "author": "ddotsenko", "author_id": 366864, "author_profile": "https://Stackoverflow.com/users/366864", "pm_score": 6, "selected": false, "text": "document.execCommand(\"ClearAuthenticationCache\")\n" }, { "answer_id": 16645815, "author": "Claudio", ...
2008/10/24
[ "https://Stackoverflow.com/questions/233507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31141/" ]
233,553
<p>I have a very simple jQuery Datepicker calendar:</p> <pre><code>$(document).ready(function(){ $("#date_pretty").datepicker({ }); }); </code></pre> <p>and of course in the HTML...</p> <pre><code>&lt;input type="text" size="10" value="" id="date_pretty"/&gt; </code></pre> <p>Today's date is nicely highlighted for the user when they bring up the calendar, but how do I get jQuery to pre-populate the textbox itself with today's date on page load, without the user doing anything? 99% of the time, the today's date default will be what they want.</p>
[ { "answer_id": 233654, "author": "lucas", "author_id": 31172, "author_profile": "https://Stackoverflow.com/users/31172", "pm_score": 6, "selected": false, "text": "var myDate = new Date();\nvar prettyDate =(myDate.getMonth()+1) + '/' + myDate.getDate() + '/' +\n myDate.getFullYear...
2008/10/24
[ "https://Stackoverflow.com/questions/233553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26848/" ]
233,560
<p>I have developed about 300 Applications which I would like to provide with multi-language capabilities independent from the Operating System. I have written a just-in-time translator, but that is too slow in applications with many components. What would you suggest I do?</p>
[ { "answer_id": 233626, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 3, "selected": true, "text": "ShowMessage('Hello'); // before\nShowMessage(_('Hello')); // after\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
233,564
<p>I have created a multi column datastore on a table that allows me to do full text indexing on the table. What I need to be able to do is weight each column different and add the scores together.</p> <p>The following query works, but is slow:</p> <pre><code>SELECT document.*, Score(1) + 2*Score(2) as Score FROM document WHERE (CONTAINS(documentContent, 'the_keyword', 1) &gt; 0 OR CONTAINS(documentTitle, 'the_keyword', 2) &gt; 0 ) ORDER BY Score DESC </code></pre> <p>After quite a bit of Googling, people have proposed the solution as:</p> <pre><code>SELECT document.*, Score(1) as Score FROM document WHERE CONTAINS(dummy, '(((the_keyword) within documentTitle))*2 OR ((the_keyword) within documentText)',1) &gt; 0) ORDER BY Score Desc </code></pre> <p>The above query is faster than its predecessor but it does not solve the actual problem. In this case, if the keyword is found in the documentTitle, it will not search the documentText (it uses the OR operator). What I really need is to ADD the two scores together so that if a keyword appears in the title AND the text it will have a higher score than if it only appears in the title. </p> <p>So, how do you add the scores for weighted columns in one CONTAINS clause? </p>
[ { "answer_id": 233761, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 0, "selected": false, "text": "select *, Score(1) + 2 * Score(2) as Score\nfrom (\n SELECT document.*, Score(1) as Score\n FROM document\n WHERE CONTAI...
2008/10/24
[ "https://Stackoverflow.com/questions/233564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31169/" ]
233,579
<p>I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. </p> <p>What would this syntax look like?</p> <p>I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons?</p> <p>(By now we definitely know that closures not will be included in the next Java release)</p> <p>OR </p> <p><strong>edit: <a href="http://puredanger.com/tech/2009/11/18/closures-after-all/" rel="noreferrer">http://puredanger.com/tech/2009/11/18/closures-after-all/</a> :D</strong></p> <p><strong>edit2: Re-thinking JDK7: <a href="http://blogs.oracle.com/mr/entry/rethinking_jdk7" rel="noreferrer">http://blogs.oracle.com/mr/entry/rethinking_jdk7</a></strong></p> <p><strong>edit3: There’s not a moment to lose!: <a href="http://blogs.oracle.com/mr/entry/quartet" rel="noreferrer">http://blogs.oracle.com/mr/entry/quartet</a></strong></p>
[ { "answer_id": 233595, "author": "Steven Huwig", "author_id": 28604, "author_profile": "https://Stackoverflow.com/users/28604", "pm_score": 5, "selected": true, "text": "boolean even = { int x => x % 2 == 0 }.invoke(15);\n" }, { "answer_id": 234004, "author": "oxbow_lakes", ...
2008/10/24
[ "https://Stackoverflow.com/questions/233579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148909/" ]
233,593
<p>Does Eclipse have a feature that lets you search a project to find all calls to deprecated methods?</p>
[ { "answer_id": 237109, "author": "Alan", "author_id": 17205, "author_profile": "https://Stackoverflow.com/users/17205", "pm_score": 2, "selected": false, "text": "@deprecated" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450/" ]
233,596
<p>In my experience it seems that most people will tell you that it is unwise to force a garbage collection but in some cases where you are working with large objects that don't always get collected in the 0 generation but where memory is an issue, is it ok to force the collect? Is there a best practice out there for doing so?</p>
[ { "answer_id": 233613, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 4, "selected": false, "text": "using" }, { "answer_id": 12527208, "author": "Morten", "author_id": 1688284, "author_profile": "https://St...
2008/10/24
[ "https://Stackoverflow.com/questions/233596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12862/" ]
233,621
<p>All the PHP files in my workspace are encoded in <strong>Unicode (UTF-8, no BOM)</strong>. I often duplicate an existing source file to use as a base for a new script. Invariably (with Path Finder or the original Finder), OS X will convert the encoding of the duplicate file to <strong>Western (Mac OS Roman)</strong>.</p> <p>Is there any way to make OS X behave and not convert the text encoding when duplicating a text file? Or make it use a specific text encoding (other than Western!) by default for all files with .php extension?</p>
[ { "answer_id": 237053, "author": "millenomi", "author_id": 6061, "author_profile": "https://Stackoverflow.com/users/6061", "pm_score": 2, "selected": false, "text": "-[NSString writeToFile:...]" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10024/" ]
233,622
<p>It sounds a lot more complicated than it really is.</p> <p>So in Perl, you can do something like this:</p> <pre><code>foreach my $var (@vars) { $hash_table{$var-&gt;{'id'}} = $var-&gt;{'data'}; } </code></pre> <p>I have a JSON object and I want to do the same thing, but with a javascript associative array in jQuery.</p> <p>I've tried the following:</p> <pre><code>hash_table = new Array(); $.each(data.results), function(name, result) { hash_table[result.(name).extra_info.a] = result.(name).some_dataset; }); </code></pre> <p>Where data is a JSON object gotten from a $.getJSON call. It looks more or less like this (my JSON syntax may be a little off, sorry):</p> <pre><code>{ results:{ datasets_a:{ dataset_one:{ data:{ //stuff } extra_info:{ //stuff } } dataset_two:{ ... } ... } datasets_b:{ ... } } } </code></pre> <p>But every time I do this, firebug throws the following error:</p> <p>"XML filter is applied to non-xml data"</p>
[ { "answer_id": 233689, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": " d = {\n 'results':{\n 'datasets_a':{\n 'dataset_one':{\n 'data':{\n ...
2008/10/24
[ "https://Stackoverflow.com/questions/233622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22390/" ]
233,632
<p>Ok</p> <p>I'm working on a little project at the moment, the Report expects an int but the ReportParameter class only lets me have a value that's a string or a string[]</p> <p>How can I pass an int?</p> <p>thanks</p> <p>dan</p>
[ { "answer_id": 233675, "author": "John Lemp", "author_id": 12915, "author_profile": "https://Stackoverflow.com/users/12915", "pm_score": 2, "selected": false, "text": "GetReportParameters()" }, { "answer_id": 233771, "author": "Thedric Walker", "author_id": 26166, "au...
2008/10/24
[ "https://Stackoverflow.com/questions/233632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30861/" ]
233,643
<p>I'd like to link to some PDFs in one of my controller views. What's the best practice for accomplishing this? The CakePHP webroot folder contains a ./files/ subfolder, I am confounded by trying to link to it without using "magic" pathnames in my href (e.g. "/path/to/my/webroot/files/myfile.pdf").</p> <p>What are my options?</p> <p><strong>EDIT:</strong> I didn't adequately describe my question. I was attempting to link to files in /app/webroot/files/ in a platform-agnostic (ie. no <code>mod_rewrite</code>) way.</p> <p>I've since worked around this issue by storing such files outside the CakePHP directory structure.</p>
[ { "answer_id": 239322, "author": "Alexander Morland", "author_id": 4013, "author_profile": "https://Stackoverflow.com/users/4013", "pm_score": 5, "selected": true, "text": "$html->link('Pdf', '/files/myfile.pdf');\n" }, { "answer_id": 280429, "author": "Chris Hawes", "aut...
2008/10/24
[ "https://Stackoverflow.com/questions/233643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5030/" ]
233,673
<p>While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python:</p> <pre><code>flist = [] for i in xrange(3): def func(x): return x * i flist.append(func) for f in flist: print f(2) </code></pre> <p>Note that this example mindfully avoids <code>lambda</code>. It prints "4 4 4", which is surprising. I'd expect "0 2 4". </p> <p>This equivalent Perl code does it right:</p> <pre><code>my @flist = (); foreach my $i (0 .. 2) { push(@flist, sub {$i * $_[0]}); } foreach my $f (@flist) { print $f-&gt;(2), "\n"; } </code></pre> <p>"0 2 4" is printed.</p> <p>Can you please explain the difference ?</p> <hr> <p>Update: </p> <p>The problem <strong>is not</strong> with <code>i</code> being global. This displays the same behavior:</p> <pre><code>flist = [] def outer(): for i in xrange(3): def inner(x): return x * i flist.append(inner) outer() #~ print i # commented because it causes an error for f in flist: print f(2) </code></pre> <p>As the commented line shows, <code>i</code> is unknown at that point. Still, it prints "4 4 4".</p>
[ { "answer_id": 233713, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 2, "selected": false, "text": "i" }, { "answer_id": 233800, "author": "Null303", "author_id": 13787, "author_profile": "htt...
2008/10/24
[ "https://Stackoverflow.com/questions/233673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
233,681
<p>I have a web service using .net c# and I want to write to a text file on the server, but I cannot get this to work. I believe it's a permission problem.</p> <p>Specifically, I think the problem is I am using <code>System.IO.Directory.GetCurrentDirectory()</code>. </p> <p>Is there a better alternative?</p>
[ { "answer_id": 233743, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 2, "selected": false, "text": "'<MACHINENAME>\\ASPNET'" }, { "answer_id": 7582879, "author": "simaglei", "author_id": 485972, "author_profile...
2008/10/24
[ "https://Stackoverflow.com/questions/233681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23149/" ]
233,691
<p><strong>Scenario:</strong></p> <p>The task I have at hand is to enable a single-signon solution between different organizations/websites. I start as an authenticated user on one organization's website, convert specific information into an Xml document, encrypt the document with triple des, and send that over as a post variable to the second organizations login page.</p> <p><strong>Question:</strong></p> <p>Once I have my xml data packaged, how do I programmatically perform a post to the second website and have the user's browser redirected to the second website as well.</p> <p>This should behave just like having a form like: </p> <p><em>action="http://www.www.com/posthere" method="post"</em></p> <p>... and having a hidden text field like: </p> <p><em>input type="hidden" value="my encrypted xml"</em></p> <p>This is being written in asp.net 2.0 webforms.</p> <p>--</p> <p><strong>Edit:</strong> Nic asks why the html form I describe above will not work. Answer: I have no control over either site; I am building the "middle man" that makes all of this happen. Site 1 is forwarding a user to the page that I am making, I have to build the XML, and then forward it to site 2. Site 1 does not want the user to know about my site, the redirect should be transparent. </p> <p>The process I have described above is what both parties (site A and site B) mandate.</p>
[ { "answer_id": 234851, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "...headers left out...\n\n<script type='text/javascript'>\n\n$(document).ready( function() {\n $('form:first').submit(...
2008/10/24
[ "https://Stackoverflow.com/questions/233691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
233,702
<p>I had a VBA project in outlook with a few email macros - but after a PC crash they are all gone and all I see is a fresh 'Project1' when I hit Alt+F11</p> <p>I'm not a VBA programmer, but had a collection of handy macros for email sorting etc. I would not like to have to code them again. Anyone know where the code files should be on the filesystem so that I might rescue the code?</p>
[ { "answer_id": 35205762, "author": "Heider Sati", "author_id": 1915577, "author_profile": "https://Stackoverflow.com/users/1915577", "pm_score": 2, "selected": false, "text": "C:\\Users\\(***Your User Name***)\\AppData\\Roaming\\Microsoft\\Outlook\\VbaProject.OTM\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3024/" ]
233,706
<p>i have a data access layer which returns data from stored procedures. If i bind this to a gridview control in asp.net 2.0, the users then have an option of filtering on that data select list where in they can choose the conditional clause of </p> <ul> <li><p>like</p></li> <li><p>=</p></li> <li><p>or</p></li> <li><p>and</p></li> </ul> <p>Once the result is returned, I do not want to hit the Db again with the filters applied.</p> <p>I have an option to use .net 3.5 if the need be. i looked at this: <a href="http://weblogs.asp.net/jgaylord/archive/2006/05/31/Filter-A-GridView-After-The-Initial-Bind.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/jgaylord/archive/2006/05/31/Filter-A-GridView-After-The-Initial-Bind.aspx</a></p> <p>and not sure of its efficiency.</p>
[ { "answer_id": 35205762, "author": "Heider Sati", "author_id": 1915577, "author_profile": "https://Stackoverflow.com/users/1915577", "pm_score": 2, "selected": false, "text": "C:\\Users\\(***Your User Name***)\\AppData\\Roaming\\Microsoft\\Outlook\\VbaProject.OTM\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
233,711
<p>I use an anonymous object to pass my Html Attributes to some helper methods. If the consumer didn't add an ID attribute, I want to add it in my helper method.</p> <p>How can I add an attribute to this anonymous object?</p>
[ { "answer_id": 233730, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": false, "text": "new { Name1=value1, Name2=value2}" }, { "answer_id": 233810, "author": "Boris Callens", "author_id": 113...
2008/10/24
[ "https://Stackoverflow.com/questions/233711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
233,718
<p>This question is about App domains and Sessions. Is it possible to have IIS run each User Session in a seperate App Domain. If Yes, Could you please let me settings in the config file that affect this.</p> <p>Regards, Anil.</p>
[ { "answer_id": 233730, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": false, "text": "new { Name1=value1, Name2=value2}" }, { "answer_id": 233810, "author": "Boris Callens", "author_id": 113...
2008/10/24
[ "https://Stackoverflow.com/questions/233718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
233,719
<p>I'm trying to read the contents of the clipboard using JavaScript. With Internet Explorer it's possible using the function</p> <pre><code>window.clipboardData.getData(&quot;Text&quot;) </code></pre> <p>Is there a similar way of reading the clipboard in Firefox, Safari and Chrome?</p>
[ { "answer_id": 234711, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 5, "selected": true, "text": "onpaste" }, { "answer_id": 54373125, "author": "Kim", "author_id": 2396925, "author_profile": "h...
2008/10/24
[ "https://Stackoverflow.com/questions/233719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25960/" ]
233,721
<p>As per RFC1035, dns names may contain \ddd \x and quote symbol. Please explain with examples about those.</p>
[ { "answer_id": 233941, "author": "jj33", "author_id": 430, "author_profile": "https://Stackoverflow.com/users/430", "pm_score": 2, "selected": false, "text": "Although labels can contain any 8 bit values in octets that make up a\nlabel, it is strongly recommended that labels follow the p...
2008/10/24
[ "https://Stackoverflow.com/questions/233721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
233,749
<p>I have this loop, which I am using to get the values of all cells within all rows of a gridview and then write it to a csv file. My loop looks like this:</p> <pre><code>string filename = @"C:\Users\gurdip.sira\Documents\Visual Studio 2008\WebSites\Supressions\APP_DATA\surpressionstest.csv"; StreamWriter sWriter = new StreamWriter(filename); string Str = string.Empty; string headertext = ""; sWriter.WriteLine(headertext); for (int i = 0; i &lt;= (this.GridView3.Rows.Count - 1); i++) { for (int j = 0; j &lt;= (this.GridView3.Columns.Count - 1); j++) { Str = this.GridView3.Rows[i].Cells[j].Text.ToString(); sWriter.Write(Str); } sWriter.WriteLine(); } sWriter.Close(); </code></pre> <p>The problem with this code is that, when stepping through, the 2nd loop (the one going through the columns) does not begin as the debugger does not hit this loop and thus my file is empty.</p> <p>Any ideas on what is causing this? The code itself looks fine.</p> <p>Thanks</p>
[ { "answer_id": 233891, "author": "EFrank", "author_id": 28572, "author_profile": "https://Stackoverflow.com/users/28572", "pm_score": 1, "selected": false, "text": " for (int i = 0; i <= (this.GridView3.Rows.Count - 1); i++)\n {\n\n for (int j = 0; j <= (this.GridView3.Rows[...
2008/10/24
[ "https://Stackoverflow.com/questions/233749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30004/" ]
233,756
<p>i've written a UserControl descendant that <strong>is</strong> in an assembly dll.</p> <p>How do i drop the control on a form?</p> <pre><code>namespace StackOverflowExample { public partial class MonthViewCalendar : UserControl { ... } } </code></pre> <p>i've added a reference to the assembly under the <strong>References</strong> node in the <strong>Solution Explorer</strong>, but no new control has appeared in my <strong>Toolbox</strong>.</p> <p>How do i make the control appear in the Toolbox so i can drop it on a form?</p> <hr> <p><strong>Update 1</strong>:</p> <p>i tried building the assembly while the Visual Studio option:</p> <p><strong>Tools</strong>--><strong>Options...</strong>--><strong>Windows Forms Designer</strong>--><strong>AutoToolboxPopulate</strong> = true</p> <p>The control didn't appear when in the toolbox in a new solution.</p> <p>Note: i somehow mistakenly wrote "...that is <em>not</em> in an assembly dll...". i don't know how i managed to write that, when it specifically <em>is</em> in an assembly dll. Controls have magically appeared when they're in the same project, but not now that it's a different project/solution.</p> <hr> <p><strong>Update 2: Answer</strong></p> <ol> <li>Right-click the <strong>Toolbox</strong></li> <li>Select <strong>Choose Items...</strong></li> <li><strong>.NET Framework Components</strong> tab</li> <li>Select <strong>Browse...</strong></li> <li><p>Browse to the <strong>assembly dll</strong> file that contains the control and select <strong>Open</strong></p> <p>Note: Controls in the assembly will silently be added to the list of .NET Framework Components.</p></li> <li><strong>Check</strong> each of the controls you wish to appear in the toolbox</li> <li>Select <strong>OK</strong></li> </ol>
[ { "answer_id": 233774, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 0, "selected": false, "text": "ToolboxItemAttribute" }, { "answer_id": 233958, "author": "Martin Marconcini", "author_id": 2684, "...
2008/10/24
[ "https://Stackoverflow.com/questions/233756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
233,759
<p>I was wondering if the C# project setting "Allow unsafe code" applies only to unsafe C# code in the project itself, or is it necessary to set this option when linking in a native C++ DLL? What about linking in a managed DLL that itself links to a native DLL? What does this option really do, under the hood?</p>
[ { "answer_id": 233763, "author": "Maxime Rouiller", "author_id": 24975, "author_profile": "https://Stackoverflow.com/users/24975", "pm_score": 3, "selected": false, "text": "unsafe(...)\n{\n}\n" }, { "answer_id": 233767, "author": "Jeff Yates", "author_id": 23234, "au...
2008/10/24
[ "https://Stackoverflow.com/questions/233759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
233,790
<p>Is there a way to colorize parts of logs in the eclipse console. I know I could send to error and standard streams and color them differently but I'm more looking someting in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed the colors in the string to have it colored in the logs.</p> <p>It sure would help making the important bits stand out without resorting to weird layout, rather keep the layout to the log4j setups </p> <p>here is an example of what I am looking for :</p> <p>[INFO ] The grid is complete ....... <strong>false</strong></p> <p>where the bold parts would be in blue, this coloring can be controlled by the application to an extent. like so (tags are conceptual and arbitrary, but you get the idea):</p> <p>log.info(String.format("The grid is complete ....... <code>&lt;blue&gt;</code>%s<code>&lt;/blue&gt;</code>", isComplete ));</p> <hr> <p>On a more general note it is the ability to embed meta information in the logs to help the presentation of these logs. Much like we tag web pages content to help the presentation of the information by CSS.</p>
[ { "answer_id": 1373290, "author": "Benjamin Seiller", "author_id": 167865, "author_profile": "https://Stackoverflow.com/users/167865", "pm_score": 7, "selected": true, "text": ".*" }, { "answer_id": 60434404, "author": "jajube", "author_id": 7915606, "author_profile":...
2008/10/24
[ "https://Stackoverflow.com/questions/233790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25812/" ]
233,793
<p>I'm trying to dynamically add some textboxes (input type=text) to a page in javascript and prefill them. The textboxes are coming up, but they are coming up empty. What is the proper way to pre-fill a textbox. Ideally I'd love to use the trick of creating a child div, setting the innerhtml property, and then adding that div to the parent main div but that didn't work. Then I thought I'd use the dom but setting textboxname.value before or after insertion won't work and doing txttextbox.setattribute('value','somevalue') won't work either. Works fine in firefox. What gives? This has to be possible? Here is my code. I know I'm only using string literals, but these will be replaced with the results of a web service call eventually. Below is some code. Oh and how do you format code to show up as you type it? I thought it said to indent four spaces, and I did that but the code is still on one line. Sorry about that.</p> <pre><code>var table=document.createElement('table'); var tbody=document.createElement('tbody'); var row=document.createElement('tr'); row.appendChild(document.createElement('td').appendChild(document.createTextNode('E-mail'))); var txtEmail=document.createElement('input'); row.appendChild(document.createElement('td').appendChild(txtEmail)); tbody.appendChild(row); table.appendChild(tbody); //document.getElementById('additionalEmails').innerHTML=""; document.getElementById('additionalEmails').appendChild(table); </code></pre>
[ { "answer_id": 233815, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "txtEmail.value = 'my text'\n" }, { "answer_id": 233853, "author": "Diodeus - James MacFarlane", "author...
2008/10/24
[ "https://Stackoverflow.com/questions/233793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16891/" ]
233,802
<p>I am trying to detect Blackberry user agents in my app, which works fine in my development version. But nothing happens when I redeploy the app in production.</p> <p>application_helper.rb</p> <pre><code> def blackberry_user_agent? request.env["HTTP_USER_AGENT"] &amp;&amp; request.env["HTTP_USER_AGENT"][/(Blackberry)/] end </code></pre> <p>application.html.erb</p> <pre><code>&lt;% if blackberry_user_agent? -%&gt; &lt;div class="message"&gt; &lt;p&gt;Using a Blackberry? &lt;a href="http://mobile.site.ca/"&gt;Use the mobile optimized version&lt;/a&gt;.&lt;/p&gt; &lt;/div&gt; </code></pre> <p>I've tried clearing the cache using rake tmp:cache:clear and restarted mongrel a few times. Apparently the HTTP_USER_AGENT is coming back nil in production. I am using Nginx with a mongrel cluster.</p>
[ { "answer_id": 233986, "author": "Mike Breen", "author_id": 22346, "author_profile": "https://Stackoverflow.com/users/22346", "pm_score": 3, "selected": true, "text": "log_format main '$remote_addr - $remote_user [$time_local] $request '\n '\"$status\" $body_bytes_sent \...
2008/10/24
[ "https://Stackoverflow.com/questions/233802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
233,828
<p>Let's say you have a aspx page that does not rely on session, but does rely on viewstate for persistance between postbacks. </p> <p>If a user is accessing this page, and leaves for a long lunch, will viewstate still be valid when he returns?</p>
[ { "answer_id": 5377527, "author": "AareP", "author_id": 11741, "author_profile": "https://Stackoverflow.com/users/11741", "pm_score": 3, "selected": false, "text": "<sessionPageState historySize=\"9\"/>" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21155/" ]
233,842
<p>I am using VB.Net WinForms. I would like to call the Adobe Reader 9 ActiveX control to print some PDFs. I have added the ActiveX control to the VS toolbox (the dll is AcroPDF.dll, the COM name "Adobe PDF Reader". After some experiment the following code works.</p> <pre><code>Dim files As String() = Directory.GetFiles(TextBoxPath.Text, "*.pdf", SearchOption.TopDirectoryOnly) Using ActiveXPDF As New AxAcroPDFLib.AxAcroPDF Me.Controls.Add(ActiveXPDF) ActiveXPDF.Hide() For Each filename As String In files ActiveXPDF.LoadFile(filename) ActiveXPDF.printAll() 'Begin Yukky Hack ' Dim endTime As Date = DateAdd(DateInterval.Second, 20, Now) Do While Now &lt; endTime My.Application.DoEvents() Loop 'End Yuk ' Next End Using </code></pre> <p>Without the Yuk bit this will only print some of the PDFs, it seems that the End Using statement is calling dispose on the control before it has finished printing.</p> <p>Therefore it seems the call to printAll is non-blocking but I can't find a callback or status property I can query to see if the print spooling has been completed. I am missing a property/method or is there a more elegant (and more responsive) work around?</p>
[ { "answer_id": 1862454, "author": "Ed Zenker", "author_id": 226624, "author_profile": "https://Stackoverflow.com/users/226624", "pm_score": -1, "selected": false, "text": "Sub Show_Document(ByVal FILENAME As String)\n Dim p As Process = Nothing\n Try\n If My.Computer.FileSys...
2008/10/24
[ "https://Stackoverflow.com/questions/233842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29411/" ]
233,850
<p>What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confusing.</p> <p>Most tetris games seem to use a naive "remake the array of blocks" at each rotation:</p> <p><a href="http://www.codeplex.com/Project/ProjectDirectory.aspx?ProjectSearchText=tetris" rel="noreferrer">http://www.codeplex.com/Project/ProjectDirectory.aspx?ProjectSearchText=tetris</a></p> <p>However, some use pre-built encoded numbers and bit shifting to represent each piece:</p> <p><a href="http://www.codeplex.com/wintris" rel="noreferrer">http://www.codeplex.com/wintris</a></p> <p>Is there a method to do this using mathematics (not sure that would work on a cell based board)?</p>
[ { "answer_id": 233882, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 5, "selected": false, "text": "[ 0 1 ]\n[ -1 0 ]\n" }, { "answer_id": 233894, "author": "Jon Skeet", "author_id": 22656, "a...
2008/10/24
[ "https://Stackoverflow.com/questions/233850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21826/" ]
233,870
<p>I know the statement:</p> <pre><code>create table xyz_new as select * from xyz; </code></pre> <p>Which copies the structure and the data, but what if I just want the structure?</p>
[ { "answer_id": 233890, "author": "Jim Hudson", "author_id": 8051, "author_profile": "https://Stackoverflow.com/users/8051", "pm_score": 10, "selected": true, "text": "create table xyz_new as select * from xyz where 1=0;\n" }, { "answer_id": 240371, "author": "Dave Costa", ...
2008/10/24
[ "https://Stackoverflow.com/questions/233870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
233,905
<p>Is is better to do a joined query like this:</p> <pre><code>var employer = (from person in db.People join employer in db.Employers on person.EmployerID equals employer.EmployerID where person.PersonID == idPerson select employer).FirstOrDefault(); </code></pre> <p>Or is it just as good to do the easy thing and do this (with null checks):</p> <pre><code>var employer = (from person in db.People where person.PersonID == idPerson select person).FirstOrDefault().Employer; </code></pre> <p>Obviously, in this one I would actually have to do it in 2 statements to get in the null check.</p> <p>Is there any sort of best practice here for either readability or performance issues?</p>
[ { "answer_id": 233943, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "var employer = (from person in db.People\n where person.PersonID == idPerson\n select perso...
2008/10/24
[ "https://Stackoverflow.com/questions/233905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4797/" ]
233,908
<p>I need to replace some 2- and 3-digit numbers with the same number plus 10000. So</p> <pre><code>Photo.123.aspx </code></pre> <p>needs to become</p> <pre><code>Photo.10123.aspx </code></pre> <p>and also</p> <pre><code>Photo.12.aspx </code></pre> <p>needs to become</p> <pre><code>Photo.10012.aspx </code></pre> <p>I know that in .NET I can delegate the replacement to a function and just add 10000 to the number, but I'd rather stick to garden-variety RegEx if I can. Any ideas?</p>
[ { "answer_id": 233977, "author": "wprl", "author_id": 17847, "author_profile": "https://Stackoverflow.com/users/17847", "pm_score": 1, "selected": false, "text": "Photo\\.{\\d\\d\\d}\\.aspx" }, { "answer_id": 234026, "author": "James Curran", "author_id": 12725, "auth...
2008/10/24
[ "https://Stackoverflow.com/questions/233908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
233,911
<p>Im currently using ie as an active x com thing on wxWidgets and was wanting to know if there is any easy way to change the user agent that will always work.</p> <p>Atm im changing the header but this only works when i manually load the link (i.e. call setUrl)</p>
[ { "answer_id": 235713, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 3, "selected": true, "text": "DISPID_AMBIENT_USERAGENT" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
233,916
<p>I have a WinForms app with an input textbox, button, and a multiline output textbox. A root path is entered in the textbox. Button click calls a function to recursively check all subdirectories for some proper directory naming validation check. The results are output into the multiline textbox.</p> <p>If the recursive work is done in a separate class, I have two options:</p> <ol> <li><p>Keep track of improper directories in a class property(e.g. ArrayList),return the ArrayList when done, and update the output textbox with all results.</p></li> <li><p>Pass in ByRef the output textbox and update/refresh it for each improper directory. Even though 1 &amp; 2 are single-threaded, with 2, I would at least get my results updated per directory.</p></li> </ol> <p>If the recursive work is done in the presentation layer and the validation is done in a separate class, I can multithread.</p> <p>Which is a cleaner way?</p>
[ { "answer_id": 233974, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 2, "selected": false, "text": "List<string>" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
233,919
<p>I have been working with T-SQL in MS SQL for some time now and somehow whenever I have to insert data into a table I tend to use syntax:</p> <pre><code>INSERT INTO myTable &lt;something here&gt; </code></pre> <p>I understand that keyword <code>INTO</code> is optional here and I do not have to use it but somehow it grew into habit in my case.</p> <p>My question is: </p> <ul> <li>Are there any implications of using <code>INSERT</code> syntax versus <code>INSERT INTO</code>?</li> <li>Which one complies fully with the standard?</li> <li>Are they both valid in other implementations of SQL standard?</li> </ul>
[ { "answer_id": 233945, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 8, "selected": true, "text": "INSERT INTO" }, { "answer_id": 233962, "author": "Tomalak", "author_id": 18771, "author_profile":...
2008/10/24
[ "https://Stackoverflow.com/questions/233919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241/" ]
233,922
<p>I have this code to give me a rollover on submit buttons, and I'm trying to make it more generic:</p> <pre><code>$('.rollover').hover( function(){ // Change the input image's source when we "roll on" srcPath = $(this).attr("src"); srcPathOver = ??????? /*need to manipulate srcPath to change from img/content/go-button.gif into img/content/go-button-over.gif */ $(this).attr({ src : srcPathOver}); }, function(){ // Change the input image's source back to the default on "roll off" $(this).attr({ src : srcPath}); } ); </code></pre> <p>Two things really,</p> <p>I want to learn how manipulate the <code>srcPath</code> variable to append the text '-over' onto the gif filename, to give a new image for the rollover. Can anyone suggest a way to do this?</p> <p>Also, can someone tell me if this code could be refined at all? I'm a bit new to jQuery and wondered if the syntax could be improved upon.</p> <p>Many thanks.</p>
[ { "answer_id": 234025, "author": "Matt Ephraim", "author_id": 22291, "author_profile": "https://Stackoverflow.com/users/22291", "pm_score": 2, "selected": false, "text": "srcPathOver = srcPath.replace(/([^.]*)\\.(.*)/, \"$1-over.$2\");\n" }, { "answer_id": 234028, "author": "...
2008/10/24
[ "https://Stackoverflow.com/questions/233922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
233,936
<p>Ok let me make an example:</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#options_2").hide(); $("#options_3").hide(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="options_1"&gt;option 1&lt;/div&gt; &lt;div id="options_2"&gt;option 2&lt;/div&gt; &lt;div id="options_3"&gt;option 3&lt;/div&gt; &lt;a href="" class="selected"&gt;choose option 1&lt;/a&gt; &lt;a href=""&gt;choose option 2&lt;/a&gt; &lt;a href=""&gt;choose option 3&lt;/a&gt; &lt;/body&gt; </code></pre> <p>As you can see only option 1 is visible by default, and the link you click to show option 1 has the class="selected" by default, showing the user that that option is currently selected. I basically want it so that when they click "choose option 2" the options 1 div hides itself and the options 2 div shows itself, and then gives the second link the selected class and removes the class from the image link.</p> <p>It basically just tabs using links and divs but due to the format I have to display it in I cannot use any of the tabs plugins I have found online.</p>
[ { "answer_id": 234009, "author": "Wayne Austin", "author_id": 31109, "author_profile": "https://Stackoverflow.com/users/31109", "pm_score": 2, "selected": false, "text": "$('a#link_1').click(function() {\n $(this).attr(\"class\", \"selected\");\n $(this).siblings('a').removeClass...
2008/10/24
[ "https://Stackoverflow.com/questions/233936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
233,966
<p>I have a great deal of data to keep synchronized over 4 or 5 sites around the world, around half a terabyte at each site. This changes (either adds or changes) by around 1.4 Gigabytes per day, and the data can change at any of the four sites.</p> <p>A large percentage (30%) of the data is duplicate packages (Perhaps packaged-up JDKs), so the solution would have to include a way of picking up the fact that there are such things lying aruond on the local machine and grab them instead of downloading from another site.</p> <p>The control of versioning is not an issue, this is not a codebase per-se.</p> <p>I'm just interested if there are any solutions out there (preferably open-source) that get close to such a thing? </p> <p>My baby script using rsync doesn't cut the mustard any more, I'd like to do more complex, intelligent synchronization.</p> <p>Thanks</p> <p>Edit : This should be UNIX based :)</p>
[ { "answer_id": 236271, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 0, "selected": false, "text": "detect-renamed" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/233966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31161/" ]
233,979
<p>I am trying to link to a file that has the '#' character in via a window.open() call. The file does exist and can be linked to just fine using a normal anchor tag.</p> <p>I have tried escaping the '#' character with '%23' but when the window.open(myurl) gets processed, the '%23' becomes '%2523'. This tells me that my url string is being escapped by the window.open call changing the '%' to the '%25'.</p> <p>Are there ways to work around this extra escaping.</p> <p>Sample code:</p> <pre><code>&lt;script language="javascript"&gt; function escapePound(url) { // original attempt newUrl = url.replace("#", "%23"); // first answer attempt - doesn't work // newUrl = url.replace("#", "\\#"); return newUrl; } &lt;/script&gt; &lt;a href="#top" onclick="url = '\\\\MyUNCPath\\PropertyRushRefi-Add#1-ABCDEF.RTF'; window.open(escapePound(url)); return true;"&gt;Some Doc&lt;/a&gt; </code></pre> <p>URL that yells says "file://MyUNCPath/PropertyRushRefi-Add%25231-ABCDEF.RTF" cannot be found</p>
[ { "answer_id": 234002, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": "\\#\n" }, { "answer_id": 234031, "author": "Rahul", "author_id": 16308, "author_profile": "https://...
2008/10/24
[ "https://Stackoverflow.com/questions/233979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18284/" ]
234,008
<p>I need to create at runtime instances of a class that uses generics, like <code>class&lt;T&gt;</code>, without knowing previously the type T they will have, I would like to do something like that:</p> <pre><code>public Dictionary&lt;Type, object&gt; GenerateLists(List&lt;Type&gt; types) { Dictionary&lt;Type, object&gt; lists = new Dictionary&lt;Type, object&gt;(); foreach (Type type in types) { lists.Add(type, new List&lt;type&gt;()); /* this new List&lt;type&gt;() doesn't work */ } return lists; } </code></pre> <p>...but I can't. I think it is not possible to write in C# inside the generic brackets a type variable. Is there another way to do it?</p>
[ { "answer_id": 234016, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "public Dictionary<Type, object> GenerateLists(List<Type> types)\n{\n Dictionary<Type, object> lists = new Dictionary<T...
2008/10/24
[ "https://Stackoverflow.com/questions/234008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
234,024
<p>I have an array I've created in JavaScript. The end result comes out to element1,element2,,,element5,element6,,,element9.... etc</p> <p>Once passed to ColdFusion, it removes the null elements, I end up with element1,element2,element5,element6,element9</p> <p>I need to maintain these spaces, any ideas? My problem may begin before this, to explain in more detail...</p> <p>I have a form with 13 elements that are acting as a search/filter type function. I want to "post" with AJAX, in essence, i'm using a button to call a jQuery function and want to pass the fields to a ColdFusion page, then have the results passed back. The JavaScript array may not even be my best option.</p> <p>Any ideas?</p>
[ { "answer_id": 452284, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<cfset jsList = \"item1,item2,,item4,item5,,item6\">\n<cfset jsArray = jsList.split(\",\")>\n<cfdump var=\"#jsArray#\">\n" }...
2008/10/24
[ "https://Stackoverflow.com/questions/234024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
234,027
<p>How can I find the index in a string that matches a boost regex?</p>
[ { "answer_id": 234248, "author": "Anthony Williams", "author_id": 5597, "author_profile": "https://Stackoverflow.com/users/5597", "pm_score": 3, "selected": false, "text": "position" }, { "answer_id": 234277, "author": "Paolo Tedesco", "author_id": 15622, "author_prof...
2008/10/24
[ "https://Stackoverflow.com/questions/234027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
234,056
<p>Anyone got a ready made function that will take an XML string and return a correctly indented string?</p> <p>eg</p> <pre><code>&lt;XML&gt;&lt;TAG1&gt;A&lt;/TAG1&gt;&lt;TAG2&gt;&lt;Tag3&gt;&lt;/Tag3&gt;&lt;/TAG2&gt;&lt;/XML&gt; </code></pre> <p>and will return nicely formatted String in return after inserting linebreaks and tabs or spaces?</p>
[ { "answer_id": 234101, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 3, "selected": false, "text": "program TestIndentXML;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n OmniXML,\n OmniXMLUtils;\n\nfunction IndentXML(const xml:...
2008/10/24
[ "https://Stackoverflow.com/questions/234056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6244/" ]
234,059
<p>I have the following code:</p> <pre><code>MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } </code></pre> <p>Is there any chance that the MemoryStream that I've allocated will somehow fail to be disposed of later? </p> <p>I've got a peer review insisting that I manually close this, and I can't find the information to tell if he has a valid point or not.</p>
[ { "answer_id": 234071, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 7, "selected": true, "text": "using" }, { "answer_id": 234080, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https:/...
2008/10/24
[ "https://Stackoverflow.com/questions/234059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
234,064
<p>Using data binding, how do you bind a new object that uses value types? </p> <p>Simple example:</p> <pre><code>public class Person() { private string _firstName; private DateTime _birthdate; private int _favoriteNumber; //Properties } </code></pre> <p>If I create a new Person() and bind it to a form with text boxes. Birth Date displays as 01/01/0001 and Favorite Number as 0. These fields are required, but I would like these boxes to be empty and have the user fill them in.</p> <p>The solution also needs to be able to default fields. In our example, I may want the Favorite Number to default to 42.</p> <p>I'm specifically asking about Silverlight, but I assume WPF and WinForms probably have the same issue.</p> <p><b>EDIT:</b></p> <p>I thought of Nullable types, however we are currently using the same domain objects on client and server and I don't want to have required fields be Nullable. I'm hoping the databinding engine exposes a way to know it is binding a new object?</p>
[ { "answer_id": 234155, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 2, "selected": false, "text": "public class Person() {\n private string? _firstName;\n private DateTime? _birthdate;\n private int? _favoriteNumber...
2008/10/24
[ "https://Stackoverflow.com/questions/234064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4231/" ]
234,076
<p>I have a "Login" button that I want to be disabled until 3 text boxes on the same WPF form are populated with text (user, password, server). </p> <p>I have a backing object with a boolean property called IsLoginEnabled which returns True if and only if all 3 controls have data. However, when should I be checking this property? Should it be on the LostFocus event of each of the 3 dependent controls?</p> <p>Thanks!</p> <p>vg1890</p>
[ { "answer_id": 234158, "author": "Andrew", "author_id": 5662, "author_profile": "https://Stackoverflow.com/users/5662", "pm_score": 2, "selected": true, "text": "IsLoginEnabled" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/234076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
234,090
<p>How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code:</p> <pre><code>&lt;input name = "deleteGameButton" type = "submit" value = "Delete" onclick = "submitToServlet('DeleteGameServlet');"&gt; </code></pre> <p>Here is the corresponding javascript:</p> <pre><code> function submitToServlet(newAction) { document.userGameForm.action = newAction; } </code></pre> <p>I'd like the servlet to have access to userBean</p> <pre><code> &lt;jsp:useBean id = "userBean" scope = "session" class = "org.project.User" /&gt; </code></pre>
[ { "answer_id": 234127, "author": "David Santamaria", "author_id": 24097, "author_profile": "https://Stackoverflow.com/users/24097", "pm_score": 0, "selected": false, "text": "<jsp:useBean id = \"userBean\" scope = \"session\" class = \"org.project.User\"/>\n <jsp:setProperty name=\"beanN...
2008/10/24
[ "https://Stackoverflow.com/questions/234090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25280/" ]
234,091
<p>We have a highly specialized DAL which sits over our DB. Our apps need to use this DAL to correctly operate against this DB.</p> <p>The generated DAL (which sits on some custom base classes) has various 'Rec' classes (Table1Rec, Table2Rec) each of which represents the record structure of a given table.</p> <p>Here is a sample Pseudo-class...</p> <pre><code>Public Class SomeTableRec Private mField1 As String Private mField1isNull As Boolean Private mField2 As Integer Private mField2isNull As Boolean Public Sub New() mField1isNull = True mField2isNull = True End Sub Public Property Field1() As String Get Return mField1 End Get Set(ByVal value As String) mField1 = value mField1isNull = False End Set End Property Public ReadOnly Property Field1isNull() As Boolean Get Return mField1isNull End Get End Property Public Property Field2() As Integer Get Return mField2 End Get Set(ByVal value As Integer) mField2 = value mField2isNull = False End Set End Property Public ReadOnly Property Field2isNull() As Boolean Get Return mField2isNull End Get End Property End Class </code></pre> <p>Each class has properties for each of the fields... Thus I can write...</p> <pre><code>Dim Rec as New Table1Rec Table1Rec.Field1 = "SomeString" Table2Rec.Field2 = 500 </code></pre> <p>Where a field can accept a NULL value, there is an additional property which indicates if the value is currently null.</p> <p>Thus....</p> <pre><code>Dim Rec as New Table1Rec Table1Rec.Field1 = "SomeString" If Table1Rec.Field1Null then ' This clearly is not true End If If Table1Rec.Field2Null then ' This will be true End If </code></pre> <p>This works because the constructor of the class sets all NULLproperties to True and the setting of any FieldProperty will cause the equivalent NullProperty to be set to false.</p> <p>I have recently had the need to expose my DAL over the web through a web service (which I of course intend to secure) and have discovered that while the structure of the 'Rec' class remains intact over the web... All logic is lost..</p> <p>If someone were to run the previous piece of code remotely they would notice that neither condition would prove true as there is no client side code which sets null to true.</p> <p><strong>I get the feeling I have architected this all wrong, but cannot see how I should improve it.</strong></p> <p><strong>What is the correct way to architect this?</strong></p>
[ { "answer_id": 614630, "author": "digiguru", "author_id": 5055, "author_profile": "https://Stackoverflow.com/users/5055", "pm_score": 2, "selected": true, "text": "Imports System.Web\nImports System.Web.Services\nImports System.Web.Services.Protocols\n\n<WebService(Namespace:=\"http://te...
2008/10/24
[ "https://Stackoverflow.com/questions/234091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
234,131
<p>I did this tests and the results seems the count function scale linearly. I have another function relying strongly in the efficiency to know if there are any data, so I would like to know how to replace this select count(*) with another more efficient (maybe constant?) query or data structure.</p> <blockquote> <p>psql -d testdb -U postgres -f truncate_and_insert_1000_rows.sql > NUL</p> <p>psql -d testdb -U postgres -f count_data.sql</p> </blockquote> <h2>--------------------------------------------------------------------------------</h2> <p>Aggregate (cost=36.75..36.76 rows=1 width=0) (actual time=0.762..0.763 rows=1 loops=1) -> Seq Scan on datos (cost=0.00..31.40 rows=2140 width=0) (actual time=0.02 8..0.468 rows=1000 loops=1) Total runtime: <strong>0.846 ms</strong> (3 filas)</p> <blockquote> <p>psql -d testdb -U postgres -f truncate_and_insert_10000_rows.sql > NUL</p> <p>psql -d testdb -U postgres -f count_data.sql</p> </blockquote> <h2>--------------------------------------------------------------------------------</h2> <p>Aggregate (cost=197.84..197.85 rows=1 width=0) (actual time=6.191..6.191 rows= 1 loops=1) -> Seq Scan on datos (cost=0.00..173.07 rows=9907 width=0) (actual time=0.0 09..3.407 rows=10000 loops=1) Total runtime: <strong>6.271 ms</strong> (3 filas)</p> <blockquote> <p>psql -d testdb -U postgres -f truncate_and_insert_100000_rows.sql > NUL</p> <p>psql -d testdb -U postgres -f count_data.sql</p> </blockquote> <h2>--------------------------------------------------------------------------------</h2> <p>Aggregate (cost=2051.60..2051.61 rows=1 width=0) (actual time=74.075..74.076 r ows=1 loops=1) -> Seq Scan on datos (cost=0.00..1788.48 rows=105248 width=0) (actual time= 0.032..46.024 rows=100000 loops=1) Total runtime: <strong>74.164 ms</strong> (3 filas)</p> <blockquote> <p>psql -d prueba -U postgres -f truncate_and_insert_1000000_rows.sql > NUL</p> <p>psql -d testdb -U postgres -f count_data.sql</p> </blockquote> <h2>--------------------------------------------------------------------------------</h2> <p>Aggregate (cost=19720.00..19720.01 rows=1 width=0) (actual time=637.486..637.4 87 rows=1 loops=1) -> Seq Scan on datos (cost=0.00..17246.60 rows=989360 width=0) (actual time =0.028..358.831 rows=1000000 loops=1) Total runtime: <strong>637.582 ms</strong> (3 filas)</p> <p>the definition of data is</p> <pre><code>CREATE TABLE data ( id INTEGER NOT NULL, text VARCHAR(100), CONSTRAINT pk3 PRIMARY KEY (id) ); </code></pre>
[ { "answer_id": 234561, "author": "Patryk Kordylewski", "author_id": 30927, "author_profile": "https://Stackoverflow.com/users/30927", "pm_score": 2, "selected": false, "text": "SELECT t.primary_key IS NOT NULL FROM table t LIMIT 1;\n" }, { "answer_id": 1691576, "author": "Mic...
2008/10/24
[ "https://Stackoverflow.com/questions/234131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18300/" ]
234,171
<p>I have a string containing a date, and another string containing the date format of the first string. Is there a function that I can call to convert that date into something like a SYSTEMTIME structure? Basically, I'd like the opposite of <a href="http://msdn.microsoft.com/en-us/library/ms776293(VS.85).aspx" rel="nofollow noreferrer">GetDateFormat()</a>.</p>
[ { "answer_id": 234183, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 3, "selected": true, "text": "sscanf" }, { "answer_id": 234202, "author": "Anthony Williams", "author_id": 5597, "author_profile": "...
2008/10/24
[ "https://Stackoverflow.com/questions/234171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3857/" ]
234,177
<p>As usual, some background information first:</p> <p>Database A (Access database) - Holds a table that has information I need from only two columns. The information from these two columns is needed for an application that will be used by people that cannot access database A.</p> <p>Database B (Access database) - Holds a table that contains only two columns (mirrors to what we need from table A). Database B is accessible to all users of the application. One issue is that on of the column names is not the same as it is in the table from Database A.</p> <p>What I need to do is transfer the necessary data via a utility that will run automatically, say once a week (the two databases don't need to be totally in sync, just close). The transfer utility will be run from a user account that has access to both databases (obviously).</p> <p>Here's the approach I've taken (again if there is a better way, please suggest away):</p> <ol> <li><p>Grab the data from database A. It is only the two columns from the necessary table.</p></li> <li><p>Write the data out to [tablename].txt file using a DataReader object and WriterStream object. I've done this so I can use a schema.ini file and force the data columns to have the same name as they will be in Database B.</p></li> <li><p>Create a DataSet object, containing a DataTable that mirrors the table from Database B.</p></li> <li><p>Suck the information from the .txt file into the DataTable using the Microsoft.Jet.OLEDB.4.0 provider with extended properties of text, hdr=yes and fmt=delimited (to match how I have the schema.ini file setup and the .txt file setup). I'm using a DataAdapter to fill the DataTable.</p></li> <li><p>Create another DataSet object, containing a DataTable that mirrors the table from Database B. </p></li> <li><p>Suck in the information from Database B so that it contains all the current data found in the table that needs to be updated from Database A. Again I'm using a DataAdapter to fill this DataTable (a different one from Step 5, since they are both using different data sources).</p></li> <li><p>Merge the DataTable that holds the data from Database A (or the .txt file, technically).</p></li> <li><p>Update Database B's table with the changes.</p></li> </ol> <p>I've written update, delete and insert commands manually for the DataAdapter that is repsonsible for talking to Database B. However, this logic is never used because the DataSet-From-Database-B.Merge(Dataset-From-TxtFile[tableName]) doesn't flip the HasChanges flag. This means the DataSet-From-Database-B.Update doesn't fire any of the commands.</p> <p>So is there any way I can get the data from DataSet-From-TxtFile to merge and apply to Database B using the method I'm using? Am I missing a crucial step here?</p> <p>I know I could always delete all the records from Database B's table and then just insert all the records from the text file (even if I had to loop through each record in the DataSet and apply row.SetAdded to ensure it triggers the HasChanges flag), but I'd rather have it apply ONLY the changes each time.</p> <p>I'm using c# and the 2.0 Framework (which I realize means I can use DataTables and TableAdapters instead of DataSets and DataAdapters since I'm only dealing with a single table, but anyway).</p> <p>TIA</p>
[ { "answer_id": 234415, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "DataTable A = load table from A\nDataTable B = load table from B\n\nforeach row in A\n col1 = row[col1]\n col2 = row...
2008/10/24
[ "https://Stackoverflow.com/questions/234177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9732/" ]
234,181
<p>I have a sorted collection of objects (it can be either SortedList or SortedDictionary, I will use it mainly for reading so add performance is not that important). How can I get the i-th value?</p> <p>So e.g. when I have numbers 1, 2, 3, 4, 5 in the collection and I want the median (so 3 in this example), how can I do it?</p>
[ { "answer_id": 234259, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 5, "selected": false, "text": "list.Values[index] \n" }, { "answer_id": 42473025, "author": "mudrak patel", "author_id": 6452486, "aut...
2008/10/24
[ "https://Stackoverflow.com/questions/234181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5363/" ]
234,210
<p>I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions.</p> <p>Mapping everything under my context path to the front controller (let's call it "<strong>app</strong>") means I should take care of static files also, something I'd rather not do (why reinvent yet another weel?), so some combination with tomcat's default servlet (let's call it "<strong>tomcat</strong>") appears to be the way to go.</p> <p>I got the thing to work doing something like </p> <pre class="lang-xml prettyprint-override"><code>&lt;servlet-mapping&gt; &lt;servlet-name&gt;app&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;tomcat&lt;/servlet-name&gt; &lt;url-pattern&gt;*.ext&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>and repeating the latter for each one of the file extensions of my static content. I'm just wondering why the following setups, which to me are equivalent to the one above, don't work.</p> <pre class="lang-xml prettyprint-override"><code>&lt;!-- failed attempt #1 --&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;app&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;tomcat&lt;/servlet-name&gt; &lt;url-pattern&gt;*.ext&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;!-- failed attempt #2 --&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;app&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;tomcat&lt;/servlet-name&gt; &lt;url-pattern&gt;/some-static-content-folder/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>Can anyone shed some light?</p>
[ { "answer_id": 245143, "author": "Philip Tinney", "author_id": 14930, "author_profile": "https://Stackoverflow.com/users/14930", "pm_score": 6, "selected": true, "text": "/some-static-content-folder/" }, { "answer_id": 26670813, "author": "PragmaCoder", "author_id": 23189...
2008/10/24
[ "https://Stackoverflow.com/questions/234210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069/" ]
234,215
<p>I am creating a WordML document from an xml file whose elements sometimes contain html-formatted text. </p> <pre><code>&lt;w:p&gt; &lt;w:r&gt; &lt;w:t&gt; html formatted content is in here taken from xml file! &lt;/w:t&gt; &lt;/w:r&gt; &lt;/w:p&gt; </code></pre> <p>This is how my templates are sort of set up. I have a recursive call-template function that does text replacement against the source xml content. When it comes across a "<code>&lt;b&gt;</code>" tag, I output a string in CDATA containing "<code>&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:b/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;</code>" to close the current run and start up a new run with bold formatting enabled. when it gets to a "<code>&lt;/b&gt;</code>" tag, it replaces it with the following CDATA string "<code>&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;</code>".</p> <p>What I'd like to do is use XSL to close the run tag and start a new run without using CDATA string inserts. Is this possible?</p>
[ { "answer_id": 239235, "author": "GerG", "author_id": 17249, "author_profile": "https://Stackoverflow.com/users/17249", "pm_score": 0, "selected": false, "text": "b" }, { "answer_id": 240076, "author": "Andrew Cowenhoven", "author_id": 12281, "author_profile": "https:...
2008/10/24
[ "https://Stackoverflow.com/questions/234215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31229/" ]
234,217
<p><strong>Note: Mathematical expression evaluation is not the focus of this question. I want to compile and execute new code at runtime in .NET.</strong> That being said...</p> <p>I would like to allow the user to enter any equation, like the following, into a text box:</p> <pre><code>x = x / 2 * 0.07914 x = x^2 / 5 </code></pre> <p>And have that equation applied to incoming data points. The incoming data points are represented by <strong>x</strong> and each data point is processed by the user-specified equation. I did this years ago, but I didn't like the solution because it required parsing the text of the equation for every calculation:</p> <pre><code>float ApplyEquation (string equation, float dataPoint) { // parse the equation string and figure out how to do the math // lots of messy code here... } </code></pre> <p>When you're processing boatloads of data points, this introduces quite a bit of overhead. I would like to be able to translate the equation into a function, on the fly, so that it only has to be parsed once. It would look something like this:</p> <pre><code>FunctionPointer foo = ConvertEquationToCode(equation); .... x = foo(x); // I could then apply the equation to my incoming data like this </code></pre> <p>Function ConvertEquationToCode would parse the equation and return a pointer to a function that applies the appropriate math.</p> <p>The app would basically be writing new code at run time. Is this possible with .NET?</p>
[ { "answer_id": 234236, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 2, "selected": false, "text": "ConvertEquationToCode" }, { "answer_id": 234303, "author": "Brian Schmitt", "author_id": 30492, "author_...
2008/10/24
[ "https://Stackoverflow.com/questions/234217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
234,231
<p>How do you create an application shortcut (.lnk file) in C# or using the .NET framework?</p> <p>The result would be a .lnk file to the specified application or URL.</p>
[ { "answer_id": 234543, "author": "Charley Rathkopf", "author_id": 10119, "author_profile": "https://Stackoverflow.com/users/10119", "pm_score": 7, "selected": true, "text": "private static void configStep_addShortcutToStartupGroup()\n{\n using (ShellLink shortcut = new ShellLink())\n ...
2008/10/24
[ "https://Stackoverflow.com/questions/234231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10119/" ]
234,233
<p>I have two machines... a development machine and a production machine. When I first brought my rails app onto the production server, I had no problem. I simply imported schema.rb by running rake db:schema:load RAILS_ENV=production. All was well.</p> <p>So, then on my development machine, I made some more changes and another migration, and then copy the new application over to the production machine. I then tried to update the database by running rake db:migrate RAILS_ENV=production. I get the following error: "There is already an object named 'schema_migrations' in the database."</p> <p>I'm thinking to myself, ya no kidding Rake... you created it! I ran trace on rake and it seems as if rake thinks it's the first time it's ever ran. However, by analyzing my 'schema_migrations' table on my development machine and my production machine you can see that there is a difference of one migration, namely the one that I want to migrate.</p> <p>I have also tried to explicitly define the version number, but that doesn't work either.</p> <p>Any ideas on how I can bring my production server up to date?</p> <p><strong>Update:</strong></p> <p>Let me start off by saying that I can't just 'drop' the database. It's a production server with a little over 100k records already in it. What happens if a similar problem occurs in the future? Am, I to just drop the table every time a database problem occurs? It might work this time, but it doesn't seem like a practical long term solution to every database problem. I doubt the problem I'm having now is unique to me.</p> <ol> <li><p>It sounds like the 'schema_info' table and the 'schema_migrations' table are the same. In my setup, I only have 'schema_migrations'. As stated previously, the difference between the 'schema_migrations' table on the production server and the development machine is just one record. That is, the record containing the version number of the change I want to migrate.</p></li> <li><p>From the book I read, 'Simply Rails 2', it states that when first moving to a production server, instead of running rake db:migrate, one should just run rake:db:schema:load.</p></li> <li><p>If it matters, I'm using Rails version 2.1.</p></li> </ol>
[ { "answer_id": 235845, "author": "Ian Terrell", "author_id": 9269, "author_profile": "https://Stackoverflow.com/users/9269", "pm_score": -1, "selected": false, "text": "rake db:migrate RAILS_ENV=production\n" }, { "answer_id": 241846, "author": "Brad", "author_id": 31352,...
2008/10/24
[ "https://Stackoverflow.com/questions/234233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
234,239
<p>C# .NET 3.5. I'm trying to understand the intrinsic limitation of the C# Action object. Within the lamda (are those, in fact, lamdas?), we can perform assignments, call functions, even execute a ternary operation, but we can't execute a multi-statement operation.</p> <p>Is this because the single-statement execution is just syntactic sugar for wrapping it in a delegate? Why does the first example below not work?</p> <pre><code>public class MyClass { private int m_Count = 0; public void Test() { int value = 0; // Does not work, throws compile error Action action = () =&gt; { if(m_Count &lt; 10) m_Count++; value = m_Count; } // Works Action action2 = () =&gt; value = delegate(){ if(m_Count &lt; 10) m_Count++; return m_Count; }; // Works Action action3 = () =&gt; value = m_Count; // Works Action action4 = () =&gt; value = m_Count &lt; 10 ? m_Count++ : 0; // Works Action action5 = () =&gt; value = Increment(); } public int Increment() { if (m_Count &lt; 10) m_Count++; return m_Count; } } </code></pre> <p>EDIT: Grr, sorry for the noise. Originally, I had </p> <pre><code>Action action = () =&gt; if(m_Count &lt; 10) m_Count++; value = m_Count; </code></pre> <p>Which threw a compile error, but then right before the post I thought I'd try wrapping it in braces</p> <pre><code>Action action = () =&gt; { if(m_Count &lt; 10) m_Count++; value = m_Count; } </code></pre> <p>Which also threw a compile error, so I jumped to conclusions that it was the same problem. It works, though, if I toss in a semi-colon after the braces</p> <pre><code>Action action = () =&gt; { if(m_Count &lt; 10) m_Count++; value = m_Count; }; </code></pre> <p>Sorry for the noise!</p> <p>EDIT 2: Thanks cfeduke, you posted that at the same time as my edit above - went ahead and marked as answer. </p>
[ { "answer_id": 234266, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 5, "selected": true, "text": " Action action = () => { if (m_Count < 10) m_Count++; value = m_Count; };\n" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/234239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17803/" ]
234,241
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7094118/reference-comparing-phps-print-and-echo">Reference: Comparing PHP&#39;s print and echo</a> </p> </blockquote> <p>Is there any major and fundamental difference between these two functions in PHP?</p>
[ { "answer_id": 234255, "author": "dl__", "author_id": 28565, "author_profile": "https://Stackoverflow.com/users/28565", "pm_score": 9, "selected": true, "text": "print()" }, { "answer_id": 234258, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackov...
2008/10/24
[ "https://Stackoverflow.com/questions/234241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
234,249
<p>I'm trying to come up with a Java regex that will match a filename only if it has a valid extension. For example it should match "foo.bar" and "foo.b", but neither "foo." nor "foo".</p> <p>I've written the following test program</p> <pre><code>public static void main(String[] args) { Pattern fileExtensionPattern = Pattern.compile("\\.\\w+\\z"); boolean one = fileExtensionPattern.matcher("foo.bar").matches(); boolean two = fileExtensionPattern.matcher("foo.b").matches(); boolean three = fileExtensionPattern.matcher("foo.").matches(); boolean four = fileExtensionPattern.matcher("foo").matches(); System.out.println(one + " " + two + " " + three + " " + four); } </code></pre> <p>I expect this to print "true true false false", but instead it prints false for all 4 cases. Where am I going wrong?</p> <p>Cheers, Don</p>
[ { "answer_id": 234283, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": true, "text": ".*" }, { "answer_id": 234427, "author": "Bill K", "author_id": 12943, "author_profile": "https://...
2008/10/24
[ "https://Stackoverflow.com/questions/234249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
234,265
<p>I'm using Chris Pederick's Firefox addon <a href="http://chrispederick.com/work/web-developer/" rel="nofollow noreferrer">"Web Developer 1.1.6"</a>. I get this warning when hitting a certain web page on my site: </p> <blockquote> <p>Unknown property 'MozOpacity'. Declaration dropped.</p> </blockquote> <p>What does this mean and how can I fix this on my site?</p>
[ { "answer_id": 234271, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 1, "selected": false, "text": "mozopacity" } ]
2008/10/24
[ "https://Stackoverflow.com/questions/234265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8088/" ]