qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
303,371
<p>I've used boost serialization but this doesn't appear to allow me to generate xml that conforms to a particular schema -- it seems it's purpose was to just to persist a class's state.</p> <p>Platform: linux</p> <p>What do you guys use to generate NOT parse xml?</p> <p>So far I'm going down Foredecker's route of just generating it myself -- it's not a large document but I really shouldn't be having this much trouble finding a decent library to generate it correctly.</p> <p>As for boost, the things that I would like to be able to do is set the node names, set attributes in my nodes, and get rid of all the extra crap that comes with it as I don't really care about having to put my document back into that class.</p>
[ { "answer_id": 303724, "author": "MattyT", "author_id": 7405, "author_profile": "https://Stackoverflow.com/users/7405", "pm_score": 6, "selected": false, "text": "Document doc;\nNode* root(doc.InsertEndChild(Element(\"RootNode\")));\nElement measurements(\"measurements\");\nElement tbr(\...
2008/11/19
[ "https://Stackoverflow.com/questions/303371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39110/" ]
303,397
<p>I have designed a xml schema to parse an incoming xml document. The receive location gets xml documents from 2 feeds, one of them has misspelled a node in the document, "Roookie" instead of "Rookie", Is there a way to have my existing xsd parse this document?</p>
[ { "answer_id": 303438, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 2, "selected": false, "text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xsl:stylesheet version=\"2.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transfor...
2008/11/19
[ "https://Stackoverflow.com/questions/303397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
303,404
<p>If I have records:</p> <pre> Row Date, LocationID, Account 1 Jan 1, 2008 1 1000 2 Jan 2, 2008 1 1000 3 Jan 3, 2008 2 1001 4 Jan 3, 2008 1 1001 5 Jan 3, 2008 3 1001 6 Jan 4, 2008 3 1002 </pre> <p>I need to get the row (<code>date</code>, <code>locatinid</code>, <code>account</code>) where the row has the most recent date for each distinct <code>locationid</code>:</p> <pre> 4 Jan 3, 2008 1 1001 3 Jan 3, 2008 2 1001 6 Jan 4, 2008 3 1002 </pre>
[ { "answer_id": 303421, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 0, "selected": false, "text": "select *\nfrom mytable t1\nwhere date = (select max(date) from mytable t2\n where t2.location = t1.locat...
2008/11/19
[ "https://Stackoverflow.com/questions/303404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
303,405
<p>I have an API call in my application where I am checking the time taken for a single call. I have put this in a FOR loop and using 10000 calls to get the average times of all calls. Now the issue which came up was that the actual application using the API, is multi-threaded. If I wish to make my application also do the same, how would I go about doing this? </p> <p>The platform is REL and my aim is to send multiple calls in the same time with either the same parameters or different parameters. Can this be implemented in C++ and if so, what library functions to use and can an example be provided for the same? </p>
[ { "answer_id": 10769819, "author": "betabandido", "author_id": 1135819, "author_profile": "https://Stackoverflow.com/users/1135819", "pm_score": 0, "selected": false, "text": "std::thread" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
303,417
<p>I found that SQL stored procedures are very interesting and useful. I have written stored procedures but i want to write well crafted, good performance tuned and concise SPs for any sort of requirement and also would love to learn about any tricks or good practices for stored procedures. How do i move from the beginner to the advanced stage in writing stored procedures?</p> <p><em>Update: Found from comments that my question should be more specific. Everyone has some tricks upon their sleeves and I was expecting such tricks and practices for SPs which they use in their code which differentiates them from others and more importantly spruce up the productivity in writing and working with stored procedures.</em></p>
[ { "answer_id": 303462, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 4, "selected": false, "text": "/*\n Usage:\n EXEC usp_ThisProc @Param1 = 1, @Param2 = 2\n*/\n" }, { "answer_id": 303819, "author": "H...
2008/11/19
[ "https://Stackoverflow.com/questions/303417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3113/" ]
303,440
<p>I'm working on a idea where my a:link have one state (blue, no underline etc) with a a:hover being white. I want my <strong>visited links to have the same state</strong> as <code>a:link</code> and <code>a:hover</code>. Is this possible? supported in most common browsers?</p>
[ { "answer_id": 303447, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 1, "selected": false, "text": "a\n{\n color:#6c7492;\n font-weight:bold;\n text-decoration:none;\n}\na:hover\n{\n border-bottom:1px ...
2008/11/19
[ "https://Stackoverflow.com/questions/303440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
303,460
<p>Greetings!</p> <p>I'm creating a User Control that will display data in a GridView control. We are using n-tier architecture and the data in question is retrieved from our database and returned to us as a ReadOnlyCollection. OurNewObject is a class containing several properties and an empty constructor that takes no parameters - it's in the following namespace: Acme.ObjectModel.</p> <p>In the user control, I have the following:</p> <pre><code>&lt;asp:GridView ID="ourGrid" runat="server" DataSourceID="ourDataSource"&gt; &lt;columns&gt; &lt;asp:BoundField DataField="Name" HeaderText="Full Name" /&gt; &lt;asp:BoundField DataField="Gender" HeaderText="Gender" /&gt; &lt;asp:BoundField DataField="BirthYear" HeaderText="Year of Birth" /&gt; &lt;asp:BoundField DataField="JoinDate" HeaderText="Date Joined" /&gt; &lt;/columns&gt; &lt;/asp:GridView&gt; &lt;asp:ObjectDataSource ID="ourDataSource" runat="server" SelectMethod="GetTopUsers" TypeName="Acme.Model.OurNewObject"&gt; &lt;/asp:ObjectDataSource&gt; </code></pre> <p>In the User Control's code behind, I have the following public method:</p> <pre><code>public ReadOnlyCollection&lt;OurNewObject&gt; GetTopUsers() { return (OurDataProxy.GetJustTheTopUsers()); } </code></pre> <p>When I place the User Control on a Web form and run it, I get the following message:</p> <p><strong>ObjectDataSource 'ourDataSource' could not find a non-generic method 'GetTopUsers' that has no parameters.</strong></p> <p>So my questions are:</p> <ol> <li>Am I using the ObjectDataSource incorrectly?</li> <li>Is there a more proper way to use the ObjectDataSource in this situation?</li> </ol> <p>Thanks.</p>
[ { "answer_id": 303506, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 1, "selected": true, "text": "[System.ComponentModel.DataObjectMethodAttribute\n (System.ComponentModel.DataObjectMethodType.Select, true)]\n"...
2008/11/19
[ "https://Stackoverflow.com/questions/303460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27870/" ]
303,488
<p>In through <code>php_info()</code> where the WSDL cache is held (<code>/tmp</code>), but I don't necessarily know if it is safe to delete all files starting with WSDL. </p> <p>Yes, I <em>should</em> be able to just delete everything from <code>/tmp</code>, but I don't know what else this could effect if I delete any all WSDL files.</p>
[ { "answer_id": 303514, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 9, "selected": true, "text": "ini_set(\"soap.wsdl_cache_enabled\", 0);\n" }, { "answer_id": 17991617, "author": "staabm", "author_id": 1597388...
2008/11/19
[ "https://Stackoverflow.com/questions/303488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8880/" ]
303,502
<p>I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#</p> <pre><code>//The C# Version struct Person { public string name; } ... Person someone = null; //Nope! Can't do that!! Person? someoneElse = null; //No problem, just like expected </code></pre> <p>But then in VB.NET...</p> <pre><code>Structure Person Public name As String End Structure ... Dim someone As Person = Nothing 'Wha? this is okay? </code></pre> <p>Is Nothing not the same as null (<em>Nothing != null - LOL?)</em>, or is this just different ways of handling the same situation between the two languages?</p> <p>Why or what is handled differently between the two that makes this okay in one, but not the other?</p> <p><strong>[Update]</strong></p> <p>Given some of the comments, I messed with this a bit more... it seems as if you actually have to use Nullable if you want to allow something to be null in VB.NET... so for example...</p> <pre><code>'This is false - It is still a person' Dim someone As Person = Nothing Dim isSomeoneNull As Boolean = someone.Equals(Nothing) 'false' 'This is true - the result is actually nullable now' Dim someoneElse As Nullable(Of Person) = Nothing Dim isSomeoneElseNull As Boolean = someoneElse.Equals(Nothing) 'true' </code></pre> <p>Too weird...</p>
[ { "answer_id": 303525, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "Nothing" }, { "answer_id": 17376576, "author": "piBoss", "author_id": 826297, "author_profile": "htt...
2008/11/19
[ "https://Stackoverflow.com/questions/303502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17091/" ]
303,510
<p>My XML (<strong>a.xhtml</strong>) starts like this</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; ... </code></pre> <p>My code starts like this</p> <pre><code>use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath-&gt;new(filename =&gt; "a.xhtml"); my $nodeset = $xp-&gt;find('/html/body//table'); </code></pre> <p>It's very slow, and it turns out that it spends a lot of time getting the DTD (<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow noreferrer">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>).</p> <p>Is there a way to explicitly declare an HTTP proxy server in the Perl XML:: family? I hate to modify the original <strong>a.xhtml</strong> document like having a local copy of the DTD.</p>
[ { "answer_id": 304842, "author": "mirod", "author_id": 11095, "author_profile": "https://Stackoverflow.com/users/11095", "pm_score": 5, "selected": true, "text": "my $p = XML::Parser->new( NoLWP => 1);\nmy $xp= XML::XPath->new( parser => $p, filename => \"a.xhtml\");\n" }, { "ans...
2008/11/19
[ "https://Stackoverflow.com/questions/303510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24349/" ]
303,511
<p>I'm setting up CruiseControl.NET and during the build I want to modify my version.txt file and have it checked in. When I do this, CruiseControl.NET doesn't know this checkin was done by the build and so the next time it checks sources, it sees there were modifications and rebuilds again (I have IfModificationExists set in the project build). How do I tell CruiseControl.NET to check this file in or let it know that this one is OK so it doesn't keep re-triggering builds?</p>
[ { "answer_id": 303665, "author": "g .", "author_id": 6944, "author_profile": "https://Stackoverflow.com/users/6944", "pm_score": 4, "selected": true, "text": "<sourcecontrol type=\"filtered\">\n <sourceControlProvider type=\"svn\">\n ... \n </sourceControlProvider>\n ...
2008/11/19
[ "https://Stackoverflow.com/questions/303511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
303,512
<p>It seems like Groovy was forgotten in this thread so I'll just ask the same question for Groovy.</p> <ul> <li>Try to limit answers to Groovy core</li> <li>One feature per answer</li> <li>Give an example and short description of the feature, not just a link to documentation</li> <li>Label the feature using bold title as the first line</li> </ul> <p>See also:</p> <ol> <li><a href="https://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a></li> <li><a href="https://stackoverflow.com/questions/63998/hidden-features-of-ruby">Hidden features of Ruby</a></li> <li><a href="https://stackoverflow.com/questions/161872/hidden-features-of-perl">Hidden features of Perl</a></li> <li><a href="https://stackoverflow.com/questions/15496/hidden-features-of-java">Hidden features of Java</a></li> </ol>
[ { "answer_id": 303561, "author": "Robert Fischer", "author_id": 27561, "author_profile": "https://Stackoverflow.com/users/27561", "pm_score": 5, "selected": false, "text": "def x = [foo:1, bar:{-> println \"Hello, world!\"}]\nx.foo\nx.bar()\n" }, { "answer_id": 303641, "autho...
2008/11/19
[ "https://Stackoverflow.com/questions/303512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
303,519
<p>someone has an idea how can I do that ?</p> <p>thanks</p>
[ { "answer_id": 303551, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": false, "text": "n" }, { "answer_id": 303610, "author": "Pyrolistical", "author_id": 21838, "author_profile": "ht...
2008/11/19
[ "https://Stackoverflow.com/questions/303519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
303,548
<p>I have the following xml that's sent to me from a web service. I'm using .NET to deserialize it, but I'm getting an exception saying that its formatted wrong. <code>There is an error in XML document (2, 2)</code> Now, if I understand that correctly, it's not liking that it's finding the first <code>&lt;error&gt;</code> node.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;messages xmlns="http://www.w3.org/1999/xml"&gt; &lt;error&gt;error text&lt;/error&gt; &lt;message&gt;message text&lt;/message&gt; &lt;/messages&gt; </code></pre> <p>my code looks like this, data being the <code>String</code> version of the XML above:</p> <pre><code>Dim resp As cResponseMessage Dim sr As New StringReader(data) Dim xs As New XmlReaderSettings() Dim xd As New XmlSerializer(GetType(cResponseMessage)) resp = xd.Deserialize(XmlTextReader.Create(sr, xs)) </code></pre> <p>and <code>cResponseMessage</code> is simply a class with an <code>XMLRoot</code> attribute and 2 properties with <code>XMLElement</code> attributes. Nothing fancy here, but it doesn't want to work.</p> <p>Any help would be great.</p>
[ { "answer_id": 303633, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 2, "selected": true, "text": "<XmlRoot(Namespace:=\"http://www.w3.org/1999/xml\", ElementName:=\"messages\")> _\nPublic Class cResponseMessage\n\n <XmlEle...
2008/11/19
[ "https://Stackoverflow.com/questions/303548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13611/" ]
303,554
<p>I have a hidden field that i want to bind to either a function on the page's code behind. I don't quite recall the exact syntax and i can't find the answer via Google. Is the code below correct? Thank.</p> <pre><code>print("&lt;asp:HiddenField ID="dummy" Value='&lt;%#Getdummy() %&gt;' runat="server" /&gt;"); </code></pre>
[ { "answer_id": 303663, "author": "WestDiscGolf", "author_id": 33116, "author_profile": "https://Stackoverflow.com/users/33116", "pm_score": 2, "selected": false, "text": "<asp:HiddenField ID=\"hdnId\" runat=\"server\" Value='<%# GetValue() %>'/>\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
303,555
<p>Suppose I have two classes with the same interface:</p> <pre><code>interface ISomeInterface { int foo{get; set;} int bar{get; set;} } class SomeClass : ISomeInterface {} class SomeOtherClass : ISomeInterface {} </code></pre> <p>Suppose I have an instance of ISomeInterface that represents a SomeClass. Is there an easy way to copy that into a new instance of SomeOtherClass without copying each member by hand?</p> <p><strong>UPDATE:</strong> For the record, I'm <em>not</em> trying to cast the instance of SomeClass into the instance of SomeOtherClass. What I'd like to do is something like this:</p> <pre><code>ISomeInterface sc = new SomeClass() as ISomeInterface; SomeOtherClass soc = new SomeOtherClass(); soc.foo = sc.foo; soc.bar = soc.bar; </code></pre> <p>I just don't want to have to do that for each by hand as these objects have lots of properties.</p>
[ { "answer_id": 303570, "author": "mendicant", "author_id": 1800, "author_profile": "https://Stackoverflow.com/users/1800", "pm_score": 3, "selected": false, "text": " public ISomeInterface CopyValues(ISomeInterface fromSomeClass, ISomeInterface toSomeOtherClass)\n {\n //copy prope...
2008/11/19
[ "https://Stackoverflow.com/questions/303555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
303,562
<p>I'm trying to write a macro that would allow me to do something like: <code>FORMAT(a &lt;&lt; "b" &lt;&lt; c &lt;&lt; d)</code>, and the result would be a string -- the same as creating an ostringstream, inserting <code>a...d</code>, and returning <code>.str()</code>. Something like:</p> <pre><code>string f(){ ostringstream o; o &lt;&lt; a &lt;&lt; "b" &lt;&lt; c &lt;&lt; d; return o.str() } </code></pre> <p>Essentially, <code>FORMAT(a &lt;&lt; "b" &lt;&lt; c &lt;&lt; d) == f()</code>.</p> <p>First, I tried:</p> <pre><code>1: #define FORMAT(items) \ ((std::ostringstream&amp;)(std::ostringstream() &lt;&lt; items)).str() </code></pre> <p>If the very first item is a C string (<code>const char *</code>), it will print the address of the string in hex, and the next items will print fine. If the very first item is an <code>std::string</code>, it will fail to compile (no matching operator <code>&lt;&lt;</code>).</p> <p>This:</p> <pre><code>2: #define FORMAT(items) \ ((std::ostringstream&amp;)(std::ostringstream() &lt;&lt; 0 &lt;&lt; '\b' &lt;&lt; items)).str() </code></pre> <p>gives what seems like the right output, but the <code>0</code> and <code>\b</code> are present in the string of course.</p> <p>The following seems to work, but compiles with warnings (taking address of temporary):</p> <pre><code>3: #define FORMAT(items) \ ((std::ostringstream&amp;)(*((std::ostream*)(&amp;std::ostringstream())) &lt;&lt; items)).str() </code></pre> <p>Does anyone know why 1 prints the address of the c-string and fails to compile with the <code>std::string</code>? Aren't 1 and 3 essentially the same?</p> <p>I suspect that C++0x variadic templates will make <code>format(a, "b", c, d)</code> possible. But is there a way to solve this now?</p>
[ { "answer_id": 303620, "author": "coppro", "author_id": 16855, "author_profile": "https://Stackoverflow.com/users/16855", "pm_score": 2, "selected": false, "text": "operator << (ostream&, char*)" }, { "answer_id": 303637, "author": "cadabra", "author_id": 39132, "auth...
2008/11/19
[ "https://Stackoverflow.com/questions/303562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39132/" ]
303,591
<p>Range intersection is a simple, but non-trivial problem.</p> <p>Its has been answered twice already:</p> <ul> <li><a href="https://stackoverflow.com/questions/224878/find-number-range-intersection">Find number range intersection</a></li> <li><a href="https://stackoverflow.com/questions/143552/comparing-date-ranges">Comparing date ranges</a></li> </ul> <p>The first solutions is O(n) and the second solution is for a database (which is less than O(n) of course).</p> <p>I have the same problem, but for a large n and I am not within a database.</p> <p>This problem seems to be very similar to <a href="https://stackoverflow.com/questions/303243/store-2d-points-for-quick-retrieval-of-those-inside-a-rectangle">Store 2D points for quick retrieval of those inside a rectangle</a> but I don't see how it maps.</p> <p>So what data structure would you store the set of ranges in, such that a search on a range costs less than O(n)? (Extra credit for using libraries available for Java)</p> <p><b>EDIT:</b></p> <p>I want to get a subset of all intersecting ranges, meaning the search range could intersect multiple ranges. </p> <p>The method that needs to be less than O(n) in Java is:</p> <pre><code>public class RangeSet { .... public Set&lt;Range&gt; intersects(Range range); .... } </code></pre> <p>Where Range is just a class containing a pair of int start and end.</p> <p>This is not an impossible question, I already have the solution, I just wanted to see if there was a more standard/simpler way of doing it</p>
[ { "answer_id": 303644, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 0, "selected": false, "text": " - if the node range intersects the input range:\n - if it's a leaf node, then add the range to your result list\n...
2008/11/19
[ "https://Stackoverflow.com/questions/303591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
303,608
<p>I noticed that doxygen uses the graphviz library for creating diagrams. Have you ever used graphviz for generating documentation? Is it worth learning the graphviz for documentation purposes outside the scope of doxygen? Or am I better off to sticking with a standard data modeling package like Visio?</p> <p>I understand the merits of it as a graphing library, but for trying to represent more complex UML (or similar) is it still worth looking into?</p>
[ { "answer_id": 976801, "author": "Quinn Taylor", "author_id": 120292, "author_profile": "https://Stackoverflow.com/users/120292", "pm_score": 4, "selected": false, "text": "-(NSString*)dotGraphString" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22724/" ]
303,611
<p>I originally used WebRequest and WebResponse to sent Http Post Messages. Always I got a response of "OK". The message I post is an XML signed with a certificate in the xml.</p> <p>The composition is this: C# service that is sending to a https website. HTTPS Website on another place that I cant say. HTTPS Local Website locally that is just receiving the messages I post locally and writing the results to a file. Just to simulate what the other website is getting.</p> <p>Local Website is signed with a self signed certificate to expire in 2048. </p> <p>This code was working fine until this week. I always posted and got an OK. In both websites. But this week the test and the real project implementation both go Kaput. On Both Websites. <br/> On the local website it was saying unable to connect to SSL. This problem is caused by the self signed certificate that for some reason beyond my understanding its giving hell. Thanks to the questions here I just validated the certificate to always be true and now it is not bugging anymore.</p> <p>To fix this just write this: </p> <pre><code>ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); </code></pre> <p>In the start of your application. So that it only runs once.</p> <p>The remaining problem is the "The remote server returned an error: (503) Server Unavailable.". I enter the URL in my browser and it works fine for me. In the code this website is not receiving anything and when it goes to the web response it gives me the above error</p> <p>I did a test application that only sends "Testing 1 2 3" but I keep getting the error. I also sent it to a harvard https website and there was no errors.</p> <pre><code>private void btnSend_Click(object sender, EventArgs e) { try { WebRequest req = WebRequest.Create(cboUrl.Text); req.PreAuthenticate = true; req.UseDefaultCredentials = true; req.Method = "POST"; req.ContentType = "text/xml"; String msg = txtMsg.Text; using (Stream s = req.GetRequestStream()) { try { s.Write( System.Text.ASCIIEncoding.ASCII.GetBytes(msg), 0, msg.Length); } finally { s.Close(); } } WebResponse resp = req.GetResponse(); StreamReader str = new StreamReader(resp.GetResponseStream()); txtRes.Text = str.ReadToEnd(); } catch (WebException ex) { txtRes.Text = ex.Message; } catch (Exception ex) { txtRes.Text = ex.Message; } } </code></pre> <p>This is another example I built from what I found in the internet:</p> <pre><code>private void button1_Click(object sender, EventArgs e) { try { HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(cboUrl.Text); myReq.Headers.Clear(); myReq.Method = "POST"; myReq.KeepAlive = false; myReq.ProtocolVersion = HttpVersion.Version11; myReq.ContentType = "text/xml"; myReq.Proxy = null; myReq.Credentials = null; myReq.ContentLength = txtMsg.Text.Length; using (StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream())) { sendingData.Write(txtMsg.Text); sendingData.Flush(); sendingData.Close(); } HttpWebResponse myResponse = (HttpWebResponse) myReq.GetResponse(); StreamReader responseStream = new StreamReader(myResponse.GetResponseStream()); txtRes.Text = responseStream.ReadToEnd(); responseStream.Close(); myResponse.Close(); } catch(WebException ex ) { txtRes.Text = ex.Message; } catch (Exception ex) { txtRes.Text = ex.Message; } } </code></pre> <p><strong>Update</strong></p> <p>Error was that the one I was calling with httpwebrequest, needed some httpheaders that I was not providing. Before the only thing that happened was that I got an "OK" response. They fixed their code and I fixed mine and now its working. </p> <p>If it happens to someone else check like the one below said the proxy settings and also check if the other side is giving an exception or returning nothing at all.</p>
[ { "answer_id": 15832221, "author": "gradosevic", "author_id": 915320, "author_profile": "https://Stackoverflow.com/users/915320", "pm_score": 1, "selected": false, "text": "request.Proxy = null;" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12924/" ]
303,613
<p>Here are the specs that I'm trying to implement in a nutshell:</p> <p>1) Some Alerts have to be sent on certain events in the application.</p> <p>2) These Alerts have Users subscribe to them.</p> <p>3) And the Users have set their own Notification preferences (e.g. Email and/or SMS).</p> <p>I have not been able to find an open source solution in Java so far.</p> <p>Is JMX Notifications an option? The more I read about JMX, the more I feel that it is trying to achieve something different that my problem.</p> <p>Any help would be useful.</p>
[ { "answer_id": 3682691, "author": "simbo1905", "author_id": 329496, "author_profile": "https://Stackoverflow.com/users/329496", "pm_score": 1, "selected": false, "text": "-Dcom.sun.management.jmxremote.port=9999 \n-Dcom.sun.management.jmxremote.authenticate=false \n-Dcom.sun.management.j...
2008/11/19
[ "https://Stackoverflow.com/questions/303613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/325613/" ]
303,625
<p>I've followed the ADAM Step by Step Guide from Microsoft and setup an ADAM instance on my local machine. I'm attempting to authenticate using the "Mary Baker" account, but every time I get a COM exception on the <code>if (entry.Guid != null)</code> line below. The exception states that there's an unknown user name or bad password.</p> <p>However, I can use the ldp utility to connect to ADAM and successfully perform a simple bind - so I know that the user name both exists, and I have the correct password.</p> <p>Additionally, I have set the msDS-UserAccountDisabled property on the user to false, and added the user to both the Administrators and Readers roles. </p> <p>Any thoughts?</p> <pre><code> path = "LDAP://localhost:50000/O=Microsoft,c=US"; userId = "CN=Mary Baker,OU=ADAM users,"; password = "Mary@101"; DirectoryEntry entry = new DirectoryEntry(path, userId, password, AuthenticationTypes.None); if (entry.Guid != null) LoadWelcomeScreen(); </code></pre> <p>Thanks.</p>
[ { "answer_id": 6287693, "author": "Ryan Sweet", "author_id": 79736, "author_profile": "https://Stackoverflow.com/users/79736", "pm_score": 2, "selected": false, "text": "displayName" }, { "answer_id": 16465582, "author": "Kwex", "author_id": 705902, "author_profile": ...
2008/11/19
[ "https://Stackoverflow.com/questions/303625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26218/" ]
303,639
<p>I'm terrible with regex, but I've had a try and a Google (and even looked in reddit's source) and I'm still stuck so here goes:</p> <p>My aim is to match the following 'codes' and replace them with the HTML tags. It's just the regex I'm stuck with.</p> <pre><code>**bold text** _italic text_ ~hyperlink~ </code></pre> <p>Here's my attempts at the bold one:</p> <pre><code>^\*\*([.^\*]+)\*\*$ </code></pre> <p>Why this isn't working? I'm using the preg syntax.</p>
[ { "answer_id": 303647, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 3, "selected": true, "text": "\\*\\*(.[^*]*)\\*\\*\n" }, { "answer_id": 303657, "author": "Paige Ruten", "author_id": 813, "author_profile...
2008/11/19
[ "https://Stackoverflow.com/questions/303639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
303,642
<p>I have written a new custom component derived from TLabel. The component adds some custom drawing to component, but nothing else. When component is painted, everything works fine. But when the redraw is needed (like dragging another window over the component), "label part" works fine but my custom drawing is not properly updated. I'm basically drawing directly to the canvas in an overridden Paint method, and when the redraw is required the parts of canvas where my code has drawn something is painted black. It seems like that the paint method is not called. What I should do to get proper redraw?</p> <p>The component is basically:</p> <pre><code>TMyComponent = class(TCustomLabel, IMyInterface) .. protected procedure Paint; override; .. procedure TMyComponent.Paint; begin inherited; MyCustomPaint; end; </code></pre> <p>Update, the paint routine:</p> <pre><code>Position := Point(0,0); Radius := 15; FillColor := clBlue; BorderColor := clBlack; Canvas.Pen.Color := BorderColor; Canvas.Pen.Width := 1; Canvas.Brush.Color := BorderColor; Canvas.Ellipse(Position.X, Position.Y, Position.X + Radius, Position.Y + Radius); Canvas.Brush.Color := FillColor; Canvas.FloodFill(Position.X + Radius div 2, Position.Y + Radius div 2, BorderColor, fsSurface); </code></pre> <p>SOLVED:</p> <p>The problem is (redundant) use of FloodFill. If the Canvas is not fully visible floodfill causes artifacts. I removed the floodfill and now it works as needed.</p>
[ { "answer_id": 303899, "author": "Jim McKeeth", "author_id": 255, "author_profile": "https://Stackoverflow.com/users/255", "pm_score": 1, "selected": false, "text": "procedure TMyComponent.MyCustomPaint;\nvar\n rect: TRect;\nbegin\n rect := self.BoundsRect;\n rect.TopLeft := ParentToC...
2008/11/19
[ "https://Stackoverflow.com/questions/303642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7735/" ]
303,656
<p>Our application is an Xbap running in full trust. I have a function similar to this:</p> <pre><code>private void ShowPage(Page page) { NavigationWindow mainWindow = Application.Current.MainWindow as NavigationWindow; mainWindow.Navigate(page); } </code></pre> <p>This works great for browsing inside an existing window. I would like to open this new page in a separate window. Is there anyway to do this?</p> <p>There is an overload that takes 'extraData' but I haven't been able to determine what to pass to navigate to a new window.</p>
[ { "answer_id": 310022, "author": "Shaun Bowe", "author_id": 1514, "author_profile": "https://Stackoverflow.com/users/1514", "pm_score": 3, "selected": true, "text": "private void ShowPage(Page page)\n{\n NavigationWindow popup = new NavigationWindow(); \n popup.Height = 400;\n ...
2008/11/19
[ "https://Stackoverflow.com/questions/303656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514/" ]
303,664
<p>I am new to Python, and I'm working on writing some database code using the <code>cx_Oracle</code> module. In the <a href="http://cx-oracle.sourceforge.net/html/module.html" rel="nofollow noreferrer">cx_Oracle documentation</a> they have a code example like this:</p> <pre><code>import sys import cx_Oracle connection = cx_Oracle.Connection("user/pw@tns") cursor = connection.cursor() try: cursor.execute("select 1 / 0 from dual") except cx_Oracle.DatabaseError, exc: error, = exc.args print &gt;&gt; sys.stderr, "Oracle-Error-Code:", error.code print &gt;&gt; sys.stderr, "Oracle-Error-Message:", error.message </code></pre> <p>My question has to do with where the "error" object is created. What does the "<code>, =</code>" do? I tried searching Python documentation, and search engines don't work very well when you're searching for operators. :-)</p> <p>I know that the exc.args is a singleton tuple, but I just don't understand the "<code>, =</code>" syntax. If I remove the comma, I get the error message, "<code>AttributeError: 'tuple' object has no attribute 'code'</code>". </p> <p>Can someone point me to where this is documented? Thanks!</p> <p><strong>EDIT:</strong></p> <p>This works without having to unpack the tuple:</p> <pre><code>import sys import cx_Oracle connection = cx_Oracle.Connection("user/pw@tns") cursor = connection.cursor() try: cursor.execute("select 1 / 0 from dual") except cx_Oracle.DatabaseError, exc: print &gt;&gt; sys.stderr, "Oracle-Error-Code:", exc.args[0].code print &gt;&gt; sys.stderr, "Oracle-Error-Message:", exc.args[0].message </code></pre>
[ { "answer_id": 303693, "author": "Andrew Beyer", "author_id": 38691, "author_profile": "https://Stackoverflow.com/users/38691", "pm_score": 2, "selected": false, "text": "error" }, { "answer_id": 303697, "author": "ddaa", "author_id": 11549, "author_profile": "https:/...
2008/11/19
[ "https://Stackoverflow.com/questions/303664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31319/" ]
303,668
<p>Hey I usually run into a situation where I will create a class that should only be instantiated by one or a few classes. In this case I would make its constructor private and make it a friend class to the objects that should be able to instantiate it. For example (in C++):</p> <pre><code>class CFoo { friend class CFoo; // private ctor because only a select few classes should instantiate private: CFoo() { ... Do stuff } } class CBar { // CBar is one of the few classes that only need to use CFoo CFoo *m_pFoo; CBar() { m_pFoo = new CFoo; } } </code></pre> <p>So my question is: Is this stupid? Or is there a better way to achieve this? I'm especially interested in a way where it would work with C# considering the language lacks the friend keyword completely. Thanks.</p>
[ { "answer_id": 303680, "author": "g .", "author_id": 6944, "author_profile": "https://Stackoverflow.com/users/6944", "pm_score": 1, "selected": false, "text": "public class CBar\n{\n CBar()\n {\n m_pFoo = new CFoo();\n }\n\n CFoo m_pFoo;\n\n private class CFoo\n ...
2008/11/19
[ "https://Stackoverflow.com/questions/303668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13115/" ]
303,679
<p>I would like to search my table having a column of first names and a column of last names. I currently accept a search term from a field and compare it against both columns, one at a time with </p> <pre><code> select * from table where first_name like '%$search_term%' or last_name like '%$search_term%'; </code></pre> <p>This works fine with single word search terms but the result set includes everyone with the name "Larry". But if someone enters a first name then a space, then a last name, I want a narrower search result. I've tried the following without success. </p> <pre><code> select * from table where first_name like '%$search_term%' or last_name like '%$search_term%' or concat_ws(' ',first_name,last_name) like '%$search_term%'; </code></pre> <p>Any advice?</p> <p><strong>EDIT:</strong> The name I'm testing with is "Larry Smith". The db stores "Larry" in the "first_name" column, and "Smith" in the "last_name" column. The data is clean, no extra spaces and the search term is trimmed left and right.</p> <p><strong>EDIT 2:</strong> I tried Robert Gamble's answer out this morning. His is very similar to what I was running last night. I can't explain it, but this morning it works. The only difference I can think of is that last night I ran the concat function as the third "or" segment of my search query (after looking through first_name and last_name). This morning I ran it as the last segment after looking through the above as well as addresses and business names. </p> <p>Does running a mysql function at the end of a query work better than in the middle?</p>
[ { "answer_id": 303730, "author": "Jack", "author_id": 24998, "author_profile": "https://Stackoverflow.com/users/24998", "pm_score": 3, "selected": false, "text": "SELECT *,concat_ws(' ',first_name,last_name) AS whole_name FROM users HAVING whole_name LIKE '%$search_term%'\n" }, { ...
2008/11/19
[ "https://Stackoverflow.com/questions/303679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1149/" ]
303,699
<p>I have a text area and a function to do syntax highlighting on it. Right now it reads the entire RichTextBox. How would I get a string variable containing the current line? Below is the code i currently have.</p> <pre><code>Private Sub HighLight() Dim rm As System.Text.RegularExpressions.MatchCollection Dim m As System.Text.RegularExpressions.Match Dim x As Integer ''lets remember where the text courser was before we mess with it For Each pass In FrmColors.lb1.Items x = rtbMain.SelectionStart rm = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass)) For Each m In rm rtbMain.Select(m.Index, m.Length) rtbMain.SelectionColor = Color.Blue Next rtbMain.Select(x, 0) rtbMain.SelectionColor = Color.Black Next End Sub </code></pre>
[ { "answer_id": 303729, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 3, "selected": true, "text": "rtbMain.Lines(lineNumber)\n" }, { "answer_id": 303733, "author": "P Daddy", "author_id": 36388, "auth...
2008/11/19
[ "https://Stackoverflow.com/questions/303699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39143/" ]
303,712
<p>In a Java application (JRE 1.5.0_12) on Windows XP, I call a native method:</p> <pre><code>public native int attachImage( ... ); </code></pre> <p>... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this window has focus. This is an issue because when this window is displayed, users often switch to another application to select the image to attach, then want to restore this application.</p>
[ { "answer_id": 303753, "author": "James Van Huis", "author_id": 31828, "author_profile": "https://Stackoverflow.com/users/31828", "pm_score": 2, "selected": true, "text": "Shell shell = new Shell(display,SWT.APPLICATION_MODAL);\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35142/" ]
303,718
<p>My Firefox 3.0.4 does not display non-existing images at all, or it displays the image alt as plain text (if available).<br/> This way I would have no idea that there is supposed to be an image there.</p> <p>Does anyone know if there is a way to make it work like IE/Opera? (ie. display a box even if the image file doesn't exists) - plugin or anything?</p> <p>Test image: <img src="https://example.com/notavalidlink" alt="[broken image test]"></p>
[ { "answer_id": 303772, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": -1, "selected": false, "text": "<img src='...' width='100' height='100' alt='...'></img>\nor\n<img src='...' alt='...' style='width:100px; height:100px...
2008/11/19
[ "https://Stackoverflow.com/questions/303718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36036/" ]
303,720
<p>I'm looking for something like <code>alert()</code>, but that doesn't "pause" the script.</p> <p>I want to display an alert and allow the next command, a form <code>submit()</code>, to continue. So the page will be changing after the alert is displayed, but it won't wait till the user has clicked OK.</p> <p>Is there something like this or is it just one of those impossible things?</p>
[ { "answer_id": 303735, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 7, "selected": true, "text": "setTimeout(\"alert('hello world');\", 1);\n" }, { "answer_id": 31519945, "author": "JasonK", "author_i...
2008/11/19
[ "https://Stackoverflow.com/questions/303720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
303,726
<p>I'm just playing around and I'm trying to grab information from websites. Unfortunately, with the following code:</p> <pre><code>import sys import socket import re from urlparse import urlsplit url = urlsplit(sys.argv[1]) sock = socket.socket() sock.connect((url[0] + '://' + url[1],80)) path = url[2] if not path: path = '/' print path sock.send('GET ' + path + ' HTTP/1.1\r\n' + 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.3.154.9 Safari/525.19\r\n' + 'Accept: */*\r\n' + 'Accept-Language: en-US,en\r\n' + 'Accept-Charset: ISO-8859-1,*,utf-8\r\n' + 'Host: 68.33.143.182\r\n' + 'Connection: Keep-alive\r\n' + '\r\n') </code></pre> <p>I get the following error:</p> <blockquote> <p>Traceback (most recent call last):<br> File "D:\Development\Python\PyCrawler\PyCrawler.py", line 10, in sock.connect((url[0] + '://' + url[1],80)) File "", line 1, in connect socket.gaierror: (11001, 'getaddrinfo failed')</p> </blockquote> <p>The only time I do not get an error is if the url passed is <a href="http://www.reddit.com" rel="nofollow noreferrer">http://www.reddit.com</a>. Every other url I have tried comes up with the socket.gaierror. Can anyone explain this? And possibly give a solution?</p>
[ { "answer_id": 303747, "author": "Piotr Lesnicki", "author_id": 38796, "author_profile": "https://Stackoverflow.com/users/38796", "pm_score": 1, "selected": false, "text": "addr = socket.gethostbyname(url[1])\n...\nsock.connect((addr,80))\n" }, { "answer_id": 303749, "author"...
2008/11/19
[ "https://Stackoverflow.com/questions/303726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
303,745
<p>This is probably a beginner question, but how do you set a recordset to a string variable? </p> <p>Here is my code: </p> <pre><code>Function getOffice (strname, uname) strEmail = uname WScript.Echo "email: " &amp; strEmail Dim objRoot : Set objRoot = GetObject("LDAP://RootDSE") Dim objDomain : Set objDomain = GetObject("LDAP://" &amp; objRoot.Get("defaultNamingContext")) Dim cn : Set cn = CreateObject("ADODB.Connection") Dim cmd : Set cmd = CreateObject("ADODB.Command") cn.Provider = "ADsDSOObject" cn.Open "Active Directory Provider" Set cmd.ActiveConnection = cn cmd.CommandText = "SELECT physicalDeliveryOfficeName FROM '" &amp; objDomain.ADsPath &amp; "' WHERE mail='" &amp; strEmail &amp; "'" cmd.Properties("Page Size") = 1 cmd.Properties("Timeout") = 300 cmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE Dim objRS : Set objRS = cmd.Execute WScript.Echo objRS.Fields(0) Set cmd = Nothing Set cn = Nothing Set objDomain = Nothing Set objRoot = Nothing Dim arStore Set getOffice = objRS.Fields(0) Set objRS = Nothing End function </code></pre> <p>When I try to run the function, it throws an error "vbscript runtime error: Type mismatch" I presume this means it can't set the string variable with a recordset value. </p> <p>How do I fix this problem?</p> <hr> <p>I just tried </p> <p>if IsNull(objRS.Fields(0).Value) = TRUE then getOFfice = "noAD" else getOFfice = objRS.Fields(0).VAlue end if </p> <p>And that throws a different error ADODB.Field: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.</p>
[ { "answer_id": 303754, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 0, "selected": false, "text": "Cstr(objRS.Fields(0))\n" }, { "answer_id": 312645, "author": "AnonJr", "author_id": 25163, "author_profile":...
2008/11/19
[ "https://Stackoverflow.com/questions/303745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
303,759
<p>I'm using VS 2008 to create a C++ DLL (not managed) project and I need convert a char* to a long long type. Is there an easy way to do it?</p> <p>Thanks in advance :)</p>
[ { "answer_id": 303796, "author": "altruic", "author_id": 38620, "author_profile": "https://Stackoverflow.com/users/38620", "pm_score": 4, "selected": true, "text": "_atoi64." }, { "answer_id": 303800, "author": "Alan", "author_id": 37843, "author_profile": "https://St...
2008/11/19
[ "https://Stackoverflow.com/questions/303759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24927/" ]
303,760
<p>The concept of a <a href="http://en.wikipedia.org/wiki/Coroutine" rel="noreferrer">coroutine</a> sounds very interesting, but I don't know, if it makes sense in a real productive environment? What are use cases for coroutines, where the coroutine implementation is more elegant, simpler or more efficient than other methods?</p>
[ { "answer_id": 303789, "author": "Bevan", "author_id": 30280, "author_profile": "https://Stackoverflow.com/users/30280", "pm_score": 5, "selected": true, "text": "yield return" }, { "answer_id": 304234, "author": "Charlie Martin", "author_id": 35092, "author_profile":...
2008/11/19
[ "https://Stackoverflow.com/questions/303760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
303,761
<p>The Drupal API has <a href="http://api.drupal.org/api/function/drupal_get_path/6" rel="noreferrer"><code>drupal_get_path($type, $name)</code></a> which will give the path of any particular theme or module. What if I want the path of the current theme?</p>
[ { "answer_id": 303792, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": false, "text": "global $theme;\n$path = drupal_get_path('theme', $theme);\n\n// there's also a $theme_path global\n\nglobal $theme_path;\n" }...
2008/11/19
[ "https://Stackoverflow.com/questions/303761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
303,763
<p>I was wondering if anyone knew of a macro or keyboard shortcut or anything really that would automate Attaching to a Process within visual studio?</p>
[ { "answer_id": 303765, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 4, "selected": true, "text": "System.Diagnostics.Debugger.Break()" }, { "answer_id": 303774, "author": "Greg Beech", "author_id": 13552, ...
2008/11/19
[ "https://Stackoverflow.com/questions/303763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
303,767
<p>I need to grab the height of the window and the scrolling offset in jQuery, but I haven't had any luck finding this in the jQuery docs or Google.</p> <p>I'm 90% certain there's a way to access height and scrollTop for an element (presumably including the window), but I just can't find the specific reference.</p>
[ { "answer_id": 303778, "author": "Joey V.", "author_id": 34462, "author_profile": "https://Stackoverflow.com/users/34462", "pm_score": 3, "selected": false, "text": "$(window).height()\n\n$(window).width()\n" }, { "answer_id": 303791, "author": "Pim Jager", "author_id": 3...
2008/11/19
[ "https://Stackoverflow.com/questions/303767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38666/" ]
303,783
<p>I'm building a fairly simple PHP script that will need to send some emails with attachments. I've found these 2 libraries to do this. </p> <p>Does either one have significant advantages over the other? Or should I just pick one at random and be done with it?</p>
[ { "answer_id": 15074414, "author": "Marco Demaio", "author_id": 260080, "author_profile": "https://Stackoverflow.com/users/260080", "pm_score": 3, "selected": false, "text": "SMTPDebug = 2" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
303,809
<p>I'm working on a simple application to start learning my way around WPF. I created a vector graphic in Microsoft Expression Design at 400px by 400px, mainly because I thought it would be easier to create it on a bigger canvas.</p> <p>I've exported the image to a XAML file as a series of objects within a 400px square canvas. All of the child objects are positioned based on that 400px canvas.</p> <p>I would like to place the image in my application window, but scaled down to maybe 100px by 100px, but I don't know how to do this. As a vector image, the concept of easy scaling seems simple, but I'm missing something. Click-n-drag resizes the canvas, but not the elements inside. Internet searches have been less than useful thus far.</p> <p>I just want to place the image in my window... not in a button or anything special, and have easy control over its size. Do I need to copy all the XAML into my window's XAML? Can I reference the XAML file somehow instead? How can I make the elements of the image scale with the overall image? Any help would be appreciated.</p>
[ { "answer_id": 310491, "author": "discorax", "author_id": 30408, "author_profile": "https://Stackoverflow.com/users/30408", "pm_score": 0, "selected": false, "text": " dot = new Image();\n BitmapImage dotSource = new BitmapImage();\n dotSource.BeginInit();\n s...
2008/11/19
[ "https://Stackoverflow.com/questions/303809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/641985/" ]
303,827
<p>How do you access a MySQL relation using RoR?</p>
[ { "answer_id": 304730, "author": "allesklar", "author_id": 19893, "author_profile": "https://Stackoverflow.com/users/19893", "pm_score": 3, "selected": true, "text": "has_many :addresses\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39155/" ]
303,829
<p>In Ruby we have the 'bang' method <code>capitalize!</code> which has the strange behavior of returning a <code>nil</code> if no changes to the string were made.</p> <p>That means I can't chain this commands with other since it effectively destroys the chain if it returns <code>nil</code>.</p> <p>What im trying to do is something like this:</p> <pre><code>fname = fullname[0...fullname.index(' ')].capitalize! </code></pre> <p>which extracts the first name from a string and should capitalize it as well. But if it is already capitalized the string stored in <code>fname</code> is <code>nil</code>.</p> <p>Of courses I can add another statement but was wondering if there is a way to do this "without breaking the chain".</p>
[ { "answer_id": 303861, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": false, "text": "fname = fullname[0...fullname.index(' ')].capitalize\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14587/" ]
303,830
<p>I have a body of text that I have to scan and each line contains at least 2 and sometimes four parts of information. The problem is that each line can be 1 out of 15-20 different actions.</p> <p>in ruby the current code looks somewhat like this:</p> <pre> text.split("\n").each do |line| #around 20 times.. .............. expressions['actions'].each do |pat, reg| #around 20 times ................. </pre> <p>This is obviously 'THE PROBLEM'. I did manage to make it faster (in C++ by a 50% margin) by combining all the regexen into one but that is still not the speed I require -- I need to parse thousands of these files FAST!</p> <p>Right now I match them with regexes -- however this is intolerably slow. I started with ruby and hopped over to C++ in hopes that I'd get a speed boost and it just isn't happening.</p> <p>I've casually read on PEGs and grammar based parsing but it looks somewhat difficult to implement. Is this the direction I should head or are there different routes?</p> <p>basically I'm parsing poker hand histories and each line of the hand history usually contains 2-3 bits of information that I need to collect: who the player was, how much money or what cards the action entailed.. etc..</p> <p>Sample text that needs to be parsed:</p> <pre> buriedtens posts $5 The button is in seat #4 *** HOLE CARDS *** Dealt to Mayhem 31337 [8s Ad] Sherwin7 folds OneMiKeee folds syhg99 calls $5 buriedtens raises to $10 </pre> <p>After I collect this information each action is turned into an xml node.</p> <p>Right now my ruby implementation of this is much faster than my C++ one but that's prob. Just cause I have not written in c code for well over 4-5 years</p> <p><strong>UPDATE:</strong> I don't want to post all the code here but so far my hands/second look like the following:</p> <pre> 588 hands/second -- boost::spirit in c++ 60 hands/second -- 1 very long and complicated regex in c++ (all the regexen put together) 33 hands/second -- normal regex style in ruby </pre> <p>I'm currently testing antlr to see if we can go any further but as of right now I'm very very happy with spirit's results.</p> <p>Related question: <a href="https://stackoverflow.com/questions/192957/efficiently-querying-one-string-against-multiple-regexes">Efficiently querying one string against multiple regexes.</a></p>
[ { "answer_id": 304532, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 0, "selected": false, "text": "regex1|regex2|regex3|...|regex15\n" }, { "answer_id": 306688, "author": "Brad Gilbert", "author_id":...
2008/11/19
[ "https://Stackoverflow.com/questions/303830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39110/" ]
303,838
<p>I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just using simple batch files to launch my app but having it run within the same prompt as CC is causing CC to think the build continues as long as my app runs.</p> <p>Are there command line parameters to <code>cmd.exe</code> that will spawn another separate prompt window?</p>
[ { "answer_id": 303844, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 9, "selected": true, "text": "start cmd.exe\n" }, { "answer_id": 303869, "author": "BlackMael", "author_id": 19377, "author_profile":...
2008/11/19
[ "https://Stackoverflow.com/questions/303838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25946/" ]
303,841
<p>I am getting this warning:</p> <pre><code>Use of uninitialized value in eval \"string\" at myscript.pl line 57. </code></pre> <p>When I run this code:</p> <pre><code>eval; { `$client -f $confFile -i $inputFile -o $outputFile`; }; if( $@ ) { # error handling here ... } </code></pre> <p>What is causing the error?</p> <p>How can I fix the underlying cause? (Or otherwise suppress the warning?)</p>
[ { "answer_id": 303855, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 4, "selected": true, "text": "eval" }, { "answer_id": 303990, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https...
2008/11/19
[ "https://Stackoverflow.com/questions/303841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39153/" ]
303,842
<p>I'm wondering if there is any way to create a User Account on a Windows XP machine that can be done through scripting from an ActiveX control on a webpage. Specifically, I'd like to know if there's any way to deploy an ActiveX control with computers (that I preconfigure and ship) that will allow use of my webpage from that computer to detect that the ActiveX control is present, and allow for automated creation of local (Windows XP) user accounts on the computer. Essentially, consider this to be a question of preinstalling an ActiveX control (if necessary) and providing a link on the desktop; the user receives the machine and logs on (with admin rights) and goes to a web site, where my server determine what the appropriate user accounts are, sends them back as HTML, and the ActiveX control creates the user accounts I specify.</p> <p>This sort of thing seems like it should be possible, but at the same time, there are obvious security flaws that are potentially involved. Access to these machines will be very limited, so the security issues are less of a concern.</p> <p>Does anyone know if this is possible? Do any of the built in WMI components do anything like this? Is this even allowed by the security model of XP? Or is this just opening up a huge security hole that should be avoided entirely?</p>
[ { "answer_id": 303855, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 4, "selected": true, "text": "eval" }, { "answer_id": 303990, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https...
2008/11/19
[ "https://Stackoverflow.com/questions/303842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28053/" ]
303,853
<p>I am considering using Maven for a Java open source project I manage.</p> <p>In the past, however, Maven has not always had the best reputation. What are your impressions of Maven, at this time? </p>
[ { "answer_id": 3361860, "author": "Jan", "author_id": 357556, "author_profile": "https://Stackoverflow.com/users/357556", "pm_score": 2, "selected": false, "text": "pom.xml" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/303853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32174/" ]
303,877
<p>TeX/LaTeX is great, I use it in many ways. Some of its advantages are:</p> <ul> <li>it uses text files, this way the input-files can be diffed and many tools exist to work with text</li> <li>it is very flexible</li> <li>it has a stable layout: if I change something at the start of the document, it doesn't affect other things at the end of the document</li> <li>it has many extensions to reach different goals (a successor would start without extensions, but would have a good extension-system)</li> <li>you can use standard build control tools to support complicated documents (thanks dmckee)</li> <li>you can encapsulate solutions and copy&amp;paste them to new documents or send them to others to learn from (thanks dmckee)</li> </ul> <p>But on the other hand some little things are not so good:</p> <ul> <li>it is hard to learn at the beginning</li> <li>it is complicated to control position of images</li> <li>a few things are a little counter-intuitive</li> <li>sometimes you have to type too much (begin{itemize} ... \end{itemize})</li> </ul> <p>So, does there exist a successor/alternative to LaTeX or at least is some hot candidate for an alternative in development. A real successor/good alternative would keep the advantages and fix the disadvantages, or at least some of them.</p>
[ { "answer_id": 304039, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 2, "selected": false, "text": " .pl 10.0i\n .po 0\n .ll 7.2i\n .lt 7.2i\n .nr LL 7.2i\n .nr LT 7.2i\n .ds...
2008/11/19
[ "https://Stackoverflow.com/questions/303877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
303,911
<p>There is a similar question <a href="https://stackoverflow.com/questions/203495/testing-rest-webservices">here</a> but it only covers some of the issues below.</p> <p>We have a client who requires web services using REST.</p> <p>We have tons of experience using SOAP and over time have gathered together a really good set of tools for SOAP development and testing e.g.</p> <ul> <li>soapUI </li> <li>Eclipse plugins</li> <li>wsdl2java</li> <li>WSStudio</li> </ul> <p>By "tools" I mean a product "out of the box" that we can start using. I'm not talking about cutting code to "roll our own" using Ajax or whatever.</p> <p>The tool set for REST doesn't seem to be nearly as mature?</p> <ul> <li><p>What tools are out there (we use C# and Java mainly) ?</p></li> <li><p>Do the tools handle GET, POST, PUT, and DELETE?</p></li> <li><p>Is there a decent Eclipse plugin?</p></li> <li><p>Is there a decent client testing application like WSStudio where you point the tool to the WSDL and it generates a proxy on the fly with the appropriate methods and inputs and you simple type the data in?</p></li> <li><p>Are there any good package monitoring tools that allow you to look at the data? (I'm not thinking about sniffers like Wireshark here but rather things like soapUI that allow you to see the request / response) ?</p></li> </ul>
[ { "answer_id": 21280384, "author": "Johan", "author_id": 398441, "author_profile": "https://Stackoverflow.com/users/398441", "pm_score": 0, "selected": false, "text": "{ \"greeting\" : { \"firstName\" : <first_name>, \"lastName\" : <last_name> } }\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/303911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9922/" ]
303,913
<pre><code>File fil = new File("Tall.txt"); FileReader inputFil = new FileReader(fil); BufferedReader in = new BufferedReader(inputFil); int [] tall = new int [100]; String s =in.readLine(); while(s!=null) { int i = 0; tall[i] = Integer.parseInt(s); //this is line 19 System.out.println(tall[i]); s = in.readLine(); } in.close(); </code></pre> <p>I am trying to use the file "Tall.txt" to write the integers contained in them into the array named "tall". It does this to some extent, but also when I run it, it throws the following exception (:</p> <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at BinarySok.main(BinarySok.java:19) </code></pre> <p>Why exactly does it do this, and how do I remove it? As I see it, I read the file as strings, and then convert it to ints, which isn't illegal.</p>
[ { "answer_id": 303921, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": false, "text": "try {\n tall[i++] = Integer.parseInt(s);\n}\ncatch (NumberFormatException ex) {\n continue;\n}\n" }, { "answer_id...
2008/11/20
[ "https://Stackoverflow.com/questions/303913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37161/" ]
303,916
<p>I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.</p> <p>I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for EmployeePresenter) are injected into the presenter.</p> <p>I would like to use an IoC container (I'm trying out Unity, though I guess this would also happen with others such as ninject or Structure Map) instead of manually injecting these instances, however if the presenter is created (or resolved from an IoC container) on an async delegate call, or an event thread (e.g. not STA threaded) then creating a new instance of a WPF window throws the following exception:</p> <blockquote> <p>The current build operation (build key Build Key[<em>namespace</em>.Window1, null]) failed: The calling thread must be STA, because many UI components require this.</p> </blockquote> <p>Now, I know that new window instances etc need to be STA, however is it possible to use an IoC Container to do the dependency injection even when the UI must be created on an STA thread?</p> <p>From looking at this problem it would seem that the class/type being resolved is instantiated at the resolve time, not when its registered...</p>
[ { "answer_id": 303921, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": false, "text": "try {\n tall[i++] = Integer.parseInt(s);\n}\ncatch (NumberFormatException ex) {\n continue;\n}\n" }, { "answer_id...
2008/11/20
[ "https://Stackoverflow.com/questions/303916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
303,939
<p>I'm wondering why styling an element within a specific class, like this:</p> <pre><code>.reddish H1 { color: red } </code></pre> <p>is shown as an example of correct syntax in the CSS1 specification under Contextual selectors:</p> <p><a href="http://www.w3.org/TR/2008/REC-CSS1-20080411/#class-as-selector" rel="nofollow noreferrer">Cascading Style Sheets, level 1</a></p> <p>but it's not shown as an example in the CSS2 spec:</p> <p><a href="http://www.w3.org/TR/2008/REC-CSS2-20080411/selector.html" rel="nofollow noreferrer">Cascading Style Sheets, Level 2</a></p> <p>At least I can't find an example of it. Has the syntax rules for this changed in CSS2, or is it simply inferred as correct syntax?</p>
[ { "answer_id": 304122, "author": "philnash", "author_id": 28376, "author_profile": "https://Stackoverflow.com/users/28376", "pm_score": 3, "selected": true, "text": ".reddish h1" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/303939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
303,955
<p>I have a generic function which gets a interface as a type, now in one condition I have to create a new class depending on the interface. I have been thinking about it and a way to solve it would be to use an IoC but I was hoping there would be an other way because an IoC seems a bit like an overkill. </p> <p>below is an attempt using the visitor pattern:</p> <pre><code>public class RepositoryManager&lt;T&gt; : IRepositoryManager&lt;T&gt; where T : class, new() { public T GetOrCreate(string id) { T item = (T)CreateNew(new T(), id); return item; } } </code></pre> <p>If instead of an interface I was getting an object then I could use the visitor pattern to figure out what class to instantiate but I can't seem to figure this out depending on the interface provided.</p> <p>An other idea I had was if I can make the where declaration like an or?</p> <pre><code>public class RepositoryManager&lt;T&gt; : IRepositoryManager&lt;T&gt; where T : class, Iabc or Ixyz, new() </code></pre> <p>I hope the question is clear :)</p> <p>-Mark</p> <hr> <p>Thanks for the reply's.</p> <p>The problem is that the method can have many different interfaces assigned to it for example:</p> <p>RepositoryManager class:</p> <pre><code>private static IMedicament CreateNew(IMedicament emptyType, string id) { return new Medicament { Id = id }; } private static IRefund CreateNew(IRefund emptyType, string id) { return new Refund { Id = id }; } RepositoryManager&lt;Iabc&gt; abcRepository = new RepositoryManager&lt;Iabc&gt;(); RepositoryManager&lt;Ixyz&gt; xyzRepository = new RepositoryManager&lt;Ixyz&gt;(); Iabc abc = abcRepository.GetOrCreate("12345"); Ixyz xyz = xyzRepository.GetOrCreate("12345"); </code></pre> <p>so using <code>T item = (T)CreateNew(new T(), id);</code> won't work because I have to tell it that T can either be of type Iabc or Ixyz but when I do that I get the following error:</p> <p>The call is ambiguous between the following methods or properties: <code>RepositoryManager&lt;T&gt;.CreateNew(IMedicament, string)</code> and <code>RepositoryManager&lt;T&gt;.CreateNew(IRefund, string)</code></p> <p>It would be nice if I get this working besides just copying the code several times.</p>
[ { "answer_id": 304155, "author": "Odd", "author_id": 11908, "author_profile": "https://Stackoverflow.com/users/11908", "pm_score": 0, "selected": false, "text": "public void Method<T>()\n{\n Type type = typeof(T);\n\n T newObject = (T)type.GetConstructor(new System.Type[] { }).Invoke(n...
2008/11/20
[ "https://Stackoverflow.com/questions/303955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305008/" ]
303,956
<p>Is it possible using <a href="https://jquery.com/" rel="noreferrer">jQuery</a> to select all <code>&lt;a&gt;</code> links which href ends with "ABC"?</p> <p>For example, if I want to find this link <code>&lt;a href="http://server/page.aspx?id=ABC"&gt;</code></p>
[ { "answer_id": 303961, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 12, "selected": true, "text": " $('a[href$=\"ABC\"]')...\n" }, { "answer_id": 3113845, "author": "Ash", "author_id": 375704, "au...
2008/11/20
[ "https://Stackoverflow.com/questions/303956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36036/" ]
303,970
<p>I am having trouble constructing a single XPath statement to return two different sets of attributes. </p> <p>For example take the following XML document:</p> <pre><code>&lt;root&gt; &lt;line name="one" alpha="a1" beta="b1"/&gt; &lt;line name="two" alpha="a2" beta="b2"/&gt; &lt;line name="three" alpha="a3" beta="b3"/&gt; &lt;/root&gt; </code></pre> <p>If I use the following XPath statement:</p> <pre><code>//@alpha </code></pre> <p>It yields the following attribute set:</p> <pre><code>alpha="a1" alpha="a2" alpha="a3" </code></pre> <p>What statement do I use to yield the following attribute set:</p> <pre><code>alpha="a1" alpha="a2" alpha="a3" beta="b1" beta="b2" beta="b3" </code></pre>
[ { "answer_id": 303999, "author": "Oppositional", "author_id": 2029, "author_profile": "https://Stackoverflow.com/users/2029", "pm_score": 5, "selected": true, "text": "|" }, { "answer_id": 304003, "author": "Mads Hansen", "author_id": 14419, "author_profile": "https:/...
2008/11/20
[ "https://Stackoverflow.com/questions/303970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3810/" ]
303,987
<p>Is there any way in Linq to check to see if a record of a parent exists in its children? </p> <p>I have a table that has a foreign key relationship with 12 other tables. All I want to do is see if any records in those child tables depend on the parent, so I can delete it without causing errors with FK constraints. </p> <p>Thanks guys.</p> <p>I ended up just making an extension class that checked each one... Time consuming but got the job done... I would still like opinions if possible</p>
[ { "answer_id": 304074, "author": "matt_dev", "author_id": 39086, "author_profile": "https://Stackoverflow.com/users/39086", "pm_score": 0, "selected": false, "text": " ParentChildrenDataContext context = new ParentChildrenDataContext();\n\n var child1Ids = from c in context...
2008/11/20
[ "https://Stackoverflow.com/questions/303987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4144/" ]
303,994
<p>Is it possible for me to turn on audit logging on my mysql database?</p> <p>I basically want to monitor all queries for an hour, and dump the log to a file.</p>
[ { "answer_id": 304008, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 8, "selected": true, "text": "mysqld --log=log_file_name\n" }, { "answer_id": 14403905, "author": "Alexandre Marcondes", "author_id...
2008/11/20
[ "https://Stackoverflow.com/questions/303994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
304,010
<p>I have a multi-threaded application that is hanging on a call to _dl_sysinfo_int80(). According to gdb, all threads are stuck in this call.</p> <p>The top of the stack trace looks like:</p> <pre><code>#0 0x002727a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x004f23de in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0 #2 0x004ef00b in _L_mutex_lock_35 () from /lib/tls/libpthread.so.0 #3 0x092828ac in construction vtable for std::ostream-in-std::basic_stringstream&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; () </code></pre> <p>Any idea what could be causing this?</p>
[ { "answer_id": 305277, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 0, "selected": false, "text": "_dl_sysinfo_int80" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/304010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1449/" ]
304,011
<p>What's the easiest way to truncate a C++ <code>float</code> variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?</p>
[ { "answer_id": 304013, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 4, "selected": true, "text": "char sz[64];\ndouble lf = 0.600000002;\nsprintf(sz, \"%.4lf\\n\", lf); //sz contains 0.6000\n\ndouble lf2 = atof(sz);\...
2008/11/20
[ "https://Stackoverflow.com/questions/304011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191808/" ]
304,041
<p>I've been working with Vector2's and XNA, and I've come to find that calling the Normalize() member function on a Zero Vector normalizes it to a vector of {NaN, NaN}. This is all well and good, but in my case I'd prefer it instead just leave them as Zero Vectors.</p> <p>Adding this code to my project enabled a cute extension method:</p> <pre><code>using ExtensionMethods; namespace ExtensionMethods { public static class MyExtensions { public static Vector2 NormalizeOrZero(this Vector2 v2) { if (v2 != Vector2.Zero) v2.Normalize(); return v2; } } } </code></pre> <p>Unfortunately, this method <em>returns</em> the normalized vector, rather than simply normalizing the vector which I use to invoke this extension method. I'd like to to instead behave as <em>vector2Instance</em>.Normalize() does.</p> <p>Aside from making this void, how do I adjust this so that the 'v2' is modified? (Essentially, I need access to the 'this' object, or I need 'v2' to be passed by reference.)</p> <p>Edit:</p> <p>And yes, I have tried this:</p> <pre><code> public static void NormalizeOrZero(this Vector2 v2) { if (v2 != Vector2.Zero) v2.Normalize(); } </code></pre> <p>Doesn't work, v2 is just a variable in the scope of NormalizeOrZero.</p>
[ { "answer_id": 304077, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 0, "selected": false, "text": "Vector2 v2 = new Vector2()\nv2 = v2.NormalizeOrZero();\n" }, { "answer_id": 304098, "author": "yfeldblum", "aut...
2008/11/20
[ "https://Stackoverflow.com/questions/304041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388/" ]
304,043
<p>I'm trying to generate pairwise combinations of rows on based on their ids. SQLite version is 3.5.9. The table contents are the following:</p> <pre><code>id|name|val 1|A|20 2|B|21 3|C|22 </code></pre> <p>with table schema being:</p> <pre><code>CREATE TABLE mytable ( id INTEGER NOT NULL, name VARCHAR, val INTEGER, PRIMARY KEY (id) ); </code></pre> <p>Then there's the self-join on ids:</p> <pre><code>sqlite&gt; select t1.id, t2.id from mytable as t1, mytable as t2 where t2.id &gt; t1.id; id|id 2|2 2|3 3|3 </code></pre> <p>Which is clearly not what I want. Now, changing the order of t2 and t1 produces the correct result:</p> <pre><code>sqlite&gt; select t1.id, t2.id from mytable as t2, mytable as t1 where t2.id &gt; t1.id; id|id 1|2 1|3 2|3 </code></pre> <p>Now, for another experiment, I tried combining on a numeric column other than row id. That, on the other hand, gives correct result in both cases.</p> <p>I am hoping someone can give an insight into what's going on here. As far as I understand, its either a bug in SQLite or some delicate aspect of SQL I don't know.</p> <p>Thanks,</p>
[ { "answer_id": 305680, "author": "converter42", "author_id": 28974, "author_profile": "https://Stackoverflow.com/users/28974", "pm_score": 0, "selected": false, "text": "SQLite version 3.6.2\nEnter \".help\" for instructions\nEnter SQL statements terminated with a \";\"\nsqlite> create t...
2008/11/20
[ "https://Stackoverflow.com/questions/304043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39167/" ]
304,049
<p>Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend?</p>
[ { "answer_id": 312741, "author": "RichieHH", "author_id": 37370, "author_profile": "https://Stackoverflow.com/users/37370", "pm_score": 4, "selected": true, "text": "(setq load-path\n (append (list nil\n \"~/.emacs.d/python-mode-1.0/\"\n \"~/.emacs.d/py...
2008/11/20
[ "https://Stackoverflow.com/questions/304049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37370/" ]
304,081
<p>I'm building a winForms app in NET3.5SP1 using VS2008Express. Am trying to deserialize an object using the System.Web.Script.Serialization library.</p> <p>The error is: Type 'jsonWinForm.Category' is not supported for deserialization of an array.</p> <p>Cheers!</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Web; using System.Net; using System.IO; using System.Web.Script.Serialization; namespace jsonWinForm { public class Category { public int categoryid; public string name; public int serverimageid; public DateTime dateuploaded; public bool enabled; } public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { using (WebClient client = new WebClient()) { //manipulate request headers (optional) client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); string targetUri = "http://www.davemateer.com/ig/genius/category.php"; //execute request and read response as string to console using (StreamReader reader = new StreamReader(client.OpenRead(targetUri))) { string s = reader.ReadToEnd(); textBox1.Text = s; Category cat = new Category(); JavaScriptSerializer serializer = new JavaScriptSerializer(); // this fails with a //Type 'jsonWinForm.Category' is not supported for deserialization of an array. serializer.Deserialize&lt;Category&gt;(s); } } } } } </code></pre>
[ { "answer_id": 304157, "author": "Dave Mateer", "author_id": 26086, "author_profile": "https://Stackoverflow.com/users/26086", "pm_score": 4, "selected": false, "text": "JavaScriptSerializer serializer = new JavaScriptSerializer();\n\n// create a generic list of categories\nList<Category...
2008/11/20
[ "https://Stackoverflow.com/questions/304081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26086/" ]
304,088
<p>The comment to <a href="https://stackoverflow.com/questions/200090/how-do-you-convert-a-c-string-to-an-int#200099">this answer</a> got me wondering. I've always thought that C was a proper subset of C++, that is, any valid C code is valid C++ code by extension. Am I wrong about that? Is it possible to write a valid C program that is not valid C++ code?</p> <p>EDIT: This is really similar to, but not an exact duplicate of <a href="https://stackoverflow.com/questions/145096/is-c-actually-a-superset-of-c#145098">this question</a>.</p>
[ { "answer_id": 304091, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 6, "selected": true, "text": "int *new;//<-- new is not a keyword in C\nchar *p = malloc(1024); //void * to char* without cast \n" }, { "ans...
2008/11/20
[ "https://Stackoverflow.com/questions/304088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
304,093
<p>I was wondering why <code>shared_ptr</code> doesn't have an implicit constructor. The fact it doesn't is alluded to here: <a href="https://stackoverflow.com/questions/142391/getting-a-boostsharedptr-for-this">Getting a boost::shared_ptr for this</a></p> <p>(I figured out the reason but thought it would be a fun question to post anyway.)</p> <pre><code>#include &lt;boost/shared_ptr.hpp&gt; #include &lt;iostream&gt; using namespace boost; using namespace std; void fun(shared_ptr&lt;int&gt; ptr) { cout &lt;&lt; *ptr &lt;&lt; endl; } int main() { int foo = 5; fun(&amp;foo); return 0; } /* shared_ptr_test.cpp: In function `int main()': * shared_ptr_test.cpp:13: conversion from `int*' to non-scalar type ` * boost::shared_ptr&lt;int&gt;' requested */ </code></pre>
[ { "answer_id": 304183, "author": "user35978", "author_id": 35978, "author_profile": "https://Stackoverflow.com/users/35978", "pm_score": -1, "selected": false, "text": "int main() {\n\n int foo = 5;\n fun(&foo);\n\n cout << foo << endl; // ops!!\n\n return 0;\n}\n" }, { ...
2008/11/20
[ "https://Stackoverflow.com/questions/304093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
304,109
<p>Having the window handle for an open application, I'm able to use the GetWindowText function to retrieve the text from the title bar of the app. I would like to take this a step farther and retrieve the icon associated with the same app. </p> <p>How might I go about doing this? I looked through what I thought would be the relevant Win32 API sections, but nothing jumped out at me.</p> <p>Any pointers would be appreciated.</p> <p>Thanks in advance!</p>
[ { "answer_id": 304120, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 5, "selected": true, "text": "Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n" }, { "answer_id": 14053737, "author"...
2008/11/20
[ "https://Stackoverflow.com/questions/304109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39171/" ]
304,117
<p>Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. </p> <p>What I'd like to model is:</p> <p>A blog article which can be given 0-n tags. Many blog articles can share the same tag. When retrieving data would like to allow retrieval of all articles matching a tag. In many ways very similar to the approach taken here at stackoverflow.</p> <p>My normal mindset would be to create a many-to-may relationship between tags and blog articles. However, I'm thinking in the context of GAE that this would be expensive, although I have seen examples of it being done. </p> <p>Perhaps using a ListProperty containing each tag as part of the article entities, and a second data model to track tags as they're added and deleted? This way no need for any relationships and the ListProperty still allows queries where any list element matching will return results.</p> <p>Any suggestions on the most efficient way to approach this on GAE?</p>
[ { "answer_id": 307312, "author": "ianb", "author_id": 20218, "author_profile": "https://Stackoverflow.com/users/20218", "pm_score": 1, "selected": false, "text": "Expando" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/304117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26241/" ]
304,129
<p>How do I return a constant from an sql statement? </p> <p>For example how would I change the code below so "my message" would return if my (boolean expression) was true</p> <pre><code>if (my boolean expression) "my message" else select top 1 name from people; </code></pre> <p>I am using ms sql 2000</p>
[ { "answer_id": 304138, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 6, "selected": true, "text": "select 'my message';\n" }, { "answer_id": 304149, "author": "Vinko Vrsalovic", "author_id": 5190, ...
2008/11/20
[ "https://Stackoverflow.com/questions/304129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
304,130
<p>Based on the advice provided at <a href="http://www.tweakguides.com/VA_4.html" rel="nofollow noreferrer">http://www.tweakguides.com/VA_4.html</a> to prevent Windows Vista from "intelligently" rearranging column formats in Windows Explorer, I have written a script to automate the process a little.</p> <pre><code>Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") 'Remove the "filthy" reg keys first. regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU\" WScript.Echo "Deleting " &amp; regKey &amp; VbCrLf WshShell.RegDelete regKey regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" WScript.Echo "Deleting " &amp; regKey &amp; VbCrLf WshShell.RegDelete regKey 'Then recreate a clean Bags key, with sub-keys and FolderType value. regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\ Windows\Shell\Bags\AllFolders\Shell\FolderType" WScript.Echo "Creating " &amp; regKey &amp; " as 'NotSpecified' REG_SZ " &amp; VbCrLf WshShell.RegWrite regKey, "NotSpecified", "REG_SZ" WScript.Echo "Now define the columns of your preference in Windows Explorer," &amp; VbCrLf WScript.Echo "and click the Apply to Folders button in Folder Options." &amp; VbCrLf </code></pre> <p>But it is refusing to delete the registry key</p> <pre><code>E:\archive\settings\Windows Vista Explorer columns.vbs(9, 1) WshShell.RegDelete: Unable to remove registry key "HKCU\Software\Classes\Local Settings\Software\Mi crosoft\Windows\Shell\BagMRU\". </code></pre> <p>The suggestion is to put trailing "\" to indicate a key, which I did. Any ideas?</p>
[ { "answer_id": 9645214, "author": "aelgoa", "author_id": 1260792, "author_profile": "https://Stackoverflow.com/users/1260792", "pm_score": 1, "selected": false, "text": "Const HKCR=&H80000000:Const HKCU=&H80000001:Const HKLM=&H80000002:Const HKU=&H80000003:Const HKCC=&H80000005\n\ndim pc...
2008/11/20
[ "https://Stackoverflow.com/questions/304130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2663/" ]
304,139
<p>So the chain of events is:</p> <ol> <li>The user submits a form.</li> <li>During the processing of the submission, there is a message generated, such as "Your record was saved."</li> <li>The user is redirected to a new page, say the search results.</li> <li>The new page needs to display the message.</li> </ol> <p>So, the question is how to get the message from step 2 to step 3? This is only one simple example...there are many other much more complicated examples.</p> <p>I am using PHP.</p> <p>Needs:</p> <ul> <li>supports multiple messages and need to be formatted on the receiving machine as required</li> <li>messages can be added on the same page (such as within step 4)</li> <li>messages added from inside any function or object</li> </ul> <p>Some options I have come up with:</p> <ul> <li>store in a session variable as an array and emptied after each display</li> <li>pass as a get or query parameter; can get annoying as you are constantly processing this and have to remember to get it; as it can get long, it could easily go over the max length of the query string</li> <li>store in the database on a per session basis (may not always be for a logged in user); this would require an extra insert on each page where they are added, possibly multiple, and an extra select on every page</li> </ul> <p>Currently I have been storing the messages in the session in an array, but I'm wondering if there is a better way. I don't think the other 2 options above are very good.</p> <p><strong>Edit:</strong> I use 2 functions for the session method: AddStatusMsg() (adds an element to the array) and DisplayStatusMsg() (returns an HTML formatted message and empties the array).</p>
[ { "answer_id": 304168, "author": "dylanfm", "author_id": 38795, "author_profile": "https://Stackoverflow.com/users/38795", "pm_score": 0, "selected": false, "text": "<?php class session\n" }, { "answer_id": 304178, "author": "Murat Ayfer", "author_id": 25910, "author_...
2008/11/20
[ "https://Stackoverflow.com/questions/304139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
304,152
<p>I am using Python and the <a href="http://twistedmatrix.com/trac/" rel="nofollow noreferrer">Twisted</a> framework to connect to an FTP site to perform various automated tasks. Our FTP server happens to be Pure-FTPd, if that's relevant.</p> <p>When connecting and calling the <strong>list</strong> method on an <strong>FTPClient</strong>, the resulting <strong>FTPFileListProtocol</strong>'s <strong>files</strong> collection does not contain any directories or file names that contain a space (' ').</p> <p>Has anyone else seen this? Is the only solution to create a sub-class of FTPFileListProtocol and override its <strong>unknownLine</strong> method, parsing the file/directory names manually?</p>
[ { "answer_id": 311236, "author": "Martin Carpenter", "author_id": 39443, "author_profile": "https://Stackoverflow.com/users/39443", "pm_score": 3, "selected": true, "text": "NLST" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/304152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2696/" ]
304,213
<p>I am using the ASP.NET <strong>Client-Side</strong> ajax control toolkit in my asp.net MVC application. I see that there is a .js file named "AjaxControlToolkit.ModalPopup.ModalPopupBehavior.js" in the AjaxControlToolkit folder. However, I cannot find any examples on how to use it.<br /><br /> [Edit] - As mentioned, I am using the Client-side, Script-only control toolkit. For those unfamiliar, here is the description from CodePlex:<br/></p> <blockquote> <p>AjaxControlToolkit-ScriptFilesOnly.zip contains script files, CSS style sheets and pictures used by the toolkit. Use this download if you don't want to use embedded resources and prefer a file-based model.</p> </blockquote> <p>I have not been able to find many resources on how to use some of the scripts included with this. CodePlex link: <a href="http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx" rel="nofollow noreferrer">http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx</a></p>
[ { "answer_id": 759377, "author": "Gramic", "author_id": 18788, "author_profile": "https://Stackoverflow.com/users/18788", "pm_score": 3, "selected": true, "text": "<script src=\"javascripts/MicrosoftAjax.js\" type=\"text/javascript\" ></script>\n<script src=\"javascripts/AjaxControlToolk...
2008/11/20
[ "https://Stackoverflow.com/questions/304213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37786/" ]
304,216
<p>Is there a way to find all nodes in a xml tree using cElementTree? The findall method works only for specified tags.</p>
[ { "answer_id": 304220, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": true, "text": "etree.findall('.//*')\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/304216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
304,226
<p>I have a custom NSTableView subclass which is bound to a data source (an NSArray) which updates asynchronously. When items are added to the array, rows are automatically added to the tableview. Awesome!</p> <p>My question is this: How can I detect that this magic has happened so that I can perform some other tasks related to the display of my custom tableview? Is there a method that I can override in my subclass which will be called when the tableview is updated?</p>
[ { "answer_id": 304304, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 4, "selected": true, "text": "enclosingScrollView" }, { "answer_id": 991114, "author": "Community", "author_id": -1, "author...
2008/11/20
[ "https://Stackoverflow.com/questions/304226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33686/" ]
304,233
<p>I'm trying to use the ASP.NET MVC Ajax.BeginForm helper but don't want to use the existing content insertion options when the call completes. Instead, I want to use a custom JavaScript function as the callback.</p> <p>This works, but the result I want should be returned as JSON. Unfortunately, the framework just treats the data as a string. Below is the client code. The server code simply returns a JsonResult with one field, UppercaseName.</p> <pre><code>&lt;script type='text/javascript'&gt; function onTestComplete(content) { var result = content.get_data(); alert(result.UppercaseName); } &lt;/script&gt; &lt;% using (Ajax.BeginForm("JsonTest", new AjaxOptions() {OnComplete = "onTestComplete" })) { %&gt; &lt;%= Html.TextBox("name") %&gt;&lt;br /&gt; &lt;input type="submit" /&gt; &lt;%} %&gt; </code></pre> <p>Instead of showing the uppercase result, it is instead showing undefined. content.get_data() seems to hold the JSON, but only in string form. How do I go about converting this to an object?</p> <p>All of this seems a bit convoluted really. Is there a better way to get at the resulting content using Ajax.BeginForm? If it's this hard, I may skip Ajax.BeginForm entirely and just use the jQuery form library.</p>
[ { "answer_id": 304517, "author": "Kobi", "author_id": 39215, "author_profile": "https://Stackoverflow.com/users/39215", "pm_score": 5, "selected": true, "text": "var json_data = content.get_response().get_object();\n" }, { "answer_id": 2107434, "author": "Russel", "author...
2008/11/20
[ "https://Stackoverflow.com/questions/304233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2656/" ]
304,240
<pre><code>&lt;?php class foo { //this class is always etended, and has some other methods that do utility work //and are never overrided public function init() { //what do to here to call bar-&gt;doSomething or baz-&gt;doSomething //depending on what class is actually instantiated? } function doSomething() { //intentionaly no functionality here } } class bar extends foo { function doSomething() { echo "bar"; } } class baz extends foo { function doSomething() { echo "baz"; } } ?&gt; </code></pre>
[ { "answer_id": 304245, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 1, "selected": false, "text": "public function init() {\n $this->doSomething();\n}\n\n$obj = new bar();\n$obj->doSomething(); // prints \"bar\"\n\n$obj2 = ...
2008/11/20
[ "https://Stackoverflow.com/questions/304240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39183/" ]
304,249
<p>I assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any suggestions for an optimal chunk of bytes per write for sending data over a network?</p> <p>To elaborate a bit more, I'm implementing something that sends data over a network connection and show the progress of that data being sent. I've noticed if I send large files at about 100 bytes each write, it is extremely slow but the progress bar works out very nicely. However, if I send at say 1M per write, it is much faster, but the progress bar doesn't work as nicely due to the larger chunks being sent.</p>
[ { "answer_id": 304841, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 2, "selected": false, "text": "Private PreferredTransferDuration As Integer = 1800 ' milliseconds, the timespan the class will attempt to achieve for each...
2008/11/20
[ "https://Stackoverflow.com/questions/304249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39185/" ]
304,256
<p>The Python <a href="http://www.python.org/doc/2.5.2/lib/datetime-datetime.html" rel="noreferrer"><code>datetime.isocalendar()</code></a> method returns a tuple <code>(ISO_year, ISO_week_number, ISO_weekday)</code> for the given <code>datetime</code> object. Is there a corresponding inverse function? If not, is there an easy way to compute a date given a year, week number and day of the week?</p>
[ { "answer_id": 304288, "author": "Tom", "author_id": 3715, "author_profile": "https://Stackoverflow.com/users/3715", "pm_score": -1, "selected": false, "text": "strptime" }, { "answer_id": 1700069, "author": "Ben James", "author_id": 189179, "author_profile": "https:/...
2008/11/20
[ "https://Stackoverflow.com/questions/304256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
304,268
<p>I am looking to use Java to get the MD5 checksum of a file. I was really surprised but I haven't been able to find anything that shows how to get the MD5 checksum of a file.</p> <p>How is it done?</p>
[ { "answer_id": 304275, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 7, "selected": false, "text": "import java.io.*;\nimport java.security.MessageDigest;\n\npublic class MD5Checksum {\n\n public static byte[] crea...
2008/11/20
[ "https://Stackoverflow.com/questions/304268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24998/" ]
304,270
<p>Ok, I have one JavaScript that creates rows in a table like this:</p> <pre><code> function AddRow(text,rowID) { var tbl = document.getElementById('tblNotePanel'); var row = tbl.insertRow(tbl.rows.length); var cell = row.insertCell(); var textNode = document.createTextNode(text); cell.id = rowID; cell.style.backgroundColor = &quot;gold&quot;; cell.onclick = clickTest; cell.appendChild(textNode); } </code></pre> <p>In the above function, I set the cell's <code>onclick</code> function to call another JavaScript function called <code>clickTest</code>. My question is when I assign the <code>onclick</code> event to call <code>clickTest</code>, how do I set parameter information to be sent when the <code>clickTest</code> method is called on the cell's <code>onclick</code> event? Or, how do I access the cell's ID in the <code>clickTest</code> function?</p> <p>Thanks, Jeff</p>
[ { "answer_id": 304282, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 2, "selected": false, "text": "this" }, { "answer_id": 304283, "author": "tvanfosson", "author_id": 12950, "author_profile": "h...
2008/11/20
[ "https://Stackoverflow.com/questions/304270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12172/" ]
304,281
<p>I can't figure out how to get the SCOPE_IDENTITY() back to my variables from an SQL2005 Store Procedure.</p> <p>My sSQL String:</p> <pre><code>sSQL = "EXEC [sp_NewClaim] " &amp; Chr(34) &amp; ClaimNumber &amp; Chr(34) &amp; ", " &amp; Request.Cookies("UserID") &amp; ", " &amp; Request.Cookies("MasterID") &amp; ", " &amp; Chr(34) &amp; strRestaurante &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Fecha &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Hora &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Request("Tiempo") &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Request("Luz") &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Request("Desc") &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Request("incidente") &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; Request("codigos") &amp; Chr(34) &amp; ", False, 0; SELECT RecordNumber = SCOPE_IDENTITY()" </code></pre> <p>My sSQL Output:</p> <pre><code>EXEC [sp_NewClaim] "W200811", 7, 8, "Otro -- WORK PLEASE", "11/19/2008", "01:19 PM", "Nublado", "Mala", "asdasd", "uyiuyui", "C-Junta", False, 0; SELECT RecordNumber = SCOPE_IDENTITY() </code></pre> <p>Executing my SQL Command:</p> <pre><code>Set rsData= Server.CreateObject("ADODB.Recordset") rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic </code></pre> <p>Trying to Output the SCOPE_IDENTITY() Produces an Empty Variable (No Output):</p> <pre><code>Response.Write("&lt;br /&gt;Record Number: " &amp; rsData("RecordNumber")) </code></pre> <p>The Store Procedure runs correctly. My Information gets stored into my database with out problems. RecordNumber is the Column with the Identity, and the Store Procedure has defined @RecordNumber as an Output:</p> <pre><code>USE [db_clcinsurance_com] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE sp_NewClaim ( @ClaimNumber nvarchar(50), @blah............ ................. @RecordNumber INT OUTPUT ) AS BEGIN INSERT INTO Accidente (ClaimNumber,........., RecordNumber) VALUES (@ClaimNumber,....., @RecordNumber) SET @RecordNumber = SCOPE_IDENTITY(); END </code></pre>
[ { "answer_id": 304294, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "CREATE PROCEDURE sp_NewClaim\n (\n @ClaimNumber nvarchar(50),\n @blah............\n .................\n)\nAS\n...
2008/11/20
[ "https://Stackoverflow.com/questions/304281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38678/" ]
304,290
<p>Why do I have to specify <code>runat="server"</code> on all my ASP.NET controls when it is a mandatory attribute and <code>server</code> is the only option available in my limited knowledge of ASP.NET, and I get an error if I don't use it?</p> <p>I do understand that I can optionally use it on my HTML tags, and I do understand the client/server paradigm and what it is actually specifying.</p> <p>Is it a redundant tag that could just be implied by the control being an ASP.NET control, or is there an underlying reason?</p>
[ { "answer_id": 304306, "author": "Dave Swersky", "author_id": 34796, "author_profile": "https://Stackoverflow.com/users/34796", "pm_score": 4, "selected": false, "text": "<INPUT type=\"submit\" runat=server />" }, { "answer_id": 304307, "author": "George Stocker", "author...
2008/11/20
[ "https://Stackoverflow.com/questions/304290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
304,317
<p>Does MySQL index foreign key columns automatically?</p>
[ { "answer_id": 33893061, "author": "Navrattan Yadav", "author_id": 3665000, "author_profile": "https://Stackoverflow.com/users/3665000", "pm_score": 2, "selected": false, "text": "Innodb" }, { "answer_id": 34448500, "author": "Ali Raza", "author_id": 5713574, "author_...
2008/11/20
[ "https://Stackoverflow.com/questions/304317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
304,319
<p>As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name.</p> <p>Is there an equivalent to the UNIX command 'which'?</p> <p>On UNIX, <code>which command</code> prints the full path of the given command to easily find and repair these shadowing problems.</p>
[ { "answer_id": 304392, "author": "RexE", "author_id": 38146, "author_profile": "https://Stackoverflow.com/users/38146", "pm_score": 6, "selected": false, "text": "($Env:Path).Split(\";\") | Get-ChildItem -filter programName*\n" }, { "answer_id": 304441, "author": "paxdiablo",...
2008/11/20
[ "https://Stackoverflow.com/questions/304319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34596/" ]
304,322
<p>Is there a way I can export my Silverlight DataGrid data to excel or csv?</p> <p>I searched the web but can't find any examples!</p> <p>Thanks a lot </p>
[ { "answer_id": 353671, "author": "DaniCE", "author_id": 19046, "author_profile": "https://Stackoverflow.com/users/19046", "pm_score": 2, "selected": false, "text": "public String ExportDataGrid(DataGrid grid)\n{\n string colPath;\n System.Reflection.PropertyInfo propInfo;\n Syst...
2008/11/20
[ "https://Stackoverflow.com/questions/304322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
304,323
<p>What is the best way to integrate an external script into the Zend Framework? Let me explain because I may be asking this the wrong way. I have a script that downloads and parses an XML file. This script, which runs as a daily cron job, needs to dump its data into the database.</p> <p>I am using Zend Framework for the site which uses this script and it seems to me that it would be best to use my subclassed model of <code>Zend_Db_Abstract</code> to do the adding and updating of the database. How does one go about doing this? Does my script go in the library next to the Zend Components (i.e. library/Mine/Xmlparse.php) and thus have access to the various ZF components? Do I simply need to include the correct model files and the Zend DB component in the file itself? What is the best way to handle this sort of integration?</p>
[ { "answer_id": 304838, "author": "smack0007", "author_id": 26566, "author_profile": "https://Stackoverflow.com/users/26566", "pm_score": 1, "selected": false, "text": "require_once('Zend/Loader.php');\nZend_Loader::registerAutoload();\n" }, { "answer_id": 305761, "author": "S...
2008/11/20
[ "https://Stackoverflow.com/questions/304323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
304,356
<p>I've written a script which takes the summary of an order and stores in into an XML file, except the problem is that I don't want people to be able to open the XML file in their browser, obviously.</p> <p>I'm hosted on a very dodgy shared server with limited abilities: no SSH, for starters.</p> <p><strong>Is there a place I can put this file so that PHP will still be able to read/write to it, but web browsers won't be able to get to it?</strong></p> <p>Ordinarily, I'd create a folder outside the document root and put it there, but I get a "Permission denied" message when I try that.</p> <p>The folders which <em>are</em> there are:</p> <ul> <li>anon_ftp</li> <li>bin</li> <li>cert</li> <li>cgi-bin</li> <li>conf</li> <li>error_docs</li> <li>etc</li> <li>httpdocs</li> <li>httpsdocs</li> <li>pd</li> <li>private</li> <li>statistics</li> <li>subdomains</li> <li>web_users</li> </ul> <p>PHP can't access the file when it's in the <code>private</code> folder. Would this be possible using .htaccess?</p>
[ { "answer_id": 304380, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 2, "selected": true, "text": "<Files ~ \"myfile.xml\">\n Order allow,deny\n Deny from all\n</Files>\n" }, { "answer_id": 304439, "author": ...
2008/11/20
[ "https://Stackoverflow.com/questions/304356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
304,371
<p>I'm looking to get some help on using the <a href="http://malsup.com/jquery/cycle/" rel="nofollow noreferrer">cycle</a> library for jQuery. I'm in the <a href="http://malsup.com/jquery/cycle/begin.html" rel="nofollow noreferrer">beginner</a> demos, and I got the absolute first one completed. This is the second one on the page.</p> <pre><code>&lt;script src="jquery-1.2.6.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="jquery.cycle.all.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('.pics').cycle({ fx: 'scrollDown', speed: 300, timeout: 2000 }); &lt;/script&gt; </code></pre> <p>My CSS is identical to the one on the page, that's why I put .pics in the quotes.</p>
[ { "answer_id": 304475, "author": "seanb", "author_id": 3354, "author_profile": "https://Stackoverflow.com/users/3354", "pm_score": 2, "selected": false, "text": "$(document).ready(function() { \n $('.pics').cycle({ \n fx: 'scrollDown', \n speed: 300, \n t...
2008/11/20
[ "https://Stackoverflow.com/questions/304371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
304,373
<p>I have the following .aspx page, and I want to view it in web browsers such as IE or Google Chrome by opening it directly in those browsers:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But somehow the browsers can't render it. In IE, the error is </p> <blockquote> <p>Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. A name was started with an invalid character. Error processing resource 'file:/</p> </blockquote> <pre><code> &lt;%@ Page Language="C#"AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %&gt; -^* </code></pre> <p>What did I do wrong?</p>
[ { "answer_id": 304379, "author": "Brettski", "author_id": 5836, "author_profile": "https://Stackoverflow.com/users/5836", "pm_score": 3, "selected": true, "text": "%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\" Inherits=\"WebApplication1._Default\" %>" ...
2008/11/20
[ "https://Stackoverflow.com/questions/304373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
304,383
<p>Is there a way to edit the log message of a certain revision in Subversion? I accidentally wrote the wrong filename in my commit message which could be confusing later.</p> <p>I've seen <em><a href="https://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git">How do I edit an incorrect commit message in Git?</a></em>, but the solution to that question doesn't seem to be similar for Subversion (according to <code>svn help commit</code>).</p>
[ { "answer_id": 304390, "author": "Kamil Kisiel", "author_id": 15061, "author_profile": "https://Stackoverflow.com/users/15061", "pm_score": 10, "selected": true, "text": "$svn propedit -r N --revprop svn:log URL \n$svn propset -r N --revprop svn:log \"new log message\" URL \n" }, { ...
2008/11/20
[ "https://Stackoverflow.com/questions/304383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
304,384
<p>How do I compare two images &amp; recognize the pattern in an image irrespective of its size and pattern size, and using .Net C#? Also, which algorithms are used for doing so from Image Processing?</p>
[ { "answer_id": 9443757, "author": "Mandah Mr.", "author_id": 1228884, "author_profile": "https://Stackoverflow.com/users/1228884", "pm_score": 1, "selected": false, "text": " ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.921f);\n // find all matchings ...
2008/11/20
[ "https://Stackoverflow.com/questions/304384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
304,386
<p>I am trying to develop a plug-in for <a href="http://trac.webkit.org/wiki/QtWebKit" rel="nofollow noreferrer">QtWebkit</a>. But I am not able to find how to develop a plugin for QtWebKit, hopefully one that can be invoked by JavaScript. Does anyone know of any tutorials or documents that explain how to do this?</p> <p>Webkit has been intregated into Qt and this integrated package is called QtWebkit. They have provided new method for for plugin creation.</p> <p>-Regards, Vivek Gupta</p>
[ { "answer_id": 420163, "author": "Henrik Hartz", "author_id": 50830, "author_profile": "https://Stackoverflow.com/users/50830", "pm_score": 2, "selected": false, "text": "QWebPage" }, { "answer_id": 8020425, "author": "Kurt Pattyn", "author_id": 52568, "author_profile...
2008/11/20
[ "https://Stackoverflow.com/questions/304386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
304,389
<p>In VB.NET, which is better to use: function overloading or default parameters?</p>
[ { "answer_id": 304484, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "Process" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/304389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34588/" ]
304,391
<p>Say I have a string of 16 numeric characters (i.e. 0123456789012345) what is the most efficient way to delimit it into sets like : 0123-4567-8901-2345, in PHP?</p> <p>Note: I am rewriting an existing system that is painfully slow.</p>
[ { "answer_id": 304411, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": true, "text": "$string = '0123456789012345';\n$sets = str_split($string, 4);\nprint_r($sets);\n" }, { "answer_id": 312070, "au...
2008/11/20
[ "https://Stackoverflow.com/questions/304391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
304,393
<p>One of the <a href="http://www.sqlite.org/whentouse.html" rel="noreferrer">appropriate uses</a> for <a href="http://www.sqlite.org" rel="noreferrer">sqlite3</a> is "in-memory databases". This sounds like a really useful tool for my C++ applications. Does anyone have an example of how this is done in C or C++? I'm specifically looking for a canonical way to slurp several flat-files into an in-memory database, then do some joins.</p>
[ { "answer_id": 304402, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 3, "selected": false, "text": "ATTACH foo.db AS foo\n" }, { "answer_id": 333057, "author": "Danielb", "author_id": 39040, "author_pro...
2008/11/20
[ "https://Stackoverflow.com/questions/304393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14167/" ]
304,396
<p>I'm looking for some sample code that will sort the list items in an HTML list by alphabetical order. Can anyone help?</p> <p>Here is a sample list for people to work with:</p> <pre><code>&lt;ul class="alphaList"&gt; &lt;li&gt;apples&lt;/li&gt; &lt;li&gt;cats&lt;/li&gt; &lt;li&gt;bears&lt;/li&gt; &lt;/ul&gt; </code></pre>
[ { "answer_id": 304428, "author": "Chatu", "author_id": 39203, "author_profile": "https://Stackoverflow.com/users/39203", "pm_score": 8, "selected": true, "text": "var items = $('.alphaList > li').get();\nitems.sort(function(a,b){\n var keyA = $(a).text();\n var keyB = $(b).text();\n\n ...
2008/11/20
[ "https://Stackoverflow.com/questions/304396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
304,430
<p>When running the following code it leaves out one row. When I do a files.Count it says there are 4 rows but there is no data stored for the 4th row. When I run the stored procedure from within SQL Manager it returns all 4 rows and all the data. Any help?</p> <pre><code> List&lt;File&gt; files = new List&lt;File&gt;(); SqlConnection active_connection = new SqlConnection(m_connection_string); SqlCommand cmd = new SqlCommand(); SqlDataReader dr = null; try { active_connection.Open(); cmd.Connection = active_connection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "dalsp_Select_Organization_Files"; SqlParameter param; param = cmd.Parameters.Add("@p_organization_guid", SqlDbType.UniqueIdentifier); param.Value = new Guid(organization_guid); param = cmd.Parameters.Add("@p_file_type", SqlDbType.NVarChar, 50); param.Value = file_type; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { while (dr.Read()) { File file = new File(); file.OrganizationGuid = dr["OrganizationGuid"].ToString(); file.FileGuid = dr["FileGuid"].ToString(); file.FileLocation = dr["FileLocation"].ToString(); file.FileName = dr["FileName"].ToString(); file.FileType = (FileTypeEnum)Enum.Parse(typeof(FileTypeEnum), dr["FileType"].ToString()); file.FileExtension = dr["FileExtension"].ToString(); file.FileDescription = dr["FileDescription"].ToString(); file.ThumbnailPath = dr["ThumbnailPath"].ToString(); files.Add(file); } } dr.Close(); dr = null; active_connection.Close(); cmd = null; } catch (Exception) { throw; } finally { if (active_connection.State != ConnectionState.Closed) { active_connection.Close(); active_connection.Dispose(); } } return files; </code></pre>
[ { "answer_id": 304465, "author": "seanb", "author_id": 3354, "author_profile": "https://Stackoverflow.com/users/3354", "pm_score": 1, "selected": false, "text": "SqlParameter param = new SqlParameter(); \n// set param stuff - here or in ctor \ncmd.Parameters.Add(param); \n" }, { ...
2008/11/20
[ "https://Stackoverflow.com/questions/304430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36798/" ]
304,451
<p>I'm trying to avoid code like this when reusing the same ViewUserControl in ASP.NET MVC. Any suggestions?</p> <pre><code>&lt;% if (ViewContext.ViewData["editMode"].ToString() == "edit"){ %&gt; &lt;%= Html.SubmitButton("submit", "Update Brand")%&gt;&lt;span class="or"&gt;Or&lt;/span&gt;&lt;a href="#" class="cancel"&gt;Cancel&lt;/a&gt; &lt;% } else { %&gt; &lt;%= Html.SubmitButton("submit", "Create New Brand")%&gt;&lt;span class="or"&gt;Or&lt;/span&gt;&lt;a href="#" class="cancel"&gt;Cancel&lt;/a&gt; &lt;%} %&gt; </code></pre> <p>And ...</p> <pre><code>&lt;% if (ViewContext.ViewData["editMode"].ToString() == "edit"){ %&gt; &lt;h1 class="edit"&gt;Edit Brand Details&lt;/h1&gt; &lt;% } else { %&gt; &lt;h1 class="create"&gt;Create A New Brand&lt;/h1&gt; &lt;%} %&gt; </code></pre>
[ { "answer_id": 401913, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 2, "selected": false, "text": "<% string submitLabel = (ViewData[\"editMode\"].ToString() == \"edit\") ? \"Update Brand\" : \"Create New Brand\" %>\n<...
2008/11/20
[ "https://Stackoverflow.com/questions/304451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
304,461
<p>I need to do a join with a table/result-set/whatever that has the integers <code>n</code> to <code>m</code> inclusive. Is there a trivial way to get that without just building the table?</p> <p>(BTW what would that type of construct be called, a "<em>Meta query</em>"?)</p> <p><code>m-n</code> is bounded to something reasonable ( &lt; 1000's)</p>
[ { "answer_id": 304644, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 5, "selected": true, "text": "AUTO_INCREMENT" }, { "answer_id": 304711, "author": "ysth", "author_id": 17389, "author_profile": "...
2008/11/20
[ "https://Stackoverflow.com/questions/304461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]