qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
308,456
<p>I have a table containing the runtimes for generators on different sites, and I want to select the most recent entry for each site. Each generator is run once or twice a week.</p> <p>I have a query that will do this, but I wonder if it's the best option. I can't help thinking that using WHERE x IN (SELECT ...) is lazy and not the best way to formulate the query - any query.</p> <p>The table is as follows:</p> <pre><code>CREATE TABLE generator_logs ( id integer NOT NULL, site_id character varying(4) NOT NULL, start timestamp without time zone NOT NULL, "end" timestamp without time zone NOT NULL, duration integer NOT NULL ); </code></pre> <p>And the query:</p> <pre><code>SELECT id, site_id, start, "end", duration FROM generator_logs WHERE start IN (SELECT MAX(start) AS start FROM generator_logs GROUP BY site_id) ORDER BY start DESC </code></pre> <p>There isn't a huge amount of data, so I'm not worried about optimizing the query. However, I do have to do similar things on tables with 10s of millions of rows, (big tables as far as I'm concerned!) and there optimisation is more important.</p> <p>So is there a better query for this, and are inline queries generally a bad idea?</p>
[ { "answer_id": 308471, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 0, "selected": false, "text": "$maxids = 'SELECT MAX(start) AS start FROM generator_logs GROUP BY site_id';\n$q =\" \n SELECT id, site_id, st...
2008/11/21
[ "https://Stackoverflow.com/questions/308456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33161/" ]
308,460
<p>I have been going back and forth between C# and Java for the last 8 years. </p> <p>One thing that strikes me is that I have completely stopped using the "Template Method" design pattern in C#. Actually, in C# I Have come to think of this pattern as an anti-pattern. </p> <p><a href="http://en.wikipedia.org/wiki/Template_method_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Template_method_pattern</a></p> <p>Coming back to Java, I find the pattern is alive and kicking. I still think it looks antique, but realise that there's no other way to do this in java. Java looks antique too ;)</p> <p>Since this is going to come up anyway, Why is it an antipattern ?</p> <ul> <li>A lot of times it uses up your inheritance hierarchy for "the wrong reasons".</li> <li>Base classes have a tendency to become littered with all sorts of unrelated code.</li> <li>It forces you to lock down design, often quite early in the development process. (Premature lock down in a lot of cases)</li> <li>Changing this at a later stage becomes just harder and harder.</li> </ul> <p>So with closures/delegates/function pointers, you normally pass around some function instead of subclassing.</p> <p>So back to the question: </p> <p>If your language has closures/delegates/function, do you use the Template Method, and when?</p>
[ { "answer_id": 3292618, "author": "dsimcha", "author_id": 23903, "author_profile": "https://Stackoverflow.com/users/23903", "pm_score": 2, "selected": false, "text": "doIt()" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
308,466
<p>I have to delete some rows from a data table. I've heard that it is not ok to change a collection while iterating through it. So instead of a for loop in which I check if a row meets the demands for deletion and then mark it as deleted, I should first iterate through the data table and add all of the rows in a list, then iterate through the list and mark the rows for deletions. What are the reasons for this, and what alternatives do I have (instead of using the rows list I mean)?.</p>
[ { "answer_id": 308486, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 5, "selected": true, "text": "for" }, { "answer_id": 308530, "author": "Andy Rose", "author_id": 1762, "author_profile": "https:/...
2008/11/21
[ "https://Stackoverflow.com/questions/308466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
308,476
<p>What is the fastest way to find out whether two <code>ICollection&lt;T&gt;</code> collections contain precisely the same entries? Brute force is clear, I was wondering if there is a more elegant method.</p> <p>We are using C# 2.0, so no extension methods if possible, please!</p> <p>Edit: the answer would be interesting both for ordered and unordered collections, and would hopefully be different for each.</p>
[ { "answer_id": 308524, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "[Tested]\n\npublic virtual bool ContainsAll<U>(SCG.IEnumerable<U> items) where U : T\n{\n HashBag<T> res = new HashBag<T>(item...
2008/11/21
[ "https://Stackoverflow.com/questions/308476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
308,477
<p>How much do using smart pointers, particularly boost::shared_ptr cost more compared to bare pointers in terms of time and memory? Is using bare pointers better for performance intensive parts of gaming/embedded systems? Would you recommend using bare pointers or smart pointers for performance intensive components? </p>
[ { "answer_id": 308507, "author": "Nicola Bonelli", "author_id": 19630, "author_profile": "https://Stackoverflow.com/users/19630", "pm_score": 3, "selected": false, "text": "shared_ptr<>" }, { "answer_id": 308661, "author": "MSalters", "author_id": 15416, "author_profi...
2008/11/21
[ "https://Stackoverflow.com/questions/308477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19501/" ]
308,479
<p>Can anybody help me out to know the possible reasons for which Apple store can reject or raise objection to submit any iPhone application.</p>
[ { "answer_id": 2624340, "author": "sixtyfootersdude", "author_id": 251589, "author_profile": "https://Stackoverflow.com/users/251589", "pm_score": 3, "selected": false, "text": "If (yes) reject" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39599/" ]
308,481
<p>I often use this recursive 'visitor' in F#</p> <pre><code>let rec visitor dir filter= seq { yield! Directory.GetFiles(dir, filter) for subdir in Directory.GetDirectories(dir) do yield! visitor subdir filter} </code></pre> <p>Recently I've started working on implementing some F# functionality in C#, and I'm trying to reproduce this as IEnumerable, but I'm having difficulty getting any further than this:</p> <pre><code>static IEnumerable&lt;string&gt; Visitor(string root, string filter) { foreach (var file in Directory.GetFiles(root, filter)) yield return file; foreach (var subdir in Directory.GetDirectories(root)) foreach (var file in Visitor(subdir, filter)) yield return file; } </code></pre> <p>What I don't understand is why I have to do a double foreach in the C# version for the recursion, but not in F#... Does the seq {} implicitly do a 'concat'?</p>
[ { "answer_id": 308610, "author": "Sunlight", "author_id": 33650, "author_profile": "https://Stackoverflow.com/users/33650", "pm_score": 5, "selected": true, "text": "yield!" }, { "answer_id": 309337, "author": "Tomas Petricek", "author_id": 33518, "author_profile": "h...
2008/11/21
[ "https://Stackoverflow.com/questions/308481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
308,491
<p>Is it possible to get Mercurial to show progress of long-running push or pull operation? Google tells me basically "no", but does somebody know better? I was expecting something like <code>hg pull -v</code>...</p>
[ { "answer_id": 308515, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 6, "selected": true, "text": "hg pull -v \n" }, { "answer_id": 901638, "author": "Martin Geisler", "author_id": 110204, "author_...
2008/11/21
[ "https://Stackoverflow.com/questions/308491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6846/" ]
308,492
<p>In Postgresql you can create additional Aggregate Functions with </p> <pre><code>CREATE AGGREGATE name(...); </code></pre> <p>But this gives an error if the aggregate already exists inside the database, so how can I check if a Aggregate already exists in the Postgres Database? </p>
[ { "answer_id": 308500, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": true, "text": "SELECT * FROM pg_proc WHERE proname = 'name' AND proisagg; \n" }, { "answer_id": 56543864, "author": "gave...
2008/11/21
[ "https://Stackoverflow.com/questions/308492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39644/" ]
308,499
<p>I want to float a div to the right at the top of my page. It contains a 50px square image, but currently it impacts on the layout of the top 50px on the page.</p> <p>Currently its:</p> <pre><code>&lt;div style="float: right;"&gt; ... &lt;/div&gt; </code></pre> <p>I tried z-index as I thought that would be the answer, but I couldn't get it going.</p> <p>I know it's something simple I'm missing, but I just can't seem to nail it.</p>
[ { "answer_id": 308519, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 2, "selected": false, "text": "position" }, { "answer_id": 308520, "author": "Richard Garside", "author_id": 31569, "author_profile": "ht...
2008/11/21
[ "https://Stackoverflow.com/questions/308499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39643/" ]
308,501
<p>I want to check that two passwords are the same using Dojo.</p> <p>Here is the HTML I have:</p> <p><code></p> <blockquote> <p><code>&lt;form id="form" action="." dojoType="dijit.form.Form" /</code>></p> <p><code>&lt;p</code>>Password: <code>&lt;input type="password"<br> name="password1"<br> id="password1"<br> dojoType="dijit.form.ValidationTextBox"<br> required="true"<br> invalidMessage="Please type a password" /</code>><code>&lt;/p</code>></p> <p><code>&lt;p</code>>Confirm: <code>&lt;input type="password"<br> name="password2"<br> id="password2"<br> dojoType="dijit.form.ValidationTextBox"<br> required="true"<br> invalidMessage="This password doesn't match your first password" /</code>><code>&lt;/p</code>></p> <p><code>&lt;div dojoType="dijit.form.Button" onClick="onSave"</code>>Save<code>&lt;/div</code>></p> <p><code>&lt;/form</code>> </code></p> </blockquote> <p>Here is the JavaScript I have so far:</p> <blockquote> <p><code> var onSave = function() {<br> if(dijit.byId('form').validate()) { alert('Good form'); }<br> else { alert('Bad form'); }<br> } </code></p> </blockquote> <p>Thanks for your help. I could do this in pure JavaScript, but I'm trying to find the Dojo way of doing it.</p>
[ { "answer_id": 308666, "author": "Richard Garside", "author_id": 31569, "author_profile": "https://Stackoverflow.com/users/31569", "pm_score": 1, "selected": false, "text": "\n <p>Confirm: <input type=\"password\"\n name=\"password2\"\n id=\"password2\"\n dojoType=\"dijit.form.Valida...
2008/11/21
[ "https://Stackoverflow.com/questions/308501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31569/" ]
308,511
<p>I have a .Net 1.1 web application sitting in a folder called C:\inetpub\wwwroot\MyTestApp, where 'MyTestApp' is a virtual directory and is configured to be on ASP.Net version 1.1.4322 in IIS 5.1.</p> <p>In the root directory (C:\inetpub\wwwroot) there is a web.config file for a .Net2.0 application, because the root folder contains some web pages written in .Net2.0.</p> <p>Whenever I try to access 'MyTestApp' though I get an error...</p> <pre><code>Parser Error Message: Unrecognized configuration section 'connectionStrings' Source File: c:\inetpub\wwwroot\web.config Line: 17 </code></pre> <p>The .Net1.1 application in the MyTestApp folder is trying to access the web.config file in the root folder, and getting upset because it is on a different version. How can I tell the MyTestApp folder NOT to use the web.config file in the root folder, but instead just use the web.config in its own folder?</p> <p>Is such a thing possible, or is nesting a .Net 1.1 application in a sub-folder under a .Net 2.0 application a no-no?</p>
[ { "answer_id": 308542, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 1, "selected": false, "text": "Web.config" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7585/" ]
308,514
<p>In firefox when you add an onclick event handler to a method an event object is automatically passed to that method. This allows, among other things, the ability to detect which specific element was clicked. For example</p> <pre><code>document.body.onclick = handleClick; function handleClick(e) { // this works if FireFox alert(e.target.className); } </code></pre> <p>Is there any way to approximate this in IE? i need to be able to detect which element is clicked from an event handler on the body element.</p>
[ { "answer_id": 308523, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "event" }, { "answer_id": 308526, "author": "Simon", "author_id": 33036, "author_profile": "https://Stackov...
2008/11/21
[ "https://Stackoverflow.com/questions/308514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28882/" ]
308,547
<p>I am using a custom validator to compare value in two text box. This is comparing the values fine. But it says "025" and "25" are different.. can this do a float comparision.</p> <p>the custom validator i am using is </p> <pre><code>&lt;asp:CompareValidator id="compval" runat="server" ControlToValidate="txtBox1" ErrorMessage="There values are not equal." Enabled="False" ControlToCompare="txtBox2"&gt;*&lt;/asp:CompareValidator&gt;&lt;/TD&gt; </code></pre> <p>Please let me know if this is possible.</p>
[ { "answer_id": 311875, "author": "Stefan", "author_id": 30604, "author_profile": "https://Stackoverflow.com/users/30604", "pm_score": 1, "selected": false, "text": "<asp:CompareValidator ID=\"cv1\" runat=\"server\" ControlToCompare=\"txt1\" ControlToValidate=\"txt2\" Operator=\"Equal\" T...
2008/11/21
[ "https://Stackoverflow.com/questions/308547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
308,555
<p>I have this Java code (JPA):</p> <pre><code>String queryString = "SELECT b , sum(v.votedPoints) as votedPoint " + " FROM Bookmarks b " + " LEFT OUTER JOIN Votes v " + " on (v.organizationId = b.organizationId) " + "WHERE b.userId = 101 " + "GROUP BY b.organizationId " + "ORDER BY votedPoint ascending "; EntityManager em = getEntityManager(); Query query = em.createQuery(queryString); query.setFirstResult(start); query.setMaxResults(numRecords); List results = query.getResultList(); </code></pre> <p>I don't know what is wrong with my query because it gives me this error: </p> <pre> java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V at org.hibernate.hql.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1802) at org.hibernate.hql.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1420) at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1130) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:271) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650) </pre> <p>Thanks.</p>
[ { "answer_id": 308568, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "\"" }, { "answer_id": 308589, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackover...
2008/11/21
[ "https://Stackoverflow.com/questions/308555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39626/" ]
308,581
<p>Is it better to have all the private members, then all the protected ones, then all the public ones? Or the reverse? Or should there be multiple private, protected and public labels so that the operations can be kept separate from the constructors and so on? What issues should I take into account when making this decision?</p>
[ { "answer_id": 308660, "author": "David Rodríguez - dribeas", "author_id": 36565, "author_profile": "https://Stackoverflow.com/users/36565", "pm_score": 2, "selected": false, "text": "class Example1 {\npublic:\n void publicOperation();\nprivate:\n void privateOperation1_();\n void ...
2008/11/21
[ "https://Stackoverflow.com/questions/308581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
308,588
<p>I am struggling to get an Epson "ESC/POS" printer to print barcodes (Using Delphi) and want to test if the printer is not faulty. Do you know where I can find a program to print a barcode in "ESC/POS"? I suppose as a last resort an OPOS program will also be OK.</p> <p>Also, a demo Delphi Program that works will also be fine. All the Delphi snippets I have so far is not working.</p> <p>The printer I am using is an Epson TM-L60II</p>
[ { "answer_id": 308829, "author": "Re0sless", "author_id": 2098, "author_profile": "https://Stackoverflow.com/users/2098", "pm_score": 4, "selected": true, "text": "{**\n* @param a ean13 barcode numeric value\n* @return the escpos code for the barcode print\n* Description uses es...
2008/11/21
[ "https://Stackoverflow.com/questions/308588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
308,590
<p>I'm running JBoss 4.0.5 on Windows 2003 x64 and wonder if there is any way to get a dump of all threads? </p> <ul> <li><p>It's stared with FireDaemon so I don't have a console windows in which to ctrl-break.</p></li> <li><p>It's running under java 1.5 so jstack won't work.</p></li> <li><p>I tried some program someone had made called sendsignal.exe, which I think actually crashed JBoss (not certain, but not going to try it again), if this was because JBoss runs under win x64 or because it runs as LocalSystem and I only have access to an "ordinary" user I don't know. It actually worked on my laptop, but it's 32-bit and I'm running as the same user as JBoss there.</p></li> </ul> <p>Someone has any other ideas that might work?</p>
[ { "answer_id": 308604, "author": "Gowri", "author_id": 3253, "author_profile": "https://Stackoverflow.com/users/3253", "pm_score": 0, "selected": false, "text": "Thread.getAllStackTraces()" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30354/" ]
308,601
<p>I am working on a Windows application which needs to be able to update itself. When a button is pressed it starts the installer and then the parent application exits. At some point during the installer, the installer attempts to rename the directory that the parent application was running from and fails with "Access Denied" If you run the installer from the desktop it works.</p> <p>I am using CreateProcess to start the installer, is there some way of using this or another API to create the installer completely independantly from the parent application so that it doesn't retain some attachment to the directory.</p>
[ { "answer_id": 308604, "author": "Gowri", "author_id": 3253, "author_profile": "https://Stackoverflow.com/users/3253", "pm_score": 0, "selected": false, "text": "Thread.getAllStackTraces()" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
308,605
<p>I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. </p> <p>Here are some examples of things I'm wringing my hands over.</p> <ul> <li>Right now, I'm using the Django-REST API with a pile of patches. </li> <li>I'm thinking of falling back to simply writing view functions in Django that return JSON results.</li> <li>I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance.</li> </ul> <p>Please nominate one approach per answer so we can vote them up or down.</p>
[ { "answer_id": 1510095, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 5, "selected": false, "text": "GET /account/profile HTTP/1.1\nHost: example.com\nAccept: application/json\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10661/" ]
308,609
<p>As as part of my daily routine, I have the misfortune of administering an ancient, once "just internal" JSP web application that relies on the following authentication schema:</p> <pre><code>... // Validate the user name and password. if ((user != null) &amp;&amp; (password != null) &amp;&amp; ( (user.equals("brianmay") &amp;&amp; password.equals("queen")) || (user.equals("rogertaylor") &amp;&amp; password.equals("queen")) || (user.equals("freddiemercury") &amp;&amp; password.equals("queen")) || (user.equals("johndeacon") &amp;&amp; password.equals("queen")) )) { // Store the user name as a session variable. session.putValue("user", user); ... </code></pre> <p>As much as I would like to, the Queen members have never been users of the system but anyway it does make a great example, does it not?</p> <p>Despite that by policy this client enforces security by domain authentication among other things, therefore this issue isn't seen as a security risk, still, my idea is to at least obfuscate that plain text credentials using perhaps a simple MD5 or SHA1 method, so such sensitive data is not visible to the naked eye.</p> <p>I'm a total newbie when it comes to JSP so I would really appreciate any piece of advice you'd be willing to share with me.</p> <p>Thanks much in advance!</p>
[ { "answer_id": 308677, "author": "carson", "author_id": 25343, "author_profile": "https://Stackoverflow.com/users/25343", "pm_score": 3, "selected": true, "text": "try\n{\n String digestInput = \"queen\";\n\n MessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\n messageD...
2008/11/21
[ "https://Stackoverflow.com/questions/308609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
308,615
<p>Please feel free to correct me if I am wrong at any point...</p> <p>I am trying to read a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="nofollow noreferrer">CSV</a> (comma separated values) file using .NET file I/O classes. Now the problem is, this CSV file may contain some fields with soft carriage returns (i.e. solitary \r or \n markers rather than the standard \r\n used in text files to end a line) within some fields and the standard text mode I/O class StreamReader does not respect the standard convention and treats the soft carriage returns as hard carriage returns thus compromising the integrity of the CSV file. </p> <p>Now using the BinaryReader class seems to be the only option left but the BinaryReader does not have a ReadLine() function hence the need to implement a ReadLine() on my own. </p> <p>My current approach reads one character from the stream at a time and fills a StringBuilder until a \r\n is obtained (ignoring all other characters including solitary \r or \n) and then returns a string representation of the StringBuilder (using ToString()). </p> <p>But I wonder: is this is the most efficient way of implementing the ReadLine() function? Please enlighten me.</p>
[ { "answer_id": 308648, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 4, "selected": true, "text": "public class LineReader : IDisposable\n{\n private Stream stream;\n private BinaryReader reader;\n\n public Lin...
2008/11/21
[ "https://Stackoverflow.com/questions/308615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39648/" ]
308,619
<p>With a vector defined as <code>std::vector&lt;std::string&gt;</code>, Wondering why the following is valid:</p> <pre><code>if ( vecMetaData[0] != &quot;Some string&quot; ) { ... </code></pre> <p>But not this:</p> <pre><code>switch ( vecMetaData[1] ) { ... </code></pre> <p>Visual studio complains :</p> <pre><code>error C2450: switch expression of type 'std::basic_string&lt;_Elem,_Traits,_Ax&gt;' is illegal 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called </code></pre>
[ { "answer_id": 308676, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 1, "selected": false, "text": "std::map<std::string, boost::function> StringSwitch;" }, { "answer_id": 309152, "author": "Reed Hedges", ...
2008/11/21
[ "https://Stackoverflow.com/questions/308619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
308,620
<p>I have a simple database with two tables. Users and Configurations. A user has a foreign key to link it to a particular configuration.</p> <p>I am having a strange problem where the following query always causes an inner join to the Configuration table regardless of the second parameter value. As far as I can tell, even though the "UserConfiguration =" part of the object initialisation is conditional, LINQ doesn't see that and determines that a relationship is followed in any case.</p> <p>If I actually remove that last initialisation, the whole thing works as expected. It doesn't inner join when loadConfiguration == false and it does join when loadConfiguration == true.</p> <p>Anyone got any ideas about this? Is this syntax just not going to work? The only thought I have now is to wrap the return in a basic if statement - I just wanted to avoid the duplicated lines.</p> <pre><code>public UserAccount GetByUsername(string username, bool loadConfiguration) { using (Database database = new Database()) { if (loadConfiguration) { DataLoadOptions loadOptions = new DataLoadOptions(); loadOptions.LoadWith&lt;User&gt;(c =&gt; c.Configuration); database.LoadOptions = loadOptions; } return (from c in database.Users where c.Username == username select new UserAccount { ID = c.ID, ConfigurationID = c.ConfigurationID, Username = c.Username, Password = c.Password.ToArray(), HashSalt = c.HashSalt, FirstName = c.FirstName, LastName = c.LastName, EmailAddress = c.EmailAddress, UserConfiguration = (loadConfiguration) ? new ApplicationConfiguration { ID = c.Configuration.ID, MonthlyAccountPrice = c.Configuration.MonthlyAccountPrice, TrialAccountDays = c.Configuration.TrialAccountDays, VAT = c.Configuration.VAT, DateCreated = c.Configuration.DateCreated } : null }).Single(); } } </code></pre> <p>Thanks in advance,</p> <p>Martin.</p>
[ { "answer_id": 308676, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 1, "selected": false, "text": "std::map<std::string, boost::function> StringSwitch;" }, { "answer_id": 309152, "author": "Reed Hedges", ...
2008/11/21
[ "https://Stackoverflow.com/questions/308620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
308,650
<p>Anyone got any insight as to select x number of non-consecutive days worth of data? Dates are standard sql datetime. So for example I'd like to select 5 most recent days worth of data, but there could be many days gap between records, so just selecting records from 5 days ago and more recent will not do.</p>
[ { "answer_id": 308670, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 0, "selected": false, "text": "select *\nfrom data\nwhere datetime >=\n( select top 1 date\n from\n ( select top 5 date from\n ( select truncat...
2008/11/21
[ "https://Stackoverflow.com/questions/308650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39655/" ]
308,659
<p>I have a login screen that I force to be ssl, so like this: <a href="https://www.foobar.com/login" rel="noreferrer">https://www.foobar.com/login</a> then after they login, they get moved to the homepage: <a href="https://www.foobar.com/dashbaord" rel="noreferrer">https://www.foobar.com/dashbaord</a></p> <p>However, I want to move people off of SSL once logged in (to save CPU), so just after checking that they are in fact logged in on <a href="https://www.foobar.com/dashbaord" rel="noreferrer">https://www.foobar.com/dashbaord</a> I move them to <a href="http://www.foobar.com/dashbaord" rel="noreferrer">http://www.foobar.com/dashbaord</a></p> <p>Well this always seems to wipe out the session variables, because when the page runs again, it confirms they are logged in (as all pages do) and session appears not to exist, so it moves them to the login screen.</p> <p>Oddness/findings:</p> <ol> <li>List item</li> <li>The second login always works, and happily gets me to <a href="http://www.foobar.com/dashbaord" rel="noreferrer">http://www.foobar.com/dashbaord</a></li> <li>It successfully creates a cookie the first login</li> <li>If I login twice, then logout, and login again, I don't need two logins (I seem to have traced this to the fact that the cookie exists). If I delete the cookie, I'm back to two logins.</li> <li>After the second login, I can move from non-ssl from ssl and the session persists.</li> <li>On the first login, the move to the non-ssl site wipes out the session entirely, manually moving back to the ssl site still forces me to login again.</li> <li>The second login using the exact same mechanism as the first, over ssl</li> </ol> <p>What I tried:</p> <ol> <li>Playing with Cake's settings for security.level and session.checkagent - nothing</li> <li>Having cake store the sessions in db (as opposed to file system) - nothing</li> <li>Testing in FF, IE, Chrome on an XP machine.</li> </ol> <p>So I feel like this is something related to the cookie being created but not being read. </p> <p>Environment: 1. Debian 2. Apache 2 3. Mysql 4 4. PHP 5 5. CakePHP 6. Sessions are being saved PHP default, as files</p>
[ { "answer_id": 308671, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 2, "selected": false, "text": "Secure" }, { "answer_id": 2153433, "author": "monmonja", "author_id": 258648, "autho...
2008/11/21
[ "https://Stackoverflow.com/questions/308659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43/" ]
308,667
<p>I need to make a Control which shows only an outline, and I need to place it over a control that's showing a video. If I make my Control transparent, then the video is obscured, because transparent controls are painted by their parent control and the video isn't painted by the control; it's shown using DirectShow or another library, so instead the parent control paints its BackColor.</p> <p>So - can I make a control that doesn't get painted <em>at all</em>, except where it's opaque? That way, the parent control wouldn't paint over the video.</p> <p>I know I could make the border out of four controls (or more if I want it dashed) but is it possible to do what I want using just one control?</p> <hr> <p>rslite is right - although you don't even need to go so far as to use PInvoke like his example does - the Control.Region property is entirely sufficient.</p>
[ { "answer_id": 308708, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": -1, "selected": false, "text": "Form.TransparencyKey" }, { "answer_id": 20849282, "author": "Pieterjan De Clippel", "author_id": 3147047, ...
2008/11/21
[ "https://Stackoverflow.com/questions/308667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
308,683
<p>When I create a new <code>Date</code> object, it is initialized to the current time but in the local timezone. How can I get the current date and time in GMT?</p>
[ { "answer_id": 308689, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 10, "selected": true, "text": "java.util.Date" }, { "answer_id": 308704, "author": "user2427", "author_id": 1356709, "author_profil...
2008/11/21
[ "https://Stackoverflow.com/questions/308683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19888/" ]
308,695
<p>I'm working in C, and I have to concatenate a few things.</p> <p>Right now I have this:</p> <pre><code>message = strcat("TEXT ", var); message2 = strcat(strcat("TEXT ", foo), strcat(" TEXT ", bar)); </code></pre> <p>Now if you have experience in C I'm sure you realize that this gives you a segmentation fault when you try to run it. So how do I work around that?</p>
[ { "answer_id": 308712, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 10, "selected": true, "text": "char" }, { "answer_id": 308718, "author": "paxdiablo", "author_id": 14860, "author_profile": "htt...
2008/11/21
[ "https://Stackoverflow.com/questions/308695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
308,703
<p>Is there a way to change all the numeric keys to &quot;Name&quot; without looping through the array (so a php function)?</p> <pre><code>[ 0 =&gt; 'blabla', 1 =&gt; 'blabla', 2 =&gt; 'blblll', // etc ... ] </code></pre>
[ { "answer_id": 308731, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 5, "selected": false, "text": "$x =array(); \n$x['foo'] = 'bar' ; \n$x['foo'] = 'baz' ; #replaces 'bar'\n" }, { "answer_id": 308757, "au...
2008/11/21
[ "https://Stackoverflow.com/questions/308703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
308,739
<p>Could some one tell me how to capture SOAP messages passed between the client and the server webservice applications.</p> <p>I tried using both tools. pocket soap <a href="http://www.pocketsoap.com/pocketsoap/" rel="nofollow noreferrer">http://www.pocketsoap.com/pocketsoap/</a></p> <p>Fiddler <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow noreferrer">http://www.fiddlertool.com/fiddler/</a></p> <p>I may miss some settings, it is not working for me.</p> <p>help will be more appreciated.</p>
[ { "answer_id": 10438793, "author": "E.Bailo", "author_id": 1373471, "author_profile": "https://Stackoverflow.com/users/1373471", "pm_score": 1, "selected": false, "text": ".\n.\n.\n Serializer->EndEnvelope();\n/* ___________________ */\n\n char * bufferxml = NULL;\n\n _variant_t p...
2008/11/21
[ "https://Stackoverflow.com/questions/308739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32670/" ]
308,746
<p>I'm getting a segmentation fault in the following C code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;unistd.h&gt; #include &lt;errno.h&gt; #include &lt;string.h&gt; #include &lt;netdb.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/socket.h&gt; #include &lt;netinet/in.h&gt; #include &lt;arpa/inet.h&gt; #define PORT 6667 #define MAXDATASIZE 1024 int bot_connect(char *hostname); int bot_connect(char *hostname) { int sockfd, numbytes, s; char buf[MAXDATASIZE]; struct addrinfo hints, *servinfo, *p; int rv; char m[1024]; char *message; char *nick = "Goo"; char *ident = "Goo"; char *realname = "Goo"; memset(&amp;hints,0,sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; rv = getaddrinfo(hostname, PORT, &amp;hints, &amp;servinfo); if (rv != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return 1; } for (p = servinfo; p != NULL; p = p-&gt;ai_next) { sockfd = socket(p-&gt;ai_family, p-&gt;ai_socktype, p-&gt;ai_protocol); if (sockfd == -1) { perror("Client: socket"); continue; } if (connect(sockfd, p-&gt;ai_addr, p-&gt;ai_addrlen) == -1) { close(sockfd); perror("Client: connect"); continue; } break; } if (p == NULL) { fprintf(stderr, "Client: failed to connect \n"); return 2; } freeaddrinfo(servinfo); strcat(m, "NICK "); strcat(m, nick); message = m; s = send(sockfd, message, strlen(message), 0); strcat(m, "USER "); strcat(m, ident); strcat(m, " * * :"); strcat(m, realname); message = m; s = send(sockfd, message, strlen(message), 0); message = "JOIN #C&amp;T"; s = send(sockfd, message, strlen(message), 0); close(sockfd); } </code></pre> <p>I know that you get segmentation faults from trying to do something with memory that you are not allowed to do, like alter read only memory, but to my knowledge, this program doesn't do that. Does anyone have any clue where the segmentation fault is coming from?</p>
[ { "answer_id": 308763, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 3, "selected": false, "text": "strcat( m, \"NICK\" );" }, { "answer_id": 308808, "author": "Graeme Perrow", "author_id": 1821, "a...
2008/11/21
[ "https://Stackoverflow.com/questions/308746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
308,749
<p>In many languages there's a pair of functions, <code>chr()</code> and <code>ord()</code>, which convert between numbers and character values. In some languages, <code>ord()</code> is called <code>asc()</code>.</p> <p>Ruby has <code>Integer#chr</code>, which works great:</p> <pre><code>&gt;&gt; 65.chr A </code></pre> <p>Fair enough. But how do you go the other way?</p> <pre><code>"A".each_byte do |byte| puts byte end </code></pre> <p>prints:</p> <pre><code>65 </code></pre> <p>and that's pretty close to what I want. But I'd really rather avoid a loop -- I'm looking for something short enough to be readable when declaring a <code>const</code>.</p>
[ { "answer_id": 308804, "author": "dylanfm", "author_id": 38795, "author_profile": "https://Stackoverflow.com/users/38795", "pm_score": 4, "selected": false, "text": "'A'.unpack('c')\n" }, { "answer_id": 308812, "author": "Kent Fredric", "author_id": 15614, "author_pro...
2008/11/21
[ "https://Stackoverflow.com/questions/308749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39223/" ]
308,752
<p>I would like to know which one is the best material that I can hand out to my students about "<em>C# comments</em>".</p>
[ { "answer_id": 308762, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "//This is a single line comment\n" }, { "answer_id": 308770, "author": "George Stocker", "autho...
2008/11/21
[ "https://Stackoverflow.com/questions/308752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18631/" ]
308,756
<p>Is it possible to check if a dynamically loaded assembly has been signed with a specific strong name?</p> <p>Is it enough / secure to compare the values returned from <strong>AssemblyName.GetPublicKey()</strong> method?</p> <pre><code>Assembly loaded = Assembly.LoadFile(path); byte[] evidenceKey = loaded.GetName().GetPublicKey(); if (evidenceKey != null) { byte[] internalKey = Assembly.GetExecutingAssembly().GetName().GetPublicKey(); if (evidenceKey.SequenceEqual(internalKey)) { return extension; } } </code></pre> <p>Can't this be spoofed? I am not sure if the SetPublicKey() method has any effect on a built assembly, but even the MSDN documentation shows how you can use this on a dynamically generated assembly (reflection emit) so that would mean you could extract the public key from the host application and inject it into an assembly of your own and run mallicious code if the above was the safe-guard, or am I missing something?</p> <p>Is there a more correct and secure approach? I know if the reversed situation was the scenario, that is, where I wanted to secure the assembly from only being called by signed hosts then I could tag the assembly with the StrongNameIdentityPermission attribute.</p>
[ { "answer_id": 308762, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "//This is a single line comment\n" }, { "answer_id": 308770, "author": "George Stocker", "autho...
2008/11/21
[ "https://Stackoverflow.com/questions/308756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25319/" ]
308,772
<p>I'm creating a public internet facing website which contains the email address of their salespeople. </p> <p>What kind of programming options do I have to generate the "mailto" and display the email from that address but limit the spambots from picking up the address? </p>
[ { "answer_id": 309220, "author": "Brian C. Lane", "author_id": 27461, "author_profile": "https://Stackoverflow.com/users/27461", "pm_score": 2, "selected": false, "text": "<script name=\"mailto\" language=\"JavaScript\">\n //<![CDATA[\n\n function load()\n {\n c1 = \"bcl\...
2008/11/21
[ "https://Stackoverflow.com/questions/308772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
308,802
<p>I'm using the <a href="http://code.msdn.microsoft.com/silverlightut/" rel="noreferrer">Silverlight UnitTest framerwork</a> does anyone have a good example have how to unit test an application with it? I'm using it quite successfully to unit test a silverlight class library.</p> <p>Any pointers and links would be greatly appreciated.</p> <p>Thanks, Nath</p>
[ { "answer_id": 16547022, "author": "Michael", "author_id": 986451, "author_profile": "https://Stackoverflow.com/users/986451", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Net;\nusing System.Windows;\nusing System.Windows.Controls;\nusing System.Windows.Document...
2008/11/21
[ "https://Stackoverflow.com/questions/308802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39643/" ]
308,813
<p>I am using Apache Felix and its Declarative Services (SCR) to wire the service dependencies between bundles.</p> <p>For example, if I need access to a java.util.Dictionary I can say the following to have SCR provide one:</p> <pre><code>/** * @scr.reference name=properties interface=java.util.Dictionary */ protected void bindProperties(Dictionary d) { } protected void unbindProperties(Dictionary d) { } </code></pre> <p>Now, I have more than one Dictionary service available, and I want to filter them using the "name" service property (I only want "name=myDictionary"). I can do that with code (using a ServiceTracker), but I'd rather specify the filter in the @scr annotation instead.</p>
[ { "answer_id": 322471, "author": "Danail Nachev", "author_id": 3219, "author_profile": "https://Stackoverflow.com/users/3219", "pm_score": 1, "selected": false, "text": "\n(name=myDictionary)\n" }, { "answer_id": 367987, "author": "Alexander Klimetschek", "author_id": 270...
2008/11/21
[ "https://Stackoverflow.com/questions/308813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
308,820
<p>I have big issue with url-rewriting for IIS 7.0.</p> <p>I've written simple module for rewriting for my NET3.5/IIS7 web application. Here is a part of the code.</p> <pre><code> public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(context_BeginRequest); } void context_BeginRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; if (app.Request.Path.Contains("pagetorewrite.aspx")) HttpContext.Current.RewritePath("~/otherpage.aspx"); } </code></pre> <p>And I register my module in web.config :</p> <pre><code> &lt;system.webServer&gt; &lt;validation validateIntegratedModeConfiguration="false"/&gt; &lt;modules&gt; &lt;add name="MyModule" type="MyModule" preCondition="" /&gt; </code></pre> <p>Under IIS 7.0 (Vista) using Classic ASP Pipeline it works perfect, but when I change pipeline mode to Integrated, then it stops working. There are no exceptions, errors and anything in debugger/events/logfiles - only message in a browser that page was not found. The stragnest thing is that pagename looks like mispelled or merged from parts of original page and rewrte-to page.</p> <p>I've deployed my code at another computer (also vista -but x64- and iis 7.0) and it works perfect in both modes. It looks that there's an configuration issue or what?</p>
[ { "answer_id": 322471, "author": "Danail Nachev", "author_id": 3219, "author_profile": "https://Stackoverflow.com/users/3219", "pm_score": 1, "selected": false, "text": "\n(name=myDictionary)\n" }, { "answer_id": 367987, "author": "Alexander Klimetschek", "author_id": 270...
2008/11/21
[ "https://Stackoverflow.com/questions/308820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39656/" ]
308,823
<p>I have to define the grammar of a file like the one shown below.</p> <p>//Sample file<br> NameCount = 4<br> Name = a<br> Name = b<br> Name = c<br> Name = d<br> //End of file<br></p> <p>Now I am able to define tokens for <strong>NameCount</strong> and <strong>Name</strong>. But i have to define the file structure including the valid number of instances of token <strong>Name</strong> , which is the value after <strong>NameCount</strong>. I have the value parsed and converted into an integer and stored in a variable at global scope of the grammar (say in variable <strong>nc</strong>). </p> <p>How to define in grammar that <strong>Name</strong> should repeat exactly <strong>nc</strong> times?</p>
[ { "answer_id": 335674, "author": "tcurdt", "author_id": 33165, "author_profile": "https://Stackoverflow.com/users/33165", "pm_score": 4, "selected": true, "text": "grammar test;\n\n@members {\n private int count = 0;\n private int names = 0;\n}\n\nfile\n : count (name)+\n {\n ...
2008/11/21
[ "https://Stackoverflow.com/questions/308823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27784/" ]
308,826
<p>The code below works. But if I comment out the line <code>Dim objRequest As MSXML2.XMLHTTP</code> and uncomment the line <code>Dim objRequest As Object</code> it fails with the error message :</p> <blockquote> <p>The parameter is incorrect</p> </blockquote> <p>Why, and what (if anything) can I do about it?</p> <pre><code>Public Function GetSessionId(strApiId, strUserName, strPassword) As String Dim strPostData As String Dim objRequest As MSXML2.XMLHTTP 'Dim objRequest As Object ' strPostData = "api_id=" &amp; strApiId &amp; "&amp;user=" &amp; strUserName &amp; "&amp;password=" &amp; strPassword Set objRequest = New MSXML2.XMLHTTP With objRequest .Open "POST", "https://api.clickatell.com/http/auth", False .setRequestHeader "Content-Type", "application/x-www-form-urlencoded" .send strPostData GetSessionId = .responseText End With End Function </code></pre> <hr> <p>Corey, yes, I know I would have to do that in order for my code to work without a reference to the MSXML type library. That's not the issue here. The code fails when using <code>Dim objRequest As Object</code> regardless of whether I use </p> <p><code>Set objRequest = NEW MSXML2.XMLHTTP</code> with the reference, or </p> <p><code>Set objRequest = CreateObject("MSXML2.XMLHTTP")</code> without the reference.</p>
[ { "answer_id": 308920, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 5, "selected": true, "text": "Dim strPostData As String\nDim objRequest As Object\n\nstrPostData = \"api_id=\" & strApiId & \"&user=\" & strUserName & \"...
2008/11/21
[ "https://Stackoverflow.com/questions/308826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39665/" ]
308,832
<p>How do I detect when an iOS app is launched for the first time?</p>
[ { "answer_id": 308846, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 2, "selected": false, "text": "registerDefaults:" }, { "answer_id": 308861, "author": "Noah Witherspoon", "author_id": 30618, ...
2008/11/21
[ "https://Stackoverflow.com/questions/308832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36182/" ]
308,833
<p>I need to transform an Oracle SQL statement into a Stored Procedure therefore users with less privileges can access certain data field:</p> <pre><code>SELECT info_field, data_field FROM table_one WHERE some_id = '&lt;id&gt;' -- I need this &lt;id&gt; to be the procedure's parameter UNION ALL SELECT info_field, data_field FROM table_two WHERE some_id = '&lt;id&gt;' UNION ALL SELECT info_field, data_field FROM table_three WHERE some_id = '&lt;id&gt;' UNION ALL ... </code></pre> <p>Given that I'm no SP expert I've been unable to figure out a good solution to loop through all the involved tables (12 aprox.).</p> <p>Any ideas would be helpful. Thanks much!</p>
[ { "answer_id": 308883, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 1, "selected": false, "text": "PROCEDURE get_fields( the_id NUMBER,\n info_field_out OUT table_one.info_field%TYPE,\n ...
2008/11/21
[ "https://Stackoverflow.com/questions/308833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
308,835
<p>I'm finding myself doing a lot of things with associative arrays in PHP.</p> <p>I was doing this:</p> <pre><code> foreach ($item as $key=&gt;$value) { if ($arr[$key] == null) { $arr[$key] = 0; } $arr[$key] += $other_arr[$value]; } </code></pre> <p>But then I realised that it works fine if I exclude the line that initializes $arr[$key], presumably since it's null which is treated as the same as 0.</p> <p>Is making that kind of assumption safe in php? And if it's safe, is it a good idea?</p>
[ { "answer_id": 308852, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "if (!isset($arr[$key]))\n $arr[$key] = 0;\n" }, { "answer_id": 32802974, "author": "ajon", "author_id": 106...
2008/11/21
[ "https://Stackoverflow.com/questions/308835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
308,837
<p>I have the following table</p> <pre><code>&lt;td class="style2"&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt; &lt;asp:ListItem&gt;Location&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Name&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SSN&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:DropDownList ID="DropDownList2" runat="server"&gt; &lt;asp:ListItem&gt;LIKE&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;=&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;td valign="bottom"&gt; &lt;asp:Button ID="btnAdd" runat="server" Text="Add" /&gt; &lt;/td&gt; </code></pre> <p>When btnAdd is clicked I want to add another row of those filters. I assume I would create a panel and have these 3 controls and the add button would create a new panel or do I create all controls on the fly and then add them with code behind. </p> <p>Edit:: When I click on btnAdd then I want to add another row as such</p> <p>Before btnAdd Click</p> <pre><code>&lt;td class="style2"&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt; &lt;asp:ListItem&gt;Location&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Name&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SSN&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:DropDownList ID="DropDownList2" runat="server"&gt; &lt;asp:ListItem&gt;LIKE&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;=&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; </code></pre> <p>After btnAdd:</p> <pre><code>&lt;td class="style2"&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt; &lt;asp:ListItem&gt;Location&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Name&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SSN&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:DropDownList ID="DropDownList2" runat="server"&gt; &lt;asp:ListItem&gt;LIKE&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;=&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;tr&gt; &lt;td class="style2"&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt; &lt;asp:ListItem&gt;Location&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Name&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SSN&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:DropDownList ID="DropDownList2" runat="server"&gt; &lt;asp:ListItem&gt;LIKE&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;=&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre>
[ { "answer_id": 308852, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "if (!isset($arr[$key]))\n $arr[$key] = 0;\n" }, { "answer_id": 32802974, "author": "ajon", "author_id": 106...
2008/11/21
[ "https://Stackoverflow.com/questions/308837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38230/" ]
308,850
<p>Windows Forms:</p> <p>For <code>System.Drawing</code> there is a way to get the font height. </p> <pre><code>Font font = new Font("Arial", 10 , FontStyle.Regular); float fontHeight = font.GetHeight(); </code></pre> <p>But how do you get the other text metrics like average character width?</p>
[ { "answer_id": 308858, "author": "Ramesh Soni", "author_id": 191, "author_profile": "https://Stackoverflow.com/users/191", "pm_score": 3, "selected": true, "text": "private void MeasureStringMin(PaintEventArgs e)\n{\n\n // Set up string.\n string measureString = \"Measure String\";...
2008/11/21
[ "https://Stackoverflow.com/questions/308850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
308,876
<p>I am connecting to a MySQL DB trough a terminal who only have a program with an ODBC connection to a MySQL DB. I can put querys in the program, but not access MySQL directly.</p> <p>I there a way to query the DB to obtain the list of fields in a table other than</p> <pre><code>select * from table </code></pre> <p>??</p> <p>(don't know why but the select returns a error)</p>
[ { "answer_id": 308882, "author": "Sebastian Hoitz", "author_id": 9535, "author_profile": "https://Stackoverflow.com/users/9535", "pm_score": 2, "selected": true, "text": "describe *tablename*\n" }, { "answer_id": 308890, "author": "Tomalak", "author_id": 18771, "autho...
2008/11/21
[ "https://Stackoverflow.com/questions/308876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385/" ]
308,892
<p>I'm looking for a good open source message bus that is suitable for embedded Linux devices (Linux and uClinux).</p> <p>It needs to satisfy the following criteria:</p> <ul> <li>Must be free software and LGPL or a more liberal license due to uClinux only supporting static linking</li> <li>Must have a C API</li> <li>Must have a relatively small footprint and not depend on third party libraries</li> <li>Must be compatible with Linux/uClinux 2.4.22+</li> <li>Should be well tested and preferably have an existing test framework set up</li> <li>Should have a well documented protocol</li> <li>Should be portable to other platforms</li> </ul> <p>The message bus would primarily be used by applications on our system in order to communicate configuration parameters etc so it doesn't need to satisfy realtime requirements.</p>
[ { "answer_id": 309021, "author": "Ben Collins", "author_id": 3279, "author_profile": "https://Stackoverflow.com/users/3279", "pm_score": 4, "selected": true, "text": "man mq_overview" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22247/" ]
308,893
<p>I have a problem with an ASP.NET application that is driving me nuts.</p> <p>When a user leaves a page inactive for a period of time the session was timing out and error were being thrown due to session variables not being resolvable (I will error trap this anyway but this is not the problem). I coded a 'defribulator' which will perform an invisible postback after half of the session timeout has expired and this seemed to work fine - leaving the application for 30 mins did not cause an error even though the session timeout was set for 20 mins. However, this morning one of the other Devs experienced a timeout - How is this possible?</p> <p>On further investigation I think that the problem occurs when the Forms Authentication timeout is exceeded - even though the defribulator has been (apparently) keeping the session alive. I have read that the Authentication ticket will only be reissued if a postback occurs after half of the specified timeout period has elepsed and this can't the issue as the defrib will have issued requests during the second half of the timeout period - so why was it not reissued?</p> <p>I suppose I could get around the problem by setting the authentication timeout to 8 hours or so but that is a poor fix.</p> <p>Can anyone shed any light on this?</p> <p>Thanks in advance</p> <p>[Edit 24/11/2008] Reviewing the Log Files has proved enlightening and confusing. I can see the defribulator firing after 10 minutes of inactivity but while the Session_Id appears to be consitent throughout, the forms authentications ticket ID changes - not sure if it is supposed to or not. I'm formulating a test plan now and will post back when i have completed them. Thanks to everyone who have provided feedback so far.</p> <p>[Edit 24/11/2008] Well I'm stumped - everthing seems to be working fine at the moment! The Authentication ticket is being regenerated when the defrib runs (the ID changes) and the session is being maintained. Was it a server issue - can't tell. I have experienced this problem before and never got to the bottom of it and it is very frustrating - surely it should not be this difficult. I'm going to have to let this drop for the timebeing as I have to get on with some other aspects of the application. I'll just have to code around this issue - which may never occur on the customer site.</p> <p>Thanks again for everyones input - if I make any progress I will post it back here.</p>
[ { "answer_id": 309033, "author": "user39603", "author_id": 39603, "author_profile": "https://Stackoverflow.com/users/39603", "pm_score": 1, "selected": false, "text": "slidingExpiration" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31580/" ]
308,905
<p>I've been reading that some devs/dbas recommend using transactions in all database calls, even read-only calls. While I understand inserting/updating within a transaction what is the benefit of reading within a transaction?</p>
[ { "answer_id": 308910, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 7, "selected": true, "text": "myRows = query(SELECT * FROM A)\nmoreRows = query(SELECT * FROM B WHERE a_id IN myRows[id])\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
308,908
<p>I have a data set that is organized in the following manner:</p> <pre><code>Timestamp|A0001|A0002|A0003|A0004|B0001|B0002|B0003|B0004 ... ---------+-----+-----+-----+-----+-----+-----+-----+----- 2008-1-1 | 1 | 2 | 10 | 6 | 20 | 35 | 300 | 8 2008-1-2 | 5 | 2 | 9 | 3 | 50 | 38 | 290 | 2 2008-1-4 | 7 | 7 | 11 | 0 | 30 | 87 | 350 | 0 2008-1-5 | 1 | 9 | 1 | 0 | 25 | 100 | 10 | 0 ... </code></pre> <p>Where A0001 is Value A of item #1 and B0001 is Value B of item #1. There can be over 60 different items in a table, and each item has an A value column and a B value column, meaning a total of over 120 columns in the table.</p> <p>Where I want to get to is a 3 column result (Item index, A Value, B Value) that sums the A and B values for each item:</p> <pre><code>Index | A Value | B Value ------+---------+-------- 0001 | 14 | 125 0002 | 20 | 260 0003 | 31 | 950 0004 | 9 | 10 .... </code></pre> <p>As I am going from columns to rows I would expect a pivot in the solution, but I am not sure of how to flesh it out. Part of the issue is how to strip out the A's and B's to form the values for the Index column. The other part is that I have never had to use a Pivot before, so I am stumbling over the basic syntax as well.</p> <p>I think that ultimately I need to have a multi step solution that first builds the summations as:</p> <pre><code>ColName | Value --------+------ A0001 | 14 A0002 | 20 A0003 | 31 A0004 | 9 B0001 | 125 B0002 | 260 B0003 | 950 B0004 | 10 </code></pre> <p>Then modify the ColName data to strip out the index:</p> <pre><code>ColName | Value | Index | Aspect --------+-------+-------+------- A0001 | 14 | 0001 | A A0002 | 20 | 0002 | A A0003 | 31 | 0003 | A A0004 | 9 | 0004 | A B0001 | 125 | 0001 | B B0002 | 260 | 0002 | B B0003 | 950 | 0003 | B B0004 | 10 | 0004 | B </code></pre> <p>Finally self join to move the B values up next to the A Values.</p> <p>This seems to be a long winded process to get what I want. So I am after advice as to whether I am headed down the right path, or is there another approach that I have over looked that will make my life so much easier.</p> <p>Note 1) The solution has to be in T-SQL on MSSQL 2005.</p> <p>Note 2) The format of the table cannot be changed.</p> <p><strong>Edit</strong> Another method I have thought about uses UNIONs and individual SUM()s on each column:</p> <pre><code>SELECT '0001' as Index, SUM(A0001) as A, SUM(B0001) as B FROM TABLE UNION SELECT '0002' as Index, SUM(A0002) as A, SUM(B0002) as B FROM TABLE UNION SELECT '0003' as Index, SUM(A0003) as A, SUM(B0003) as B FROM TABLE UNION SELECT '0004' as Index, SUM(A0004) as A, SUM(B0004) as B FROM TABLE UNION ... </code></pre> <p>But this approach really doesn't look very nice either</p> <p><strong>EDIT</strong> So far there are 2 great responses. But I would like to add two more conditions to the query :-) </p> <p>1) I need to select the rows based on a range of timestamps (minv &lt; timestamp &lt; maxv). </p> <p>2) I also need to conditionally select rows on a UDF that processes the timestamp</p> <p>Using Brettski's table names, would the above translate to:</p> <pre><code>... (SELECT A0001, A0002, A0003, B0001, B0002, B0003 FROM ptest WHERE timestamp&gt;minv AND timestamp&lt;maxv AND fn(timestamp)=fnv) p unpivot (val for item in (A0001, A0002, A0003, B0001, B0002, B0003)) as unpvt ... </code></pre> <p>Given that I have conditionally add the fn() requirement, I think that I also need to go down the dynamic SQL path as proposed by Jonathon. Especially as I have to build the same query for 12 different tables - all of the same style.</p>
[ { "answer_id": 309274, "author": "Brettski", "author_id": 5836, "author_profile": "https://Stackoverflow.com/users/5836", "pm_score": 1, "selected": false, "text": "-- Create the temp table\nCREATE TABLE #s (item nvarchar(10), val int)\n\n-- Insert UNPIVOT product into the temp table\nIN...
2008/11/21
[ "https://Stackoverflow.com/questions/308908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31326/" ]
308,926
<p>How can I verify a given xpath string is valid in C#/.NET?</p> <p>I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against?</p>
[ { "answer_id": 308953, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 5, "selected": true, "text": "XPathExpression" }, { "answer_id": 309084, "author": "ripper234", "author_id": 11236, "author_profile":...
2008/11/21
[ "https://Stackoverflow.com/questions/308926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
308,928
<p>How do I add radio buttons as my parameter type in SSRS reports?</p> <p>Thanks in advance, Anna</p>
[ { "answer_id": 2340551, "author": "pulkit", "author_id": 281901, "author_profile": "https://Stackoverflow.com/users/281901", "pm_score": 3, "selected": false, "text": "=iif( Fields!m_chkDentalStatusGood.Value , Chr(158), Chr(153))\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
308,931
<p>All, </p> <p>I currently have my solution comprising of 2 Class librarys and a Web Site building within teamCity using Msbuild. Now I want to precompile the website and make it available as an artifact. However when i try to Precompile it using </p> <pre><code>&lt;Target Name="PrecompileWeb" DependsOnTargets="Build"&gt; &lt;AspNetCompiler PhysicalPath="$(BuildDir)\Location\" TargetPath="$(BuildDir)\Publish" Force="true" Debug="true" /&gt; &lt;/Target&gt; </code></pre> <p>I get an error becasue it is looking for a virtual path (which i don't have as all I want to do it precompile the files I am not interested in publishing the site) if I put a dummy path in I get another error (correctly) about it not being an application under IIS </p> <p>Any ideas</p>
[ { "answer_id": 308975, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 3, "selected": true, "text": "Rebuild;ResolveReferences;_CopyWebApplication" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11802/" ]
308,935
<p>I'm preparing a string that will be <code>eval</code>'ed. The string will contain a clause built from an existing <code>Array</code>. I have the following:</p> <pre><code>def stringify(arg) return "[ '" + arg.join("', '") + "' ]" if arg.class == Array "'#{arg}'" end a = [ 'a', 'b', 'c' ] eval_str = 'p ' + stringify(a) eval(eval_str) </code></pre> <p>which prints the string <code>["a", "b", "c"]</code>.</p> <p>Is there a more idiomatic way to do this? <code>Array#to_s</code> doesn't cut it. Is there a way to assign the output from the <code>p</code> method to a variable?</p> <p>Thanks!</p>
[ { "answer_id": 308956, "author": "dylanfm", "author_id": 38795, "author_profile": "https://Stackoverflow.com/users/38795", "pm_score": 0, "selected": false, "text": ">> a = %w[a b c]\n=> [\"a\", \"b\", \"c\"]\n>> r = \"['#{a.join(\"', '\")}']\"\n=> \"['a', 'b', 'c']\"\n>> r.class\n=> Str...
2008/11/21
[ "https://Stackoverflow.com/questions/308935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39443/" ]
308,954
<p>I need a method to return a random string in the format:</p> <p>Letter Number Letter Number Letter Number</p>
[ { "answer_id": 308960, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "private int RandomNumber(int min, int max)\n{\n Random random = new Random();\n return random.Next(min, m...
2008/11/21
[ "https://Stackoverflow.com/questions/308954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
308,963
<p>What is the proper way to split up SQL statements to send to an Oracle ADO.NET client? For instance, lets say you have the following code in a text file and want to execute these statements:</p> <pre><code>CREATE TABLE foo (bar VARCHAR2(100)); INSERT INTO foo (bar) VALUES('one'); INSERT INTO foo (bar) VALUES('two'); </code></pre> <p>I believe trying to send all those in one Command will cause Oracle to complain about the ";". My first thought would be to split on ";" character, and send them one at a time.</p> <p>But, Stored procedures can contain semi-colons as well, so how would I make it so the split routine would keep the whole stored proc together? Does it need to look for begin/end statements as well, or "/"?</p> <p>Is there any difference in these respects between ODP.NET and the Micrsoft Oracle Provider?</p>
[ { "answer_id": 309003, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": false, "text": "BEGIN\n INSERT INTO foo (bar) VALUES('one');\n INSERT INTO foo (bar) VALUES('two');\nEND;\n" }, { "answer_i...
2008/11/21
[ "https://Stackoverflow.com/questions/308963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16501/" ]
308,985
<p>I'm coding a simple code editor for a very simple scripting language we use at work. My syntax highlighting code works fine if I do it on the entire <code>RichTextBox</code> (<code>rtbMain</code>) but when I try to get it to work on just that line, so I can run the function with <code>rtbMain</code> changes, it gets weird. I can't seem to figure out why. Am I even going about this the right way?</p> <p><code>rtbMain</code> is the main text box. <code>frmColors.lbRegExps</code> is a listbox of words to highlight (later it will have slightly more powerful regular expressions.) <code>frmColor.lbHexColors</code> is another listbox with the corresponding hex colors for the words.</p> <pre><code>Private Sub HighLight(ByVal All As Boolean) Dim RegExp As System.Text.RegularExpressions.MatchCollection Dim RegExpMatch As System.Text.RegularExpressions.Match Dim FirstCharIndex As Integer = rtbMain.GetFirstCharIndexOfCurrentLine Dim CurrentLine As Integer = rtbMain.GetLineFromCharIndex(FirstCharIndex) Dim CurrentLineText As String = rtbMain.Lines(CurrentLine) Dim CharsToCurrentLine As Integer = rtbMain.SelectionStart Dim PassNumber As Integer = 0 LockWindowUpdate(Me.Handle.ToInt32) 'Let's lock the window so it doesn't scroll all crazy. If All = True Then 'Highlight everything. For Each pass In frmColors.lbRegExps.Items RegExp = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass)) For Each RegExpMatch In RegExp rtbMain.Select(RegExpMatch.Index, RegExpMatch.Length) rtbMain.SelectionColor = ColorTranslator.FromHtml(frmColors.lbHexColors.Items(PassNumber)) Next PassNumber += 1 Next Else 'Highlight just that row. For Each pass In FrmColors.lbRegExps.Items RegExp = System.Text.RegularExpressions.Regex.Matches(LCase(CurrentLineText), LCase(pass)) For Each RegExpMatch In RegExp rtbMain.Select(RegExpMatch.Index + (CharsToCurrentLine - RegExpMatch.Length), RegExpMatch.Length) rtbMain.SelectionColor = Color.Blue Next Next End If rtbMain.Select(CharsToCurrentLine, 0) 'Reset colors and positon and then unlock drawing. rtbMain.SelectionColor = Color.Black LockWindowUpdate(0) End Sub </code></pre>
[ { "answer_id": 776776, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Private Sub HighLight(ByVal All As Boolean)\n Dim RegExp As System.Text.RegularExpressions.MatchCollection\n Dim RegExpM...
2008/11/21
[ "https://Stackoverflow.com/questions/308985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39143/" ]
308,988
<p>It is really annoying.</p> <pre><code>Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainForm()); &lt;-- pausing visual studio breaks here. </code></pre> <p>Thanks guys.</p>
[ { "answer_id": 309086, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 0, "selected": false, "text": "F9" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/308988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11059/" ]
308,999
<p>In a comment on this <a href="https://stackoverflow.com/questions/306130/python-decorator-makes-function-forget-that-it-belongs-to-a-class#306277">answer to another question</a>, someone said that they weren't sure what <code>functools.wraps</code> was doing. So, I'm asking this question so that there will be a record of it on StackOverflow for future reference: what does <code>functools.wraps</code> do, exactly?</p>
[ { "answer_id": 309000, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 11, "selected": true, "text": "def logged(func):\n def with_logging(*args, **kwargs):\n print(func.__name__ + \" was called\")\n r...
2008/11/21
[ "https://Stackoverflow.com/questions/308999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
309,008
<p>I want to write a function that accepts two objects as parameters and compare only the fields contained within the objects. I do not know what type the objects will be at design time, but the objects passed will be classes used within our application.</p> <p>Is it possible to compare object's fields without knowing their types at runtime?</p>
[ { "answer_id": 309131, "author": "Pondidum", "author_id": 1500, "author_profile": "https://Stackoverflow.com/users/1500", "pm_score": 2, "selected": false, "text": "Public Overrides Function GetHashCode() As Integer\n Dim sb As New System.Text.StringBuilder\n\n sb.Append(_dateOfBir...
2008/11/21
[ "https://Stackoverflow.com/questions/309008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38595/" ]
309,014
<p>I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values):</p> <pre><code>&lt;property name="project.config" value="debug" /&gt; &lt;property name="server" value="(local)" /&gt; &lt;property name="database" value="Test" /&gt; &lt;property name="username" value="sa" /&gt; &lt;property name="password" value="password" /&gt; </code></pre> <p>I then create the osql connection based on the username/password:</p> <pre><code>&lt;if test="${username==''}"&gt; &lt;property name="osql.connection" value="-E" /&gt; &lt;/if&gt; &lt;if test="${username!=''}"&gt; &lt;property name="osql.connection" value="-U ${username} -P ${password}" /&gt; &lt;/if&gt; </code></pre> <p>I then pass these values onto my batch file:</p> <pre><code>&lt;exec program="setup.bat"&gt; &lt;arg value="${server}"/&gt; &lt;arg value="${database}" /&gt; &lt;arg value="${osql.connection}" /&gt; &lt;/exec&gt; </code></pre> <p>The setup.bat file uses osql to drop the database:</p> <pre><code>osql -S %1 -d master %3 -Q "IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'%2') DROP DATABASE [%2]" </code></pre> <p>This works fine if I do not pass a username/password to the nant script and use integrated security instead ("-E" to osql). If I do specify a username/password, then the nant script just pauses (like it is awaiting some input). I do know that I am specifying the correct username/password as I can log into SQL Connection Manager and delete the database.</p> <p>Please let me know if there are any suggestions on what to try or alternate ways to do this.</p>
[ { "answer_id": 309110, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 0, "selected": false, "text": "SET Server=%1\nSET Database=%2\nSHIFT \nSHIFT\nosql -S %Server% ... %* -Q \"...%Database%...\"\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/309014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2779/" ]
309,023
<p>We have a Java application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application.</p> <p>In order to get this, we have realized in the called method of the class which represents the frame of our application (extension of a <code>JFrame</code>) following implementation:</p> <pre><code>setVisible(true); toFront(); </code></pre> <p>Under Windows XP, this works the first time it is called, on the second time only the tab in the taskbar flashes, the frame doesn't come to the front anymore. Same goes for Win2k. On Vista it seems to work fine.</p> <p>Do you have any ideas?</p>
[ { "answer_id": 310807, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 5, "selected": false, "text": "if(getState()!=Frame.NORMAL) { setState(Frame.NORMAL); }\ntoFront();\nrepaint();\n" }, { "answer_id": 387365, ...
2008/11/21
[ "https://Stackoverflow.com/questions/309023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15108/" ]
309,035
<p>I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). <strong>This problem only shows up when I turn sorting on.</strong> </p> <p>Everything else works fine. For example, I can change the header background to red and it turns red and the rest of the grid styles are applied appropriately.</p> <p>Anybody have any clues about what the deal is? I've included code snippets below. I'm also fairly new to CSS. If anyone has any tips to make my CSS markup better in some way, let me know.</p> <p>Thanks!</p> <p>Here is the ASP.NET code. I can add ForeColor="White" to the HeaderStyle and everything works normally.</p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" CssClass="grid" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." AllowSorting="True" CellPadding="4" GridLines="Both"&gt; &lt;FooterStyle CssClass="grid-footer" /&gt; &lt;RowStyle CssClass="grid-row" /&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Kingdom" HeaderText="Kingdom" SortExpression="Kingdom" /&gt; &lt;asp:BoundField DataField="Phylum" HeaderText="Phylum" SortExpression="Phylum" /&gt; &lt;asp:BoundField DataField="GenusSpeciesStrain" HeaderText="Genus species (strain)" SortExpression="GenusSpeciesStrain" /&gt; &lt;asp:BoundField DataField="Family" HeaderText="Family" SortExpression="Family" /&gt; &lt;asp:BoundField DataField="Subfamily" HeaderText="Subfamily" SortExpression="Subfamily" /&gt; &lt;asp:BoundField DataField="ElectronInput" HeaderText="Electron Input" SortExpression="ElectronInput" /&gt; &lt;asp:BoundField DataField="OperonLayout" HeaderText="Operon Layout" SortExpression="OperonLayout" /&gt; &lt;/Columns&gt; &lt;PagerStyle CssClass="grid-pager" /&gt; &lt;SelectedRowStyle CssClass="grid-selected-row" /&gt; &lt;HeaderStyle CssClass="grid-header" /&gt; &lt;EditRowStyle CssClass="grid-row-edit" /&gt; &lt;AlternatingRowStyle CssClass="grid-row-alternating" /&gt; </code></pre> <p></p> <p>And this is the content from style sheet I'm using:</p> <pre><code>body { } .grid { color: #333333; } .grid-row { background-color: #EFF3FB; } .grid-row-alternating { background-color: White; } .grid-selected-row { color: #333333; background-color: #D1DDF1; font-weight: bold; } .grid-header, .grid-footer { color: White; background-color: #507CD1; font-weight: bold; } .grid-pager { color: White; background-color: #2461BF; text-align: center; } .grid-row-edit { background-color: #2461BF; } </code></pre>
[ { "answer_id": 309123, "author": "gabe", "author_id": 34315, "author_profile": "https://Stackoverflow.com/users/34315", "pm_score": 1, "selected": false, "text": "\n.grid-header, .grid-footer { color: White; background-color: #507CD1; font-weight: bold; }\n" }, { "answer_id": 309...
2008/11/21
[ "https://Stackoverflow.com/questions/309035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3161/" ]
309,040
<p>I've compiled a java project into a Jar file, and am having issues running it.</p> <p>When I run:</p> <pre><code>java -jar myJar.jar </code></pre> <p>I get the following error</p> <pre><code>Could not find the main class: myClass </code></pre> <p>The class file is not in the root directory of the jar so I've tried changing the path of the main class to match the path to the class file and I get the same issue.</p> <p>Should I be flattening the file structure? if so how do I do this. I'm using Ant to build the Jar file if thats of any use.</p> <p><strong>UPDATE</strong> </p> <p>Here is the contents of the jar and the relevant Ant sections, I've changed the name of the firm I work for to "org":</p> <pre><code>META-INF/ META-INF/MANIFEST.MF dataAccessLayer/ dataAccessLayer/databaseTest.class org/ org/eventService/ org/eventService/DatabaseObject.class org/eventService/DatabaseObjectFactory.class org/eventService/DbEventClientImpl$HearBeatMonitor.class org/eventService/DbEventClientImpl.class org/eventService/EmptyQueryListException.class org/eventService/EventHandlerWorkItem.class org/eventService/EventProcessor.class org/eventService/EventTypeEnum.class org/eventService/EventWorkQueue$MonitorThread.class org/eventService/EventWorkQueue$PoolWorker.class org/eventService/EventWorkQueue.class org/eventService/FailedToLoadDriverException.class org/eventService/IConnectionFailureListener.class org/eventService/InvalidEventTypeException.class org/eventService/JdbcInterfaceConnection.class org/eventService/NullArgumentException.class org/eventService/OracleDatabaseObject.class org/eventService/ProactiveClientEventLogger.class org/eventService/ProactiveClientEventLoggerException.class org/eventService/PropertyMap.class org/eventService/SQLServerDatabaseObject.class org/eventService/TestHarness.class org/eventService/Utilities.class </code></pre> <p>And the ant target:</p> <pre><code>&lt;target name="compile" depends="init" description="compile the source "&gt; &lt;javac srcdir="src" destdir="bin" classpathref="project.class.path"/&gt; &lt;/target&gt; &lt;target name="buildjar" description="build jar file" depends="compile"&gt; &lt;mkdir dir="dist"/&gt; &lt;jar destfile="dist/myJar.jar" basedir="bin" includes="**/*.class" &gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="org.eventService.ProactiveClientEventLogger"/&gt; &lt;/manifest&gt; &lt;/jar&gt; &lt;/target&gt; </code></pre>
[ { "answer_id": 309058, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 4, "selected": true, "text": "Main-Class" }, { "answer_id": 309068, "author": "asalamon74", "author_id": 21348, "author_profile": "htt...
2008/11/21
[ "https://Stackoverflow.com/questions/309040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
309,049
<p>I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page.</p> <p>I would like to know how to synchronize queries between both php files. So when I click on a row in the base page, the layer will be expanded to include additional information, or indeed the whole query.</p> <p>I was thinking I could do this by having the primary key in the first query for the table, however I don't want it displayed and was wondering if there was a better approach to this?</p>
[ { "answer_id": 644203, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<?php\nif (isset($_POST['submit'])) {\n\n$myFile = \"/posts/edit/644203\";\n$fh = fopen($myFile, 'w') or die(\"can't open file...
2008/11/21
[ "https://Stackoverflow.com/questions/309049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
309,071
<p>I'd like to find all the types inheriting from a base/interface. Anyone have a good method to do this? Ideas?</p> <p>I know this is a strange request but its something I'm playing with none-the-less.</p>
[ { "answer_id": 309076, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "mscorlib" }, { "answer_id": 309080, "author": "Cristian Libardo", "author_id": 16526, "author_profile...
2008/11/21
[ "https://Stackoverflow.com/questions/309071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
309,081
<p>I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. </p> <p>If theres no way of doing it just using css. Is there a way to do it using jQuery?</p>
[ { "answer_id": 309112, "author": "Anand", "author_id": 12649, "author_profile": "https://Stackoverflow.com/users/12649", "pm_score": 2, "selected": false, "text": "<a></a>" }, { "answer_id": 309130, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https:...
2008/11/21
[ "https://Stackoverflow.com/questions/309081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1231/" ]
309,098
<p>How (i.e. using which API) is the virtual keyboard opened on Symbian S60 5th edition? The documentation seems to lack information about this.</p>
[ { "answer_id": 4315560, "author": "tihi", "author_id": 525309, "author_profile": "https://Stackoverflow.com/users/525309", "pm_score": 2, "selected": false, "text": "// lineEdit is an instance of QLineEdit \nQApplication::postEvent(lineEdit, new QEvent(QEvent::RequestSoftwareInputPane...
2008/11/21
[ "https://Stackoverflow.com/questions/309098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39684/" ]
309,101
<p>How do I get the <code>GridView</code> control to render the <code>&lt;thead&gt;</code> <code>&lt;tbody&gt;</code> tags? I know <code>.UseAccessibleHeaders</code> makes it put <code>&lt;th&gt;</code> instead of <code>&lt;td&gt;</code>, but I cant get the <code>&lt;thead&gt;</code> to appear.</p>
[ { "answer_id": 309119, "author": "Phil Jenkins", "author_id": 35496, "author_profile": "https://Stackoverflow.com/users/35496", "pm_score": 9, "selected": true, "text": "gv.HeaderRow.TableSection = TableRowSection.TableHeader;\n" }, { "answer_id": 808819, "author": "ASalvo", ...
2008/11/21
[ "https://Stackoverflow.com/questions/309101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
309,115
<p>I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function.</p> <p>I managed to get an array with the ids of the elements that were selected, and now I want to post that. One way I could do this is to have a dummy form in my page, with a hidden value, and then set the hidden value with the selected items, and post that form; this looks crufty, though. </p> <p>Is there a cleaner way to achieve this, by sending the array directly to the controller? I've tried a few different things but it looks like the controller can't map the data it's receiving. Here's the code so far:</p> <pre><code>function generateList(selectedValues) { var s = { values: selectedValues //selectedValues is an array of string }; $.post("/Home/GenerateList", $.toJSON(s), function() { alert("back") }, "json"); } </code></pre> <p>And then my Controller looks like this</p> <pre><code>public ActionResult GenerateList(List&lt;string&gt; values) { //do something } </code></pre> <p>All I managed to get is a "null" in the controller parameter...</p> <p>Any tips?</p>
[ { "answer_id": 310136, "author": "MrDustpan", "author_id": 34720, "author_profile": "https://Stackoverflow.com/users/34720", "pm_score": 9, "selected": true, "text": "function test()\n{\n var stringArray = new Array();\n stringArray[0] = \"item1\";\n stringArray[1] = \"item2\";\...
2008/11/21
[ "https://Stackoverflow.com/questions/309115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79101/" ]
309,129
<p>I got the following class :</p> <pre><code>class ConstraintFailureSet(dict, Exception) : """ Container for constraint failures. It act as a constraint failure itself but can contain other constraint failures that can be accessed with a dict syntax. """ def __init__(self, **failures) : dict.__init__(self, failures) Exception.__init__(self) print isinstance(ConstraintFailureSet(), Exception) True raise ConstraintFailureSet() TypeError: exceptions must be classes, instances, or strings (deprecated), not ConstraintFailureSet </code></pre> <p>What the heck ?</p> <p>And the worst is that I can't try super() since Exception are old based class...</p> <p>EDIT : And, yes, I've tried to switch the order of inheritance / init.</p> <p>EDIT2 : I am using CPython 2.4 on Ubuntu8.10. You newer know is this kind of infos is usefull ;-). Anyway, this little riddle has shut the mouth of 3 of my collegues. You'd be my best-friend-of-the day...</p>
[ { "answer_id": 309196, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 2, "selected": false, "text": "dict" }, { "answer_id": 309211, "author": "e-satis", "author_id": 9951, "author_profile": "https://St...
2008/11/21
[ "https://Stackoverflow.com/questions/309129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9951/" ]
309,149
<p>When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The problem is then that when the number of datasets is unknown one needs to randomly generate these colors and often they end up very close to each other (green, light green for example). </p> <p>Any ideas on how this could be solved and how it would be possibler to generate distinctly different colors? </p> <p>I'd be great if any examples (feel free to just discuss the problem and solution without examples if you find that easier) were in C# and RGB based colors.</p>
[ { "answer_id": 309193, "author": "Sam Meldrum", "author_id": 16005, "author_profile": "https://Stackoverflow.com/users/16005", "pm_score": 8, "selected": true, "text": "0, 0, 255\n0, 255, 0\n255, 0, 0\n" }, { "answer_id": 3881380, "author": "Filip Rooms", "author_id": 469...
2008/11/21
[ "https://Stackoverflow.com/questions/309149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298/" ]
309,153
<p>Is there a way to link to a chm file, and therein to a certain topic, from a Microsoft Word docx document? Something in the lines of:</p> <blockquote> <p>"For more information about this Property see [link ref="./SomeDirectory/somedocument.chm!Sometopic.Somesubtopic" text="MyClass.MyProperty"]</p> </blockquote>
[ { "answer_id": 310510, "author": "Frank V", "author_id": 18196, "author_profile": "https://Stackoverflow.com/users/18196", "pm_score": 0, "selected": false, "text": "C:\\Helpfiles\\Help.chm#Topic\n" }, { "answer_id": 320800, "author": "Dirk Vollmar", "author_id": 40347, ...
2008/11/21
[ "https://Stackoverflow.com/questions/309153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
309,159
<p>I'm trying to do some abstraction in Haskell98 but doen't know how to do it.</p> <p>What I want to do is to define a class for types that may be converted into lists.</p> <pre><code>toList :: a -&gt; [b] </code></pre> <p>But I don't know how to define a class for this method. I brought up the following three ideas:</p> <pre><code>class ToList a b where toList :: a -&gt; [b] class ToList a where toList :: a -&gt; [b] class ToList a where toList :: a b -&gt; [b] </code></pre> <p>The first one doesn't work because Haskell98 doesn't allow multiple parameter classes.</p> <p>The second one doesn't work because b depends on a and can't be implemented for every b.</p> <p>The third doesn't work either because I don't know how to instanciate the class with a type where 'b' isn't the last type-parameter.</p> <pre><code>data HTree a b = Nil | Node a b (HTree a b) (HTree a b) toList Nil = [] toList Node x y l r = toList l ++ [(x,y)] ++ toList r </code></pre> <p>or</p> <pre><code>toList Nil = [] toList Node x y l r = toList l ++ [x] ++ toList r </code></pre> <p>How would I do something like that?</p>
[ { "answer_id": 311234, "author": "mattiast", "author_id": 8272, "author_profile": "https://Stackoverflow.com/users/8272", "pm_score": -1, "selected": false, "text": "(HTree a)" }, { "answer_id": 312250, "author": "luqui", "author_id": 33796, "author_profile": "https:/...
2008/11/21
[ "https://Stackoverflow.com/questions/309159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9632/" ]
309,161
<p>Is it a simple case of just never using the this.XYZ construct?</p>
[ { "answer_id": 309182, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 4, "selected": true, "text": "this" }, { "answer_id": 309183, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https...
2008/11/21
[ "https://Stackoverflow.com/questions/309161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11538/" ]
309,165
<p>Let's say I have an int with the value of 1. How can I convert that int to a zero padded string, such as <code>00000001</code>?</p>
[ { "answer_id": 309194, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 5, "selected": false, "text": "DECLARE @iVal int = 1\nselect REPLACE(STR(@iVal, 8, 0), ' ', '0')\n" }, { "answer_id": 309207, "author": "...
2008/11/21
[ "https://Stackoverflow.com/questions/309165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
309,203
<p>I used a new Date() object to fill a field in a MySQL DB, but the actual value stored in that field is in my local timezone.</p> <p>How can I configure MySQL to store it in the UTC/GMT timezone?</p> <p>I think, configuring the connection string will help but I don't know how. There are many properties in the connection string like useTimezone, serverTimzone, useGmtMillisForDatetimes, useLegacyDatetimeCode, ...</p>
[ { "answer_id": 309316, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 1, "selected": false, "text": "PreparedStatement" }, { "answer_id": 13405155, "author": "Ted Bigham", "author_id": 868121, "author_...
2008/11/21
[ "https://Stackoverflow.com/questions/309203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19888/" ]
309,205
<p>Since C# is strongly typed, do we really need to prefix variables anymore?</p> <p>e.g.</p> <pre><code>iUserAge iCounter strUsername </code></pre> <p>I used to prefix in the past, but <b>going forward I don't see any benefit</b>.</p>
[ { "answer_id": 309228, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 2, "selected": false, "text": "I" }, { "answer_id": 309239, "author": "Todd Smith", "author_id": 31624, "author_profile": "htt...
2008/11/21
[ "https://Stackoverflow.com/questions/309205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
309,206
<p>At the risk of becoming the village idiot, can someone explain to me why generics are called generics? I understand their usage and benefits, but if the <a href="http://dictionary.reference.com/browse/generic" rel="noreferrer">definition of generic</a> is "general" and generic collections are type safe, then why isn't this a misnomer?</p> <p>For example, an ArrayList can hold anything that's an object:</p> <pre><code>ArrayList myObjects = new ArrayList(); myObjects.Add("one"); myObjects.Add(1); </code></pre> <p>while a generic collection of type string can only hold strings:</p> <pre><code>var myStrings = new List&lt;string&gt;(); myStrings.Add("one"); myStrings.Add("1"); </code></pre> <p>I'm just not clear on why it's called "generic". If the answer is "...which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code." from <a href="http://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx" rel="noreferrer">here</a>, then I suppose that makes sense. Perhaps I'm having this mental lapse because I only began programming after Java introduced generics, so I don't recall a time before them. But still...</p> <p>Any help is appreciated.</p>
[ { "answer_id": 1793614, "author": "Jason Orendorff", "author_id": 94977, "author_profile": "https://Stackoverflow.com/users/94977", "pm_score": 4, "selected": false, "text": "generic" }, { "answer_id": 1793677, "author": "Pavel Minaev", "author_id": 111335, "author_pr...
2008/11/21
[ "https://Stackoverflow.com/questions/309206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2034/" ]
309,255
<p>Does anyone know how to add a an MSBuild .proj file to my solution?</p> <p>I was just given existing code from a vendor with a solution that references an MSBuild .proj file as one of its projects. When I open the solution, the project shows as (unavailable). It appears that I need to install some sort of project template to get this project to open correctly. I installed the <a href="http://www.codeplex.com/MSBuildTemplate" rel="nofollow noreferrer">Codeplex MSBuild Template</a>, but this doesn't appear to be it. </p> <p>Any ideas?</p>
[ { "answer_id": 6822820, "author": "ShadowChaser", "author_id": 497666, "author_profile": "https://Stackoverflow.com/users/497666", "pm_score": 2, "selected": false, "text": "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n <ItemGroup>\n <ProjectReference Incl...
2008/11/21
[ "https://Stackoverflow.com/questions/309255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12497/" ]
309,291
<p>I'm writing an error handling module for a fairly complex system architected into layers. Sometimes our data layer throws obscure exceptions.</p> <p>It would be really handy to log out the <i>values</i> of the parameters of the method that threw the exception. </p> <p>I can reflect on the TargetSite property of the exception to find the method's parameter types and names, but I don't seem to be able to get the values... am I missing something?</p> <hr> <p>Dupe</p> <p><a href="https://stackoverflow.com/questions/157911/in-a-net-exception-how-to-get-a-stacktrace-with-argument-values">In a .net Exception how to get a stacktrace with argument values</a></p>
[ { "answer_id": 309331, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "throw new ArgumentOutOfRangeException(string parameterName, \n object actualValue, string message);\n" ...
2008/11/21
[ "https://Stackoverflow.com/questions/309291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3546/" ]
309,292
<p>I have an ARM kit beside me and a Linux kernel source code patched with Xenomai on my machine. I understand I can send data to the kit through an USB cable and a (windows-based, of course) software, but I'm stumped as to exactly <em>what</em> I should be sending that would make the kit run Linux.</p> <p>(clarifications from comments: It is an Atmel AT91SAM9260-EK kit. It uses SAM-BA and SAM-PROG for the loading and unloading of data through either a serial or USB cable.)</p>
[ { "answer_id": 309331, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "throw new ArgumentOutOfRangeException(string parameterName, \n object actualValue, string message);\n" ...
2008/11/21
[ "https://Stackoverflow.com/questions/309292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39702/" ]
309,303
<p>Currently this expression <code>"I ([a-zA-z]\d]{3} "</code> returns when the following pattern is true:</p> <pre> I AAA I Z99 </pre> <p>I need to modify this so it will return a range of alphanumerics after the I from 2 to 13 that do not have a space.</p> <p>Example:</p> <pre> I AAA I A321 I ASHG310310 </pre> <p>Thanks,</p> <p>Dave</p>
[ { "answer_id": 309335, "author": "Raymond Martineau", "author_id": 33952, "author_profile": "https://Stackoverflow.com/users/33952", "pm_score": 2, "selected": false, "text": "I ([a-zA-Z]|\\d){2,13}\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/309303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
309,322
<p>For my personal stuff I just use the <code>svnadmin hotcopy</code> command once a week but for more mission critical repositories that include many developers, is that enough? Or should I spend the time to put together a more rigorous backup strategy that includes full backups and incremental backups?</p> <p><code>hotcopy</code> seems like the easiest way to go, but I want to be able to restore a repo if, for some reason, it becomes corrupted. Will just doing a dump via <code>hotcopy</code> allow me to do this?</p>
[ { "answer_id": 309463, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "python" }, { "answer_id": 1667123, "author": "Aaron Newton", "author_id": 201648, "author_profile": "...
2008/11/21
[ "https://Stackoverflow.com/questions/309322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13841/" ]
309,333
<p>I have an enum construct like this:</p> <pre><code>public enum EnumDisplayStatus { None = 1, Visible = 2, Hidden = 3, MarkedForDeletion = 4 } </code></pre> <p>In my database, the enumerations are referenced by value. My question is, how can I turn the number representation of the enum back to the string name. </p> <p>For example, given <code>2</code> the result should be <code>Visible</code>.</p>
[ { "answer_id": 309339, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 10, "selected": true, "text": "int" }, { "answer_id": 309345, "author": "Hath", "author_id": 5186, "author_profile": "https://Sta...
2008/11/21
[ "https://Stackoverflow.com/questions/309333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39655/" ]
309,334
<p>What features do you wish were in common languages? More precisely, I mean features which generally don't exist at all but would be nice to see, rather than, "I wish dynamic typing was popular."</p>
[ { "answer_id": 309365, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 0, "selected": false, "text": "type datafoobak = item.datafoobak\nitem.datafoobak = 'tootle'\nitem.handledata()\nitem.datafoobak = datafoobak\n" }, { ...
2008/11/21
[ "https://Stackoverflow.com/questions/309334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192/" ]
309,382
<p>Say I have a xml document that looks like this</p> <pre><code>&lt;foo&gt; &lt;bar id="9" /&gt; &lt;bar id="4" /&gt; &lt;bar id="3" /&gt; &lt;/foo&gt; </code></pre> <p>I would like to use linq to reset the id's to 0, 1 ,2. What would be the easiest way to do this?</p> <p>Thanks</p>
[ { "answer_id": 309407, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "XElement xml = GetXml();\nvar i = 0;\nforeach (var e in xml.Elements(\"bar\"))\n e.SetAttributeValue(\"id\", i++);\n" }, {...
2008/11/21
[ "https://Stackoverflow.com/questions/309382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29961/" ]
309,396
<p>I've got a few methods that should call <code>System.exit()</code> on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since <code>System.exit()</code> terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I subsitute a stub for <code>System.exit()</code>? </p> <p>[EDIT] The class in question is actually a command-line tool which I'm attempting to test inside JUnit. Maybe JUnit is simply not the right tool for the job? Suggestions for complementary regression testing tools are welcome (preferably something that integrates well with JUnit and EclEmma).</p>
[ { "answer_id": 309427, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 9, "selected": true, "text": "System.exit()" }, { "answer_id": 309435, "author": "Scott Bale", "author_id": 2495576, "author_profile": "ht...
2008/11/21
[ "https://Stackoverflow.com/questions/309396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
309,402
<p>In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other. </p> <p>In my code I query faxusers and then foreach user, I query Faxarchives to get the user history. </p> <p>I might do something like: </p> <pre><code>function getUserarchive( $userid) { $out= ""; $dbname = 'Faxarchive'; $db = mysql_select_db($dbname); $sql = "select sent, received from faxarchivetable where userid = '" . $userid . "'"; if ( $rs = mysql_query($sql) { while ($row = mysql_fetch_array($rs) ) { $out = $row['sent'] . " " . $row['received']; }//end while }//end if query return ($out); }//end function $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'Faxusers'; $db = mysql_select_db($dbname); $sql="select distinct userid from faxuserstable"; if ( $rs = mysql_query($sql) { while ($row = mysql_fetch_array($rs) ) { $out = $row['userid'] . ":" . getuserarchive($row['userid']); }//end while }//end if query </code></pre> <p>I'm guessing the switching between databases for each user is causing the slowness. Anyways how i can improve the speed of the processing? </p> <p>thanks in advance.</p>
[ { "answer_id": 309552, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 0, "selected": false, "text": "SELECT sent, received \nFROM Faxarchive.faxarchivetable\nWHERE userid IN ( SELECT DISTINCT userid FROM Faxusers.faxuse...
2008/11/21
[ "https://Stackoverflow.com/questions/309402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
309,405
<p>Currently, we're storing the user's HTTP_REFERER so we can redirect the user back to the previous page they were browsing before they logged in.</p> <p>Http Referer comes from the client and can be spoofed or blank. Is there a more secure/reliable method to deliver this handy user redirect?</p>
[ { "answer_id": 309418, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 2, "selected": false, "text": "history.go(-1);\n" }, { "answer_id": 309428, "author": "Greg", "author_id": 24181, "author_prof...
2008/11/21
[ "https://Stackoverflow.com/questions/309405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26180/" ]
309,412
<p>Is there any way to install Setuptools for Python 2.6 in Windows without having an exe installer? </p> <p>There isn't one built at the moment, and the maintainer of Setuptools has stated that it will probably be a while before he'll get to it. </p> <p>Does anyone know of a way to install it anyway?</p>
[ { "answer_id": 380007, "author": "will-mvn", "author_id": 47632, "author_profile": "https://Stackoverflow.com/users/47632", "pm_score": 3, "selected": false, "text": "python.exe setup.py bdist_wininst\n" }, { "answer_id": 2755659, "author": "Tommy B", "author_id": 331062,...
2008/11/21
[ "https://Stackoverflow.com/questions/309412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/349836/" ]
309,424
<p>If you have a <code>java.io.InputStream</code> object, how should you process that object and produce a <code>String</code>?</p> <hr /> <p>Suppose I have an <code>InputStream</code> that contains text data, and I want to convert it to a <code>String</code>, so for example I can write that to a log file.</p> <p>What is the easiest way to take the <code>InputStream</code> and convert it to a <code>String</code>?</p> <pre><code>public String convertStreamToString(InputStream is) { // ??? } </code></pre>
[ { "answer_id": 309448, "author": "Harry Lime", "author_id": 21590, "author_profile": "https://Stackoverflow.com/users/21590", "pm_score": 12, "selected": true, "text": "IOUtils" }, { "answer_id": 309718, "author": "Paul de Vrieze", "author_id": 4100, "author_profile":...
2008/11/21
[ "https://Stackoverflow.com/questions/309424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16616/" ]
309,438
<p>We have a JavaScript construct that will play .wav files within Firefox on Windows and MacOSX, but it does not work for Red Hat Linux. What extension do I need?</p>
[ { "answer_id": 309611, "author": "luiscubal", "author_id": 32775, "author_profile": "https://Stackoverflow.com/users/32775", "pm_score": 2, "selected": false, "text": "<audio>" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/309438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
309,485
<p>I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a <code>System.NotSupportedException</code>: </p> <blockquote> <p><em>"The given path's format is not supported."</em></p> </blockquote> <p>This was generated by either <code>File.Copy()</code> or <code>Directory.CreateDirectory()</code>.</p> <p>It didn't take long to realize that my file names needed to be sanitized. So I did the obvious thing:</p> <pre><code>public static string SanitizePath_(string path, char replaceChar) { string dir = Path.GetDirectoryName(path); foreach (char c in Path.GetInvalidPathChars()) dir = dir.Replace(c, replaceChar); string name = Path.GetFileName(path); foreach (char c in Path.GetInvalidFileNameChars()) name = name.Replace(c, replaceChar); return dir + name; } </code></pre> <p>To my surprise, I continued to get exceptions. It turned out that ':' is not in the set of <code>Path.GetInvalidPathChars()</code>, because it is valid in a path root. I suppose that makes sense - but this has to be a pretty common problem. Does anyone have some short code that sanitizes a path? The most thorough I've come up with this, but it feels like it is probably overkill.</p> <pre><code> // replaces invalid characters with replaceChar public static string SanitizePath(string path, char replaceChar) { // construct a list of characters that can't show up in filenames. // need to do this because ":" is not in InvalidPathChars if (_BadChars == null) { _BadChars = new List&lt;char&gt;(Path.GetInvalidFileNameChars()); _BadChars.AddRange(Path.GetInvalidPathChars()); _BadChars = Utility.GetUnique&lt;char&gt;(_BadChars); } // remove root string root = Path.GetPathRoot(path); path = path.Remove(0, root.Length); // split on the directory separator character. Need to do this // because the separator is not valid in a filename. List&lt;string&gt; parts = new List&lt;string&gt;(path.Split(new char[]{Path.DirectorySeparatorChar})); // check each part to make sure it is valid. for (int i = 0; i &lt; parts.Count; i++) { string part = parts[i]; foreach (char c in _BadChars) { part = part.Replace(c, replaceChar); } parts[i] = part; } return root + Utility.Join(parts, Path.DirectorySeparatorChar.ToString()); } </code></pre> <p>Any improvements to make this function faster and less baroque would be much appreciated.</p>
[ { "answer_id": 310797, "author": "Dour High Arch", "author_id": 22437, "author_profile": "https://Stackoverflow.com/users/22437", "pm_score": 2, "selected": false, "text": "Path.GetDirectoryName" }, { "answer_id": 847251, "author": "Andre", "author_id": 104672, "autho...
2008/11/21
[ "https://Stackoverflow.com/questions/309485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2683/" ]
309,491
<p>I'm using the following code to try to read the results of a <code>df</code> command in Linux using <code>popen</code>.</p> <pre><code>#include &lt;iostream&gt; // file and std I/O functions int main(int argc, char** argv) { FILE* fp; char * buffer; long bufSize; size_t ret_code; fp = popen("df", "r"); if(fp == NULL) { // head off errors reading the results std::cerr &lt;&lt; "Could not execute command: df" &lt;&lt; std::endl; exit(1); } // get the size of the results fseek(fp, 0, SEEK_END); bufSize = ftell(fp); rewind(fp); // allocate the memory to contain the results buffer = (char*)malloc( sizeof(char) * bufSize ); if(buffer == NULL) { std::cerr &lt;&lt; "Memory error." &lt;&lt; std::endl; exit(2); } // read the results into the buffer ret_code = fread(buffer, 1, sizeof(buffer), fp); if(ret_code != bufSize) { std::cerr &lt;&lt; "Error reading output." &lt;&lt; std::endl; exit(3); } // print the results std::cout &lt;&lt; buffer &lt;&lt; std::endl; // clean up pclose(fp); free(buffer); return (EXIT_SUCCESS); } </code></pre> <p>This code is giving me a "Memory error" with an exit status of '2', so I can see <em>where</em> it's failing, I just don't understand <em>why</em>.</p> <p>I put this together from example code that I found on <a href="http://ubuntuforums.org/showthread.php?t=285287" rel="nofollow noreferrer">Ubuntu Forums</a> and <a href="http://en.cppreference.com/w/cpp/io/c/fread" rel="nofollow noreferrer">C++ Reference</a>, so I'm not married to it. If anyone can suggest a better way to read the results of a system() call, I'm open to new ideas.</p> <p><strong>EDIT to the original:</strong> Okay, <code>bufSize</code> is coming up negative, and now I understand why. You can't randomly access a pipe, as I naively tried to do.</p> <p>I can't be the first person to try to do this. Can someone give (or point me to) an example of how to read the results of a system() call into a variable in C++?</p>
[ { "answer_id": 309505, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 0, "selected": false, "text": "ftell" }, { "answer_id": 309523, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stac...
2008/11/21
[ "https://Stackoverflow.com/questions/309491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
309,494
<p>I'm trying to make a program in Visual C# that has my one created class, and at application launch it creates an array of my class object, and this array of my object can be used all over the program. So any function, or a control's event can access the array of objects and their member variables. I created my class as "public" but for some reason i get these errors upon build: "The name 'MyArrayObjectNameHere' does not exist in the current context" When I try to access the objects member variables inside a load file dialog event in which I am trying to load data from a file into the member variables of the object array.</p> <p>Is there a certain place the object array needs to be declared and constructed so it exists in every context? If so, can you tell me where this is?</p> <p>I currently declare it in the main function before form1 is run.</p> <p>My class definition looks like this in its own .cs file and the programs namespace:</p> <pre><code>public class MyClass { public int MyInt1; public int MyInt2; } </code></pre> <p>I declare the array of objects like this inside the main function before the form load:</p> <pre><code>MyClass[] MyArrayObject; MyArrayObject = new MyClass[50]; for (int i = 0; i &lt; 50; i++) { MyArrayObject[i] = new MyClass(); } </code></pre> <p>Thanks in advance for any help.</p>
[ { "answer_id": 309519, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "public static class MyClassManager\n{\n private MyClass[] _myclasses;\n public MyClass[] MyClassArray\n {\n get\n {\n...
2008/11/21
[ "https://Stackoverflow.com/questions/309494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117494/" ]
309,495
<p>I'm currently using <code>Win32ShellFolderManager2</code> and <code>ShellFolder.getLinkLocation</code> to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, <code>getLinkLocation</code>, this does not work. Specifically, I get an exception stating "Could not get shell folder ID list".</p> <p>Searching the web does turn up mentions of this error message, but always in connection with <code>JFileChooser</code>. I'm not using <code>JFileChooser</code>, I just need to resolve a <code>.lnk</code> file to its destination.</p> <p>Does anyone know of a 3rd-party parser for <code>.lnk</code> files written in Java I could use?</p> <p>I've since found unofficial documentation for the .lnk format <a href="http://mediasrv.ns.ac.yu/extra/fileformat/windows/lnk/shortcut.pdf" rel="noreferrer">here</a>, but I'd rather not have to do the work if anyone has done it before, since the format is rather scary.</p>
[ { "answer_id": 352738, "author": "Sam Brightman", "author_id": 2492, "author_profile": "https://Stackoverflow.com/users/2492", "pm_score": 2, "selected": false, "text": "& 0xff" }, { "answer_id": 672775, "author": "Community", "author_id": -1, "author_profile": "https...
2008/11/21
[ "https://Stackoverflow.com/questions/309495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15255/" ]
309,496
<p>How can I initialize a const / static array of structs as clearly as possible?</p> <pre><code>class SomeClass { struct MyStruct { public string label; public int id; }; const MyStruct[] MyArray = { {"a", 1} {"b", 5} {"q", 29} }; }; </code></pre>
[ { "answer_id": 309528, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "ValueTuple" }, { "answer_id": 309540, "author": "Winston Smith", "author_id": 35086, "author_profile"...
2008/11/21
[ "https://Stackoverflow.com/questions/309496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
309,497
<p>My company has a requirement that all production sites pass an AppScan security scan. Sometimes, when we scan a SharePoint installation, the software detects a blind SQL injection vulnerability. I'm pretty sure this is a false positive--AppScan is probably interpreting some other activity in the HTTP response as success of the blind injection. But it's difficult to prove that this is the case.</p> <p>I suspect that SharePoint, both MOSS 07 and WSS 3.0, uses stored procedures exclusively behind the scenes. Does anyone know if there is any documentation from Microsoft to this effect, and furthermore, whether any of the stored procedures use dynamically-generated SQL? If everything were sprocs, and none of them dynamic, we would have pretty good evidence that SharePoint has no SQL injection vulnerability.</p>
[ { "answer_id": 19728455, "author": "kravietz", "author_id": 1274149, "author_profile": "https://Stackoverflow.com/users/1274149", "pm_score": -1, "selected": false, "text": "WAITFOR DELAY" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/309497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]