qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
67,835
<p>Using VBA, how can I:</p> <ol> <li>test whether a file exists, and if so,</li> <li>delete it?</li> </ol>
[ { "answer_id": 67853, "author": "Leo Moore", "author_id": 6336, "author_profile": "https://Stackoverflow.com/users/6336", "pm_score": 3, "selected": false, "text": "Dir" }, { "answer_id": 67858, "author": "Rich Adams", "author_id": 10018, "author_profile": "https://St...
2008/09/15
[ "https://Stackoverflow.com/questions/67835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10439/" ]
67,859
<p>I am trying to create a query string of variable assignments separated by the <code>&amp;</code> symbol (ex: <code>"var1=x&amp;var2=y&amp;..."</code>). I plan to pass this string into an embedded flash file.</p> <p>I am having trouble getting an <code>&amp;</code> symbol to show up in XSLT. If I just type <code>&amp;</code> with no tags around it, there is a problem rendering the XSLT document. If I type <code>&amp;amp;</code> with no tags around it, then the output of the document is <code>&amp;amp;</code> with no change. If I type <code>&lt;xsl:value-of select="&amp;" /&gt;</code> or <code>&lt;xsl:value-of select="&amp;amp;" /&gt;</code> I also get an error. Is this possible? Note: I have also tried <code>&amp;amp;amp;</code> with no success.</p>
[ { "answer_id": 67876, "author": "Thunder3", "author_id": 2832, "author_profile": "https://Stackoverflow.com/users/2832", "pm_score": 3, "selected": false, "text": "disable-output-escaping=\"yes\"" }, { "answer_id": 67892, "author": "tomasr", "author_id": 10292, "autho...
2008/09/15
[ "https://Stackoverflow.com/questions/67859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
67,879
<p>I have an application that runs as a child application in a virtual directory.</p> <p>I want to pass a value from the parent application, but I believe that Session is keyed per application, and won't work.</p> <p>To further complicate things, the parent application is WebForms, while the child is NVelocity MVC.</p> <p>Does anyone know a trick that allows me to use some sort of Session type functionality between virtual applications?</p> <p>EDIT: A webservice isn't really what I had in mind, all I need to do is pass the logged in users username to the child app. Besides, if calling a webservice back on the parent, I won't get the same session, so I won't know what user.</p>
[ { "answer_id": 67935, "author": "foxxtrot", "author_id": 10369, "author_profile": "https://Stackoverflow.com/users/10369", "pm_score": 0, "selected": false, "text": "HttpWebRequest req = (HttpWebRequest)WebRequest.Create(\"/ASPSession.ASP?SessionVar=\" + SessionVarName);\nreq.Headers.Add...
2008/09/15
[ "https://Stackoverflow.com/questions/67879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
67,890
<p>I'm writing a web app that points to external links. I'm looking to create a non-sequential, non-guessable id for each document that I can use in the URL. I did the obvious thing: treating the url as a string and str#crypt on it, but that seems to choke on any non-alphanumberic characters, like the slashes, dots and underscores.</p> <p>Any suggestions on the best way to solve this problem?</p> <p>Thanks!</p>
[ { "answer_id": 67900, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Digest::MD5.hexdigest(my_url)\n" }, { "answer_id": 68028, "author": "manveru", "author_id": 8367, "author_p...
2008/09/15
[ "https://Stackoverflow.com/questions/67890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10461/" ]
67,894
<p>Why do we need to use:</p> <pre><code>extern "C" { #include &lt;foo.h&gt; } </code></pre> <p><strong>Specifically:</strong> </p> <ul> <li><p>When should we use it?</p></li> <li><p>What is happening at the compiler/linker level that requires us to use it? </p></li> <li><p>How in terms of compilation/linking does this solve the problems which require us to use it?</p></li> </ul>
[ { "answer_id": 67930, "author": "gnkdl_gansklgna", "author_id": 10470, "author_profile": "https://Stackoverflow.com/users/10470", "pm_score": 8, "selected": true, "text": "printf()" }, { "answer_id": 67932, "author": "Trent", "author_id": 9083, "author_profile": "http...
2008/09/15
[ "https://Stackoverflow.com/questions/67894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1597/" ]
67,916
<p>I have something that is driving me absolutely crazy...</p> <pre><code> Public Function GetAccountGroups() As IList(Of AccountGroup) Dim raw_account_groups As IList(Of AccountGroup) raw_account_groups = _repository.GetAccountGroups().ToList() Dim parents = (From ag In raw_account_groups _ Where ag.parent_id = 0 _ Select ag).ToList() parents(0).sub_account_groups = (From sag In raw_account_groups _ Where sag.parent_id = 0 _ Select sag).ToList() Dim sql_func As Func(Of AccountGroup, List(Of AccountGroup)) = Function(p) _ (From sag In raw_account_groups _ Where sag.parent_id = p.id _ Select sag).ToList() parents.ForEach(Function(p) p.sub_account_groups = sql_func(p)) Return parents End Function </code></pre> <p>The line <code>parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))</code> has this error...</p> <blockquote> <p>Operator '=' is not defined for types 'System.Collections.Generic.IList(Of st.data.AccountGroup)' and 'System.Collections.Generic.List(Of st.data.AccountGroup)'. </p> </blockquote> <p>but I really can't see how it is any different from this code from Rob Connery</p> <pre><code>public IList&lt;Category&gt; GetCategories() { IList&lt;Category&gt; rawCategories = _repository.GetCategories().ToList(); var parents = (from c in rawCategories where c.ParentID == 0 select c).ToList(); parents.ForEach(p =&gt; { p.SubCategories = (from subs in rawCategories where subs.ParentID == p.ID select subs).ToList(); }); return parents; } </code></pre> <p>which compiles perfectly... what am I doing incorrectly?</p>
[ { "answer_id": 68795, "author": "Jeff Moser", "author_id": 1869, "author_profile": "https://Stackoverflow.com/users/1869", "pm_score": 0, "selected": false, "text": "Module Module1\n Sub Main()\n End Sub\nEnd Module\n\nClass AccountGroup\n Public parent_id As Integer\n Public...
2008/09/15
[ "https://Stackoverflow.com/questions/67916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10479/" ]
67,937
<p>Does anyone know an easy way to import a raw, XML RSS feed into C#? Am looking for an easy way to get the XML as a string so I can parse it with a Regex.</p> <p>Thanks, -Greg</p>
[ { "answer_id": 68008, "author": "Darrel Miller", "author_id": 6819, "author_profile": "https://Stackoverflow.com/users/6819", "pm_score": 4, "selected": false, "text": "using System.Net \n\nWebClient wc = new WebClient();\n\nStream st = wc.OpenRead(“http://example.com/feed.rss”);\n\nusin...
2008/09/15
[ "https://Stackoverflow.com/questions/67937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8855/" ]
67,959
<p>I've run into a few gotchas when doing C# XML serialization that I thought I'd share:</p> <ul> <li>You can't serialize items that are read-only (like KeyValuePairs)</li> <li>You can't serialize a generic dictionary. Instead, try this wrapper class (from <a href="http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx" rel="noreferrer">http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx</a>):</li> </ul> <hr/> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; [XmlRoot("dictionary")] public class SerializableDictionary&lt;TKey, TValue&gt; : Dictionary&lt;TKey, TValue&gt;, IXmlSerializable { public System.Xml.Schema.XmlSchema GetSchema() { return null; } public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer keySerializer = new XmlSerializer(typeof(TKey)); XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) return; while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { reader.ReadStartElement("item"); reader.ReadStartElement("key"); TKey key = (TKey)keySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement("value"); TValue value = (TValue)valueSerializer.Deserialize(reader); reader.ReadEndElement(); this.Add(key, value); reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); } public void WriteXml(System.Xml.XmlWriter writer) { XmlSerializer keySerializer = new XmlSerializer(typeof(TKey)); XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue)); foreach (TKey key in this.Keys) { writer.WriteStartElement("item"); writer.WriteStartElement("key"); keySerializer.Serialize(writer, key); writer.WriteEndElement(); writer.WriteStartElement("value"); TValue value = this[key]; valueSerializer.Serialize(writer, value); writer.WriteEndElement(); writer.WriteEndElement(); } } } </code></pre> <p>Any other XML Serialization gotchas out there?</p>
[ { "answer_id": 68476, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "IEnumerables<T>" }, { "answer_id": 69072, "author": "user7116", "author_id": 7116, "author_profile": "https...
2008/09/15
[ "https://Stackoverflow.com/questions/67959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109/" ]
67,980
<p>I need to pass a UUID instance via http request parameter. Spring needs a custom type converter (from String) to be registered. How do I register one?</p>
[ { "answer_id": 69314, "author": "alexei.vidmich", "author_id": 7199, "author_profile": "https://Stackoverflow.com/users/7199", "pm_score": 2, "selected": false, "text": "@InitBinder\npublic void initBinder(WebDataBinder binder) {\n binder.registerCustomEditor(UUID.class, new UUIDEdito...
2008/09/15
[ "https://Stackoverflow.com/questions/67980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7199/" ]
68,012
<p>I am relatively new to JavaScript and am trying to understand how to use it correctly.</p> <p>If I wrap JavaScript code in an anonymous function to avoid making variables <code>public</code> the functions within the JavaScript are not available from within the html that includes the JavaScript. </p> <p>On initially loading the page the JavaScript loads and is executed but on subsequent reloads of the page the JavaScript code does not go through the execution process again. Specifically there is an ajax call using <code>httprequest</code> to get that from a PHP file and passes the returned data to a callback function that in <em>onsuccess</em> processes the data, if I could call the function that does the <code>httprequest</code> from within the html in a </p> <pre><code>&lt;script type="text/javascript" &gt;&lt;/script&gt; </code></pre> <p>block on each page load I'd be all set - as it is I have to inject the entire JavaScript code into that block to get it to work on page load, hoping someone can educate me.</p>
[ { "answer_id": 68046, "author": "HFLW", "author_id": 252822, "author_profile": "https://Stackoverflow.com/users/252822", "pm_score": 1, "selected": false, "text": "<script type=\"text/javascript\">\n(function() {\n var private = \"private var\";\n window.onload = function() {\n ...
2008/09/15
[ "https://Stackoverflow.com/questions/68012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,018
<p>If I have a Resource bundle property file:</p> <p>A.properties:</p> <pre><code>thekey={0} This is a test </code></pre> <p>And then I have java code that loads the resource bundle:</p> <pre><code>ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale); labels.getString("thekey"); </code></pre> <p>How can I replace the {0} text with some value</p> <pre><code>labels.getString("thekey", "Yes!!!"); </code></pre> <p>Such that the output comes out as:</p> <pre><code>Yes!!! This is a test. </code></pre> <p>There are no methods that are part of Resource Bundle to do this. Also, I am in Struts, is there some way to use MessageProperties to do the replacement.</p>
[ { "answer_id": 68075, "author": "user10544", "author_id": 10544, "author_profile": "https://Stackoverflow.com/users/10544", "pm_score": 5, "selected": true, "text": "MessageFormat.format(\"{0} This {1} a test\", new Object[] {\"Yes!!!\", \"is\"});\n" }, { "answer_id": 68163, ...
2008/09/15
[ "https://Stackoverflow.com/questions/68018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
68,029
<p>Got this from some mysql queries, puzzled since error 122 is usually a 'out of space' error but there's plenty of space left on the server... any ideas?</p>
[ { "answer_id": 28057763, "author": "Archil", "author_id": 4476218, "author_profile": "https://Stackoverflow.com/users/4476218", "pm_score": 2, "selected": false, "text": "quotaoff -a\n" } ]
2008/09/15
[ "https://Stackoverflow.com/questions/68029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,042
<p>Let's say that on the C++ side my function takes a variable of type <code>jstring</code> named <code>myString</code>. I can convert it to an ANSI string as follows:</p> <pre><code>const char* ansiString = env-&gt;GetStringUTFChars(myString, 0); </code></pre> <p>is there a way of getting</p> <p><code>const wchar_t* unicodeString =</code> ...</p>
[ { "answer_id": 68065, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "wchar_t" }, { "answer_id": 1666532, "author": "Benj", "author_id": 193128, "author_profile": "https://Sta...
2008/09/15
[ "https://Stackoverflow.com/questions/68042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,067
<p>I'm using BlogEngine.NET (a fine, fine tool) and I was playing with the TinyMCE editor and noticed that there's a place for me to create a list of external links, but it has to be a javascript file:</p> <p><code>external_link_list_url : "example_link_list.js"</code></p> <p>this is great, of course, but the list of links I want to use needs to be generated dynamically from the database. This means that I need to create this JS file from the server on page load. Does anyone know of a way to do this? Ideally, I'd like to just overwrite this file each time the editor is accessed.</p> <p>Thanks!</p>
[ { "answer_id": 68132, "author": "JustAsItSounds", "author_id": 10586, "author_profile": "https://Stackoverflow.com/users/10586", "pm_score": 2, "selected": false, "text": "context.Response.ContentType = \"text/javascript\";\n" }, { "answer_id": 68831, "author": "JustAsItSound...
2008/09/15
[ "https://Stackoverflow.com/questions/68067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
68,103
<p>I have a XULRunner application that needs to copy image data to the clipboard. I have figured out how to handle copying text to the clipboard, and I can paste PNG data from the clipboard. What I can't figure out is how to get data from a data URL into the clipboard so that it can be pasted into other applications.</p> <p>This is the code I use to copy text (well, XUL):</p> <pre><code>var transferObject=Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); var stringWrapper=Components.classes["@mozilla.org/supports-string;1"]. createInstance(Components.interfaces.nsISupportsString); var systemClipboard=Components.classes["@mozilla.org/widget/clipboard;1"]. createInstance(Components.interfaces.nsIClipboard); var objToSerialize=aDOMNode; transferObject.addDataFlavor("text/xul"); var xmls=new XMLSerializer(); var serializedObj=xmls.serializeToString(objToSerialize); stringWrapper.data=serializedObj; transferObject.setTransferData("text/xul",stringWrapper,serializedObj.length*2); </code></pre> <p>And, as I said, the data I'm trying to transfer is a PNG as a data URL. So I'm looking for the equivalent to the above that will allow, e.g. Paint.NET to paste my app's data.</p>
[ { "answer_id": 130880, "author": "Joel Anair", "author_id": 7441, "author_profile": "https://Stackoverflow.com/users/7441", "pm_score": 3, "selected": true, "text": "dataURL" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7441/" ]
68,109
<p>My professor did an informal benchmark on a little program and the Java times were: 1.7 seconds for the first run, and 0.8 seconds for the runs thereafter. </p> <ul> <li><p>Is this due entirely to the loading of the runtime environment into the operating environment ?</p> <p>OR </p></li> <li><p>Is it influenced by Java's optimizing the code and storing the results of those optimizations (sorry, I don't know the technical term for that)?</p></li> </ul>
[ { "answer_id": 68602, "author": "big_peanut_horse", "author_id": 10720, "author_profile": "https://Stackoverflow.com/users/10720", "pm_score": 2, "selected": false, "text": "java.lang.String.equals(...)" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10577/" ]
68,113
<p>I've just inherited a java application that needs to be installed as a service on XP and vista. It's been about 8 years since I've used windows in any form and I've never had to create a service, let alone from something like a java app (I've got a jar for the app and a single dependency jar - log4j). What is the magic necessary to make this run as a service? I've got the source, so code modifications, though preferably avoided, are possible.</p>
[ { "answer_id": 10756495, "author": "11101101b", "author_id": 875305, "author_profile": "https://Stackoverflow.com/users/875305", "pm_score": 6, "selected": false, "text": "MyServiceName.exe" }, { "answer_id": 42204087, "author": "Ravi Parekh", "author_id": 410439, "au...
2008/09/16
[ "https://Stackoverflow.com/questions/68113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10273/" ]
68,120
<p>I'm not overly familiar with Tomcat, but my team has inherited a complex project that revolves around a Java Servlet being hosted in Tomcat across many servers. Custom configuration management software is used to write out the server.xml, and various resources (connection pools, beans, server variables, etc) written into server.xml configure the servlet. This is all well and good.</p> <p>However, the names of some of the resources aren't known in advance. For example, the Servlet may need access to any number of "Anonymizers" as configured by the operator. Each anonymizer has a unique name associated with it. We create and configure each anonymizer using java beans similar to the following:</p> <pre><code>&lt;Resource name="bean/Anonymizer_toon" type="com.company.tomcatutil.AnonymizerBean" factory="org.apache.naming.factory.BeanFactory" className="teAnonymizer" databaseId="50" /&gt; &lt;Resource name="bean/Anonymizer_default" type="com.company.tomcatutil.AnonymizerBean" factory="org.apache.naming.factory.BeanFactory" className="teAnonymizer" databaseId="54" /&gt; </code></pre> <p>However, this appears to require us to have explicit entries in the Servlet's context.xml file for each an every possible resource name in advance. I'd like to replace the explicit context.xml entries with wildcards, or know if there is a better solution to this type of problem.</p> <p>Currently:</p> <pre><code> &lt;ResourceLink name="bean/Anonymizer_default" global="bean/Anonymizer_default" type="com.company.tomcatutil.AnonymizerBean"/&gt; &lt;ResourceLink name="bean/Anonymizer_toon" global="bean/Anonymizer_toon" type="com.company.tomcatutil.AnonymizerBean"/&gt; </code></pre> <p>Replaced with something like:</p> <pre><code> &lt;ResourceLink name="bean/Anonymizer_*" global="bean/Anonymizer_*" type="com.company.tomcatutil.AnonymizerBean"/&gt; </code></pre> <p>However, I haven't been able to figure out if this is possible or what the correct syntax might be. Can anyone make any suggestions about better ways to handle this?</p>
[ { "answer_id": 10756495, "author": "11101101b", "author_id": 875305, "author_profile": "https://Stackoverflow.com/users/875305", "pm_score": 6, "selected": false, "text": "MyServiceName.exe" }, { "answer_id": 42204087, "author": "Ravi Parekh", "author_id": 410439, "au...
2008/09/16
[ "https://Stackoverflow.com/questions/68120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10452/" ]
68,150
<p>I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code. I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again. I imagine <em>something</em> I end up programming will need a B-Tree, or is that just delusional? How long do you typically save the code you write for possible reuse? </p>
[ { "answer_id": 68170, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "junk/" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7545/" ]
68,160
<p>Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process. </p> <p>If this is possible, what commands would you use? (I'm trying to do this on a Linux box)</p>
[ { "answer_id": 14279282, "author": "Alex Zeffertt", "author_id": 779147, "author_profile": "https://Stackoverflow.com/users/779147", "pm_score": 6, "selected": false, "text": "gcore $(pidof processname)" }, { "answer_id": 43099251, "author": "dev", "author_id": 2456048, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
68,165
<p>I have a link on a long HTML page. When I click it, I wish a <code>div</code> on another part of the page to be visible in the window by scrolling into view.</p> <p>A bit like <code>EnsureVisible</code> in other languages.</p> <p>I've checked out <code>scrollTop</code> and <code>scrollTo</code> but they seem like red herrings.</p> <p>Can anyone help?</p>
[ { "answer_id": 68175, "author": "mjallday", "author_id": 6084, "author_profile": "https://Stackoverflow.com/users/6084", "pm_score": 4, "selected": false, "text": "<a href=\"#myAnchorALongWayDownThePage\">Click here to scroll</a>\n\n<A name='myAnchorALongWayDownThePage\"></a>\n" }, {...
2008/09/16
[ "https://Stackoverflow.com/questions/68165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,234
<p>Let’s say I'm developing a helpdesk application that will be used by multiple departments. Every URL in the application will include a key indicating the specific department. The key will always be the first parameter of every action in the system. For example</p> <pre><code>http://helpdesk/HR/Members http://helpdesk/HR/Members/PeterParker http://helpdesk/HR/Categories http://helpdesk/Finance/Members http://helpdesk/Finance/Members/BruceWayne http://helpdesk/Finance/Categories </code></pre> <p>The problem is that in each action on each request, I have to take this parameter and then retrieve the Helpdesk Department model from the repository based on that key. From that model I can retrieve the list of members, categories etc., which is different for each Helpdesk Department. This obviously violates DRY.</p> <p>My question is, how can I create a base controller, which does this for me so that the particular Helpdesk Department specified in the URL is available to all derived controllers, and I can just focus on the actions?</p>
[ { "answer_id": 72330, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 0, "selected": false, "text": "public abstract class BaseController : Controller \n{\n}\n\npublic class DerivedController : BaseController \n{\n}\n" ...
2008/09/16
[ "https://Stackoverflow.com/questions/68234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,243
<p>I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.</p>
[ { "answer_id": 68362, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 0, "selected": false, "text": "my_essay = << END_STR\nThis is within the string\nEND_STR\n\n<< self\n def other_method\n ...\n end\nend\n" }, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,247
<p>I sometimes need to modify OSS code or other peoples' code (usually C-based, but sometimes C++/Java) and find myself "grep"ing headers for types, function declarations etc. as I follow code flow and try to understand the system. Is there a good tool that exists to aid in code browsing. I'd love to be able to click on a type and be taken to the declaration or click on a function name and be taken to it's implementation. I'm on a linux box, so replies like "just use Visual Studio" won't necessarily work for me. Thanks!</p>
[ { "answer_id": 68367, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": " Find this C symbol:\n Find this function definition:\n Find functions called by this function:\n Find functions callin...
2008/09/16
[ "https://Stackoverflow.com/questions/68247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,282
<p>When defining a method on a class in Python, it looks something like this:</p> <pre><code>class MyClass(object): def __init__(self, x, y): self.x = x self.y = y </code></pre> <p>But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "this" keyword without declaring it as an argument in the method prototype. </p> <p>Was this an intentional language design decision in Python or are there some implementation details that require the passing of "self" as an argument?</p>
[ { "answer_id": 68320, "author": "Ryan", "author_id": 8819, "author_profile": "https://Stackoverflow.com/users/8819", "pm_score": 6, "selected": false, "text": ">>> class C:\n... def foo(self):\n... print(\"Hi!\")\n...\n>>>\n>>> def bar(self):\n... print(\"Bork bork bork!\...
2008/09/16
[ "https://Stackoverflow.com/questions/68282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
68,283
<p>What's a quick and easy way to view and edit ID3 tags (artist, album, etc.) using C#?</p>
[ { "answer_id": 68407, "author": "mmcdole", "author_id": 2635, "author_profile": "https://Stackoverflow.com/users/2635", "pm_score": 6, "selected": false, "text": "class MusicID3Tag\n\n{\n\n public byte[] TAGID = new byte[3]; // 3\n public byte[] Title = new byte[30]; // ...
2008/09/16
[ "https://Stackoverflow.com/questions/68283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10606/" ]
68,291
<p>If you were running a news site that created a list of 10 top news stories, and you wanted to make tweaks to your algorithm and see if people liked the new top story mix better, how would you approach this? </p> <p>Simple Click logging in the DB associated with the post entry? </p> <p>A/B testing where you would show one version of the algorithm togroup A and another to group B and measure the clicks? </p> <p>What sort of characteristics would you base your decision on as to whether the changes were better? </p>
[ { "answer_id": 68407, "author": "mmcdole", "author_id": 2635, "author_profile": "https://Stackoverflow.com/users/2635", "pm_score": 6, "selected": false, "text": "class MusicID3Tag\n\n{\n\n public byte[] TAGID = new byte[3]; // 3\n public byte[] Title = new byte[30]; // ...
2008/09/16
[ "https://Stackoverflow.com/questions/68291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/281/" ]
68,323
<p>Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an <code>is_deleted='0'</code> field on each table in the database and set it to <code>'1'</code> if particular user roles hit a delete button on a specific record.</p> <p>For future maintenance now, each <code>SELECT</code> query will need to ensure they do not include records <code>where is_deleted='1'</code>.</p> <p>Is there a better solution for implementing soft deletion?</p> <p>Update: I should also note that we have an Audit database that tracks changes (field, old value, new value, time, user, ip) to all tables/fields within the Application database.</p>
[ { "answer_id": 68328, "author": "David J. Sokol", "author_id": 1390, "author_profile": "https://Stackoverflow.com/users/1390", "pm_score": 7, "selected": true, "text": "WHERE IS_DELETED='0'" }, { "answer_id": 68338, "author": "ctcherry", "author_id": 10322, "author_pr...
2008/09/16
[ "https://Stackoverflow.com/questions/68323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10583/" ]
68,327
<p>I create a new Button object but did not specify the <code>command</code> option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created?</p>
[ { "answer_id": 68455, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 2, "selected": false, "text": "bind" }, { "answer_id": 68524, "author": "akdom", "author_id": 145, "author_profile": "https://St...
2008/09/16
[ "https://Stackoverflow.com/questions/68327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
68,335
<p>I have a text file on my local machine that is generated by a daily Python script run in cron. </p> <p>I would like to add a bit of code to have that file sent securely to my server over SSH.</p>
[ { "answer_id": 68365, "author": "pdq", "author_id": 8598, "author_profile": "https://Stackoverflow.com/users/8598", "pm_score": 7, "selected": true, "text": "scp" }, { "answer_id": 68377, "author": "Drew Olson", "author_id": 9434, "author_profile": "https://Stackoverf...
2008/09/16
[ "https://Stackoverflow.com/questions/68335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10668/" ]
68,346
<p>Here's a problem I've been trying to solve at work. I'm not a database expert, so that perhaps this is a bit sophomoric. All apologies.</p> <p>I have a given database D, which has been duplicated on another machine (in a perhaps dubious manner), resulting in database D'. It is my task to check that database D and D' are in fact exactly identical.</p> <p>The problem, of course, is what to actually do if they are not. For this purpose, my thought was to run a symmetric difference on each corresponding table and see the differences.</p> <p>There is a "large" number of tables, so I do not wish to run each symmetric difference by hand. How do I then implement a symmetric difference "function" (or stored procedure, or whatever you'd like) that can run on arbitrary tables without having to explicitly enumerate the columns?</p> <p>This is running on Windows, and your hedge fund will explode if you don't follow through. Good luck.</p>
[ { "answer_id": 2533784, "author": "user303677", "author_id": 303677, "author_profile": "https://Stackoverflow.com/users/303677", "pm_score": 2, "selected": false, "text": "SELECT s.name, s.type \nFROM \n(\n SELECT s1.name, s1.type\n FROM syscolumns s1\n WHERE object_name(s1.id) ...
2008/09/16
[ "https://Stackoverflow.com/questions/68346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
68,352
<p>I use this question in interviews and I wonder what the best solution is.</p> <p>Write a Perl sub that takes <em>n</em> lists, and then returns 2^<em>n</em>-1 lists telling you which items are in which lists; that is, which items are only in the first list, the second, list, both the first and second list, and all other combinations of lists. Assume that <em>n</em> is reasonably small (less than 20).</p> <p>For example:</p> <pre><code>list_compare([1, 3], [2, 3]); =&gt; ([1], [2], [3]); </code></pre> <p>Here, the first result list gives all items that are only in list 1, the second result list gives all items that are only in list 2, and the third result list gives all items that are in both lists.</p> <pre><code>list_compare([1, 3, 5, 7], [2, 3, 6, 7], [4, 5, 6, 7]) =&gt; ([1], [2], [3], [4], [5], [6], [7]) </code></pre> <p>Here, the first list gives all items that are only in list 1, the second list gives all items that are only in list 2, and the third list gives all items that are in both lists 1 and 2, as in the first example. The fourth list gives all items that are only in list 3, the fifth list gives all items that are only in lists 1 and 3, the sixth list gives all items that are only in lists 2 and 3, and the seventh list gives all items that are in all 3 lists.</p> <p>I usually give this problem as a follow up to the subset of this problem for <em>n</em>=2.</p> <p>What is the solution? </p> <p>Follow-up: The items in the lists are strings. There might be duplicates, but since they are just strings, duplicates should be squashed in the output. Order of the items in the output lists doesn't matter, the order of the lists themselves does.</p>
[ { "answer_id": 68417, "author": "nohat", "author_id": 3101, "author_profile": "https://Stackoverflow.com/users/3101", "pm_score": 0, "selected": false, "text": "sub list_compare {\n my (@lists) = @_;\n my %compare;\n my $bit = 1;\n foreach my $list (@lists) {\n $compar...
2008/09/16
[ "https://Stackoverflow.com/questions/68352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3101/" ]
68,372
<p>We all know how to use <code>&lt;ctrl&gt;-R</code> to reverse search through history, but did you know you can use <code>&lt;ctrl&gt;-S</code> to forward search if you set <code>stty stop ""</code>? Also, have you ever tried running bind -p to see all of your keyboard shortcuts listed? There are over 455 on Mac OS X by default. </p> <p>What is your single most favorite obscure trick, keyboard shortcut or shopt configuration using bash?</p>
[ { "answer_id": 68388, "author": "HFLW", "author_id": 252822, "author_profile": "https://Stackoverflow.com/users/252822", "pm_score": 4, "selected": false, "text": "watch --interval=10 lynx -dump http://dslrouter/stats.html\n" }, { "answer_id": 68390, "author": "ctcherry", ...
2008/09/16
[ "https://Stackoverflow.com/questions/68372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3499/" ]
68,391
<p>In an effort to reduce code duplication in my little Rails app, I've been working on getting common code between my models into it's own separate module, so far so good.</p> <p>The model stuff is fairly easy, I just have to include the module at the beginning, e.g.:</p> <pre><code>class Iso &lt; Sale include Shared::TracksSerialNumberExtension include Shared::OrderLines extend Shared::Filtered include Sendable::Model validates_presence_of :customer validates_associated :lines owned_by :customer def initialize( params = nil ) super self.created_at ||= Time.now.to_date end def after_initialize end order_lines :despatched # tracks_serial_numbers :items sendable :customer def created_at=( date ) write_attribute( :created_at, Chronic.parse( date ) ) end end </code></pre> <p>This is working fine, now however, I'm going to have some controller and view code that's going to be common between these models as well, so far I have this for my sendable stuff:</p> <pre><code># This is a module that is used for pages/forms that are can be "sent" # either via fax, email, or printed. module Sendable module Model def self.included( klass ) klass.extend ClassMethods end module ClassMethods def sendable( class_to_send_to ) attr_accessor :fax_number, :email_address, :to_be_faxed, :to_be_emailed, :to_be_printed @_class_sending_to ||= class_to_send_to include InstanceMethods end def class_sending_to @_class_sending_to end end # ClassMethods module InstanceMethods def after_initialize( ) super self.to_be_faxed = false self.to_be_emailed = false self.to_be_printed = false target_class = self.send( self.class.class_sending_to ) if !target_class.nil? self.fax_number = target_class.send( :fax_number ) self.email_address = target_class.send( :email_address ) end end end end # Module Model end # Module Sendable </code></pre> <p>Basically I'm planning on just doing an include Sendable::Controller, and Sendable::View (or the equivalent) for the controller and the view, but, is there a cleaner way to do this? I 'm after a neat way to have a bunch of common code between my model, controller, and view.</p> <p>Edit: Just to clarify, this just has to be shared across 2 or 3 models.</p>
[ { "answer_id": 68934, "author": "hoyhoy", "author_id": 3499, "author_profile": "https://Stackoverflow.com/users/3499", "pm_score": 3, "selected": false, "text": "# maybe put this in environment.rb or in your module declaration\nclass ActiveRecord::Base\n include Iso\nend\n\n# applicatio...
2008/09/16
[ "https://Stackoverflow.com/questions/68391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/841/" ]
68,408
<p>Is there any <strong>simple algorithm</strong> to determine the likeliness of 2 names representing the same person? </p> <p>I'm not asking for something of the level that Custom department might be using. Just a simple algorithm that would tell me if 'James T. Clark' is most likely the same name as 'J. Thomas Clark' or 'James Clerk'.</p> <p>If there is an algorithm in <code>C#</code> that would be great, but I can translate from any language.</p>
[ { "answer_id": 68570, "author": "Stanislav Kniazev", "author_id": 10757, "author_profile": "https://Stackoverflow.com/users/10757", "pm_score": 3, "selected": true, "text": "PartialStringComparer cmp = new PartialStringComparer();\ntbResult.Text = cmp.Compare(textBox1.Text, textBox2.Text...
2008/09/16
[ "https://Stackoverflow.com/questions/68408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3610/" ]
68,444
<p>We have a program that produces several SWF files, some CSS and XML files, all of which need to be deployed for the thing to work.</p> <p>Is there a program or technique out there for wrapping all these files together into a single SWF file?</p>
[ { "answer_id": 192919, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 1, "selected": false, "text": "mxmlc" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6277/" ]
68,447
<p>From the Displays pane in System Preferences, I can manually change the main monitor by dragging the menu bar from one display to the other. I'd like to automate this and make it part of an AppleScript.</p>
[ { "answer_id": 1906298, "author": "Laurent Etiemble", "author_id": 121278, "author_profile": "https://Stackoverflow.com/users/121278", "pm_score": 2, "selected": false, "text": "/Library/Preferences/com.apple.windowserver.plist" }, { "answer_id": 1911234, "author": "apaderno"...
2008/09/16
[ "https://Stackoverflow.com/questions/68447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6311/" ]
68,477
<p>Is there a way to send a file using POST from a Python script?</p>
[ { "answer_id": 68502, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": false, "text": "urllib2" }, { "answer_id": 525193, "author": "gotgenes", "author_id": 38140, "author_profile": "htt...
2008/09/16
[ "https://Stackoverflow.com/questions/68477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
68,485
<p>In <b>Prototype</b> I can show a "loading..." image with this code:</p> <pre><code>var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); function showLoad () { ... } </code></pre> <p>In <b>jQuery</b>, I can load a server page into an element with this:</p> <pre><code>$('#message').load('index.php?pg=ajaxFlashcard'); </code></pre> <p>but how do I attach a loading spinner to this command as I did in Prototype?</p>
[ { "answer_id": 68503, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 11, "selected": true, "text": "$('#loadingDiv')\n .hide() // Hide it initially\n .ajaxStart(function() {\n $(this).show();\n })\n .ajaxSto...
2008/09/16
[ "https://Stackoverflow.com/questions/68485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
68,509
<p>If I use the following code I lose the ability to right click on variables in the code behind and refactor (rename in this case) them</p> <pre><code>&lt;a href='&lt;%# "/Admin/Content/EditResource.aspx?ResourceId=" + Eval("Id").ToString() %&gt;'&gt;Edit&lt;/a&gt; </code></pre> <p>I see this practice everywhere but it seems weird to me as I no longer am able to get compile time errors if I change the property name. My preferred approach is to do something like this</p> <pre><code>&lt;a runat="server" id="MyLink"&gt;Edit&lt;/a&gt; </code></pre> <p>and then in the code behind</p> <pre><code>MyLink.Href= "/Admin/Content/EditResource.aspx?ResourceId=" + myObject.Id; </code></pre> <p>I'm really interested to hear if people think the above approach is better since that's what I always see on popular coding sites and blogs (e.g. Scott Guthrie) and it's smaller code, but I tend to use ASP.NET because it is compiled and prefer to know if something is broken at compile time, not run time.</p>
[ { "answer_id": 70100, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<a href='<%# DataBinder.Eval(Container.DataItem,\"Id\",\"\"/Admin/Content/EditResource.aspx?ResourceId={0}\") %'>\n" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6084/" ]
68,537
<p>A basic problem I run into quite often, but ever found a clean solution to, is one where you want to code behaviour for interaction between different objects of a common base class or interface. To make it a bit concrete, I'll throw in an example;</p> <p><em>Bob has been coding on a strategy game which supports "cool geographical effects". These round up to simple constraints such as if troops are walking in water, they are slowed 25%. If they are walking on grass, they are slowed 5%, and if they are walking on pavement they are slowed by 0%.</em></p> <p><em>Now, management told Bob that they needed new sorts of troops. There would be jeeps, boats and also hovercrafts. Also, they wanted jeeps to take damage if they went drove into water, and hovercrafts would ignore all three of the terrain types. Rumor has it also that they might add another terrain type with even more features than slowing units down and taking damage.</em></p> <p>A very rough pseudo code example follows:</p> <pre><code>public interface ITerrain { void AffectUnit(IUnit unit); } public class Water : ITerrain { public void AffectUnit(IUnit unit) { if (unit is HoverCraft) { // Don't affect it anyhow } if (unit is FootSoldier) { unit.SpeedMultiplier = 0.75f; } if (unit is Jeep) { unit.SpeedMultiplier = 0.70f; unit.Health -= 5.0f; } if (unit is Boat) { // Don't affect it anyhow } /* * List grows larger each day... */ } } public class Grass : ITerrain { public void AffectUnit(IUnit unit) { if (unit is HoverCraft) { // Don't affect it anyhow } if (unit is FootSoldier) { unit.SpeedMultiplier = 0.95f; } if (unit is Jeep) { unit.SpeedMultiplier = 0.85f; } if (unit is Boat) { unit.SpeedMultiplier = 0.0f; unit.Health = 0.0f; Boat boat = unit as Boat; boat.DamagePropeller(); // Perhaps throw in an explosion aswell? } /* * List grows larger each day... */ } } </code></pre> <p>As you can see, things would have been better if Bob had a solid design document from the beginning. As the number of units and terrain types grow, so does code complexity. Not only does Bob have to worry about figuring out which members might need to be added to the unit interface, but he also has to repeat alot of code. It's very likely that new terrain types require additional information from what can be obtained from the basic IUnit interface. </p> <p>Each time we add another unit into the game, each terrain must be updated to handle the new unit. Clearly, this makes for a lot of repetition, not to mention the ugly runtime check which determines the type of unit being dealt with. I've opted out calls to the specific subtypes in this example, but those kinds of calls are neccessary to make. <em>An example would be that when a boat hits land, its propeller should be damaged. Not all units have propellers.</em></p> <p>I am unsure what this kind of problem is called, but it is a many-to-many dependence which I have a hard time decoupling. I don't fancy having 100's of overloads for each IUnit subclass on ITerrain as I would want to come clean with coupling.</p> <p>Any light on this problem is highly sought after. Perhaps I'm thinking way out of orbit all together?</p>
[ { "answer_id": 68560, "author": "Jiaaro", "author_id": 2908, "author_profile": "https://Stackoverflow.com/users/2908", "pm_score": 0, "selected": false, "text": " boat = new\niUnit(\"watercraft\") field = new\niTerrain(\"grass\")\nfield.effects(boat)" }, { "answer_id": 68888, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2166173/" ]
68,541
<p>When trying to use <code>libxml2</code> as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.</p> <p>I have installed <code>python25</code> and all <code>libxml2</code> and <code>libxml2-py25</code> related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo?</p>
[ { "answer_id": 69513, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 2, "selected": false, "text": "'echo $PATH'\n" }, { "answer_id": 77114, "author": "Community", "author_id": -1, "author_profile": "htt...
2008/09/16
[ "https://Stackoverflow.com/questions/68541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,543
<p>So, I am kinda new to ASP.net development still, and I already don't like the stock ASP.net controls for displaying my database query results in table format. (I.e. I would much rather handle the HTML myself and so would the designer!)</p> <p>So my question is: What is the best and most secure practice for doing this without using ASP.net controls? So far my only idea involves populating my query result during the Page_Load event and then exposing a DataTable through a getter to the *.aspx page. From there I think I could just iterate with a foreach loop and craft my table as I see fit.</p>
[ { "answer_id": 68556, "author": "David J. Sokol", "author_id": 1390, "author_profile": "https://Stackoverflow.com/users/1390", "pm_score": 3, "selected": true, "text": "<Repeater>" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/506/" ]
68,561
<p>1, Create and build a default Windows Forms project and look at the project properties. It says that the project is targetting .NET Framework 2.0. </p> <p>2, Create a Setup project that installs just the single executable from the Windows Forms project. </p> <p>3, Run that installer and it always says that it needs to install .NET 3.5 SP1 on the machine. But it obviously only really needs 2.0 and so I do not want customers to be forced to install .NET 3.5 when they do not need it. They might already have 2.0 installed and so forcing the upgrade is not desirable!</p> <p>I have looked at the prerequisites of the setup project and checked the .NET Framework 2.0 entry and all the rest are unchecked. So I cannot find any reason for this strange runtime requirement. Anybody know how to resolve this one?</p>
[ { "answer_id": 71018, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 1, "selected": false, "text": "\"Deployable\"\n{\n \"CustomAction\"\n {\n }\n \"DefaultFeature\"\n {\n \"Name\" = \"8:DefaultFeature\"...
2008/09/16
[ "https://Stackoverflow.com/questions/68561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6276/" ]
68,565
<p>I like the XMLReader class for it's simplicity and speed. But I like the xml_parse associated functions as it better allows for error recovery. It would be nice if the XMLReader class would throw exceptions for things like invalid entity refs instead of just issuinng a warning.</p>
[ { "answer_id": 68615, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 3, "selected": true, "text": "<p>\n Here is <strong>a very simple</strong> XML document.\n</p>\n" }, { "answer_id": 77607, "author": "Community...
2008/09/16
[ "https://Stackoverflow.com/questions/68565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,569
<p>I am a C++/C# developer and never spent time working on web pages. I would like to put text (randomly and diagonally perhaps) in large letters across the background of some pages. I want to be able to read the foreground text and also be able to read the "watermark". I understand that is probably more of a function of color selection. </p> <p>I have been unsuccessful in my attempts to do what I want. I would imagine this to be very simple for someone with the web design tools or html knowledge. </p>
[ { "answer_id": 68591, "author": "dawnerd", "author_id": 69503, "author_profile": "https://Stackoverflow.com/users/69503", "pm_score": 2, "selected": false, "text": "<style type=\"text/css\">\n.watermark{background:url(urltoimage.png);}\n</style>\n<div class=\"watermark\">\n<p>this is som...
2008/09/16
[ "https://Stackoverflow.com/questions/68569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10755/" ]
68,572
<p>I have a question that I may be over thinking at this point but here goes...</p> <p>I have 2 classes Users and Groups. Users and groups have a many to many relationship and I was thinking that the join table group_users I wanted to have an IsAuthorized property (because some groups are private -- users will need authorization). </p> <p><strong>Would you recommend creating a class for the join table as well as the User and Groups table?</strong> Currently my classes look like this.</p> <pre><code>public class Groups { public Groups() { members = new List&lt;Person&gt;(); } ... public virtual IList&lt;Person&gt; members { get; set; } } public class User { public User() { groups = new Groups() } ... public virtual IList&lt;Groups&gt; groups{ get; set; } } </code></pre> <p>My mapping is like the following in both classes (I'm only showing the one in the users mapping but they are very similar):</p> <pre><code>HasManyToMany&lt;Groups&gt;(x =&gt; x.Groups) .WithTableName("GroupMembers") .WithParentKeyColumn("UserID") .WithChildKeyColumn("GroupID") .Cascade.SaveUpdate(); </code></pre> <p><strong>Should I write a class for the join table that looks like this?</strong></p> <pre><code>public class GroupMembers { public virtual string GroupID { get; set; } public virtual string PersonID { get; set; } public virtual bool WaitingForAccept { get; set; } } </code></pre> <p>I would really like to be able to adjust the group membership status and I guess I'm trying to think of the best way to go about this. </p>
[ { "answer_id": 68591, "author": "dawnerd", "author_id": 69503, "author_profile": "https://Stackoverflow.com/users/69503", "pm_score": 2, "selected": false, "text": "<style type=\"text/css\">\n.watermark{background:url(urltoimage.png);}\n</style>\n<div class=\"watermark\">\n<p>this is som...
2008/09/16
[ "https://Stackoverflow.com/questions/68572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1385358/" ]
68,578
<p>Is there a way to fall through multiple case statements without stating <code>case value:</code> repeatedly?</p> <p>I know this works:</p> <pre><code>switch (value) { case 1: case 2: case 3: // Do some stuff break; case 4: case 5: case 6: // Do some different stuff break; default: // Default stuff break; } </code></pre> <p>but I'd like to do something like this:</p> <pre><code>switch (value) { case 1,2,3: // Do something break; case 4,5,6: // Do something break; default: // Do the Default break; } </code></pre> <p>Is this syntax I'm thinking of from a different language, or am I missing something?</p>
[ { "answer_id": 68620, "author": "Neal", "author_id": 7071, "author_profile": "https://Stackoverflow.com/users/7071", "pm_score": 6, "selected": false, "text": "Dim number As Integer = 8\nSelect Case number\n Case 1 To 5\n Debug.WriteLine(\"Between 1 and 5, inclusive\")\n ...
2008/09/16
[ "https://Stackoverflow.com/questions/68578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7870/" ]
68,583
<p>I have the following code snippet.</p> <pre><code>$items['A'] = "Test"; $items['B'] = "Test"; $items['C'] = "Test"; $items['D'] = "Test"; $index = 0; foreach($items as $key =&gt; $value) { echo "$index is a $key containing $value\n"; $index++; } </code></pre> <p>Expected output:</p> <pre><code>0 is a A containing Test 1 is a B containing Test 2 is a C containing Test 3 is a D containing Test </code></pre> <p>Is there a way to leave out the <code>$index</code> variable?</p>
[ { "answer_id": 68647, "author": "dawnerd", "author_id": 69503, "author_profile": "https://Stackoverflow.com/users/69503", "pm_score": 2, "selected": false, "text": "$items[A] = \"Test\";\n$items[B] = \"Test\";\n$items[C] = \"Test\";\n$items[D] = \"Test\";\n\nfor($i=0;$i<count($items);$i+...
2008/09/16
[ "https://Stackoverflow.com/questions/68583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264/" ]
68,598
<p>I've seen this done in Borland's <a href="https://en.wikipedia.org/wiki/Turbo_C++" rel="noreferrer">Turbo C++</a> environment, but I'm not sure how to go about it for a C# application I'm working on. Are there best practices or gotchas to look out for?</p>
[ { "answer_id": 68722, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 6, "selected": false, "text": "DragEnter" }, { "answer_id": 89470, "author": "Hans Passant", "author_id": 17034, "author_pro...
2008/09/16
[ "https://Stackoverflow.com/questions/68598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,610
<p>I am having problems getting text within a table to appear centered in IE. </p> <p>In Firefox 2, 3 and Safari everything work fine, but for some reason, the text doesn't appear centered in IE 6 or 7. </p> <p>I'm using:</p> <pre class="lang-css prettyprint-override"><code>h2 { font: 300 12px "Helvetica", serif; text-align: center; text-transform: uppercase; } </code></pre> <p>I've also tried adding <code>margin-left:auto;</code>, <code>margin-right:auto</code> and <code>position:relative;</code> </p> <p>to no avail. </p>
[ { "answer_id": 68637, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "text-align: center" }, { "answer_id": 68643, "author": "1077", "author_id": 10776, "author_profile": "https...
2008/09/16
[ "https://Stackoverflow.com/questions/68610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10761/" ]
68,614
<p>I have a large application that uses EJB 2.x entity beans (BMP). This is well-known to be a horrible persistence strategy (I can elaborate if necessary).</p> <p>I'd like to start migrating this application to use a much more expressive, transparent, and non-invasive persistence strategy, and given my company's previous experience with it, Hibernate 3.x is the obvious choice.</p> <p>Migrating to Hibernate is going to take a while, as over 100 tables in the application use entity beans. So I'm looking at a phased approach where the two persistence strategies run in parallel, ideally on the same tables at the same time, if possible.</p> <p>My question is, what are the pitfalls (if any) of combining these two persistence strategies? Will they get in each other's way?</p>
[ { "answer_id": 68637, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "text-align: center" }, { "answer_id": 68643, "author": "1077", "author_id": 10776, "author_profile": "https...
2008/09/16
[ "https://Stackoverflow.com/questions/68614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10433/" ]
68,617
<p>This is re-posted from something I posted on the DDD Yahoo! group.</p> <p>All things being equal, do you write phone.dial(phoneNumber) or phoneNumber.dialOn(phone)? Keep in mind possible future requirements (account numbers in addition to phone numbers, calculators in addition to phones).</p> <p>The choice tends to illustrate how the idioms of Information Expert, Single Responsibility Principle, and Tell Don't Ask are at odds with each other.</p> <p>phoneNumber.dialOn(phone) favors Information Expert and Tell Don't Ask, while phone.dial(phoneNumber) favors Single Responsibility Principle.</p> <p>If you are familiar with Ken Pugh's work in Prefactoring, this is the <a href="http://moffdub.wordpress.com/2008/09/10/the-spreadsheet-conundrum/" rel="noreferrer">Spreadsheet Conundrum</a>; do you add rows or columns?</p>
[ { "answer_id": 68625, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 4, "selected": false, "text": "phone.dial()" }, { "answer_id": 69023, "author": "Steven A. Lowe", "author_id": 9345, "author_profile...
2008/09/16
[ "https://Stackoverflow.com/questions/68617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10759/" ]
68,624
<p>I would like to parse a string such as <code>p1=6&amp;p2=7&amp;p3=8</code> into a <code>NameValueCollection</code>.</p> <p>What is the most elegant way of doing this when you don't have access to the <code>Page.Request</code> object?</p>
[ { "answer_id": 68648, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 10, "selected": true, "text": "// C#\nNameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);\n" }, { "answer_id": 68733, "...
2008/09/16
[ "https://Stackoverflow.com/questions/68624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4998/" ]
68,630
<p>Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? </p>
[ { "answer_id": 68712, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 8, "selected": false, "text": "$ python -m timeit \"x=(1,2,3,4,5,6,7,8)\"\n10000000 loops, best of 3: 0.0388 usec per loop\n\n$ python -m timeit \"x=[1,2,3,4,5,...
2008/09/16
[ "https://Stackoverflow.com/questions/68630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
68,633
<p>I need a Regex that will match a java method declaration. I have come up with one that will match a method declaration, but it requires the opening bracket of the method to be on the same line as the declaration. If you have any suggestions to improve my regex or simply have a better one then please submit an answer.</p> <p>Here is my regex: <code>"\w+ +\w+ *\(.*\) *\{"</code></p> <p>For those who do not know what a java method looks like I'll provide a basic one:</p> <pre><code>int foo() { } </code></pre> <p>There are several optional parts to java methods that may be added as well but those are the only parts that a method is guaranteed to have.</p> <p>Update: My current Regex is <code>"\w+ +\w+ *\([^\)]*\) *\{"</code> so as to prevent the situation that Mike and adkom described.</p>
[ { "answer_id": 68669, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 3, "selected": true, "text": "(?:(?:public)|(?:private)|(?:static)|(?:protected)\\s+)*\n" }, { "answer_id": 68697, "author": "akdom", "auth...
2008/09/16
[ "https://Stackoverflow.com/questions/68633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/340/" ]
68,640
<p>Is it possible in C# to have a Struct with a member variable which is a Class type? If so, where does the information get stored, on the Stack, the Heap, or both?</p>
[ { "answer_id": 68681, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 6, "selected": true, "text": "using System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n ...
2008/09/16
[ "https://Stackoverflow.com/questions/68640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10722/" ]
68,645
<p>How do I create class (i.e. <a href="https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods" rel="nofollow noreferrer">static</a>) variables or methods in Python?</p>
[ { "answer_id": 68672, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 12, "selected": true, "text": ">>> class MyClass:\n... i = 3\n...\n>>> MyClass.i\n3 \n" }, { "answer_id": 68747, "author": "emb", "...
2008/09/16
[ "https://Stackoverflow.com/questions/68645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2246/" ]
68,651
<p>If I pass PHP variables with <code>.</code> in their names via $_GET PHP auto-replaces them with <code>_</code> characters. For example:</p> <pre><code>&lt;?php echo "url is ".$_SERVER['REQUEST_URI']."&lt;p&gt;"; echo "x.y is ".$_GET['x.y'].".&lt;p&gt;"; echo "x_y is ".$_GET['x_y'].".&lt;p&gt;"; </code></pre> <p>... outputs the following:</p> <pre><code>url is /SpShipTool/php/testGetUrl.php?x.y=a.b x.y is . x_y is a.b. </code></pre> <p>... my question is this: is there <strong>any</strong> way I can get this to stop? Cannot for the life of me figure out what I've done to deserve this</p> <p>PHP version I'm running with is 5.2.4-2ubuntu5.3.</p>
[ { "answer_id": 68742, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 7, "selected": true, "text": "<?php\n$varname.ext; /* invalid variable name */\n?>\n" }, { "answer_id": 1939911, "author": "crb", "author...
2008/09/16
[ "https://Stackoverflow.com/questions/68651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,664
<p>Suppose I have:</p> <ol> <li>Toby</li> <li>Tiny</li> <li>Tory</li> <li>Tily</li> </ol> <p>Is there an algorithm that can easily create a list of common characters in the same positions in all these strings? (in this case the common characters are 'T' at position 0 and 'y' at position 3)</p> <p>I tried looking at some of the algorithms used for DNA sequence matching but it seems most of them are just used for finding common substrings regardless of their positions.</p>
[ { "answer_id": 68752, "author": "Josh Smeaton", "author_id": 10583, "author_profile": "https://Stackoverflow.com/users/10583", "pm_score": 1, "selected": false, "text": "str[] = { \"Toby\", \"Tiny\", \"Tory\", \"Tily\" };\nresult = null;\nlargestString = str.getLargestString(); // Made u...
2008/09/16
[ "https://Stackoverflow.com/questions/68664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
68,666
<p>Why does the following code sometimes causes an Exception with the contents "CLIPBRD_E_CANT_OPEN":</p> <pre><code>Clipboard.SetText(str); </code></pre> <p>This usually occurs the first time the Clipboard is used in the application and not after that.</p>
[ { "answer_id": 69081, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 6, "selected": false, "text": "for (int i = 0; i < 10; i++)\n{\n try\n {\n Clipboard.SetText(str);\n return;\n }\n catch {...
2008/09/16
[ "https://Stackoverflow.com/questions/68666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10784/" ]
68,677
<p>I'm using SQL Server 2000 to print out some values from a table using <code>PRINT</code>. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:</p> <pre><code>DECLARE @binvalue binary(4) SET @binvalue = 0x12345678 PRINT CAST(@binvalue AS nvarchar) </code></pre> <p>Expected:</p> <blockquote> <p>0x12345678</p> </blockquote> <p>Instead, it prints two gibberish characters.</p> <p>How can I print the value of binary data? Is there a built-in or do I need to roll my own?</p> <p>Update: This isn't the only value on the line, so I can't just PRINT @binvalue. It's something more like PRINT N'other stuff' + ???? + N'more stuff'. Not sure if that makes a difference: I didn't try just PRINT @binvalue by itself.</p>
[ { "answer_id": 68858, "author": "Ricardo C", "author_id": 232589, "author_profile": "https://Stackoverflow.com/users/232589", "pm_score": 2, "selected": false, "text": "DECLARE @binvalue binary(4)\nSET @binvalue = 0x61000000\nPRINT @binvalue \nPRINT cast('a' AS binary(4))\nPRINT cast(0x6...
2008/09/16
[ "https://Stackoverflow.com/questions/68677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3750/" ]
68,691
<p>After cleaning a folder full of HTML files with TIDY, how can the tables content be extracted for further processing?</p>
[ { "answer_id": 73418, "author": "pdc", "author_id": 8925, "author_profile": "https://Stackoverflow.com/users/8925", "pm_score": 2, "selected": true, "text": "Content-Type" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1359937/" ]
68,711
<p>any idea how if the following is possible in PHP as a single line ?:</p> <pre><code>&lt;?php $firstElement = functionThatReturnsAnArray()[0]; </code></pre> <p>... It doesn't seem to 'take'. I need to do this as a 2-stepper:</p> <pre><code>&lt;?php $allElements = functionThatReturnsAnArray(); $firstElement = $allElements[0]; </code></pre> <p>... just curious - other languages I play with allow things like this, and I'm lazy enoug to miss this in PHP ... any insight appreciated ...</p>
[ { "answer_id": 68745, "author": "calebbrown", "author_id": 7007, "author_profile": "https://Stackoverflow.com/users/7007", "pm_score": 4, "selected": true, "text": "<?php\n$firstElement = reset(functionThatReturnsAnArray());\n" }, { "answer_id": 68828, "author": "Scott Reynen...
2008/09/16
[ "https://Stackoverflow.com/questions/68711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,749
<p>Using .Net (C#), how can you work with USB devices? </p> <p>How can you detect USB events (connections/disconnections) and how do you communicate with devices (read/write).</p> <p>Is there a native .Net solution to do this?</p>
[ { "answer_id": 13829628, "author": "Syn", "author_id": 1895588, "author_profile": "https://Stackoverflow.com/users/1895588", "pm_score": 4, "selected": false, "text": "class USBControl : IDisposable\n {\n // used for monitoring plugging and unplugging of USB devices.\n p...
2008/09/16
[ "https://Stackoverflow.com/questions/68749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5903/" ]
68,750
<p>This should hopefully be a simple one.</p> <p>I would like to add an extension method to the System.Web.Mvc.ViewPage&lt; T > class.</p> <p>How should this extension method look?</p> <p>My first intuitive thought is something like this:</p> <pre><code>namespace System.Web.Mvc { public static class ViewPageExtensions { public static string GetDefaultPageTitle(this ViewPage&lt;Type&gt; v) { return ""; } } } </code></pre> <p><strong>Solution</strong></p> <p>The general solution is <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68772">this answer</a>.</p> <p>The specific solution to extending the System.Web.Mvc.ViewPage class is <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68802">my answer</a> below, which started from the <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68772">general solution</a>.</p> <p>The difference is in the specific case you need both a generically typed method declaration AND a statement to enforce the generic type as a reference type.</p>
[ { "answer_id": 68772, "author": "David Thibault", "author_id": 5903, "author_profile": "https://Stackoverflow.com/users/5903", "pm_score": 5, "selected": true, "text": "namespace System.Web.Mvc\n{\n public static class ViewPageExtensions\n {\n public static string GetDefault...
2008/09/16
[ "https://Stackoverflow.com/questions/68750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
68,774
<p>I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?</p>
[ { "answer_id": 68796, "author": "The.Anti.9", "author_id": 2128, "author_profile": "https://Stackoverflow.com/users/2128", "pm_score": 7, "selected": true, "text": "import socket\nsock = socket.socket()\nsock.connect((address, port))\n" }, { "answer_id": 68911, "author": "Ada...
2008/09/16
[ "https://Stackoverflow.com/questions/68774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324/" ]
68,821
<p>I want to dynamically hide/show some of the columns in a NSTableView, based on the data that is going to be displayed - basically, if a column is empty I'd like the column to be hidden. I'm currently populating the table with a controller class as the delegate for the table.</p> <p>Any ideas? I see that I can set the column hidden in Interface Builder, however there doesn't seem to be a good time to go through the columns and check if they are empty or not, since there doesn't seem to be a method that is called before/after all of the data in the table is populated.</p>
[ { "answer_id": 71609, "author": "amrox", "author_id": 4468, "author_profile": "https://Stackoverflow.com/users/4468", "pm_score": 2, "selected": false, "text": "NSTableColumn *aColumn = [[NSTableColumn alloc] initWithIdentifier:attr];\n[aColumn setWidth:DEFAULTCOLWIDTH];\n[aColumn setMin...
2008/09/16
[ "https://Stackoverflow.com/questions/68821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3857/" ]
68,843
<p>How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place?</p> <p>Moreover, if I specify <code>sleep(1,1,"xyz")</code> or any arbitrary number of arguments, the compiler still compiles it. But the strange thing is that gcc is able to find the definition of this function at link time, I don't understand how is this possible, because actual <code>sleep()</code> function takes a single argument only, but our program mentioned three arguments.</p> <pre><code>/********************************/ int main() { short int i; for(i = 0; i&lt;5; i++) { printf("%d",i);`print("code sample");` sleep(1); } return 0; } </code></pre>
[ { "answer_id": 68861, "author": "Jason Dagit", "author_id": 5113, "author_profile": "https://Stackoverflow.com/users/5113", "pm_score": 2, "selected": false, "text": "int sleep(int);\n" }, { "answer_id": 68874, "author": "Ben Collins", "author_id": 3279, "author_profi...
2008/09/16
[ "https://Stackoverflow.com/questions/68843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
68,851
<p>I am trying out FirePHP.</p> <p>I installed it and restarted Firefox, enabled Firebug for my localhost, moved the demo <code>oo.php</code> file that comes with the download into an IIS virtual directory, changed the include path, removed the <code>apache_request_headers()</code> call since I am running IIS, and the only output I see is</p> <blockquote> <p>Notice: Undefined offset: 1 in C:\Documents and Settings\georgem\My Documents\projects\auctronic\FirePHPCore\FirePHP.class.php on line 167 <br/> Hello World</p> </blockquote> <p>Nothing appears in the Firebug console. </p> <p>Am I missing something?</p> <p><strong>EDIT:</strong> Noticed it said that output buffering has to be enabled so I added a call to <a href="http://php.net/manual/en/function.ob-start.php" rel="nofollow noreferrer"><code>ob_start()</code></a> at the top of the file...same results.</p>
[ { "answer_id": 78174, "author": "djn", "author_id": 9673, "author_profile": "https://Stackoverflow.com/users/9673", "pm_score": 1, "selected": false, "text": "fb.php" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/68851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
68,907
<p>How can you measure the amount of time a function will take to execute? </p> <p>This is a relatively short function and the execution time would probably be in the millisecond range.</p> <p>This particular question relates to an embedded system, programmed in C or C++.</p>
[ { "answer_id": 68919, "author": "Galen", "author_id": 7894, "author_profile": "https://Stackoverflow.com/users/7894", "pm_score": 2, "selected": false, "text": "start_time = timer\nfunction()\nexec_time = timer - start_time\n" }, { "answer_id": 68925, "author": "Mike Stone", ...
2008/09/16
[ "https://Stackoverflow.com/questions/68907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
68,964
<p>So for e.g. 0110 has bits 1 and 2 set, 1000 has bit 3 set 1111 has bits 0,1,2,3 set</p>
[ { "answer_id": 69007, "author": "Mladen Janković", "author_id": 6300, "author_profile": "https://Stackoverflow.com/users/6300", "pm_score": 2, "selected": false, "text": "for( int i = 0; variable ; ++i, variable >>= 1 ) {\n if( variable & 1 )\n // store bit index - i\n}\n" }, { ...
2008/09/16
[ "https://Stackoverflow.com/questions/68964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8884/" ]
68,993
<p>Say I have a line in an emacs buffer that looks like this:</p> <pre><code>foo -option1 value1 -option2 value2 -option3 value3 \ -option4 value4 ... </code></pre> <p>I want it to look like this:</p> <pre><code>foo -option1 value1 \ -option2 value2 \ -option3 value3 \ -option4 value4 \ ... </code></pre> <p>I want each option/value pair on a separate line. I also want those subsequent lines indented appropriately according to mode rather than to add a fixed amount of whitespace. I would prefer that the code work on the current block, stopping at the first non-blank line or line that does not contain an option/value pair though I could settle for it working on a selected region. </p> <p>Anybody know of an elisp function to do this? </p>
[ { "answer_id": 76888, "author": "Bryan Oakley", "author_id": 7432, "author_profile": "https://Stackoverflow.com/users/7432", "pm_score": 3, "selected": true, "text": "(defun tcl-multiline-options ()\n \"spread option/value pairs across multiple lines with continuation characters\"\n (i...
2008/09/16
[ "https://Stackoverflow.com/questions/68993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7432/" ]
68,999
<p>I'm using a Java socket, connected to a server. If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is there an easier way?</p> <p>I'm looking for a short answer, I don't want to use other protocols etc. Obviously do I neither want to have a solution that ties my application to a specific OS. Please people, IN-CODE solutions only. </p>
[ { "answer_id": 69105, "author": "hoyhoy", "author_id": 3499, "author_profile": "https://Stackoverflow.com/users/3499", "pm_score": 4, "selected": false, "text": "time curl -I 'http://server:3000'\n" }, { "answer_id": 69195, "author": "Dave Cheney", "author_id": 6449, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10889/" ]
69,000
<p>I have a WPF application in VS 2008 with some web service references. For varying reasons (max message size, authentication methods) I need to manually define a number of settings in the WPF client's app.config for the service bindings.</p> <p>Unfortunately, this means that when I update the service references in the project we end up with a mess - multiple bindings and endpoints. Visual Studio creates new bindings and endpoints with a numeric suffix (ie "Service1" as a duplicate of "Service"), resulting in an invalid configuration as there may only be a single binding per service reference in a project.</p> <p>This is easy to duplicate - just create a simple "Hello World" ASP.Net web service and WPF application in a solution, change the maxBufferSize and maxReceivedMessageSize in the app.config binding and then update the service reference.</p> <p>At the moment we are working around this by simply undoing checkout on the app.config after updating the references but I can't help but think there must be a better way!</p> <p>Also, the settings we need to manually change are:</p> <pre><code>&lt;security mode="TransportCredentialOnly"&gt; &lt;transport clientCredentialType="Ntlm" /&gt; &lt;/security&gt; </code></pre> <p>and:</p> <pre><code>&lt;binding maxBufferSize="655360" maxReceivedMessageSize="655360" /&gt; </code></pre> <p>We use a service factory class so if these settings are somehow able to be set programmatically that would work, although the properties don't seem to be exposed.</p>
[ { "answer_id": 69654, "author": "Wiren", "author_id": 2538222, "author_profile": "https://Stackoverflow.com/users/2538222", "pm_score": 3, "selected": true, "text": "REM generate meta data\ncall \"SVCUTIL.EXE\" /t:metadata \"MyProject.dll\" /reference:\"MyReference.dll\"\n\nREM making su...
2008/09/16
[ "https://Stackoverflow.com/questions/69000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10890/" ]
69,016
<p>I have an array of objects that when another object hits one of them, the object will be removed. I have removed it from the stage using removeChild() and removed from the array using splice(), but somehow the object is still calling some of its functions which is causing errors. How do I completely get rid of an object? There are no event listeners tied to it either.</p>
[ { "answer_id": 75679, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 2, "selected": false, "text": "stage.removeEventListener(...)" }, { "answer_id": 117162, "author": "Brian Hodge", "author_id": 20628, "auth...
2008/09/16
[ "https://Stackoverflow.com/questions/69016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
69,030
<p>I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu.</p> <p>Here is the script as it stands now:</p> <pre><code>tell application "System Events" tell (first process whose frontmost is true) set helpMenuItem to menu bar item "Help" of menu bar 1 click helpMenuItem end tell end tell </code></pre> <p>And I'm thinking of something like this:</p> <pre><code>tell application "System Events" tell (first process whose frontmost is true) set helpMenuItem to menu bar item "Help" of menu bar 1 set searchBox to menu item 1 of menu of helpMenuItem if (searchBox's focused) = true then key code 53 -- type esc else click helpMenuItem end if end tell end tell </code></pre> <p>... but I get this error:</p> <blockquote> <p>Can’t get focused of {menu item 1 of menu "Help" of menu bar item "Help" of menu bar 1 of application process "Script Editor" of application "System Events"}.</p> </blockquote> <p>So is there a way I can get my script to detect whether the search box is already focused?</p> <hr> <p>I solved my problem by <a href="https://stackoverflow.com/questions/69391/">working around it</a>. I still don't know how to check if a menu item is selected though, so I will leave this topic open.</p>
[ { "answer_id": 69404, "author": "tjw", "author_id": 11029, "author_profile": "https://Stackoverflow.com/users/11029", "pm_score": 3, "selected": true, "text": "focused" }, { "answer_id": 1545862, "author": "Steve Jones", "author_id": 187427, "author_profile": "https:/...
2008/09/16
[ "https://Stackoverflow.com/questions/69030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10906/" ]
69,063
<p>Most of our Eclipse projects have multiple source folders, for example:</p> <ul> <li>src/main/java</li> <li>src/test/java</li> </ul> <p>When you right-click on a class and choose New JUnit Test, the default source folder for the new test is "src/main/java" (presumably the first source folder listed in the project properties).</p> <p>Is there any way to change the default source folder for new JUnit tests, so that when I do the above action, the new test will be created in say the "src/test/java" folder by default?</p>
[ { "answer_id": 5400024, "author": "fastcodejava", "author_id": 184730, "author_profile": "https://Stackoverflow.com/users/184730", "pm_score": 0, "selected": false, "text": "src/test/java" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/69063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10433/" ]
69,068
<p>How can I split long commands over multiple lines in a batch file?</p>
[ { "answer_id": 69079, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 11, "selected": true, "text": "^" }, { "answer_id": 4455750, "author": "jeb", "author_id": 463115, "author_profile": "https://Stackoverflo...
2008/09/16
[ "https://Stackoverflow.com/questions/69068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
69,073
<p>When attempting to print using the SSRS Viewer Web Part in SharePoint I get the following error.</p> <blockquote> <p>An error occured during printing. (0x8007F303)</p> </blockquote> <p>The settings we are using in this box (production) are exactly the same as the settings in testing where this works perfectly fine. </p> <p>Anyone have any good ideas or faced this before?</p>
[ { "answer_id": 69731, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 1, "selected": false, "text": "[HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft SQL Server\\80\\Reporting Services]" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/69073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
69,089
<p>We have a web application that uses SQL Server 2008 as the database. Our users are able to do full-text searches on particular columns in the database. SQL Server's full-text functionality does not seem to provide support for hit highlighting. Do we need to build this ourselves or is there perhaps some library or knowledge around on how to do this? </p> <p>BTW the application is written in C# so a .Net solution would be ideal but not necessary as we could translate.</p>
[ { "answer_id": 127080, "author": "xnagyg", "author_id": 2622295, "author_profile": "https://Stackoverflow.com/users/2622295", "pm_score": 1, "selected": false, "text": " search_kiemeles=replace(lcase(search),\"\"\"\",\"\")\n do while not rs.eof 'The search result l...
2008/09/16
[ "https://Stackoverflow.com/questions/69089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1899/" ]
69,104
<p>A J2ME client is sending HTTP POST requests with chunked transfer encoding.</p> <p>When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.</p> <p>However, when I read the Request.InputStream to the end, it returns 0.</p> <p>Here's the code I'm using to read the input stream.</p> <pre><code>using (var reader = new StreamReader(httpRequestBodyStream, BodyTextEncoding)) { string readString = reader.ReadToEnd(); Console.WriteLine("CharSize:" + readString.Length); return BodyTextEncoding.GetBytes(readString); } </code></pre> <p>I can simulate the behaiviour of the client with Fiddler, e.g.</p> <p><strong>URL</strong> <a href="http://localhost:15148/page.aspx" rel="nofollow noreferrer">http://localhost:15148/page.aspx</a></p> <p><strong>Headers:</strong> User-Agent: Fiddler Transfer-Encoding: Chunked Host: somesite.com:15148</p> <p><strong>Body</strong> rabbits rabbits rabbits rabbits. thanks for coming, it's been very useful!</p> <p>My body reader from above will return a zero length byte array...lame...</p> <p>Does anyone know how to enable chunked encoding on IIS and ASP.NET Development Server (cassini)?</p> <p>I found <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;278998" rel="nofollow noreferrer">this script</a> for IIS but it isn't working.</p>
[ { "answer_id": 80576, "author": "Andrew", "author_id": 15127, "author_profile": "https://Stackoverflow.com/users/15127", "pm_score": 1, "selected": false, "text": "string responseText = null;\nWebRequest rabbits= WebRequest.Create(uri);\nusing (Stream resp = rabbits.GetResponse().GetResp...
2008/09/16
[ "https://Stackoverflow.com/questions/69104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
69,107
<p>What is the best way to refactor the attached code to accommodate multiple email addresses?</p> <p>The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email address fields.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="includes/jquery/jquery-1.2.6.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script language="javascript"&gt; $(document).ready(function() { var validateUsername = $('#Email_Address_Status_Icon_1'); $('#Email_Address_1').keyup(function() { var t = this; if (this.value != this.lastValue) { if (this.timer) clearTimeout(this.timer); validateUsername.removeClass('error').html('Validating Email'); this.timer = setTimeout(function() { if (IsEmail(t.value)) { validateUsername.html('Valid Email'); } else { validateUsername.html('Not a valid Email'); }; }, 200); this.lastValue = this.value; } }); }); function IsEmail(email) { var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (regex.test(email)) return true; else return false; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;label for="Email_Address_1"&gt;Friend #1&lt;/label&gt;&lt;/div&gt; &lt;input type="text" ID="Email_Address_1"&gt; &lt;span id="Email_Address_Status_Icon_1"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="Email_Address_2"&gt;Friend #2&lt;/label&gt;&lt;/div&gt; &lt;input type="text" id="Email_Address_2"&gt; &lt;span id="Email_Address_Status_Icon_2"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="Email_Address_3"&gt;Friend #3&lt;/label&gt;&lt;/div&gt; &lt;input type="text" id="Email_Address_3"&gt; &lt;span id="Email_Address_Status_Icon_3"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 69148, "author": "Pandincus", "author_id": 2273, "author_profile": "https://Stackoverflow.com/users/2273", "pm_score": 3, "selected": true, "text": "<div>\n <label for=\"Email_Address_1\">Friend #1</label></div>\n <input type=\"text\" class=\"email\">\n <span></sp...
2008/09/16
[ "https://Stackoverflow.com/questions/69107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
69,115
<p>Below is my current char* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is there any trick or other way that I am missing?</p> <p>How can I make this faster?</p> <p>Compiled with -O3 in g++</p> <pre><code>static const char _hex2asciiU_value[256][2] = { {'0','0'}, {'0','1'}, /* snip..., */ {'F','E'},{'F','F'} }; std::string char_to_hex( const unsigned char* _pArray, unsigned int _len ) { std::string str; str.resize(_len*2); char* pszHex = &amp;str[0]; const unsigned char* pEnd = _pArray + _len; clock_t stick, etick; stick = clock(); for( const unsigned char* pChar = _pArray; pChar != pEnd; pChar++, pszHex += 2 ) { pszHex[0] = _hex2asciiU_value[*pChar][0]; pszHex[1] = _hex2asciiU_value[*pChar][1]; } etick = clock(); std::cout &lt;&lt; "ticks to hexify " &lt;&lt; etick - stick &lt;&lt; std::endl; return str; } </code></pre> <p><strong>Updates</strong></p> <p>Added timing code</p> <p><a href="https://stackoverflow.com/questions/69115/char-to-hex-string-exercise#69126">Brian R. Bondy</a>: replace the std::string with a heap alloc'd buffer and change ofs*16 to ofs &lt;&lt; 4 - however the heap allocated buffer seems to slow it down? - result ~11ms</p> <p><a href="https://stackoverflow.com/questions/69115/#69305">Antti Sykäri</a>:replace inner loop with </p> <pre><code> int upper = *pChar &gt;&gt; 4; int lower = *pChar &amp; 0x0f; pszHex[0] = pHex[upper]; pszHex[1] = pHex[lower]; </code></pre> <p>result ~8ms</p> <p><a href="https://stackoverflow.com/questions/69115?sort=votes#69218">Robert</a>: replace <code>_hex2asciiU_value</code> with a full 256-entry table, sacrificing memory space but result ~7ms!</p> <p><a href="https://stackoverflow.com/questions/69115/char-to-hex-string-exercise#70254">HoyHoy</a>: Noted it was producing incorrect results</p>
[ { "answer_id": 69126, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 2, "selected": false, "text": "16" }, { "answer_id": 69197, "author": "C. K. Young", "author_id": 13, "author_profile": "https://...
2008/09/16
[ "https://Stackoverflow.com/questions/69115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/716/" ]
69,159
<p>I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out: </p> <pre><code>"Too Many Connections" </code></pre> <p>I can't log in anywhere to close the connections manually. </p> <p><strong>Is that any way to close open connections using a script or other type of command?.</strong> </p> <p>Should I just wait?</p>
[ { "answer_id": 69179, "author": "hoyhoy", "author_id": 3499, "author_profile": "https://Stackoverflow.com/users/3499", "pm_score": 0, "selected": false, "text": "max_connections=500\n" }, { "answer_id": 69244, "author": "Larry OBrien", "author_id": 10116, "author_prof...
2008/09/16
[ "https://Stackoverflow.com/questions/69159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9803/" ]
69,188
<p><a href="http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx" rel="nofollow noreferrer">http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx</a></p> <p>This post shows how to test setting a cookie and then seeing it in ViewData. What I what to do is see if the correct cookies were written (values and name). Any reply, blog post or article will be greatly appreciated.</p>
[ { "answer_id": 69535, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": -1, "selected": false, "text": "function ReadCookie(cookieName) {\n var theCookie=\"\"+document.cookie;\n var ind=theCookie.indexOf(cookieName);\n if...
2008/09/16
[ "https://Stackoverflow.com/questions/69188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/438/" ]
69,192
<p>Suppose we have two stacks and no other temporary variable.</p> <p>Is to possible to "construct" a queue data structure using only the two stacks?</p>
[ { "answer_id": 69436, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 10, "selected": false, "text": "inbox" }, { "answer_id": 77010, "author": "pythonquick", "author_id": 6225, "author_profile": "https://S...
2008/09/16
[ "https://Stackoverflow.com/questions/69192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7086/" ]
69,209
<p>Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node?After deletion the previous node should point to the node next to deleted node. </p>
[ { "answer_id": 69235, "author": "Eltariel", "author_id": 584, "author_profile": "https://Stackoverflow.com/users/584", "pm_score": 0, "selected": false, "text": "next" }, { "answer_id": 69306, "author": "Ben Combee", "author_id": 1323, "author_profile": "https://Stack...
2008/09/16
[ "https://Stackoverflow.com/questions/69209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7086/" ]
69,250
<p>In most C or C++ environments, there is a "debug" mode and a "release" mode compilation.<br> Looking at the difference between the two, you find that the debug mode adds the debug symbols (often the -g option on lots of compilers) but it also disables most optimizations.<br> In "release" mode, you usually have all sorts of optimizations turned on.<br> Why the difference?</p>
[ { "answer_id": 69252, "author": "Benoit", "author_id": 10703, "author_profile": "https://Stackoverflow.com/users/10703", "pm_score": 6, "selected": true, "text": "\nvoid foo() {\n1: int i;\n2: for(i = 0; i < 2; )\n3: i++;\n4: return;\n" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/69250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
69,262
<p>I am wondering if there is a method or format string I'm missing in .NET to convert the following:</p> <pre><code> 1 to 1st 2 to 2nd 3 to 3rd 4 to 4th 11 to 11th 101 to 101st 111 to 111th </code></pre> <p><a href="http://www.dotnet-friends.com/fastcode/csharp/fastcodeincsc3bd4149-03d0-40fe-90fd-63bcee77b43e.aspx" rel="noreferrer">This link</a> has a bad example of the basic principle involved in writing your own function, but I am more curious if there is an inbuilt capacity I'm missing.</p> <p><strong>Solution</strong></p> <p>Scott Hanselman's answer is the accepted one because it answers the question directly.</p> <p>For a solution however, see <a href="https://stackoverflow.com/questions/69262/is-there-an-easy-way-in-net-to-get-st-nd-rd-and-th-endings-for-numbers#69284">this great answer</a>.</p>
[ { "answer_id": 69284, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": false, "text": "function ordinal($num) {\n $ones = $num % 10;\n $tens = floor($num / 10) % 10;\n if ($tens == 1) {\n $suff = \"...
2008/09/16
[ "https://Stackoverflow.com/questions/69262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
69,275
<p>I'm trying to draw a graph on an ASP webpage. I'm hoping an API can be helpful, but so far I have not been able to find one. </p> <p>The graph contains labeled nodes and unlabeled directional edges. The ideal output would be something like <a href="http://en.wikipedia.org/wiki/Image:6n-graf.svg" rel="noreferrer">this</a>. </p> <p>Anybody know of anything pre-built than can help?</p>
[ { "answer_id": 74815, "author": "wxs", "author_id": 12981, "author_profile": "https://Stackoverflow.com/users/12981", "pm_score": 4, "selected": true, "text": "graph untitled {\n graph[bgcolor=\"transparent\"];\n node [fontname=\"Bitstream Vera Sans\", fontsize=\"22.00\", shape=cir...
2008/09/16
[ "https://Stackoverflow.com/questions/69275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/165305/" ]
69,277
<p>I have an Enumerable array</p> <pre><code>int meas[] = new double[] {3, 6, 9, 12, 15, 18}; </code></pre> <p>On each successive call to the mock's method that I'm testing I want to return a value from that array.</p> <pre><code>using(_mocks.Record()) { Expect.Call(mocked_class.GetValue()).Return(meas); } using(_mocks.Playback()) { foreach(var i in meas) Assert.AreEqual(i, mocked_class.GetValue(); } </code></pre> <p>Does anyone have an idea how I can do this?</p>
[ { "answer_id": 69382, "author": "vrdhn", "author_id": 414441, "author_profile": "https://Stackoverflow.com/users/414441", "pm_score": 0, "selected": false, "text": "get_next() {\n foreach( float x in meas ) {\n yield x;\n }\n}\n" }, { "answer_id": 69642, "author": "Darre...
2008/09/16
[ "https://Stackoverflow.com/questions/69277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
69,281
<p>I've recently started using Eclipse Ganymede CDT for C development and I couldn't like it more. I'm aware the learning curve could be sort of pronounced, therefore and with your help, my goal is to flatten it as much as possible. I'm looking for the best hacks, hints, tips, tricks, and best practices to really unleash the full power of the IDE.</p>
[ { "answer_id": 69335, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 5, "selected": true, "text": ".h" } ]
2008/09/16
[ "https://Stackoverflow.com/questions/69281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
69,296
<p>I have a a property defined as:</p> <pre><code>[XmlArray("delete", IsNullable = true)] [XmlArrayItem("contact", typeof(ContactEvent)), XmlArrayItem("sms", typeof(SmsEvent))] public List&lt;Event&gt; Delete { get; set; } </code></pre> <p>If the List&lt;> Delete has no items</p> <pre><code>&lt;delete /&gt; </code></pre> <p>is emitted. If the List&lt;> Delete is set to null</p> <pre><code>&lt;delete xsi:nil="true" /&gt; </code></pre> <p>is emitted. Is there a way using attributes to get the delete element not to be emitted if the collection has no items?</p> <p><a href="https://stackoverflow.com/questions/69296/xml-serialization-and-empty-collections#69407">Greg</a> - Perfect thanks, I didn't even read the IsNullable documentation just assumed it was signalling it as not required.</p> <p><a href="https://stackoverflow.com/questions/69296/xml-serialization-and-empty-collections#69518">Rob Cooper</a> - I was trying to avoid ISerializable, but Gregs suggestion works. I did run into the problem you outlined in (1), I broke a bunch of code by just returning null if the collection was zero length. To get around this I created a EventsBuilder class (the class I am serializing is called Events) that managed all the lifetime/creation of the underlying objects of the Events class that spits our Events classes for serialization.</p>
[ { "answer_id": 811038, "author": "theahuramazda", "author_id": 99290, "author_profile": "https://Stackoverflow.com/users/99290", "pm_score": 4, "selected": false, "text": "public List<Event> Delete { get; set; }\n[XMLIgnore]\npublic bool DeleteSpecified\n{\n get\n {\n bool isRendered =...
2008/09/16
[ "https://Stackoverflow.com/questions/69296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2281/" ]
69,316
<p>What are the biggest pros and cons of <a href="http://incubator.apache.org/thrift/" rel="noreferrer">Apache Thrift</a> vs <a href="http://code.google.com/apis/protocolbuffers/" rel="noreferrer">Google's Protocol Buffers</a>?</p>
[ { "answer_id": 69374, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 7, "selected": false, "text": "Set" }, { "answer_id": 296349, "author": "eishay", "author_id": 16201, "author_profile": "https://Stackove...
2008/09/16
[ "https://Stackoverflow.com/questions/69316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
69,332
<p>I suspect that one of my applications eats more CPU cycles than I want it to. The problem is - it happens in bursts, and just looking at the task manager doesn't help me as it shows immediate usage only.</p> <p>Is there a way (on Windows) to track the history of CPU &amp; Memory usage for some process. E.g. I will start tracking "firefox", and after an hour or so will see a graph of its CPU &amp; memory usage during that hour.</p> <p>I'm looking for either a ready-made tool or a programmatic way to achieve this.</p>
[ { "answer_id": 69416, "author": "Martin08", "author_id": 8203, "author_profile": "https://Stackoverflow.com/users/8203", "pm_score": 9, "selected": true, "text": "perfmon" }, { "answer_id": 10515335, "author": "Rich Kreider", "author_id": 1384476, "author_profile": "h...
2008/09/16
[ "https://Stackoverflow.com/questions/69332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
69,352
<p>What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu item, but I can't seem to find an event to trigger to minimize the form.</p>
[ { "answer_id": 69359, "author": "JP Richardson", "author_id": 10333, "author_profile": "https://Stackoverflow.com/users/10333", "pm_score": 5, "selected": false, "text": "FormName.WindowState = FormWindowState.Minimized;\n" }, { "answer_id": 69362, "author": "Craig Eddy", ...
2008/09/16
[ "https://Stackoverflow.com/questions/69352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7516/" ]
69,391
<p>In OS X, in order to quickly get at menu items from the keyboard, I want to be able to type a key combination, have it run a script, and have the script focus the Search field in the Help menu. It should work just like the key combination for Spotlight, so if I run it again, it should dismiss the menu. I can run the script with Quicksilver, but how can I write the script?</p>
[ { "answer_id": 69393, "author": "easeout", "author_id": 10906, "author_profile": "https://Stackoverflow.com/users/10906", "pm_score": 2, "selected": true, "text": "tell application \"System Events\"\n tell (first process whose frontmost is true)\n click menu \"Help\" of menu ba...
2008/09/16
[ "https://Stackoverflow.com/questions/69391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10906/" ]
69,411
<p>What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both. </p>
[ { "answer_id": 69419, "author": "John Douthat", "author_id": 2774, "author_profile": "https://Stackoverflow.com/users/2774", "pm_score": 2, "selected": false, "text": "man scp" }, { "answer_id": 69421, "author": "Serafina Brocious", "author_id": 4977, "author_profile"...
2008/09/16
[ "https://Stackoverflow.com/questions/69411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
69,430
<p>I'm building an HTML UI with some text elements, such as tab names, which look bad when selected. Unfortunately, it's very easy for a user to double-click a tab name, which selects it by default in many browsers.</p> <p>I might be able to solve this with a JavaScript trick (I'd like to see those answers, too) -- but I'm really hoping there's something in CSS/HTML directly that works across all browsers.</p>
[ { "answer_id": 69474, "author": "Dave Rutledge", "author_id": 2486915, "author_profile": "https://Stackoverflow.com/users/2486915", "pm_score": 3, "selected": false, "text": "display:box" }, { "answer_id": 69494, "author": "dimarzionist", "author_id": 10778, "author_p...
2008/09/16
[ "https://Stackoverflow.com/questions/69430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3561/" ]