qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
156,686
<p>How do I initialize an automatic download of a file in Internet Explorer?</p> <p>For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically .... etc". The download should begin shortly after the page loads.</p> <p>In Firefox this is easy, you just need to include a meta tag in the header, <code>&lt;meta http-equiv="Refresh" content="n;url"&gt;</code> where n is the number of seconds and <code>url</code> is the download URL. This does not work in Internet Explorer. How do I make this work in Internet Explorer browsers?</p>
[ { "answer_id": 156703, "author": "ullmark", "author_id": 23044, "author_profile": "https://Stackoverflow.com/users/23044", "pm_score": 5, "selected": false, "text": "setTimeout(function () { window.location = 'my download url'; }, 5000)\n" }, { "answer_id": 156715, "author": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4685/" ]
156,688
<p>I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflect this.</p> <p>Is there a way a can check the data integruity by performing a select statement on the database, alternatively is there a way to force the database to recache? </p>
[ { "answer_id": 156703, "author": "ullmark", "author_id": 23044, "author_profile": "https://Stackoverflow.com/users/23044", "pm_score": 5, "selected": false, "text": "setTimeout(function () { window.location = 'my download url'; }, 5000)\n" }, { "answer_id": 156715, "author": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
156,689
<p>Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks?</p> <p>Example:</p> <pre><code>@MappedSuperclass() public class BaseEntity { private Long id; private Long version; ... @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() {return id;} public void setId(Long id) {this.id = id;} @Version public Long getVersion() {return version;} ... // Common properties @Temporal(TemporalType.TIMESTAMP) public Date creationDate() {return creationDate;} ... } @Entity public class Customer extends BaseEntity { private String customerName; ... } </code></pre>
[ { "answer_id": 414950, "author": "Matt Sidesinger", "author_id": 1481472, "author_profile": "https://Stackoverflow.com/users/1481472", "pm_score": 3, "selected": false, "text": "public abstract class BaseEntity implements Serializable {\n\n public abstract Long getId();\n public ab...
2008/10/01
[ "https://Stackoverflow.com/questions/156689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
156,696
<p>Which browsers other than Firefox support Array.forEach()? <a href="http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach#Compatibility" rel="noreferrer">Mozilla say it's an extension to the standard</a> and I realise it's trivial to add to the array prototype, I'm just wondering what other browsers support it?</p>
[ { "answer_id": 65302130, "author": "jac wida", "author_id": 14762559, "author_profile": "https://Stackoverflow.com/users/14762559", "pm_score": 0, "selected": false, "text": "foreach" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21030/" ]
156,697
<p>In my environment here I use Java to serialize the result set to XML. It happens basically like this:</p> <pre><code>//foreach column of each row xmlHandler.startElement(uri, lname, "column", attributes); String chars = rs.getString(i); xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endElement(uri, lname, "column"); </code></pre> <p>The XML looks like this in Firefox:</p> <pre><code>&lt;row num="69004"&gt; &lt;column num="1"&gt;10069&lt;/column&gt; &lt;column num="2"&gt;sd&amp;#26;&lt;/column&gt; &lt;column num="3"&gt;FCVolume &lt;/column&gt; &lt;/row&gt; </code></pre> <p>But when I parse the XML I get the a</p> <blockquote> <p>org.xml.sax.SAXParseException: Character reference "<strong>&amp;#26</strong>" is an invalid XML character.</p> </blockquote> <p>My question now is: Which charactes do I have to replace or how do I have to encode my characters, that they will be valid XML?</p>
[ { "answer_id": 156741, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 2, "selected": false, "text": "<column num=\"1\"><![CDATA[10069]]></column>\n<column num=\"2\"><![CDATA[sd&]]></column>\n" }, { "answer_id": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21027/" ]
156,701
<p>This is a question with many answers - I am interested in knowing what others consider to be "best practice".</p> <p>Consider the following situation: you have an object-oriented program that contains one or more data structures that are needed by many different classes. How do you make these data structures accessible?</p> <ol> <li><p>You can explicitly pass references around, for example, in the constructors. This is the "proper" solution, but it means duplicating parameters and instance variables all over the program. This makes changes or additions to the global data difficult.</p></li> <li><p>You can put all of the data structures inside of a single object, and pass around references to this object. This can either be an object created just for this purpose, or it could be the "main" object of your program. This simplifies the problems of (1), but the data structures may or may not have anything to do with one another, and collecting them together in a single object is pretty arbitrary.</p></li> <li><p>You can make the data structures "static". This lets you reference them directly from other classes, without having to pass around references. This entirely avoids the disadvantages of (1), but is clearly not OO. This also means that there can only ever be a single instance of the program.</p></li> </ol> <p>When there are a lot of data structures, all required by a lot of classes, I tend to use (2). This is a compromise between OO-purity and practicality. What do other folks do? (For what it's worth, I mostly come from the Java world, but this discussion is applicable to any OO language.)</p>
[ { "answer_id": 156919, "author": "Zarkonnen", "author_id": 15255, "author_profile": "https://Stackoverflow.com/users/15255", "pm_score": 2, "selected": false, "text": "FwurzleDigestionListener" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732/" ]
156,712
<p>If I hit a page which calls <code>session_start()</code>, how long would I have to wait before I get a new session ID when I refresh the page?</p>
[ { "answer_id": 156733, "author": "jochil", "author_id": 23794, "author_profile": "https://Stackoverflow.com/users/23794", "pm_score": 3, "selected": false, "text": "phpinfo()" }, { "answer_id": 156819, "author": "flamingLogos", "author_id": 8161, "author_profile": "ht...
2008/10/01
[ "https://Stackoverflow.com/questions/156712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1741868/" ]
156,724
<p>I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in :) Here's an excerpt of the stack trace:</p> <pre><code>Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.PresenceHome.customerId to java.lang.String </code></pre> <p>I'm trying to get a parameter set on my URL passed into one of my beans. To do this, I've got the following set up in my pages.xml:</p> <pre><code>&lt;page view-id="/customer/presences.xhtml"&gt; &lt;begin-conversation flush-mode="MANUAL" join="true" /&gt; &lt;param name="customerId" value="#{presenceHome.customerId}" /&gt; &lt;raise-event type="PresenceHome.init" /&gt; &lt;navigation&gt; &lt;rule if-outcome="persisted"&gt; &lt;end-conversation /&gt; &lt;redirect view-id="/customer/presences.xhtml" /&gt; &lt;/rule&gt; &lt;/navigation&gt; &lt;/page&gt; </code></pre> <p>My bean starts like this:</p> <pre><code>@Name("presenceHome") @Scope(ScopeType.CONVERSATION) public class PresenceHome extends EntityHome&lt;Presence&gt; implements Serializable { @In private CustomerDao customerDao; @In(required = false) private Long presenceId; @In(required = false) private Long customerId; private Customer customer; // Getters, setters and other methods follow. They return the correct types defined above } </code></pre> <p>Finally the link I use to link one one page to the next looks like this:</p> <pre><code>&lt;s:link styleClass="#{selected == 'presences' ? 'selected' : ''}" view="/customer/presences.xhtml" title="Presences" propagation="none"&gt; &lt;f:param name="customerId" value="#{customerId}" /&gt; Presences &lt;/s:link&gt; </code></pre> <p>All this seems to work fine. When I hover over the link above in my page, I get a URL ending in something like "?customerId=123". So the parameter is being passed over and it's something that can be easily converted into a Long type. But for some reason, it's not. I've done similar things to this before in other projects and it's worked then. I just can't see what it isn't working now.</p> <p>If I remove the element from my page declaration, I get through to the page fine.</p> <p>So, does anyone have any thoughts?</p>
[ { "answer_id": 157090, "author": "Chobicus", "author_id": 1514822, "author_profile": "https://Stackoverflow.com/users/1514822", "pm_score": 0, "selected": false, "text": "<f:param name=\"customerId\" value=\"#{customerId.toString()}\" />" }, { "answer_id": 157310, "author": "...
2008/10/01
[ "https://Stackoverflow.com/questions/156724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900/" ]
156,745
<p>I am using Eclipse for quite some time and I still haven't found how to configure the Problems View to display only the Errors and Warnings of interest. Is there an easy way to filter out warnings from a specific resource or from a specific path? For example, when I generate javadoc I get tons of irrelevant html warnings. Also, is there a way to change the maximum number of appearing warnings/errors?</p> <p>I am aware of the filters concept, but I am looking for some real life examples. What kind of filters or practices do other people use?</p> <p><strong>Edit:</strong> I found the advice to filter on "On selected element and its children" to be the best one. I have one other issue however. If I have "a lot" of warnings or errors, only the first 100 appear. In the rare case I want to see all of them, how do I do it?</p>
[ { "answer_id": 9283019, "author": "Claude COULOMBE", "author_id": 1209842, "author_profile": "https://Stackoverflow.com/users/1209842", "pm_score": 2, "selected": false, "text": "Configure Contents" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24054/" ]
156,748
<p>How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site?</p> <p>Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at:</p> <p><a href="http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/" rel="noreferrer">http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/</a></p> <p>Is there a better / updated way with Preview 5?,</p>
[ { "answer_id": 1116780, "author": "Simon_Weaver", "author_id": 16940, "author_profile": "https://Stackoverflow.com/users/16940", "pm_score": 4, "selected": false, "text": " [RequireSsl(Redirect = true)]\n" }, { "answer_id": 2359061, "author": "Amadiere", "author_id": 7...
2008/10/01
[ "https://Stackoverflow.com/questions/156748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13238/" ]
156,767
<p>When verbally talking about methods, I'm never sure whether to use the word <em>argument</em> or <em>parameter</em> or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms?</p> <p>I'm a C# programmer, but I also wonder whether people use different terms in different languages.</p> <p>For the record I'm self-taught without a background in Computer Science. (Please don't tell me to read <a href="http://www.amazon.co.uk/Code-Complete-Practical-Handbook-Construction/dp/0735619670/" rel="noreferrer">Code Complete</a> because I'm asking this for the benefit of other people who don't already have a copy of <a href="http://www.stevemcconnell.com/" rel="noreferrer">Steve McConnell</a>'s marvellous book.)</p> <h3>Summary</h3> <p>The general consensus seems to be that it's OK to use these terms interchangeably in a team environment. Except perhaps when you're defining the precise terminology; then you can also use "<em>formal</em> argument/parameter" and "<em>actual</em> argument/parameter" to disambiguate.</p>
[ { "answer_id": 156787, "author": "Torbjörn Hansson", "author_id": 22683, "author_profile": "https://Stackoverflow.com/users/22683", "pm_score": 11, "selected": true, "text": "public void MyMethod(string myParam) { }\n\n...\n\nstring myArg1 = \"this is my argument\";\nmyClass.MyMethod(myA...
2008/10/01
[ "https://Stackoverflow.com/questions/156767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5351/" ]
156,769
<p>The workflow is like this:</p> <ol> <li>I receive a scan of a coupon with data (firstname, lastname, zip, city + misc information) on it.</li> <li>Before I create a new customer, I have to search the database if the customer might exist already.</li> </ol> <p>Now my question: What's the best way to find an existing customer, when there is no unique ID available?</p> <p>PS: I do have a unique ID in the database, just not on the coupons we receive ;)</p>
[ { "answer_id": 156805, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": -1, "selected": false, "text": "SELECT ID FROM tbl_customers WHERE \n first_name LIKE 'JOHN' \n AND last_name LIKE 'Doe' \n AND zip_code=12345 \n AN...
2008/10/01
[ "https://Stackoverflow.com/questions/156769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24053/" ]
156,777
<p>This is a followup question of <a href="https://stackoverflow.com/questions/156697/how-to-encode-characters-from-oracle-to-xml">How to encode characters from Oracle to Xml?</a></p> <p>In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler.</p> <p>When I try to output characters in a CDATA Section:</p> <p>It happens basically like this:</p> <pre><code>xmlHandler.startElement(uri, lname, "column", attributes); String chars = "&lt;![CDATA["+rs.getString(i)+"]]&gt;"; xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endElement(uri, lname, "column"); </code></pre> <p>I get this:</p> <pre><code>&lt;column&gt;&amp;lt;![CDATA[33665]]&amp;gt;&lt;/column&gt; </code></pre> <p>But I want this:</p> <pre><code>&lt;column&gt;&lt;![CDATA[33665]]&gt;&lt;/column&gt; </code></pre> <p>So how can I output a CDATA section with a Sax ContentHandler?</p>
[ { "answer_id": 157635, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 4, "selected": true, "text": "<![CDATA[" }, { "answer_id": 3594066, "author": "Dani", "author_id": 434140, "author_profile": "https:...
2008/10/01
[ "https://Stackoverflow.com/questions/156777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21027/" ]
156,779
<p>I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method:</p> <pre><code>public static T GetItem&lt;T&gt;(string key, Func&lt;T&gt; defaultValue) { if (HttpContext.Current.Session[key] == null) { HttpContext.Current.Session[key] = defaultValue.Invoke(); } return (T)HttpContext.Current.Session[key]; } </code></pre> <p>Now, how do I actually use this, passing in the Func&lt;T&gt; as an inline method parameter?</p>
[ { "answer_id": 156789, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "defaultValue.Invoke()" }, { "answer_id": 156802, "author": "Marc Gravell", "author_id": 23354, "a...
2008/10/01
[ "https://Stackoverflow.com/questions/156779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
156,799
<p>In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?</p>
[ { "answer_id": 156876, "author": "janm", "author_id": 7256, "author_profile": "https://Stackoverflow.com/users/7256", "pm_score": 3, "selected": false, "text": "static int s_value_one;\nstatic int s_value_two = 123;\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11554/" ]
156,800
<p>I have created a nice silverlight control doing exactly what I want it to do, and it looks great :) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely.</p> <p>I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The problem I'm having is that the control don't show up exactly how it should:</p> <ul> <li>The loading progress don't show</li> <li>The control usually don't become visible before I move my mouse over the aria where it's contained</li> </ul> <p>Obviously it's something with my HTML/CSS design causing this, but it will be extremely time consuming to find the issue - so does anyone have knowledge in this area? What are the rules around how to make sure the control is displayed properly? What CSS properties should be used?</p> <p>PS: Since I have a 2.0 app, I'm using the object tag approach to Silverlight, and it's contained in a DIV with height and width set in style.</p> <p>Code snippet was requested. It's something like this (basically a copy of the HTML test page from the silverlight test project (which work perfectly)):</p> <pre><code>&lt;div id="silverlightControlHost" style="height: 300px; width: 750px;"&gt; &lt;object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%"&gt; &lt;param name="source" value="Contiki.SilverLight.FileUploader.xap" /&gt; &lt;param name="onerror" value="onSilverlightError" /&gt; &lt;param name="background" value="white" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt; &lt;iframe style='visibility: hidden; height: 0; width: 0; border: 0px'&gt;&lt;/iframe&gt; &lt;/div&gt; </code></pre> <p>This DIV is contained in a cell in a table, which again is part of a larger design. There's a lot of CSS as mentioned. Don't know if this helps...</p>
[ { "answer_id": 225662, "author": "Torbjørn", "author_id": 22621, "author_profile": "https://Stackoverflow.com/users/22621", "pm_score": 3, "selected": true, "text": "<script type=\"text/javascript\">\n function refreshSL()\n {\n var div = document.getElementById('silverlight...
2008/10/01
[ "https://Stackoverflow.com/questions/156800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22621/" ]
156,810
<p>What is the best way to download files to local hard drive when logged in to another computer using ssh in bash. I'm aware of sftp, but it is not convienent, e.g. it lacks tab completion of directory names. I'm using Ubuntu 8.04.1 . I don't have a public IP and would not like to setup dynamic Dynamic DNS solution.</p>
[ { "answer_id": 156881, "author": "Sam Stokes", "author_id": 20131, "author_profile": "https://Stackoverflow.com/users/20131", "pm_score": 4, "selected": true, "text": "$ scp me@myserver.mydomain.com:.bashr<TAB>\n" }, { "answer_id": 185600, "author": "ephemient", "author_i...
2008/10/01
[ "https://Stackoverflow.com/questions/156810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11439/" ]
156,815
<p>In a <a href="https://stackoverflow.com/questions/9033#9099">question answer</a> I find the following coding tip:-</p> <p>2) simple lambdas with one parameter:</p> <pre><code>x =&gt; x.ToString() //simplify so many calls </code></pre> <p>As someone who has not yet used 3.0 I don't really understand this tip but it looks interesting so I would appreciate an expantion on how this simplifies calls with a few examples.</p> <p>I've researched lambdas so I <strong>think</strong> I know what they do, however I <strong>may</strong> not fully understand so a <strong>little</strong> unpacking might also be in order.</p>
[ { "answer_id": 156823, "author": "Jacob", "author_id": 22107, "author_profile": "https://Stackoverflow.com/users/22107", "pm_score": 2, "selected": false, "text": "private string Lambda(object x) {\n return x.ToString();\n}\n" }, { "answer_id": 156838, "author": "Jon Skeet",...
2008/10/01
[ "https://Stackoverflow.com/questions/156815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
156,833
<p>I need to consume a wcf service dynamically when all i know is its URL. I do not have the option of creating a service reference or web reference as my client side code picks up the URL from a config file. What classes and methods can i use from the System.ServiceModel namespace for doing so.</p>
[ { "answer_id": 156848, "author": "Rinat Abdullin", "author_id": 47366, "author_profile": "https://Stackoverflow.com/users/47366", "pm_score": 1, "selected": false, "text": "using (WebChannelFactory<IService> wcf = new WebChannelFactory<IService>(new Uri(\"http://localhost:8000/Web\")))\n...
2008/10/01
[ "https://Stackoverflow.com/questions/156833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16439/" ]
156,835
<p>I have inherited some code for a custom CMS that is a little out of my league and keep stumbling over the same errors, Notice: Undefined variable: media in /Applications/MAMP/htdocs/Chapman/Chapman_cms/admin/team-2.php on line 48. This is supposed to create new users and edit old users. However, it does not work when I try and add a new user.</p> <p>Below is the pertinant code:</p> <pre><code>$db = new database("mysql",$dbHost,$dbName,$dbUser,$dbPass); $target = 'add'; if ($_GET['task'] == 'edit') { $media = $db-&gt;get_row(edit_media_item($db, $_GET['team_id'])); $target = 'update'; &lt;p&gt;&lt;label for="copy"&gt;Full Name:&lt;/label&gt; &lt;input type="text" name="title" value="&lt;?=$media['title']?&gt;" /&gt; &lt;textarea name="media" id="media" cols="30" rows="5" style="width: 100%"&gt;&lt;?=$media['copy']?&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;input type="hidden" name="process" value="&lt;?=$target.",copy,4,team-1,".$media['id'].""?&gt;"&gt; &lt;p&gt;&lt;input type="submit" name="save" value="Submit" /&gt; &lt;input type="reset" name="reset" value="Reset" /&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>Any help would be much appreciated.</p>
[ { "answer_id": 156882, "author": "Lasar", "author_id": 9438, "author_profile": "https://Stackoverflow.com/users/9438", "pm_score": 0, "selected": false, "text": "<?=$media['copy']?>" }, { "answer_id": 156909, "author": "Ólafur Waage", "author_id": 22459, "author_profi...
2008/10/01
[ "https://Stackoverflow.com/questions/156835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
156,852
<p>Ok, here's one for the Java/JavaScript gurus:</p> <p>In my app, one of the controllers passes a TreeMap to it's JSP. This map has car manufacturer's names as keys and Lists of Car objects as values. These Car objects are simple beans containing the car's name, id, year of production etc. So, the map looks something like this (this is just an example, to clarify things a bit):</p> <p>Key: Porsche<br/> Value: List containing three Car objects(for example 911,Carrera,Boxter with their respectable years of production and ids)<br/> Key: Fiat<br/> Value: List containing two Car objects(for example, Punto and Uno)<br/> etc...</p> <p>Now, in my JSP i have two comboboxes. One should receive a list of car manufacturers(keys from the map - this part I know how to do), and the other one should <strong>dynamicaly change</strong> to display the names of the cars when the user selects a certain manufacturer from the first combobox. So, for example, user selects a "Porsche" in the first combobox, and the second immediately displays "911, Carrera, Boxter"...</p> <p>After spending a couple of days trying to find out how to do this, I'm ready to admit defeat. I tried out a lot of different things but every time I hit a wall somewehere along the way. Can anybody suggest how I should approach this one? Yes, I'm a JavaScript newbie, if anybody was wondering... <br/></p> <p>EDIT: I've retagged this as a code-challenge. Kudos to anybody who solves this one without using any JavaScript framework (like JQuery).</p>
[ { "answer_id": 156865, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "var map = {\n 'porsche': [ 'boxter', '911', 'carrera' ],\n 'fiat': ['punto', 'uno']\n};\n" }, { "answer_id": 16060...
2008/10/01
[ "https://Stackoverflow.com/questions/156852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19911/" ]
156,873
<p>I'm writing a shell for a project of mine, which by design parses commands that looks like this:</p> <p>COMMAND_NAME ARG1="Long Value" ARG2=123 ARG3=me@me.com</p> <p>My problem is that Python's command line parsing libraries (getopt and optparse) forces me to use '-' or '--' in front of the arguments. This behavior doesn't match my requirements.</p> <p>Any ideas how can this be solved? Any existing library for this?</p>
[ { "answer_id": 156901, "author": "Thomas Wouters", "author_id": 17624, "author_profile": "https://Stackoverflow.com/users/17624", "pm_score": 0, "selected": false, "text": "parser = optparse.OptionParser()\nparser.add_option(\"--ARG1\", dest=\"arg1\", help=\"....\")\nparser.add_option(.....
2008/10/01
[ "https://Stackoverflow.com/questions/156873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9941/" ]
156,880
<p>I have some REST web services implemented in WCF. I wish to make these services return "Bad Request" when the xml contains invalid elements.</p> <p>The xml serialization is being handled by XmlSerializer. By default XmlSerializer ignores unknown elements. I know it is possible to hook XmlSerializer.UnknownElement and throw an exception from this handler, but because this is in WCF I have no control over serialization. Any ideas how I might implement this behavior.</p>
[ { "answer_id": 163331, "author": "DavidWhitney", "author_id": 1297, "author_profile": "https://Stackoverflow.com/users/1297", "pm_score": 1, "selected": false, "text": " protected override void OnWriteMessage(XmlDictionaryWriter writer)\n {\n ...\n }\n\n protected over...
2008/10/01
[ "https://Stackoverflow.com/questions/156880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2281/" ]
156,911
<p>I am going to work on a project where a fairly large web app needs to tweaked to handle several languages. The thing runs with a hand crafted PHP code but it's pretty clean.</p> <p>I was wondering what would be the best way to do that?</p> <ol> <li><p>Making something on my own, trying to fit the actual architecture.</p></li> <li><p>Rewriting a good part of it using a framework (e.g., Symfony) that will manage i18n for me?</p></li> </ol> <p>For option 1, where should I store the i18n data? *.po, xliff, pure DB?</p> <p>I thought about an alternative: using Symfony only for the translation, but setting the controller to load the website as it already is. Quick, but dirty. On the other hand, it allows us to make the next modification, moving slowly to full Symfony: this web site is really a good candidate for that.</p> <p>But maybe there are some standalone translation engines that would do the job better than an entire web framework. It's a bit like using a bazooka to kill a fly...</p>
[ { "answer_id": 1620010, "author": "Niklas Rosencrantz", "author_id": 108207, "author_profile": "https://Stackoverflow.com/users/108207", "pm_score": -1, "selected": false, "text": "{% get_current_language as LANGUAGE_CODE %}{{ LANGUAGE_CODE }}{% get_available_languages as LANGUAGES %}{% ...
2008/10/01
[ "https://Stackoverflow.com/questions/156911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9951/" ]
156,912
<p>I am working on developing an on-screen keyboard with java. This keyboard has a <code>JComponent</code> for every possible key. When a mouse down is detected on the button, I want to send a specific keyboard code to the application currently on focus. The keyboard itself is within a <code>JFrame</code> with no decorations and set to always-on-top.</p> <p>I found that the Robot class can be used to simulate these keyboard events on the native queue. However, in this case, selecting the <code>JComponent</code> would mean that the key-press is received on the <code>JFrame</code>, and I wouldn't be able to receive it in the other application</p> <p>How can I keep my on-screen keyboard "Always-without-focus"? Is it maybe possible to use another approach to send the key-press? </p>
[ { "answer_id": 187501, "author": "Mario Ortegón", "author_id": 2309, "author_profile": "https://Stackoverflow.com/users/2309", "pm_score": 2, "selected": false, "text": " setUndecorated(true);\n setFocusableWindowState(false);\n setFocusable(false);\n enableInputMethods(false...
2008/10/01
[ "https://Stackoverflow.com/questions/156912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309/" ]
156,913
<p><strong>Concrete use case:</strong> In the Eclipse IDE, new 'plugins' can be added by copying a plugin's file(s) into the <code>$ECLIPSE_HOME/plugins</code> directory. However, I want to keep my original Eclipse installation 'clean' without additional plugins because I want to run this basic installation on its own at times. </p> <p>What is a way of avoiding having to copy the files (and hence therefore not being able to run a clean version) and instead logically 'overlaying' the contents of another directory so that it appears to be in the directory at runtime?</p> <p>e.g. something like:</p> <pre><code>gravelld@gravelld-laptop:~$ ls $ECLIPSE_HOME/plugins/ org.junit_3.8.2.v200706111738 org.junit4_4.3.1 org.junit.source_3.8.2.v200706111738 gravelld@gravelld-laptop:~$ ls myplugins/ org.dangravell.myplugin.jar gravelld@gravelld-laptop:~$ overlay myplugins/ $ECLIPSE_HOME/plugins gravelld@gravelld-laptop:~$ ls $ECLIPSE_HOME/plugins/ org.dangravell.myplugin.jar org.junit_3.8.2.v200706111738 org.junit4_4.3.1 org.junit.source_3.8.2.v200706111738 </code></pre> <p>Another use case may be around patching and so on...</p> <p>Can something be done with symbolic links or mnt for this?</p> <p>Thanks!</p>
[ { "answer_id": 157180, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "/path/links -> /remote/links/commonPlugins\n/eclipse/links -> ../links\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
156,916
<p>I need to list all files whose names start with 'SomeLongString'. But the case of 'SomeLongString' can vary. How?</p> <p>I am using zsh, but a bash solution is also welcome.</p>
[ { "answer_id": 156953, "author": "Horst Gutmann", "author_id": 22312, "author_profile": "https://Stackoverflow.com/users/22312", "pm_score": 4, "selected": false, "text": "find" }, { "answer_id": 156958, "author": "Jacek Szymański", "author_id": 23242, "author_profile...
2008/10/01
[ "https://Stackoverflow.com/questions/156916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
156,930
<p>We have an existing classic ASP intranet consisting of hundreds of pages. Its directory structure looks like this...</p> <pre><code>/root app_1 app_2 ... img js style </code></pre> <p>Obviously app_1 and so on have better names in the actual directory structure.</p> <p>Even though the many applications have different behaviour, they are all part of the same intranet and therefore share a common look and feel by including stylesheets via /style, images via /img and client script via /js.</p> <p>The trouble (for me at least) comes when I want to add an intranet application in ASP.NET.</p> <p>Ultimately, I'd like this structure:</p> <pre><code>/root app_1 app_2 dotnetapp_1 dotnetapp_2 ... img js style </code></pre> <p>It seems to me that ASP.NET "applications" like to think of themselves as separate from everything around them (this may just be my comprehension of how they are). You create a new "project" in Visual Studio and it's like you have a new "root" a level below the actual root I want to use. It's like this new application is a thing, standing alone, with its own images and style and whatnot. However, I want it to be a sub-part of the existing intranet.</p> <p>Ultimately I want to be able to make my whole classic ASP intranet the "root" and have ASP.NET "sub-applications" that can still access /style and /img and, I guess for ASP.NET I'll have /masterpages.</p> <p>I've tried this before, but I think VS choked on the couple of hundred classic ASP pages that it added to the "project" when I made my existing intranet root directory the ASP.NET project root (via File->Open->Web Site). I'd be nice to edit my existing classic ASP intranet using VS 2008 SP1 (I currently use the excellent <a href="http://notepad-plus.sourceforge.net/uk/site.htm" rel="nofollow noreferrer">Notepad++</a>) because I'd like to get more hands on with VS but I guess this isn't absolutely necessary.</p> <p>I also tried treating each new ASP.NET application as an application in its own right, effectively making the /dotnetapp_1 directory the "root" of the application (again, via File->Open->Web Site in VS2008). However, VS then complained when I tried to reference /masterpages because it "belonged to another application." I think I kludged it by adding a virtual directory inside each ASP.NET directory that "pointed" to the root /masterpages but I'm not sure VS was able to happily provide WYSIWYG editing when I did this, as opposed to making a copy of the masterpage in every ASP.NET application I add to the intranet.</p> <p>I'm also quite likely to visit the .NET MVC framework so please offer any answers with that framework in mind. I'm hoping "projects" aren't quite to important with MVC and that rather it's just a bunch of files that creates an application that contributes to the whole (that being the intranet).</p> <p>So, the question is: <strong>How I can best add-on ASP.NET applications to an existing classic ASP intranet (I'm not concerned about the technicalities of session sharing between classic ASP and ASP.NET, only the structural layout of directories and projects) and be able to edit these separate applications in Visual Studio 2008 SP1 and yet have these application "related" to each other by a common, intranet look and feel*?</strong></p> <ul> <li>Please don't just post the answer "use MasterPages." I appreciate MasterPages are .NET's method of sharing styles (and more probably) between related pages in the <em>same</em> application. I get that. What I'm looking for is the best method of adding ASP.NET applications into the existing intranet as smoothly as I can that makes editing each application simple and where each application can share (if possible) an intranet-common style.</li> </ul>
[ { "answer_id": 157244, "author": "rohancragg", "author_id": 5351, "author_profile": "https://Stackoverflow.com/users/5351", "pm_score": 2, "selected": false, "text": "/root\n app_1\n app_2\n dotnetapp_1\n <virtual>img\n <virtual>js\n ...\n img\n js\n style\n" }, { "a...
2008/10/01
[ "https://Stackoverflow.com/questions/156930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7508/" ]
156,936
<p>I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance and I would be glad to accept your help.</p> <p>I would like to expose an iterator for a class like this:</p> <pre><code>template &lt;class T&gt; class MyContainer { public: // Here is the problem: // typedef for MyIterator without exposing std::vector publicly? MyIterator Begin() { return mHiddenContainerImpl.begin(); } MyIterator End() { return mHiddenContainerImpl.end(); } private: std::vector&lt;T&gt; mHiddenContainerImpl; }; </code></pre> <p>Am I trying at something that isn't a problem? Should I just typedef std::vector&lt; T >::iterator? I am hoping on just depending on the iterator, not the implementing container...</p>
[ { "answer_id": 156995, "author": "Sébastien RoccaSerra", "author_id": 2797, "author_profile": "https://Stackoverflow.com/users/2797", "pm_score": 1, "selected": false, "text": "typedef typename std::vector<T>::iterator MyIterator;\n" }, { "answer_id": 157010, "author": "Pierr...
2008/10/01
[ "https://Stackoverflow.com/questions/156936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2166173/" ]
156,941
<p>I have a scenario like this which I want to use capistrano to deploy my ruby on rails application:</p> <ol> <li>The web application is on a thin cluster with the config file stored under /etc/thin. also an init script is in /etc/init.d/thin, so it would start automatically whenever my server needs a reboot</li> <li>Also nginx is executed the same way (as an init script daemon)</li> <li>To make sure in case if somebody hacked my webserver I don't want them to do something too horrible, so the web user is not allowed to sudo. </li> <li>Thin and nginx both runs as the webuser to enforce such security</li> </ol> <p>Now when I need to do the deployment, I would need the files to be installed under /home/webuser/railsapps/helloworld, and I need the cap script restart my thin afterwards. I want to keep all files owned by the webuser, so the cap script primary user is running as webuser. Now the problem arise when I want to restart the thin daemon because webuser can't sudo. </p> <p>I am thinking if its possible to invoke two separate sessions- webuser for file deployment, and then a special sudoer to restart the daemon. Can anyone give me a sample script on this?</p>
[ { "answer_id": 156957, "author": "Dre", "author_id": 23033, "author_profile": "https://Stackoverflow.com/users/23033", "pm_score": 2, "selected": false, "text": "someuser ALL=NOPASSWD: /etc/init.d/apache2\n" }, { "answer_id": 6385966, "author": "Morgz", "author_id": 35101...
2008/10/01
[ "https://Stackoverflow.com/questions/156941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16371/" ]
156,954
<p>I need something in between a full text search and an index search:<br> I want to search for text in one column of my table (probably there will be an index on the column, too, if that matters).</p> <p>Problem is, I want to search for words in the column, but I don't want to match parts. </p> <p>For example, my column might contain business names:<br> <em>Mighty Muck Miller and Partners Inc.<br> Boy &amp; Butter Breakfast company</em> </p> <p>Now if I search for "<em>Miller</em>" I want to find the first line. But if I search for "<em>iller</em>" I don't want to find it, because there is no word starting with "iller". Searching for "<em>Break</em>" should find "<em>Boy &amp; Butter Breakfast company</em>", though, since one word is starting with "<em>Break</em>".</p> <p>So if I try and use </p> <pre><code>WHERE BusinessName LIKE %Break% </code></pre> <p>it will find too many hits.</p> <p>Is there any way to Search for Words separated by whitespace <strong>or other delimiters</strong>? </p> <p>(LINQ would be best, plain SQL would do, too)</p> <p><strong>Important:</strong> Spaces are by far not the only delimiters! Slashes, colons, dots, all non-alphanumerical characters should be considered for this to work!</p>
[ { "answer_id": 156978, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 2, "selected": false, "text": "where BusinessName like 'Break%' -- to find if it is beginning with the word\nor BusinessName like '% Break%' -- to find if it co...
2008/10/01
[ "https://Stackoverflow.com/questions/156954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
156,975
<p>I have a JLabel (actually, it is a JXLabel).</p> <p>I have put an icon and text on it.</p> <p><code>&lt;icon&gt;&lt;text&gt;</code></p> <p>Now I wand to add some spacing on the left side of the component, like this:</p> <p><code>&lt;space&gt;&lt;icon&gt;&lt;text&gt;</code></p> <p>I DON'T accept suggestion to move the JLabel or add spacing by modifying the image.</p> <p>I just want to know how to do it with plain java code.</p>
[ { "answer_id": 157017, "author": "rjohnston", "author_id": 246, "author_profile": "https://Stackoverflow.com/users/246", "pm_score": 2, "selected": false, "text": "JPanel panel = new JPanel();\npanel.setLayoutManager(new BoxLayout(panel, BoxLayout.LINE_AXIS);\n\npanel.add(new JLabel(\"th...
2008/10/01
[ "https://Stackoverflow.com/questions/156975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15173/" ]
156,994
<p>I'm running MySQL 5 on a linux server on my local network. Running windows XP for my desktop. Had a look at the <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html" rel="nofollow noreferrer">MySQL GUI Tools</a> but I dont think they help. I cannot install apache on the remote server &amp; use something like PHPmyAdmin.</p>
[ { "answer_id": 157066, "author": "Liam", "author_id": 18333, "author_profile": "https://Stackoverflow.com/users/18333", "pm_score": 1, "selected": false, "text": "insert into tablename values('" }, { "answer_id": 160585, "author": "Gareth", "author_id": 24352, "author...
2008/10/01
[ "https://Stackoverflow.com/questions/156994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6828/" ]
157,005
<p>In HTML forms, buttons can be disabled by defining the "disabled" attribute on them, with any value:</p> <pre><code>&lt;button name="btn1" disabled="disabled"&gt;Hello&lt;/button&gt; </code></pre> <p>If a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attribute can be set to that would leave the button enabled.</p> <p>This is causing me problems when I want to enable / disable buttons when using JSP Documents (jspx). As JSP documents have to be well-formed XML documents, I can't see any way of conditionally including this attribute, as something like the following isn't legal:</p> <pre><code>&lt;button name="btn1" &lt;%= (isDisabled) ? "disabled" : "" %/&gt; &gt;Hello&lt;/button&gt; </code></pre> <p>While I could replicate the tag twice using a JSTL if tag to get the desired effect, in my specific case I have over 15 attributes declared on the button (lots of javascript event handler attributes for AJAX) so duplicating the tag is going to make the JSP very messy.</p> <p>How can I solve this problem, without sacrificing the readability of the JSP? Are there any custom tags that can add attributes to the parent by manipulating the output DOM?</p>
[ { "answer_id": 157064, "author": "Marcus Downing", "author_id": 1000, "author_profile": "https://Stackoverflow.com/users/1000", "pm_score": -1, "selected": false, "text": "<% if (isDisabled) { %>\n <button name=\"btn1\" disabled=\"disabled\">Hello</button>\n<% } else { %>\n <button nam...
2008/10/01
[ "https://Stackoverflow.com/questions/157005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24068/" ]
157,018
<p>I recently started learning <a href="http://www.gnu.org/software/emacs/" rel="noreferrer">Emacs</a>. I went through the tutorial, read some introductory articles, so far so good.</p> <p>Now I want to use it for Python development. From what I understand, there are two separate Python modes for Emacs: python-mode.el, which is part of the Python project; and python.el, which is part of Emacs 22.</p> <p>I read all information I could find but most of it seems fairly outdated and I'm still confused. </p> <p>The questions:</p> <ol> <li>What is their difference?</li> <li>Which mode should I install and use? </li> <li>Are there other Emacs add-ons that are essential for Python development?</li> </ol> <p>Relevant links:</p> <ul> <li><a href="http://wiki.python.org/moin/EmacsEditor" rel="noreferrer">EmacsEditor</a> @ wiki.python.org</li> <li><a href="http://www.emacswiki.org/cgi-bin/wiki/PythonMode" rel="noreferrer">PythonMode</a> @ emacswiki.org</li> </ul>
[ { "answer_id": 4569972, "author": "seb", "author_id": 559140, "author_profile": "https://Stackoverflow.com/users/559140", "pm_score": 3, "selected": false, "text": "__init__.py" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712/" ]
157,020
<p>I have an script that falls over if any of the procedures it is trying to create already exists. How can I check/drop if this procedure is already created?</p>
[ { "answer_id": 157248, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 1, "selected": false, "text": "IF EXISTS\n(\n SELECT *\n FROM SYSPROCS\n WHERE SPECIFIC_SCHEMA = ???\n AND SPECIFIC_NAME = ???\n AND...
2008/10/01
[ "https://Stackoverflow.com/questions/157020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,034
<p>I have column that contains strings. The strings in that column look like this:</p> <p>FirstString/SecondString/ThirdString</p> <p>I need to parse this so I have two values:</p> <p>Value 1: FirstString/SecondString Value 2: ThirdString</p> <p>I could have actually longer strings but I always nee it seperated like [string1/string2/string3/...][stringN]</p> <p>What I need to end up with is this:</p> <p>Column1: [string1/string2/string3/etc....] Column2: [stringN]</p> <p>I can't find anyway in access to do this. Any suggestions? Do i need regular expressions? If so, is there a way to do this in the query designer?</p> <p><strong>Update</strong>: Both of the expressions give me this error: "The expression you entered contains invalid syntax, or you need to enclose your text data in quotes."</p> <pre><code>expr1: Left( [Property] , InStrRev( [Property] , "/") - 1), Mid( [Property] , InStrRev( [Property] , "/") + 1) expr1: mid( [Property] , 1, instr( [Property] , "/", -1)) , mid( [Property] , instr( [Property] , "/", -1)+1, length( [Property] )) </code></pre>
[ { "answer_id": 157135, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 2, "selected": true, "text": "Left(col, InStrRev(col, \"/\") - 1), Mid(col, InStrRev(col, \"/\") + 1) \n" }, { "answer_id": 493545, "author": "Mar...
2008/10/01
[ "https://Stackoverflow.com/questions/157034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
157,039
<p>I have an iterable of entries on which I would like to gather some simple statistics, say the count of all numbers divisible by two and the count of all numbers divisible by three.</p> <p>My first alternative, While only iterating through the list once and avoiding the list expansion (and keeping the <a href="http://www.refactoring.com/catalog/splitLoop.html" rel="noreferrer">split loop</a> refactoring in mind), looks rather bloated:</p> <p>(alt 1)</p> <pre><code>r = xrange(1, 10) twos = 0 threes = 0 for v in r: if v % 2 == 0: twos+=1 if v % 3 == 0: threes+=1 print twos print threes </code></pre> <p>This looks rather nice, but has the drawback of expanding the expression to a list:</p> <p>(alt 2)</p> <pre><code>r = xrange(1, 10) print len([1 for v in r if v % 2 == 0]) print len([1 for v in r if v % 3 == 0]) </code></pre> <p>What I would really like is something like a function like this:</p> <p>(alt 3)</p> <pre><code>def count(iterable): n = 0 for i in iterable: n += 1 return n r = xrange(1, 10) print count(1 for v in r if v % 2 == 0) print count(1 for v in r if v % 3 == 0) </code></pre> <p>But this looks a lot like something that could be done without a function. The final variant is this:</p> <p>(alt 4)</p> <pre><code>r = xrange(1, 10) print sum(1 for v in r if v % 2 == 0) print sum(1 for v in r if v % 3 == 0) </code></pre> <p>and while the smallest (and in my book probably the most elegant) it doesn't feel like it expresses the intent very well.</p> <p>So, my question to you is:</p> <p>Which alternative do you like best to gather these types of stats? Feel free to supply your own alternative if you have something better.</p> <p>To clear up some confusion below:</p> <ul> <li>In reality my filter predicates are more complex than just this simple test.</li> <li>The objects I iterate over are larger and more complex than just numbers</li> <li>My filter functions are more different and hard to parameterize into one predicate</li> </ul>
[ { "answer_id": 157080, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 2, "selected": false, "text": "filter" }, { "answer_id": 157094, "author": "John Montgomery", "author_id": 5868, "author_profile": "...
2008/10/01
[ "https://Stackoverflow.com/questions/157039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010/" ]
157,044
<p>I'm attempting to check for the existence of a node using the following .NET code:</p> <pre><code>xmlDocument.SelectSingleNode( String.Format("//ErrorTable/ProjectName/text()='{0}'", projectName)); </code></pre> <p>This always raises:</p> <blockquote> <p>XPathException: Expression must evaluate to a node-set. </p> </blockquote> <p>Why am I getting this error and how can I resolve it? Thank you.</p>
[ { "answer_id": 157085, "author": "rjohnston", "author_id": 246, "author_profile": "https://Stackoverflow.com/users/246", "pm_score": 1, "selected": false, "text": "Node node = xmlDocument.SelectSingleNode(String.Format(\"//ErrorTable/ProjectName = '{0}'\", projectName));\n\nif (node != n...
2008/10/01
[ "https://Stackoverflow.com/questions/157044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6651/" ]
157,058
<p>I have a list of tuples eg. [{1,40},{2,45},{3,54}....{7,23}] where 1...7 are days of the week (calculated by finding calendar:day_of_the_week()). So now I want to change the list to [{Mon,40},{Tue,45},{Wed,54}...{Sun,23}]. Is there an easier way to do it than lists:keyreplace?</p>
[ { "answer_id": 157112, "author": "Jon Gretar", "author_id": 5601, "author_profile": "https://Stackoverflow.com/users/5601", "pm_score": 3, "selected": true, "text": "lists:map(fun({A,B}) -> {httpd_util:day(A),B} end, [{1,40},{2,45},{3,54},{7,23}]).\n" }, { "answer_id": 173536, ...
2008/10/01
[ "https://Stackoverflow.com/questions/157058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727/" ]
157,070
<p>When you're adding javaDoc comments to your code and you're outlining the structure of an XML document that you're passing back, what's the best way to represent attributes? Is there a best practice for this?</p> <p>My general structure for my javaDoc comments is like this:</p> <pre><code>/** * ... * * @return XML document in the form: * * &lt;pre&gt; * &amp;lt;ROOT_ELEMENT&amp;gt; * &amp;lt;AN_ELEMENT&amp;gt; * &amp;lt;MULTIPLE_ELEMENTS&amp;gt;* * &amp;lt;/ROOT_ELEMENT&amp;gt; * &lt;/pre&gt; */ </code></pre>
[ { "answer_id": 166205, "author": "Philip Morton", "author_id": 21709, "author_profile": "https://Stackoverflow.com/users/21709", "pm_score": 0, "selected": false, "text": "/**\n * ...\n * \n * @return XML document in the form:\n * \n * <pre>\n * &lt;ROOT_ELEMENT&gt;\n * &lt;AN_ELEMENT...
2008/10/01
[ "https://Stackoverflow.com/questions/157070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]
157,101
<p>I downloaded some example code from the internet, but when I compiled it I ran into some trouble. My compiler tells me: comdef.h: No such file or directory.</p> <p>I searched a bit on the internet, but I couldn't find anyone else with the same problem and I have no clue where I can obtain this header file.</p> <p>I use codeblocks with the GNU GCC compiler.</p>
[ { "answer_id": 157154, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "comdef.h" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23163/" ]
157,114
<p>I made a view to abstract columns of different tables and pre-filter and pre-sort them. There is one column whose content I don't care about but I need to know whether the content is null or not. So my view should pass an alias as "<em>true</em>" in case the value of this specified column <strong>isn't null</strong> and "<em>false</em>" in case the value <strong>is null</strong>.</p> <p>How can I select such a boolean with T-SQL?</p>
[ { "answer_id": 157136, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 7, "selected": true, "text": "SELECT CASE WHEN columnName IS NULL THEN 'false' ELSE 'true' END FROM tableName;\n" }, { "answer_id": 157148,...
2008/10/01
[ "https://Stackoverflow.com/questions/157114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5703/" ]
157,117
<p>We have a strange problem occurring <em>once in a while</em> on our servers. It usually happens when one or more of our web applications are upgraded. Debugging the problem has gotten me this far...</p> <p>During the processing of a request:</p> <ul> <li>In the ASP.NET application we put an object in session</li> <li>In code running later (same request) we look up that same session value. <strong>It's empty!</strong></li> </ul> <p>So it looks like the session service isn't working, right? This code runs hundreds of times a day, and never fails in development environments or in production situation, only related to upgrading the web application(s) on the web server.</p> <p>And the strange thing: We haven't really fond a proper way of fixing the situation either. IIS reset, ASP.NET state server stop/start, web.config edits, and even server reboots have all bin used - normally a combination is needed to fix it + plus a lot of swearing and pulling of hears. And in most cases it isn't fixed right away, but maybe two or three minutes <em>after</em> the third IIS reset or whatever. (So it might not be what fixed it after all.)</p> <p>I'm going crazy here. Any ideas what might be the problem? Is it a microsoft bug?</p> <p>Some more info:</p> <ul> <li>We're running under .NET 2.0</li> <li>We are using the ASP.NET state service</li> <li>The code accessing the session variable and getting back null is in an assembly referenced by the ASP.NET app. It uses the HttpContect.Current to get at the session</li> </ul>
[ { "answer_id": 157140, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 0, "selected": false, "text": "If Not IsNothing(Context.Session) Then\n 'do something\nend if\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22621/" ]
157,119
<p>As far as i know it is not possible to do the following in C# 2.0</p> <pre><code>public class Father { public virtual Father SomePropertyName { get { return this; } } } public class Child : Father { public override Child SomePropertyName { get { return this; } } } </code></pre> <p>I workaround the problem by creating the property in the derived class as "new", but of course that is not polymorphic.</p> <pre><code>public new Child SomePropertyName </code></pre> <p>Is there any solution in 2.0? What about any features in 3.5 that address this matter? </p>
[ { "answer_id": 157128, "author": "Anthony", "author_id": 5599, "author_profile": "https://Stackoverflow.com/users/5599", "pm_score": 1, "selected": false, "text": "public class FatherProp\n{\n}\n\npublic class ChildProp: FatherProp\n{\n}\n\n\npublic class Father\n{\n public virtual Fa...
2008/10/01
[ "https://Stackoverflow.com/questions/157119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20335/" ]
157,132
<p>I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.</p> <p>Is there a way to abort an upload process from the server side without waiting the HTTP request to finish?</p>
[ { "answer_id": 157188, "author": "Nikhil Kashyap", "author_id": 11299, "author_profile": "https://Stackoverflow.com/users/11299", "pm_score": 1, "selected": false, "text": "multi = new MultipartRequest(request, dirName, FILE_SIZE_LIMIT); \n\nif(submitButton.equals(multi.getParameter(\"Su...
2008/10/01
[ "https://Stackoverflow.com/questions/157132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686/" ]
157,149
<p>Is it possible to split the information in a .csproj across more than one file? A bit like a project version of the <code>partial class</code> feature.</p>
[ { "answer_id": 157175, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 6, "selected": true, "text": "<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n ....\n</Project>...
2008/10/01
[ "https://Stackoverflow.com/questions/157149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24092/" ]
157,163
<p>I want to run a command as soon as a certain text appears in a log file. How do I do that in Bash?</p>
[ { "answer_id": 157171, "author": "ketorin", "author_id": 24094, "author_profile": "https://Stackoverflow.com/users/24094", "pm_score": 5, "selected": true, "text": "tail -f file.log | grep --line-buffered \"my pattern\" | while read line\ndo\n echo $line\ndone\n" }, { "answer_id...
2008/10/01
[ "https://Stackoverflow.com/questions/157163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24094/" ]
157,178
<p>I still very new using Subversion.</p> <p>Is it possible to have a working copy on a network available share (c:\svn\projects\website) that everyone (in this case 3 of use) can checkout and commit files to? We don't need a build server because it is an asp site and the designers are used to having immediate results when they save a file. I could try and show them how to set it up local on their machines but if we could just share the files on the development server and still have the ability to commit when someone is done, that would be ideal.</p> <p>An easy solution would be for all of us to use the same subversion username and that would at least allow me to put files under version control.</p> <p>But is it possible to checkout a folder from the svn respository but still require each person to login with their user/pass to commit?</p> <p>EDIT: I'm trying to take our current work flow, which is editing the LIVE version of a site using Frontpage Extensions or FTP. And move it to something BETTER. In this case a copy of the live site on a development server that I setup to mirror the live server, remove frontpage extensions access. Then the designers can still have the same effect of instant gratification but I will not have to worry they are editing the live files. Even using a shared user/pass in subversion is still version control. It may not be ideal and if the designers were actually programmers I would try to get them fully on board but that's just not the case. This is the best I can do in this case and avoid a huge learning curve and work stoppage.</p>
[ { "answer_id": 157290, "author": "Rinat Abdullin", "author_id": 47366, "author_profile": "https://Stackoverflow.com/users/47366", "pm_score": 2, "selected": false, "text": "[general]\npassword-db = userfile\nrealm = example realm\n\n# anonymous users can only read the repository\nanon-ac...
2008/10/01
[ "https://Stackoverflow.com/questions/157178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
157,195
<p>Anybody knows how to do this? I got all the information of the email (body, subject, from , to, cc, bcc) and need to generate an .eml file out of it.</p>
[ { "answer_id": 157229, "author": "Neall", "author_id": 619, "author_profile": "https://Stackoverflow.com/users/619", "pm_score": 3, "selected": false, "text": "From: \"DR CLEMENT OKON\" <drclement@nigerianspam.com>\nTo: \"You\" <you@yourdomain.com>\nSubject: REQUEST FOR URGENT BUSINESS R...
2008/10/01
[ "https://Stackoverflow.com/questions/157195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6200/" ]
157,198
<p>I was reading <a href="http://www.ibm.com/developerworks/java/library/j-dcl.html" rel="nofollow noreferrer">this article</a> about "Double-Checked locking" and out of the main topic of the article I was wondering why at some point of the article the author uses the next Idiom: </p> <blockquote> <p>Listing 7. Attempting to solve the out-of-order write problem </p> <pre><code>public static Singleton getInstance() { if (instance == null) { synchronized(Singleton.class) { //1 Singleton inst = instance; //2 if (inst == null) { synchronized(Singleton.class) { //3 inst = new Singleton(); //4 } instance = inst; //5 } } } return instance; } </code></pre> </blockquote> <p>And my question is: Is there any reason to synchronize twice some code with the same lock? Have this any purpose it?</p> <p>Many thanks in advance.</p>
[ { "answer_id": 157240, "author": "David Santamaria", "author_id": 24097, "author_profile": "https://Stackoverflow.com/users/24097", "pm_score": 0, "selected": false, "text": "public static Singleton getInstance()\n{\n if (instance == null)\n {\n synchronized(Singleton.class) { ...
2008/10/01
[ "https://Stackoverflow.com/questions/157198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24097/" ]
157,208
<p>I would like to send HTML email with graphic elements included. I have no idea to attach garaphics to this email.</p>
[ { "answer_id": 160804, "author": "acrosman", "author_id": 24215, "author_profile": "https://Stackoverflow.com/users/24215", "pm_score": 2, "selected": false, "text": " $headers = \"From: sender@example.com\\n\" .\n \"MIME-Version: 1.0\\n\" .\n \"Content-type: text/html; charset=iso...
2008/10/01
[ "https://Stackoverflow.com/questions/157208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,232
<p>I have wrapped Log4net in a static wrapper and want to log </p> <pre><code>loggingEvent.LocationInformation.MethodName loggingEvent.LocationInformation.ClassName </code></pre> <p>However all I get is the name of my wrapper.</p> <p>How can I log that info using a forwardingappender and a static wrapper class like </p> <pre><code>Logger.Debug("Logging to Debug"); Logger.Info("Logging to Info"); Logger.Warn("Logging to Warn"); Logger.Error(ex); Logger.Fatal(ex); </code></pre>
[ { "answer_id": 157891, "author": "Claus Thomsen", "author_id": 15555, "author_profile": "https://Stackoverflow.com/users/15555", "pm_score": 6, "selected": true, "text": " public static class Logger\n {\n private readonly static Type ThisDeclaringType = typeof(Logger);\n private st...
2008/10/01
[ "https://Stackoverflow.com/questions/157232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15555/" ]
157,254
<p>Image a Button on your windows form that does something when being clicked.</p> <p>The click events thats raised is typically bound to a method such as</p> <blockquote> <p>protected void Button1_Click(object sender, EventArgs e) {</p> <p>}</p> </blockquote> <p>What I see sometimes in other peoples' code is that the implementation of the buttons' behaviour is not put into the Button1_Click method but into an own method that is called from here like so:</p> <blockquote> <p>private DoStuff() { }</p> <p>protected void Button1_Click(object sender, EventArgs e) { this.DoStuff(); }</p> </blockquote> <p>Although I see the advantage here (for instance if this piece of code is needed internally somewhere else, it can be easily used), I am wondering, <strong>if this is a general good design decision</strong>?</p> <p>So the question is: Is it a generally good idea to put event handling code into an own method and if so what naming convention for those methods are proven to be best practice?</p>
[ { "answer_id": 157291, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "button1.Click += delegate { DoStuff(); }\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23369/" ]
157,260
<p>In the past and with most my current projects I tend to use a for loop like this:</p> <pre><code>var elements = document.getElementsByTagName('div'); for (var i=0; i&lt;elements.length; i++) { doSomething(elements[i]); } </code></pre> <p>I've heard that using a "reverse while" loop is quicker but I have no real way to confirm this:</p> <pre><code>var elements = document.getElementsByTagName('div'), length = elements.length; while(length--) { doSomething(elements[length]); } </code></pre> <p>What is considered as best practice when it comes to looping though elements in JavaScript, or any array for that matter?</p>
[ { "answer_id": 157264, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 3, "selected": false, "text": ".forEach" }, { "answer_id": 157286, "author": "roenving", "author_id": 23142, "author_...
2008/10/01
[ "https://Stackoverflow.com/questions/157260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21677/" ]
157,272
<p>We have a database that we are using to store test results for an embedded device. There's a table with columns for different types of failures (details not relevant), along with a primary key 'keynum' and a 'NUM_FAILURES' column that lists the number of failures. We store passes and failures, so a pass has a '0' in 'NUM_FAILURES'.</p> <p>In order to keep the database from growing without bounds, we want to keep the last 1000 results, plus any of the last 50 failures that fall outside of the 1000. So, worst case, the table could have 1050 entries in it. I'm trying to find the most efficient SQL insert trigger to remove extra entries. I'll give what I have so far as an answer, but I'm looking to see if anyone can come up with something better, since SQL isn't something I do very often.</p> <p>We are using SQLITE3 on a non-Windows platform, if it's relevant.</p> <p><strong>EDIT:</strong> To clarify, the part that I am having problems with is the DELETE, and specifically the part related to the last 50 failures.</p>
[ { "answer_id": 157285, "author": "mbyrne215", "author_id": 5241, "author_profile": "https://Stackoverflow.com/users/5241", "pm_score": 0, "selected": false, "text": "CREATE VIEW tablename_view AS SELECT keynum FROM tablename WHERE NUM_FAILURES!='0' \n ORDER BY keynum DESC LIMIT 50;\nC...
2008/10/01
[ "https://Stackoverflow.com/questions/157272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5241/" ]
157,294
<p>We have a project consisting of multiple subprojects. With each subproject we potentially have some hibernate mapping files but in the end only <strong>one actual hibernate session</strong>. Those subprojects could be combined in several ways, some depend on each other. My problem is that actually I want to have a SessionFactoryBean which would be able to collect those mappings/mappinglocations from the applicationContext(s) and configure itself.</p> <p>Has somebody written something like this, or do I have to do it myself (I envision something a bit like the urlresolver or viewresolver functionality from SpringMVC)?</p>
[ { "answer_id": 157338, "author": "skaffman", "author_id": 21234, "author_profile": "https://Stackoverflow.com/users/21234", "pm_score": 0, "selected": false, "text": "LocalSessionFactoryBean" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/917/" ]
157,318
<p>We are using a PHP scripting for tunnelling file downloads, since we don't want to expose the absolute path of downloadable file:</p> <pre><code>header("Content-Type: $ctype"); header("Content-Length: " . filesize($file)); header("Content-Disposition: attachment; filename=\"$fileName\""); readfile($file); </code></pre> <p>Unfortunately we noticed that downloads passed through this script can't be resumed by the end user. </p> <p>Is there any way to support resumable downloads with such a PHP-based solution?</p>
[ { "answer_id": 157352, "author": "Sietse", "author_id": 6400, "author_profile": "https://Stackoverflow.com/users/6400", "pm_score": 4, "selected": false, "text": "Range" }, { "answer_id": 157355, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://...
2008/10/01
[ "https://Stackoverflow.com/questions/157318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,342
<p>Cron installation is vixie-cron</p> <p><code>/etc/cron.daily/rmspam.cron</code></p> <pre><code>#!/bin/bash /usr/bin/rm /home/user/Maildir/.SPAM/cur/*; </code></pre> <p>I Have this simple bash script that I want to add to a cron job (also includes spam learning commands before) but this part always fails with "File or directory not found" From what I figure is the metachar isn't being interperted correctly when run as a cron job. If I execute the script from the commandline it works fine.</p> <p>I'd like a why for this not working and of course a working solution :)</p> <p>Thanks</p> <p>edit #1 came back to this question when I got popular question badge for it. I first did this,</p> <pre><code>#!/bin/bash find /home/user/Maildir/.SPAM/cur/ -t file | xargs rm </code></pre> <p>and just recently was reading through the xargs man page and changed it to this</p> <pre><code>#!/bin/bash find /home/user/Maildir/.SPAM/cur/ -t file | xargs --no-run-if-empty rm </code></pre> <p>short xargs option is -r</p>
[ { "answer_id": 157350, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 0, "selected": false, "text": "00 3 * * * /home/me/myscript.sh\n" }, { "answer_id": 157369, "author": "janm", "author_id": 7256, "autho...
2008/10/01
[ "https://Stackoverflow.com/questions/157342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4275/" ]
157,354
<p>I happened to debate with a friend during college days whether advanced mathematics is necessary for any veteran programmer. He used to argue fiercely against that. He said that programmers need only basic mathematical knowledge from high school or fresh year college math, no more no less, and that almost all of programming tasks can be achieved without even need for advanced math. He argued, however, that algorithms are fundamental &amp; must-have asset for programmers.</p> <p>My stance was that all computer science advances depended almost solely on mathematics advances, and therefore a thorough knowledge in mathematics would help programmers greatly when they're working with real-world challenging problems.</p> <p>I still cannot settle on which side of the arguments is correct. Could you tell us your stance, from your own experience?</p>
[ { "answer_id": 2367748, "author": "Earlz", "author_id": 69742, "author_profile": "https://Stackoverflow.com/users/69742", "pm_score": 2, "selected": false, "text": "(x|y) & (x|z) & (x|foo)\n" }, { "answer_id": 2367840, "author": "Arun", "author_id": 278326, "author_pr...
2008/10/01
[ "https://Stackoverflow.com/questions/157354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24113/" ]
157,357
<p>Is there a way to use form fields that does not correspond to database field for temporary processings?</p> <p>I.e. I want to add:</p> <ul> <li>temp fields <strong>item1</strong>, <strong>item2</strong></li> <li>database field <strong>sum</strong></li> <li>button with record hook that sets <strong>sum</strong> = <strong>item1</strong> + <strong>item2</strong></li> </ul>
[ { "answer_id": 971132, "author": "Randakar", "author_id": 36574, "author_profile": "https://Stackoverflow.com/users/36574", "pm_score": 2, "selected": false, "text": "$session->SetNameValue(\"item1\", $value1);\n$session->SetNameValue(\"item2\", $value2);\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3448/" ]
157,359
<p>I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that).</p> <p>I've been using datetime.now() as a first stab, but this isn't perfect:</p> <pre><code>&gt;&gt;&gt; for i in range(0,1000): ... datetime.datetime.now() ... datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 562000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 578000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) datetime.datetime(2008, 10, 1, 13, 17, 27, 609000) etc. </code></pre> <p>The changes between clocks for the first second of samples looks like this:</p> <pre><code>uSecs difference 562000 578000 16000 609000 31000 625000 16000 640000 15000 656000 16000 687000 31000 703000 16000 718000 15000 750000 32000 765000 15000 781000 16000 796000 15000 828000 32000 843000 15000 859000 16000 890000 31000 906000 16000 921000 15000 937000 16000 968000 31000 984000 16000 </code></pre> <p>So it looks like the timer data is only updated every ~15-32ms on my machine. The problem comes when we come to analyse the data because sorting by something other than the timestamp and then sorting by timestamp again can leave the data in the wrong order (chronologically). It would be nice to have the time stamps accurate to the point that any call to the time stamp generator gives a unique timestamp.</p> <p>I had been considering some methods involving using a time.clock() call added to a starting datetime, but would appreciate a solution that would work accurately across threads on the same machine. Any suggestions would be very gratefully received.</p>
[ { "answer_id": 157711, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 4, "selected": true, "text": " class TimeStamper(object):\n def __init__(self):\n self.lock = threading.Lock()\n self.prev = ...
2008/10/01
[ "https://Stackoverflow.com/questions/157359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15369/" ]
157,392
<p>I want to find out, with an SQL query, whether an index is UNIQUE or not. I'm using SQLite 3.</p> <p>I have tried two approaches:</p> <pre><code>SELECT * FROM sqlite_master WHERE name = 'sqlite_autoindex_user_1' </code></pre> <p>This returns information about the index ("type", "name", "tbl_name", "rootpage" and "sql"). Note that the sql column is empty when the index is automatically created by SQLite.</p> <pre><code>PRAGMA index_info(sqlite_autoindex_user_1); </code></pre> <p>This returns the columns in the index ("seqno", "cid" and "name").</p> <p>Any other suggestions?</p> <p><strong>Edit:</strong> The above example is for an auto-generated index, but my question is about indexes in general. For example, I can create an index with "CREATE UNIQUE INDEX index1 ON visit (user, date)". It seems no SQL command will show if my new index is UNIQUE or not.</p>
[ { "answer_id": 157636, "author": "dland", "author_id": 18625, "author_profile": "https://Stackoverflow.com/users/18625", "pm_score": 2, "selected": false, "text": "select count(*) from t\ngroup by foo, bar, baz\nhaving count(*) > 1\n" }, { "answer_id": 459512, "author": "Noah...
2008/10/01
[ "https://Stackoverflow.com/questions/157392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12534/" ]
157,424
<p>I have a dictionary of 200,000 items (the keys are strings and the values are integers).</p> <p>What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)?</p> <pre><code> a={ 'keyC':1, 'keyB':2, 'keyA':1 } b = a.items() b.sort( key=lambda a:a[0]) b.sort( key=lambda a:a[1], reverse=True ) print b &gt;&gt;&gt;[('keyB', 2), ('keyA', 1), ('keyC', 1)] </code></pre>
[ { "answer_id": 157445, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 5, "selected": true, "text": "a = { 'key':1, 'another':2, 'key2':1 }\n\nb= a.items()\nb.sort( key=lambda a:(-a[1],a[0]) )\nprint b\n" }, { "answer...
2008/10/01
[ "https://Stackoverflow.com/questions/157424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,459
<p>I have a products table...</p> <p><a href="http://img357.imageshack.us/img357/6393/productscx5.gif" rel="nofollow noreferrer">alt text http://img357.imageshack.us/img357/6393/productscx5.gif</a></p> <p>and a revisions table, which is supposed to track changes to product info</p> <p><a href="http://img124.imageshack.us/img124/1139/revisionslz5.gif" rel="nofollow noreferrer">alt text http://img124.imageshack.us/img124/1139/revisionslz5.gif</a></p> <p>I try to query the database for all products, with their most recent revision...</p> <pre><code>select * from `products` as `p` left join `revisions` as `r` on `r`.`product_id` = `p`.`product_id` group by `p`.`product_id` order by `r`.`modified` desc </code></pre> <p>but I always just get the first revision. I need to do this in <strong>one</strong> select (ie no sub queries). I can manage it in mssql, is this even possible in mysql?</p>
[ { "answer_id": 159621, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "SELECT p.*, r.*\nFROM products AS p\n JOIN revisions AS r USING (product_id)\n LEFT OUTER JOIN revisions AS r2 \n ...
2008/10/01
[ "https://Stackoverflow.com/questions/157459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18856/" ]
157,480
<p>How can this line in Java be translated to Ruby:<br> String className = "java.util.Vector";<br> ...<br> Object o = Class.forName(className).newInstance(); </p> <p>Thanks!</p>
[ { "answer_id": 157499, "author": "Ken", "author_id": 20621, "author_profile": "https://Stackoverflow.com/users/20621", "pm_score": 7, "selected": true, "text": "Object::const_get('String').new()\n" }, { "answer_id": 158145, "author": "Ian Terrell", "author_id": 9269, ...
2008/10/01
[ "https://Stackoverflow.com/questions/157480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,504
<p>I have object A which in turn has a property of type Object B</p> <pre><code>Class A property x as Object B End Class </code></pre> <p>On my ASP.NET page when I select a gridview item which maps to an object of type A I serialize the object onto the QueryString and pass it to the next page. </p> <p>However I run into problems if property x actually has some value as it looks like I exceed the QueryString capacity length of 4k (although I didn't think the objects were that large) </p> <p>I have already considered the following approaches to do this</p> <ul> <li>Session Variables</li> </ul> <p><strong>Approach not used as I have read that this is bad practice.</strong></p> <ul> <li>Using a unique key for the object and retrieving it on the next page. </li> </ul> <p><strong>Approach not used as the objects do not map to a single instance in a table, they arte composed of data from different databases.</strong> </p> <p>So I guess my question is two fold</p> <ul> <li>Is it worth using GKZip to compress the querystring further (is this possible??)</li> <li>What other methods would people suggest to do this?</li> </ul>
[ { "answer_id": 157593, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 1, "selected": false, "text": "public void Page_Load()\n{\n\n if(!IsPostBack)\n { \n const string key = \"FunkyObject\";\n if(S...
2008/10/01
[ "https://Stackoverflow.com/questions/157504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11802/" ]
157,511
<p>I have a <code>Dictionary&lt;string, someobject&gt;</code>.</p> <p>EDIT: It was pointed out to me, that my example was bad. My whole intention was not to update the references in a loop but to update different values based on differnt threads need to update/get the data. I changed the loop to a method.</p> <p>I need to update items in my dictionary - one key at a time and i was wondering if there are any problems in using the lock on the .key value of my Dictionary object?</p> <pre><code>private static Dictionary&lt;string, MatrixElement&gt; matrixElements = new Dictionary&lt;string, MatrixElement&gt;(); //Pseudo-code public static void UpdateValue(string key) { KeyValuePair&lt;string, MatrixElement&gt; keyValuePair = matrixElements[key]; lock (keyValuePair.Key) { keyValuePair.Value = SomeMeanMethod(); } } </code></pre> <p>Would that hold up in court or fail? I just want each value in the dictionary to be locked independantly so locking (and updating) one value does not lock the others. Also i'm aware the locking will be holding for a long time - but the data will be invalid untill updated fully.</p>
[ { "answer_id": 157536, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 3, "selected": false, "text": "string a = \"Something\";\nstring b = \"Something\";\n" }, { "answer_id": 157570, "author": "Philip Rieck", "...
2008/10/01
[ "https://Stackoverflow.com/questions/157511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
157,528
<p>As in a title, does anyone know how to freeze GridView header in ASP.NET ? </p>
[ { "answer_id": 157606, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": ".Freezing\n{\n position:relative ;\n top:expression(this.offsetParent.scrollTop);\n z-index: 10;\n} \n" }, { ...
2008/10/01
[ "https://Stackoverflow.com/questions/157528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3182/" ]
157,554
<p>I've got a XmlNodeList which I need to have it in a format that I can then re-use within a XSLT stylesheet by calling it from a C# extension method.</p> <p>Can anyone help? I have read that it might have something to do with using a XPathNavigator but I'm still a bit stuck.</p>
[ { "answer_id": 157624, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "XsltArgumentList arguments = new XsltArgumentList();\nXmlNodeList nodelist;\nXmlDocument nodesFrament = new XmlDocument(...
2008/10/01
[ "https://Stackoverflow.com/questions/157554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4455/" ]
157,557
<p>In VB.Net, I can declare a variable in a function as Static, like this:</p> <pre><code>Function EncodeForXml(ByVal data As String) As String Static badAmpersand As Regex = new Regex("&amp;(?![a-zA-Z]{2,6};|#[0-9]{2,4};)") data = badAmpersand.Replace(data, "&amp;amp;") ''// more processing return data End Function </code></pre> <p>Note that I need to use the keyword <code>Static</code>, rather than <code>Shared</code>, which is the normal way to express this in VB.Net. How can I do this in C#? I can't find its equivalent.</p>
[ { "answer_id": 157575, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": true, "text": "Monitor" }, { "answer_id": 157733, "author": "Rinat Abdullin", "author_id": 47366, "author_profile"...
2008/10/01
[ "https://Stackoverflow.com/questions/157557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
157,600
<p>I would like to receive suggestions on the data generators that are available, for SQL server. If posting a response, please provide any features that you think are important. </p> <p>I have never used a application like this, so I am looking to be educated on the topic. Thank you.</p> <p>(My goal is to fill a database with 10,000+ records in each table, to test an application.)</p>
[ { "answer_id": 157688, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": "import csv\nimport random\n\nclass SomeEntity( list ):\n titles = ( 'attr1', 'attr2' ) # ... for all columns\n def __...
2008/10/01
[ "https://Stackoverflow.com/questions/157600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19854/" ]
157,603
<p>I'm using VisualSVN Server to host an SVN repo, and for some automation work, I'd like to be able to get specific versions via the http[s] layer.</p> <p>I can get the HEAD version simply via an http[s] request to the server (httpd?) - but is there any ability to specify the revision, perhaps as a query-string? I can't seem to find it...</p> <p>I don't want to do a checkout unless I can help it, as there are a lot of files in the specific folder, and I don't want them all - just one or two.</p>
[ { "answer_id": 157726, "author": "Bert Huijben", "author_id": 2094, "author_profile": "https://Stackoverflow.com/users/2094", "pm_score": 2, "selected": false, "text": "using (SvnClient client = new SvnClient())\nusing (FileStream fs = File.Create(\"c:\\\\temp\\\\file.txt\"))\n{\n // ...
2008/10/01
[ "https://Stackoverflow.com/questions/157603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23354/" ]
157,628
<p>I have a helper method has been created which allows a MovieClip-based class in code and have the constructor called. Unfortunately the solution is not complete because the MovieClip callback <b>onLoad()</b> is never called. </p> <p>(Link to the <a href="http://www.flashdevelop.org/community/viewtopic.php?f=13&amp;t=458" rel="nofollow noreferrer">Flashdevelop thread</a> which created the method .)</p> <p>How can the following function be modified so both the <b>constructor</b> and <b>onLoad()</b> is properly called.</p> <pre><code> //------------------------------------------------------------------------ // - Helper to create a strongly typed class that subclasses MovieClip. // - You do not use "new" when calling as it is done internally. // - The syntax requires the caller to cast to the specific type since // the return type is an object. (See example below). // // classRef, Class to create // id, Instance name // ..., (optional) Arguments to pass to MovieClip constructor // RETURNS Reference to the created object // // e.g., var f:Foo = Foo( newClassMC(Foo, "foo1") ); // public function newClassMC( classRef:Function, id:String ):Object { var mc:MovieClip = this.createEmptyMovieClip(id, this.getNextHighestDepth()); mc.__proto__ = classRef.prototype; if (arguments.length &gt; 2) { // Duplicate only the arguments to be passed to the constructor of // the movie clip we are constructing. var a:Array = new Array(arguments.length - 2); for (var i:Number = 2; i &lt; arguments.length; i++) a[Number(i) - 2] = arguments[Number(i)]; classRef.apply(mc, a); } else { classRef.apply(mc); } return mc; } </code></pre> <p>An example of a class that I may want to create:</p> <pre><code>class Foo extends MovieClip </code></pre> <p>And some examples of how I would currently create the class in code:</p> <pre><code>// The way I most commonly create one: var f:Foo = Foo( newClassMC(Foo, "foo1") ); // Another example... var obj:Object = newClassMC(Foo, "foo2") ); var myFoo:Foo = Foo( obj ); </code></pre>
[ { "answer_id": 164928, "author": "Luke", "author_id": 21406, "author_profile": "https://Stackoverflow.com/users/21406", "pm_score": 2, "selected": false, "text": "import mx.events.EventDispatcher;\n\nclass com.tequila.common.View extends MovieClip\n{\n private static var _symbolClass ...
2008/10/01
[ "https://Stackoverflow.com/questions/157628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14747/" ]
157,629
<p>Hi im new to MVC and I've fished around with no luck on how to build MVC User Controls that have ViewData returned to them. I was hoping someone would post a step by step solution on how to approach this problem. If you could make your solution very detailed that would help out greatly.</p> <p>Sorry for being so discrete with my question, I would just like to clarify that what Im ultimatly trying to do is pass an id to a controller actionresult method and wanting to render it to a user control directly from the controller itself. Im unsure on how to begin with this approach and wondering if this is even possible. It will essentially in my mind look like this</p> <pre><code>public ActionResult RTest(int id){ RTestDataContext db = new RTestDataContext(); var table = db.GetTable&lt;tRTest&gt;(); var record = table.SingleOrDefault(m=&gt; m.id = id); return View("RTest", record); } </code></pre> <p>and in my User Control I would like to render the objects of that record and thats my issue.</p>
[ { "answer_id": 157743, "author": "stimms", "author_id": 361, "author_profile": "https://Stackoverflow.com/users/361", "pm_score": 0, "selected": false, "text": "<%Html.RenderPartial(\"~/UserControls/CategoryChooser.ascx\", ViewData);%>\n" }, { "answer_id": 157745, "author": "...
2008/10/01
[ "https://Stackoverflow.com/questions/157629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24130/" ]
157,646
<p>I was looking for a generic method in .Net to encode a string for use in an Xml element or attribute, and was surprised when I didn't immediately find one. So, before I go too much further, could I just be missing the built-in function? </p> <p>Assuming for a moment that it really doesn't exist, I'm putting together my own generic <code>EncodeForXml(string data)</code> method, and I'm thinking about the best way to do this. </p> <p>The data I'm using that prompted this whole thing could contain bad characters like &amp;, &lt;, &quot;, etc. It could also contains on occasion the properly escaped entities: &amp;amp;, &amp;lt;, and &amp;quot;, which means just using a CDATA section may not be the best idea. That seems kinda klunky anyay; I'd much rather end up with a nice string value that can be used directly in the xml.</p> <p>I've used a regular expression in the past to just catch bad ampersands, and I'm thinking of using it to catch them in this case as well as the first step, and then doing a simple replace for other characters. </p> <p>So, could this be optimized further without making it too complex, and is there anything I'm missing? :</p> <pre class="lang-vb prettyprint-override"><code>Function EncodeForXml(ByVal data As String) As String Static badAmpersand As new Regex("&amp;(?![a-zA-Z]{2,6};|#[0-9]{2,4};)") data = badAmpersand.Replace(data, "&amp;amp;") return data.Replace("&lt;", "&amp;lt;").Replace("""", "&amp;quot;").Replace("&gt;", "gt;") End Function </code></pre> <p><em>Sorry for all you C# -only folks-- I don't really care which language I use, but I wanted to make the Regex static and you can't do that in C# without declaring it outside the method, so this will be VB.Net</em></p> <p>Finally, we're still on .Net 2.0 where I work, but if someone could take the final product and turn it into an extension method for the string class, that'd be pretty cool too.</p> <p><strong>Update</strong> The first few responses indicate that .Net does indeed have built-in ways of doing this. But now that I've started, I kind of want to finish my EncodeForXml() method just for the fun of it, so I'm still looking for ideas for improvement. Notably: a more complete list of characters that should be encoded as entities (perhaps stored in a list/map), and something that gets better performance than doing a .Replace() on immutable strings in serial.</p>
[ { "answer_id": 157674, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 3, "selected": false, "text": "XmlTextWriter.WriteString()" }, { "answer_id": 421938, "author": "Dscoduc", "author_id": 51949, "author_...
2008/10/01
[ "https://Stackoverflow.com/questions/157646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
157,661
<p>Say you have several webparts, one as a controller and several which take information from the controller and act on it. This is fairly easy to model using the Consumer/Producer interface introduced in ASP 2.0. </p> <p>How would you be able to add interactions the other way around whilst still maintaining the above? </p> <p>A simple example would be: the user enters information into webpart A which performs a search and the results would be displayed on webpart B. Webpart C allows you to filter the results which should trigger webpart A to re-submit the query and hence update the results in B. </p> <p>It doesn't seem possible to do in WSS 3.0 because you are only allowed 1 interface to be used in all of the connections at any one time. </p> <p>Does this even make sense ? :-)</p>
[ { "answer_id": 159715, "author": "andrew", "author_id": 17767, "author_profile": "https://Stackoverflow.com/users/17767", "pm_score": 1, "selected": false, "text": " private Calendar _calendarWP = null;\n public Calendar CalendarWP\n {\n get\n {\n if (_calend...
2008/10/01
[ "https://Stackoverflow.com/questions/157661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21299/" ]
157,685
<p>I'm trying to change the background color of a single subplot in a MATLAB figure.</p> <p>It's clearly feasible since the UI allows it, but I cannot find the function to automate it.</p> <p>I've looked into <code>whitebg</code>, but it changes the color scheme of the whole figure, not just the current subplot. </p> <p>(I'm using MATLAB Version 6.1 by the way)</p>
[ { "answer_id": 157719, "author": "Douglas F Shearer", "author_id": 13831, "author_profile": "https://Stackoverflow.com/users/13831", "pm_score": 2, "selected": false, "text": "subplot(3, 2, 4), hist(rand(50)), whitebg('y');\n" }, { "answer_id": 157725, "author": "Doug Trojan"...
2008/10/01
[ "https://Stackoverflow.com/questions/157685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8027/" ]
157,689
<p>How do I use the ofstream to write text to the end of a file without erasing its content inside?</p>
[ { "answer_id": 157698, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "ios::app" }, { "answer_id": 1488730, "author": "Nona Urbiz", "author_id": 135056, "author_profile...
2008/10/01
[ "https://Stackoverflow.com/questions/157689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,705
<p>I've got some XML, for example purposes it looks like this:</p> <pre><code>&lt;root&gt; &lt;field1&gt;test&lt;/field1&gt; &lt;f2&gt;t2&lt;/f2&gt; &lt;f2&gt;t3&lt;/f2&gt; &lt;/root&gt; </code></pre> <p>I want to transform it with XSLT, but I want to suppress the second f2 element in the output - how do I check inside my template to see if the f2 element already exists in the output when the second f2 element in the source is processed? My XSLT looks something like this at present:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="no" omit-xml-declaration="yes" standalone="no" /&gt; &lt;xsl:template match="/"&gt; &lt;xsl:for-each select="./root"&gt; &lt;output&gt; &lt;xsl:apply-templates /&gt; &lt;/output&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*" &gt; &lt;xsl:element name="{name(.)}"&gt; &lt;xsl:value-of select="." /&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>I need to do some sort of check around the xsl:element in the template I think, but I'm not sure how to interrogate the output document to see if the element is already present.</p> <p>Edit: Forgot the pre tags, code should be visible now!</p>
[ { "answer_id": 158125, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 4, "selected": true, "text": "<xsl:if test=\"count(preceding-sibling::node()[name()=name(current())])=0\">\n ... do stuff in here.\n</xsl:if>\n" }, ...
2008/10/01
[ "https://Stackoverflow.com/questions/157705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22073/" ]
157,737
<p>Which Ajax framework/toolkit can you recommend for building the GUI of web applications that are using struts?</p>
[ { "answer_id": 963263, "author": "Richard Clayton", "author_id": 118885, "author_profile": "https://Stackoverflow.com/users/118885", "pm_score": 0, "selected": false, "text": "<author name=\"Boynton\">\n <book>\n <title>Barnyard Dance!</title>\n <year>1993</year>\n </book>\n <bo...
2008/10/01
[ "https://Stackoverflow.com/questions/157737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,747
<p>I want to use VBScript to catch errors and log them (ie on error "log something") then resume the next line of the script.</p> <p>For example,</p> <pre> On Error Resume Next 'Do Step 1 'Do Step 2 'Do Step 3 </pre> <p>When an error occurs on step 1, I want it to log that error (or perform other custom functions with it) then resume at step 2. Is this possible? and how can I implement it?</p> <p>EDIT: Can I do something like this?</p> <pre> On Error Resume myErrCatch 'Do step 1 'Do step 2 'Do step 3 myErrCatch: 'log error Resume Next </pre>
[ { "answer_id": 157785, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https://Stackoverflow.com/users/5017", "pm_score": 8, "selected": true, "text": "On Error Resume Next\n\nDoStep1\n\nIf Err.Number <> 0 Then\n WScript.Echo \"Error in DoStep1: \" & Err.Description\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/157747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6128/" ]
157,759
<p>I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determine the OS of the running machine.</p> <p>Thanks, Joe</p>
[ { "answer_id": 157784, "author": "Douglas F Shearer", "author_id": 13831, "author_profile": "https://Stackoverflow.com/users/13831", "pm_score": 3, "selected": false, "text": "system_profiler SPSoftwareDataType\n" }, { "answer_id": 159927, "author": "Community", "author_i...
2008/10/01
[ "https://Stackoverflow.com/questions/157759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7587/" ]
157,770
<p>I'm trying to format a column in a <code>&lt;table/&gt;</code> using a <code>&lt;col/&gt;</code> element. I can set <code>background-color</code>, <code>width</code>, etc., but can't set the <code>font-weight</code>. Why doesn't it work?</p> <pre><code>&lt;table&gt; &lt;col style="font-weight:bold; background-color:#CCC;"&gt; &lt;col&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;4&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 157798, "author": "Philip Morton", "author_id": 21709, "author_profile": "https://Stackoverflow.com/users/21709", "pm_score": -1, "selected": false, "text": "col" }, { "answer_id": 157836, "author": "mwilliams", "author_id": 23909, "author_profile": "ht...
2008/10/01
[ "https://Stackoverflow.com/questions/157770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15788/" ]
157,786
<p>I am looking for a way in LINQ to match the follow SQL Query.</p> <pre><code>Select max(uid) as uid, Serial_Number from Table Group BY Serial_Number </code></pre> <p>Really looking for some help on this one. The above query gets the max uid of each Serial Number because of the <code>Group By</code> Syntax.</p>
[ { "answer_id": 157919, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 8, "selected": true, "text": " using (DataContext dc = new DataContext())\n {\n var q = from t in dc.TableTests\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/157786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
157,795
<p>Windows Forms allows you to develop Components, non-visual elements that can have a designer. Built-in components include the BackgroundWorker, Timer, and a lot of ADO .NET objects. It's a nice way to provide easy configuration of a complicated object, and it it enables designer-assisted data binding.</p> <p>I've been looking at WPF, and it doesn't seem like there's any concept of components. Am I right about this? Is there some method of creating components (or something like a component) that I've missed?</p> <p>I've accepted Bob's answer because after a lot of research I feel like fancy Adorners are probably the only way to do this.</p>
[ { "answer_id": 507163, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": 1, "selected": false, "text": "<Window x:Class=\"MyApp.Window1\"\n xmlns:sys=\"clr-namespace:System;assembly=mscorlib\"\n xmlns=\"http://schemas.microso...
2008/10/01
[ "https://Stackoverflow.com/questions/157795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2547/" ]
157,807
<p>If you have an API, and you are a UK-based developer with a highly international audience, should your API be </p> <pre><code>setColour() </code></pre> <p>or</p> <pre><code>setColor() </code></pre> <p>(To take one word as a simple example.)</p> <p>UK-based engineers are often quite defensive about their 'correct' spellings but it could be argued that US spelling is more 'standard' in the international market.</p> <p>I guess the question is does it matter? Do developers in other locales struggle with GB spelling, or is it normally quite apparent what things mean?</p> <p>Should it all be US-English?</p>
[ { "answer_id": 157841, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 6, "selected": false, "text": "en-gb" }, { "answer_id": 157874, "author": "Carl", "author_id": 951280, "author_profile": "https:...
2008/10/01
[ "https://Stackoverflow.com/questions/157807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974/" ]
157,812
<p>I have a field on a table in MS Access, tblMyTable.SomeID, and I want to set the default value as a user preference in tblUserPref.DefaultSomeID. It doesn't appear that I can set the default value to use a query in the table definition of tblMyTable. I have a form where records are entered into tblMyTable. I've tried to set the default value of the field on the form, but doesn't seem to accept a query either. So, as a last resort, I'm trying to do it with VBA. I can query the value that I want in VBA, but I can't figure out which event to attach the code to.</p> <p>I want to run the code whenever a new blank record is opened in the form, before the user starts to type into it. I do not want to run the code when an existing record is opened or edited. However, if the code runs for both new blank records and for existing records, I can probably code around that. So far, all of the events I have tried on the field and on the form itself have not run when I wanted them to. Can anyone suggest which event I should use, and on which object?</p>
[ { "answer_id": 157849, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 0, "selected": false, "text": "Private Sub Form_Current()\n If Me.NewRecord Then\n Me.f2 = \"humbug\"\n End If\nEnd Sub\n" }, { "answer_id"...
2008/10/01
[ "https://Stackoverflow.com/questions/157812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2192597/" ]
157,827
<p>My code needs to run all networking routines in a separate NSThread. I have got a library, which I pass a callback routine for communication:</p> <pre><code>my thread code library my callback (networking) library my thread code </code></pre> <p>My callback routine must POST some data to an HTTP server (NSURLConnection), wait for the answer (start a NSRunLoop?), then return to the library.<br> The library then processes the data. After the library returns to my thread, I can then post a notification to the main thread which handles drawing and user input.</p> <p>Is there any sample code covering how to use NSURLConnection in a NSThread?</p>
[ { "answer_id": 171745, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "+[NSURLConnection sendSynchronousRequest:returningResponse:error:]" }, { "answer_id": 688186, "author": "Kendall H...
2008/10/01
[ "https://Stackoverflow.com/questions/157827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8030/" ]
157,832
<p>This is sort of SQL newbie question, I think, but here goes.</p> <p>I have a SQL Query (SQL Server 2005) that I've put together based on an example user-defined function:</p> <pre><code>SELECT CASEID, GetNoteText(CASEID) FROM ( SELECT CASEID FROM ATTACHMENTS GROUP BY CASEID ) i GO </code></pre> <p>the UDF works great (it concatenates data from multiple rows in a related table, if that matters at all) but I'm confused about the "i" after the FROM clause. The query works fine with the i but fails without it. What is the significance of the "i"?</p> <p>EDIT: As Joel noted below, it's not a keyword</p>
[ { "answer_id": 157907, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 3, "selected": false, "text": "SELECT \n c.CASEID, c.CASE_NAME,\n a.COUNT AS ATTACHMENTSCOUNT, o.COUNT as OTHERCOUNT,\n dbo.GetNoteText(c.CA...
2008/10/01
[ "https://Stackoverflow.com/questions/157832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8151/" ]
157,846
<p>What is the benefit of using the servletContext as opposed the request in order to obtain a requestDispatcher?</p> <pre><code>servletContext.getRequestDispatcher(dispatchPath) </code></pre> <p>and using </p> <pre><code>argRequest.getRequestDispatcher(dispatchPath) </code></pre>
[ { "answer_id": 3679333, "author": "kalyan", "author_id": 443714, "author_profile": "https://Stackoverflow.com/users/443714", "pm_score": 1, "selected": false, "text": "getRequestDispatcher" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,850
<p>In a C# Web app, VS 2005 (I am avoiding 2008 because I find the IDE to be hard to deal with), I am getting into a layout stew.</p> <p>I am moving from absolute positioning toward CSS relative positioning.</p> <p>I'd like to divide the screen into four blocks: top (header band), middle left (a stacked menu), middle right (content - here the AJAX tab container), and bottom (footer band), with all 4 blocks positioned relatively, but the controls in the middle right (content) block positioned absolutely relative to the top left corner of the block. A nice side benefit would be to have the IDE design window show all controls as they actually would be displayed, but I doubt this is possible. The IDE is positioning all controls inside the tab panels relative to the top left of the design window; quite a mess.</p> <p>Right now, my prejudice is that CSS is good for relatively positioning blocks, artwork, text etc, but not good for input forms where it is important to line up lots of labels, text boxes, ddl's, check boxes, etc.</p> <p>At any rate, my CSS is not yet up to the task - does anyone know of a good article, book, blog, etc which discusses CSS as it is implemented in ASP.NET, and which might include an example with an AJAX tab control? Any help would be appreciated. </p> <p>Many thanks</p> <p>Mike Thomas </p>
[ { "answer_id": 159349, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 1, "selected": false, "text": "position: relative;" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
157,856
<p>Imagine this sample java class:</p> <pre><code>class A { void addListener(Listener obj); void removeListener(Listener obj); } class B { private A a; B() { a = new A(); a.addListener(new Listener() { void listen() {} } } </code></pre> <p>Do I need to add a finalize method to B to call a.removeListener? Assume that the A instance will be shared with some other objects as well and will outlive the B instance.</p> <p>I am worried that I might be creating a garbage collector problem here. What is the best practice?</p>
[ { "answer_id": 157903, "author": "janm", "author_id": 7256, "author_profile": "https://Stackoverflow.com/users/7256", "pm_score": 4, "selected": false, "text": "class A {\n void addListener(Listener obj);\n void removeListener(Listener obj);\n}\n\nclass B {\n private static clas...
2008/10/01
[ "https://Stackoverflow.com/questions/157856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3657/" ]
157,873
<p>I'm having a test hang in our rails app can't figure out which one (since it hangs and doesn't get to the failure report). I found this blog post <a href="http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/" rel="noreferrer">http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/</a> which adds a setup hook to print the test name but when I try to do the same thing it gives me an error saying wrong number of arguments for setup (1 for 0). Any help at all would be appreciated.</p>
[ { "answer_id": 158034, "author": "Jean", "author_id": 7898, "author_profile": "https://Stackoverflow.com/users/7898", "pm_score": 2, "selected": false, "text": "# File test/unit/testcase.rb, line 100\n def setup\n end\n" }, { "answer_id": 158251, "author": "Aaron Hi...
2008/10/01
[ "https://Stackoverflow.com/questions/157873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3041/" ]
157,905
<p>The subject says it all, almost. How do I automatically fix jsp pages so that relative URLs are mapped to the context path instead of the server root? That is, given for example</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="/css/style.css" /&gt; </code></pre> <p>how do I set-up things in a way that maps the css to <code>my-server/my-context/css/style.css</code> instead of <code>my-server/css/style.css</code>? Is there an automatic way of doing that, other than changing all lines like the above to</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="&lt;%= request.getContextPath() %&gt;/css/style.css" /&gt; </code></pre>
[ { "answer_id": 157909, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<BASE HREF=\"\">" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/157905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069/" ]
157,911
<p>I am trying to add an unhandled exception handler in .net (c#) that should be as helpfull for the 'user' as possible. The end users are mostly programers so they just need a hint of what object are they manipulating wrong.</p> <p>I'm developing a windows similar to the windows XP error report when an application crashes but that gives as much imediate information as possible imediatly about the exception thrown.</p> <p>While the stack trace enables me (since I have the source code) to pinpoint the source of the problem, the users dont have it and so they are lost without further information. Needless to say I have to spend lots of time supporting the tool.</p> <p>There are a few system exceptions like KeyNotFoundException thrown by the Dictionary collection that really bug me since they dont include in the message the key that wasnt found. I can fill my code with tons of try catch blocks but its rather agressive and is lots more code to maintain, not to mention a ton more of strings that have to end up being localized.</p> <p>Finally the question: Is there any way to obtain (at runtime) the values of the arguments of each function in the call stack trace? That alone could resolve 90% of the support calls.</p>
[ { "answer_id": 157973, "author": "Andrew", "author_id": 5662, "author_profile": "https://Stackoverflow.com/users/5662", "pm_score": 0, "selected": false, "text": "KeyNotFoundException" }, { "answer_id": 157996, "author": "Wolfwyrd", "author_id": 15570, "author_profile...
2008/10/01
[ "https://Stackoverflow.com/questions/157911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23190/" ]
157,923
<p>I've started to "play around" with PowerShell and am trying to get it to "behave".</p> <p>One of the things I'd like to do is to customize the PROMPT to be "similar" to what "$M$P$_$+$G" do on MS-Dos:</p> <p>A quick rundown of what these do:</p> <p><b>Character</b><b>| Description</b><br> <b>$m </b> The remote name associated with the current drive letter or the empty string if current drive is not a network drive. <br> <b>$p </b> Current drive and path <br> <b>$_ </b> ENTER-LINEFEED <br> <b>$+ </b> Zero or more plus sign (+) characters depending upon the depth of the <b>pushd</b> directory stack, one character for each level pushed <br> <b>$g </b> > (greater-than sign) <br></p> <p>So the final output is something like:</p> <pre><code> \\spma1fp1\JARAVJ$ H:\temp ++&gt; </code></pre> <p>I've been able to add the <code>$M</code> and <code>$_</code> functionality (and a nifty History feature) to my prompt as follows:</p> <pre><code>function prompt { ## Get the history. Since the history may be either empty, ## a single item or an array, the @() syntax ensures ## that PowerShell treats it as an array $history = @(get-history) ## If there are any items in the history, find out the ## Id of the final one. ## PowerShell defaults the $lastId variable to '0' if this ## code doesn't execute. if($history.Count -gt 0) { $lastItem = $history[$history.Count - 1] $lastId = $lastItem.Id } ## The command that we're currently entering on the prompt ## will be next in the history. Because of that, we'll ## take the last history Id and add one to it. $nextCommand = $lastId + 1 ## Get the current location $currentDirectory = get-location ## Set the Windows Title to the current location $host.ui.RawUI.WindowTitle = "PS: " + $currentDirectory ## And create a prompt that shows the command number, ## and current location "PS:$nextCommand $currentDirectory &gt;" } </code></pre> <p>But the rest is not yet something I've managed to duplicate....</p> <p>Thanks a lot for the tips that will surely come!</p>
[ { "answer_id": 157991, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 1, "selected": false, "text": "$(get-location -Stack).count\n" }, { "answer_id": 158054, "author": "EBGreen", "author_id": 1358, "autho...
2008/10/01
[ "https://Stackoverflow.com/questions/157923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12344/" ]
157,933
<p>I was able to implement a thread-safe Dictionary in C# by deriving from IDictionary and defining a private SyncRoot object:</p> <pre><code>public class SafeDictionary&lt;TKey, TValue&gt;: IDictionary&lt;TKey, TValue&gt; { private readonly object syncRoot = new object(); private Dictionary&lt;TKey, TValue&gt; d = new Dictionary&lt;TKey, TValue&gt;(); public object SyncRoot { get { return syncRoot; } } public void Add(TKey key, TValue value) { lock (syncRoot) { d.Add(key, value); } } // more IDictionary members... } </code></pre> <p>I then lock on this SyncRoot object throughout my consumers (multiple threads):</p> <p>Example:</p> <pre><code>lock (m_MySharedDictionary.SyncRoot) { m_MySharedDictionary.Add(...); } </code></pre> <p>I was able to make it work, but this resulted in some ugly code. My question is, is there a better, more elegant way of implementing a thread-safe Dictionary?</p>
[ { "answer_id": 158005, "author": "fryguybob", "author_id": 4592, "author_profile": "https://Stackoverflow.com/users/4592", "pm_score": 6, "selected": true, "text": "public class SafeDictionary<TKey, TValue>: IDictionary<TKey, TValue>\n{\n private readonly object syncRoot = new object(...
2008/10/01
[ "https://Stackoverflow.com/questions/157933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5563/" ]
157,938
<p>I have got a python script which is creating an ODBC connection. The ODBC connection is generated with a connection string. In this connection string I have to include the username and password for this connection. </p> <p>Is there an easy way to obscure this password in the file (just that nobody can read the password when I'm editing the file) ? </p>
[ { "answer_id": 157975, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 8, "selected": true, "text": ">>> import base64\n>>> print(base64.b64encode(\"password\".encode(\"utf-8\")))\ncGFzc3dvcmQ=\n>>> print(base64.b64decode(...
2008/10/01
[ "https://Stackoverflow.com/questions/157938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3056/" ]
157,944
<p>Given an array of type <code>Element[]</code>:</p> <pre><code>Element[] array = {new Element(1), new Element(2), new Element(3)}; </code></pre> <p>How do I convert this array into an object of type <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayList.html" rel="noreferrer"><code>ArrayList&lt;Element&gt;</code></a>?</p> <pre><code>ArrayList&lt;Element&gt; arrayList = ???; </code></pre>
[ { "answer_id": 157950, "author": "Tom", "author_id": 22850, "author_profile": "https://Stackoverflow.com/users/22850", "pm_score": 13, "selected": true, "text": "new ArrayList<>(Arrays.asList(array));\n" }, { "answer_id": 157956, "author": "Bill the Lizard", "author_id": ...
2008/10/01
[ "https://Stackoverflow.com/questions/157944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939/" ]