qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
191,746
<p>Given the following HTML:</p> <pre><code>&lt;select name="my_dropdown" id="my_dropdown"&gt; &lt;option value="1"&gt;displayed text 1&lt;/option&gt; &lt;/select&gt; </code></pre> <p>How do I grab the string "displayed text 1" using Javascript/the DOM?</p>
[ { "answer_id": 191755, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 1, "selected": false, "text": "myOptionNode.childNodes[0];\n" }, { "answer_id": 191767, "author": "Liam", "author_id": 18333, "...
2008/10/10
[ "https://Stackoverflow.com/questions/191746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26848/" ]
191,757
<p>I thought this would be really simple, but it's presenting some difficulties. If I have</p> <pre><code>std::string name = &quot;John&quot;; int age = 21; </code></pre> <p>How do I combine them to get a single string <code>&quot;John21&quot;</code>?</p>
[ { "answer_id": 191775, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 2, "selected": false, "text": "itoa" }, { "answer_id": 191776, "author": "tloach", "author_id": 14092, "author_profile": "https://St...
2008/10/10
[ "https://Stackoverflow.com/questions/191757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
191,766
<p>When I get a java.io.InvalidClassException, it gives me the serialVersionUID that it wants, and the serialVersionUID that it got. Is there an easy way to tell which of my dozens of jars using the wrong serialVersionUID?</p> <p><strong>Update</strong>: I should mention that our intention is to update everything at the same time, but I'm trying to debug a problem in our build and deploy process.</p>
[ { "answer_id": 191822, "author": "entzik", "author_id": 12297, "author_profile": "https://Stackoverflow.com/users/12297", "pm_score": 2, "selected": false, "text": "java.io.ObjectStreamClass.getSerialVersionUID()" }, { "answer_id": 353985, "author": "user44722", "author_i...
2008/10/10
[ "https://Stackoverflow.com/questions/191766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
191,787
<p>I want to find a sql command or something that can do this where I have a table named tblFoo and I want to name it tblFooBar. However, I want the primary key to also be change, for example, currently it is:</p> <pre><code>CONSTRAINT [PK_tblFoo] PRIMARY KEY CLUSTERED </code></pre> <p>And I want a name change to change it to:</p> <pre><code>CONSTRAINT [PK_tblFooBar] PRIMARY KEY CLUSTERED </code></pre> <p>Then, recursively go through and cascade this change on all tables that have a foreigh key relationship, eg. from this:</p> <pre><code>CHECK ADD CONSTRAINT [FK_tblContent_tblFoo] FOREIGN KEY([fooID]) </code></pre> <p>To this:</p> <pre><code> CHECK ADD CONSTRAINT [FK_tblContent_tblFooBar] FOREIGN KEY([fooID]) </code></pre> <p>Naturally, I am trying not to go through and do this all manually because a) it is an error prone process, and b)it doesn't scale.</p>
[ { "answer_id": 191888, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 4, "selected": true, "text": "DECLARE\n @old_name VARCHAR(100),\n @new_name VARCHAR(100)\n\nSET @old_name = 'tblFoo'\nSET @new_name = 'tblFoo...
2008/10/10
[ "https://Stackoverflow.com/questions/191787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
191,788
<p>In my c# app, I've got a list that I navigate with an Enumerator. It works great for moving forward through the list, but the Enumerator class doesn't have a MoveBack method. </p> <p>Is there different class that has a MoveBack method, or do I need to write my own?</p>
[ { "answer_id": 384510, "author": "Hosam Aly", "author_id": 41283, "author_profile": "https://Stackoverflow.com/users/41283", "pm_score": 0, "selected": false, "text": "IEnumerator<int> e1 = yourListOfInt.GetEnumerator();\nIEnumerator<int> e2 = e1;\nfor (int i = 0; i < 3; ++i) e2.MoveNext...
2008/10/10
[ "https://Stackoverflow.com/questions/191788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26339/" ]
191,791
<p>I am hoping to find a way to do this in vb.net: </p> <p>Say you have function call getPaint(Color). You want the call to be limited to the parameter values of (red,green,yellow). When they enter that parameter, the user is provided the available options, like how a boolean parameter functions.</p> <p>Any ideas? </p>
[ { "answer_id": 191811, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 2, "selected": false, "text": "Enum Color\n Red = 1\n Green = 2\n Yellow = 3\nEnd Enum\n" }, { "answer_id": 191832, "author": "...
2008/10/10
[ "https://Stackoverflow.com/questions/191791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44449/" ]
191,808
<p>I'm currently looking at ways to allow people to select multiple files at once to batch upload images. I'm evaluating these options for my ASP.NET web app:</p> <ul> <li><a href="http://developer.yahoo.com/yui/uploader/" rel="nofollow noreferrer">YUI Uploader</a></li> <li><a href="http://www.codeplex.com/FlajaxianFileUpload" rel="nofollow noreferrer">Flajaxian</a></li> <li><a href="http://swfupload.org/" rel="nofollow noreferrer">SWFUpload</a></li> <li><a href="http://www.sitepen.com/blog/2008/09/02/the-dojo-toolkit-multi-file-uploader/" rel="nofollow noreferrer">Dojo Toolkit Multi file uploader</a></li> </ul> <p>I'm leaning toward YUI because the documentation is clear and I basically already wrote the file uploaders and thumbnailers which Flajaxian provides, the javascript seems more compact too. I can't even begin evaluating Dojo because it's unclear to me how to get the parts that would integrate with .NET out of the PHP examples.</p> <p>Has anyone had really good or really bad experiences with any of these?</p>
[ { "answer_id": 1368939, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 2, "selected": true, "text": "flickr" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/191808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
191,812
<p>How can I create a custom property for my .Net assembly which would then be visible under the Details tab in Windows explorer?</p> <p>Something to sit parallel with "File Description", "Type", "Product Version"... etc</p> <p>Update: To quote my comment to Lars ... "Whilst I would have liked to do this from within Visual studio, that is certainly not my priority. Actually I hope to integrate any solution into an existing nant build process. So affecting the assemblies post compile is entirely acceptable. Have you ever heard of such a tool?"</p> <p>Further Update: I'm not sure if what I'm talking about is an attribute or not, to clarify a little what I would like to creat in an entry in the following property page...</p> <p><img src="https://i.stack.imgur.com/GgG90.png" alt="alt text" title="Nunit Properties"></p>
[ { "answer_id": 191996, "author": "KyleLanser", "author_id": 12923, "author_profile": "https://Stackoverflow.com/users/12923", "pm_score": 2, "selected": false, "text": "[assembly: AssemblyDescription(\"One Line of Content Here\")]\n" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/191812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
191,817
<p>I'm roughing a layout together and doing some browser testing. Never came across this issue before, check out the contact form in the footer of this page</p> <p><a href="http://staging.terrilynn.com/fundraising/" rel="nofollow noreferrer"><a href="http://staging.terrilynn.com/fundraising/" rel="nofollow noreferrer">http://staging.terrilynn.com/fundraising/</a></a></p> <p>There is a div with a width of 298px floated to the right that comes first in the source order. It is followed by several other divs, each with their child form elements floated left.</p> <p>The div's that should appear to the left of right-floated message div are disappearing.</p> <p>Page displays correctly in firefox. Any help would be appreciated.</p> <pre><code>&lt;div id='footer-contact-form'&gt; &lt;h1&gt;Request Information &lt;span class='note'&gt;(all fields required)&lt;/span&gt;&lt;/h1&gt; &lt;form class="monkForm" method="post" action="http://my.ekklesia360.com/FormBuilder/handleSubmit.php" id="footer-info-request"&gt; &lt;fieldset&gt; &lt;legend&gt;Footer Info Request&lt;/legend&gt; &lt;div class="textarea required" id="w2376"&gt; &lt;p class="data"&gt; &lt;label for="area_2376"&gt;Message&lt;/label&gt; &lt;textarea id="area_2376" name="e_2376" rows="5" cols="20"&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class="text required" id="w2377"&gt; &lt;p class="data"&gt; &lt;label for="text_2377"&gt;Name&lt;/label&gt; &lt;input id="text_2377" type="text" name="e_2377" value="" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class="text required" id="w2378"&gt; &lt;p class="data"&gt; &lt;label for="text_2378"&gt;Phone&lt;/label&gt; &lt;input id="text_2378" type="text" name="e_2378" value="" /&gt; &lt;/p&gt;&lt;/div&gt; &lt;div class="text" id="w2379"&gt; &lt;p class="data"&gt; &lt;label for="text_2379"&gt;Email&lt;/label&gt; &lt;input id="text_2379" type="text" name="e_2379" value="" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;p id="formsubmit"&gt;&lt;input type="submit" name="submit" value="Send" /&gt;&lt;/p&gt; &lt;input type="hidden" name="token" value="8143f99c1d01b4d1207dbe7860e5586d" /&gt; &lt;input type="hidden" name="SITEID" value="2185" /&gt; &lt;input type="hidden" name="cpBID" value="367780" /&gt; &lt;input type="hidden" name="formslug" value="footer-info-request" /&gt; &lt;input type="hidden" name="CMSCODE" value="EKK" /&gt; &lt;input type="hidden" name="fkey" value="" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt;&lt;!-- #footer-contact-form --&gt; </code></pre>
[ { "answer_id": 191878, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "<p>" }, { "answer_id": 192076, "author": "matte", "author_id": 25768, "author_profile": "https://...
2008/10/10
[ "https://Stackoverflow.com/questions/191817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26858/" ]
191,826
<p>I'm actually developing a Web Service in Java using Axis 2. I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions :</p> <pre><code>public class MyService { public Object myMethod() throws MyException { [...] } } </code></pre> <p>I then generated the WSDL using Axis2 ant task. With the WSDL I generate a client stub to test my service. The generated code contains a "MyExceptionException" and the "myMethod" in the stub declare to throw this :</p> <pre><code>public class MyServiceStub extends org.apache.axis2.client.Stub { [...] public MyServiceStub.MyMethodResponse myMethod(MyServiceStub.MyMethod myMethod) throws java.rmi.RemoteException, MyExceptionException0 { [...] } [...] } </code></pre> <p>But when calling the method surrounded by a catch, the "MyExceptionException" is never transmitted by the server which transmit an AxisFault instead (subclass of RemoteException).</p> <p>I assume the problem is server-side but don't find where. The service is deployed as an aar file in the axis2 webapp on a tomcat 5.5 server. The services.xml looks like this :</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;service name="MyService" scope="application"&gt; &lt;description&gt;&lt;/description&gt; &lt;messageReceivers&gt; &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/&gt; &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/&gt; &lt;/messageReceivers&gt; &lt;parameter name="ServiceClass"&gt;MyService&lt;/parameter&gt; &lt;parameter name="ServiceTCCL"&gt;composite&lt;/parameter&gt; &lt;/service&gt; </code></pre> <p>If the behavior is normal then I'll drop the use of Exceptions (which is not vital to my project) but I'm circumspect why Java2WSDL generate custom &lt;wsdl:fault&gt; in operation input &amp; output declaration and WSDL2Java generate an Exception class (and declare to throw it in the stub method) if this is not usable...</p>
[ { "answer_id": 2919955, "author": "Russell", "author_id": 351795, "author_profile": "https://Stackoverflow.com/users/351795", "pm_score": 1, "selected": false, "text": " MyFaultException ex = new MyFaultException(\"My Exception Message\");\n MyFault fault = new MyFault();\n...
2008/10/10
[ "https://Stackoverflow.com/questions/191826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26859/" ]
191,842
<p>If I have a native C++ windows program (i.e. the entry point is WinMain) how do I view output from console functions like std::cout?</p>
[ { "answer_id": 191880, "author": "luke", "author_id": 16434, "author_profile": "https://Stackoverflow.com/users/16434", "pm_score": 5, "selected": false, "text": "#include <windows.h>\n#include <stdio.h>\n#include <fcntl.h>\n#include <io.h>\n#include <iostream>\n#include <fstream>\n#ifnd...
2008/10/10
[ "https://Stackoverflow.com/questions/191842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
191,844
<p>I have a Java array such as: </p> <pre><code>String[] arr = new String[] {"123","doc","projectReport.doc"}; </code></pre> <p>In my opinion the natural way to access would be: </p> <pre><code> #set($att_id = $arr[0]) #set($att_type = $arr[1]) #set($att_name = $arr[2]) </code></pre> <p>But that it is not working. I have come with this workaround. But it a bit too much code for such an easy task. </p> <pre><code>#set($counter = 0) #foreach($el in $arr) #if($counter==0) #set($att_id = $el) #elseif($counter==1) #set($att_type = $el) #elseif($counter==2) #set($att_name = $el) #end #set($counter = $counter + 1) #end </code></pre> <p>Is there any other way?</p>
[ { "answer_id": 192018, "author": "Brian", "author_id": 8959, "author_profile": "https://Stackoverflow.com/users/8959", "pm_score": 3, "selected": false, "text": "List" }, { "answer_id": 505343, "author": "Nathan Bubna", "author_id": 8131, "author_profile": "https://St...
2008/10/10
[ "https://Stackoverflow.com/questions/191844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
191,845
<p>Currently, I've got images (max. 6MB) stored as BLOB in a InnoDB table. As the size of the data is growing, the nightly backup is growing slower and slower hindering normal performance.</p> <p>So, the binary data needs to go to the file system. (pointers to the files will be kept in the DB.)</p> <p>The data has a tree like relation:</p> <pre><code>- main site - user_0 - album_0 - album_1 - album_n - user_1 - user_n etc... </code></pre> <p>Now I want the data to be distributed evenly trough the directory structure. How should I accomplish this?</p> <p>I guess I could try <code>MD5('userId, albumId, imageId');</code> and slice up the resulting string to get my directory path:</p> <pre> /var/imageStorage/f/347e/013b/c042/51cf/985f7ad0daa987d.jpeg </pre> <p>This would allow me to map the first character to a server and evenly distribute the directory structure over multiple servers.</p> <p>This would however <em>not</em> keep images organised per user, likely spreading the images for 1 album over multiple servers.</p> <p>My question is:<br> What is the best way to store the image data in the file system in a balanced way, while keeping user/album data together ?</p> <p>Am I thinking in the right direction? or is this the wrong way of doing things altogether?</p> <p><strong>Update:</strong><br> I will go for the <code>md5(user_id)</code> string slicing for the split up on highest level. And then put all user data in that same bucket. This will ensure an even distribution of data while keeping user data stored close together.</p> <pre> /var - imageStorage - f/347e/013b - f347e013bc04251cf985f7ad0daa987d - 0 - album1_10 - picture_1.jpeg - 1 - album1_1 - picture_2.jpeg - picture_3.jpeg - album1_11 - picture_n.jpeg - n - album1_n </pre> <p>I think I will use albumId splitted up from behind (I like that idea!) as to keep the number of albums per directory smaller (although it won't be necessary for most users). </p> <p>Thanks!</p>
[ { "answer_id": 191863, "author": "Node", "author_id": 7190, "author_profile": "https://Stackoverflow.com/users/7190", "pm_score": 6, "selected": true, "text": "UserID = 6435624 \nPath = /images/24/56/6435624\n" }, { "answer_id": 21829997, "author": "fustaki", "author_id":...
2008/10/10
[ "https://Stackoverflow.com/questions/191845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22674/" ]
191,855
<p>If I have added/removed/modified a large number of files in my local ClearCase view, how can I be certain that all the files have been added to source control?</p>
[ { "answer_id": 191857, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 3, "selected": false, "text": "cleartool ls -view_only -r" }, { "answer_id": 191964, "author": "VonC", "author_id": 6309, "author_...
2008/10/10
[ "https://Stackoverflow.com/questions/191855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9254/" ]
191,879
<p>Eg.</p> <pre><code>ConnectionDetails cd = new ConnectionDetails (); cd.ProviderName = "System.Data.OleDb"; cd.DataSource = "serverAddress"; cd.Catalog = "database"; cd.UserId = "userId"; cd.Password = "password"; string connectionString = cs.CreateConnectionString(); // Should return: // "Provider=SQLOLEDB;Data Source=serverAddress;Initial Catalog=database;User Id=userId;Password=password;" </code></pre> <p>I'd write my own class but I'm not sure how to retrieve a connection string provider property (SQLOLEDB in this example) programmatically from an invariant db provider name (System.Data.OleDb).</p> <p>Edit:</p> <p>You can do a</p> <pre><code>DbProviderFactories.GetFactory("System.Data.OleDB").CreateConnectionStringBuilder() </code></pre> <p>But the DBConnectionStringBuilder that is returned still doesn't know it's connection string provider property, even though in this case it the derived class has a "Provider" property.</p>
[ { "answer_id": 191932, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 2, "selected": false, "text": "DbConnectionStringBuilder csb = new DbConnectionStringBuilder();\ncsb[\"ProviderName\"] = \"System.Data.OleDb\";\ncsb[\"DataSo...
2008/10/10
[ "https://Stackoverflow.com/questions/191879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
191,881
<p>I need to <a href="https://en.wikipedia.org/wiki/Serialization" rel="noreferrer">serialize</a> an object to <a href="https://www.json.org/" rel="noreferrer">JSON</a>. I'm using <a href="https://api.jquery.com/" rel="noreferrer">jQuery</a>. Is there a "standard" way to do this?</p> <p>My specific situation: I have an array defined as shown below:</p> <pre><code>var countries = new Array(); countries[0] = 'ga'; countries[1] = 'cd'; ... </code></pre> <p>and I need to turn this into a string to pass to <a href="https://www.w3schools.com/jquery/ajax_ajax.asp" rel="noreferrer"><code>$.ajax()</code></a> like this:</p> <pre><code>$.ajax({ type: "POST", url: "Concessions.aspx/GetConcessions", data: "{'countries':['ga','cd']}", ... </code></pre>
[ { "answer_id": 191911, "author": "Tahir Akhtar", "author_id": 18027, "author_profile": "https://Stackoverflow.com/users/18027", "pm_score": 6, "selected": false, "text": "$.toJSON(value)" }, { "answer_id": 912247, "author": "Community", "author_id": -1, "author_profil...
2008/10/10
[ "https://Stackoverflow.com/questions/191881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
191,883
<p>I want to be able to do the following:</p> <pre><code>$normal_array = array(); $array_of_arrayrefs = array( &amp;$normal_array ); // Here I want to access the $normal_array reference **as a reference**, // but that doesn't work obviously. How to do it? end( $array_of_arrayrefs )["one"] = 1; // choking on this one print $normal_array["one"]; // should output 1 </code></pre> <p>Regards</p> <p>/R</p>
[ { "answer_id": 191939, "author": "Joe Scylla", "author_id": 25771, "author_profile": "https://Stackoverflow.com/users/25771", "pm_score": -1, "selected": false, "text": "error_reporting" }, { "answer_id": 191947, "author": "Andrew Moore", "author_id": 26210, "author_p...
2008/10/10
[ "https://Stackoverflow.com/questions/191883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
191,894
<p>I have the following component </p> <pre><code>public class MyTimer : IMyTimer { public MyTimer(TimeSpan timespan){...} } </code></pre> <p>Where timespan should be provided by the property ISettings.MyTimerFrequency.</p> <p>How do I wire this up in windsor container xml? I thought I could do something like this:</p> <pre><code> &lt;component id="settings" service="MySample.ISettings, MySample" type="MySample.Settings, MySample" factoryId="settings_dao" factoryCreate="GetSettingsForInstance"&gt; &lt;parameters&gt;&lt;instance_id&gt;1&lt;/instance_id&gt;&lt;/parameters&gt; &lt;/component&gt; &lt;component id="my_timer_frequency" type="System.TimeSpan" factoryId="settings" factoryCreate="MyTimerFrequency" /&gt; &lt;component id="my_timer" service="MySample.IMyTimer, MySample" type="MySample.MyTimer, MySample"&gt; &lt;parameters&gt;&lt;timespan&gt;${my_timer_frequency}&lt;/timespan&gt;&lt;/parameters&gt; </code></pre> <p>but I am getting an error because MyTimerFrequency is a property when the factory facility expects a method.</p> <p>Is there a simple resolution here? Am I approaching the whole thing the wrong way?</p> <p><strong>EDIT:</strong> There is definitely a solution, see my answer below.</p>
[ { "answer_id": 197501, "author": "George Mauer", "author_id": 5056, "author_profile": "https://Stackoverflow.com/users/5056", "pm_score": 3, "selected": true, "text": "public class MyClass {\n public object Item {\n get;\n }\n public object get_Item() {return null;}\n}\n" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/191894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
191,897
<p>I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I'm currently using SqlServer and a CTE to recursively examine all the nodes and their upstream components and this works as long as the upstream path doesn't fork alot. However, some queries take exponentially longer than others even when they are not much farther physically down the path (i.e. two or three segments "downstream") because of the added upstream complexity; in some cases I've let it go over ten minutes before killing the query. I'm using a simple two-column table, one column being the facility itself and the other being the facility that is upstream from the one listed in the first column.</p> <p>I tried adding an index using the current facility to help speed things up but that made no difference. And, as for the possible connections in the graph, any nodes could have multiple upstream connections and could be connected to from multiple "downstream" nodes.</p> <p>It is certainly possible that there are cycles in the data but I have not yet figured out a good way to verify this (other than when the CTE query reported a maximum recursive count hit; those were easy to fix).</p> <p>So, my question is, am I storing this information wrong? Is there a better way other than a CTE to query the upstream points? </p>
[ { "answer_id": 191986, "author": "oz10", "author_id": 14069, "author_profile": "https://Stackoverflow.com/users/14069", "pm_score": 1, "selected": false, "text": "vertex1 vertex2 {edge_label1}+\n" }, { "answer_id": 192020, "author": "Cervo", "author_id": 16219, "autho...
2008/10/10
[ "https://Stackoverflow.com/questions/191897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16623/" ]
191,923
<p>I have an XML file loaded into a DOM document, I wish to iterate through all 'foo' tags, getting values from every tag below it. I know I can get values via </p> <pre><code>$element = $dom-&gt;getElementsByTagName('foo')-&gt;item(0); foreach($element-&gt;childNodes as $node){ $data[$node-&gt;nodeName] = $node-&gt;nodeValue; } </code></pre> <p>However, what I'm trying to do, is from an XML like, </p> <pre><code>&lt;stuff&gt; &lt;foo&gt; &lt;bar&gt;&lt;/bar&gt; &lt;value/&gt; &lt;pub&gt;&lt;/pub&gt; &lt;/foo&gt; &lt;foo&gt; &lt;bar&gt;&lt;/bar&gt; &lt;pub&gt;&lt;/pub&gt; &lt;/foo&gt; &lt;foo&gt; &lt;bar&gt;&lt;/bar&gt; &lt;pub&gt;&lt;/pub&gt; &lt;/foo&gt; &lt;/stuff&gt; </code></pre> <p>iterate over every <em>foo</em> tag, and get specific <em>bar</em> or <em>pub</em>, and get values from there. Now, how do I iterate over <em>foo</em> so that I can still access specific child nodes by name?</p>
[ { "answer_id": 192015, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 7, "selected": true, "text": "$elements = $dom->getElementsByTagName('foo');\n$data = array();\nforeach($elements as $node){\n foreach($node->childNodes as ...
2008/10/10
[ "https://Stackoverflow.com/questions/191923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4224/" ]
191,926
<p>I have a database on ms sql 2000 that is being hit by hundreds of users at a time. There are intense reports using reporting services 2005 hitting the same database.</p> <p>When there are lots of reports running and people using the database concurrently we see blocking processes to the level that the system starts to give time out to any transaction made after some time in that situation.</p> <p>Is there a global way of minimize blocking so the transaction can continue to flow.</p>
[ { "answer_id": 192007, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "WITH(NOLOCK)" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/191926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
191,929
<p>If I were to use more than one, what order should I use modifier keywords such as:</p> <p><code>public</code>, <code>private</code>, <code>protected</code>, <code>virtual</code>, <code>abstract</code>, <code>override</code>, <code>new</code>, <code>static</code>, <code>internal</code>, <code>sealed</code>, and any others I'm forgetting.</p>
[ { "answer_id": 18270569, "author": "Jeppe Stig Nielsen", "author_id": 1336654, "author_profile": "https://Stackoverflow.com/users/1336654", "pm_score": 1, "selected": false, "text": "C" }, { "answer_id": 33237262, "author": "Wai Ha Lee", "author_id": 1364007, "author_...
2008/10/10
[ "https://Stackoverflow.com/questions/191929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
191,940
<p>Is it possible to define a class in C# such that</p> <pre><code>class GenericCollection&lt;T&gt; : SomeBaseCollection&lt;T&gt; where T : Delegate </code></pre> <p>I couldn't for the life of me accomplish this last night in .NET 3.5. I tried using</p> <p><code>delegate, Delegate, Action&lt;T&gt; and Func&lt;T, T&gt;</code></p> <p>It seems to me that this should be allowable in some way. I'm trying to implement my own EventQueue.</p> <p>I ended up just doing this [primitive approximation mind you].</p> <pre><code>internal delegate void DWork(); class EventQueue { private Queue&lt;DWork&gt; eventq; } </code></pre> <p>But then I lose the ability to reuse the same definition for different types of functions.</p> <p>Thoughts?</p>
[ { "answer_id": 191949, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "static GenericCollection()\n{\n if (!typeof(T).IsSubclassOf(typeof(Delegate)))\n {\n throw new InvalidOpe...
2008/10/10
[ "https://Stackoverflow.com/questions/191940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8945/" ]
191,950
<p>In my project I have a class that is inherited by many other classes. We'll call it ClassBase.</p> <pre><code>public class ClassInheritFromBase : ClassBase </code></pre> <p>When ClassBase is being inherited, <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> throws an "Ambiguous reference" warning on the ClassBase, and anything inside the new class that inherited from ClassBase does not have IntelliSense and gets warnings that it cannot find it.</p> <p>The project compiles and runs fine.</p> <p>If I change the namespace ClassBase is in and then change the inheriting classes, they find it fine and ReSharper has no problem, IntelliSense works ... until it is compiled. After the compile it goes back to having the ambiguous reference warnings and everything else.</p> <p>Has this been seen before and how can it be fixed? I saw an entry in JetBrains bug tracking for an issue just like this, but they closed it as unable to reproduce.</p>
[ { "answer_id": 22411256, "author": "HiredMind", "author_id": 79648, "author_profile": "https://Stackoverflow.com/users/79648", "pm_score": 0, "selected": false, "text": "Copy Local = false" }, { "answer_id": 31254550, "author": "Evan", "author_id": 4343254, "author_pr...
2008/10/10
[ "https://Stackoverflow.com/questions/191950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215/" ]
191,952
<p>If I have the following Linq code:</p> <pre><code>context.Table1s.InsertOnSubmit(t); context.Table1s.InsertOnSubmit(t2); context.Table1s.InsertOnSubmit(t3); context.SubmitChanges(); </code></pre> <p>And I get a database error due to the 2nd insert, Linq throws an exception that there was an error. But, is there a way to find out that it was the 2nd insert that had the problem and not the 1st or 3rd?</p> <p>To clarify, there are business reasons that I would expect the 2nd to fail (I am using a stored procedure to do the insert and am also doing some validation and raising an error if it fails). I want to be able to tell the user which one failed and why. I know this validation would be better done in the C# code and not in the database, but that is currently not an option.</p>
[ { "answer_id": 22411256, "author": "HiredMind", "author_id": 79648, "author_profile": "https://Stackoverflow.com/users/79648", "pm_score": 0, "selected": false, "text": "Copy Local = false" }, { "answer_id": 31254550, "author": "Evan", "author_id": 4343254, "author_pr...
2008/10/10
[ "https://Stackoverflow.com/questions/191952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3291/" ]
191,955
<p>What is the correct way to do this? For example, how would I change a stored procedure with this signature:</p> <pre><code>CREATE PROCEDURE dbo.MyProcedure @Param BIT = NULL AS SELECT * FROM dbo.SomeTable T WHERE T.SomeColumn = @Param </code></pre> <p>So that giving @Param with a value of 1 or 0 performs the filter, but not specifying it or passing NULL performs no filtering?</p>
[ { "answer_id": 191971, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "CREATE PROCEDURE dbo.MyProcedure \n @Param BIT = NULL\nAS\n SELECT *\n FROM dbo.SomeTable T\n WHERE T.SomeColumn...
2008/10/10
[ "https://Stackoverflow.com/questions/191955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6651/" ]
191,974
<p>The SQL implementation of relational databases has been around in their current form for something like 25 years (since System R and Ingres). Even the main (loosely adhered to) standard is ANSI-92 (although there were later updates) is a good 15 years old.</p> <p>What innovations can you think of with SQL based databases in the last ten years or so. I am specifically excluding OLAP, Columnar and other non-relational (or at least non SQL) innovations. I also want to exclude 'application server' type features and bundling (like reporting tools)</p> <p>Although the basic approach has remained fairly static, I can think of:</p> <ul> <li>Availability</li> <li>Ability to handle larger sets of data</li> <li>Ease of maintenance and configuration</li> <li>Support for more advanced data types (blob, xml, unicode etc)</li> </ul> <p>Any others that you can think of?</p>
[ { "answer_id": 192087, "author": "hova", "author_id": 2170, "author_profile": "https://Stackoverflow.com/users/2170", "pm_score": 2, "selected": false, "text": "SELECT (invoiceprice * detailweight) / SUM(weight) OVER(PARITTION BY invoice) as weighted, * \nFROM tblInvoiceDetails\n" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/191974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3893/" ]
191,980
<p>Should I create two <code>CFile</code> objects and copy one into the other character by character? Or is there something in the library that will do this for me?</p>
[ { "answer_id": 191992, "author": "jeffm", "author_id": 1544, "author_profile": "https://Stackoverflow.com/users/1544", "pm_score": 5, "selected": true, "text": "CopyFile" }, { "answer_id": 200063, "author": "skst", "author_id": 4858, "author_profile": "https://Stackov...
2008/10/10
[ "https://Stackoverflow.com/questions/191980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
191,984
<p>I am writing a little application, which is writing jpeg images at a constant rate on a SD card. I choose an EXT3 filesystem, but the same behaviour was observed with an EXT2 filesystem.</p> <p>My writing loop looks like this :</p> <pre><code>get_image() fwrite() fsync() </code></pre> <p>Or like this :</p> <pre><code>get_image() fopen() fwrite() fsync() fclose() </code></pre> <p>I also display some timing statistics, and I can see my program is sometime blocked for several seconds. The average rate is still good, because if I keep the incoming images into a fifo, then I will write many image in a short period of time after such a stall. Do you know if it is a problem with the OS or if it is related to the SD card itself ? How could I move closer to realtime ? I don't need strong realtime, but being stalled for several seconds is not acceptable.</p> <p>Some precision : Yes it is necessary to fsync after every file, because I want the image to be on disk, not in some user or kernel buffer. Without fsyncing, I have much better throughoutput, but still unacceptable stall. I don't think it is a buffer problem, since the first stall happens after 50 Mbytes have been written. And according to the man page, fsync is here precisely to ensure there is no data buffered.</p> <p>Precision regarding the average write rate : I am writing at a rate that is sustainable by the card I am using. If I pile incoming image while waiting for an fsync to complete, then after this stall the write transfer rate will increase and I will quickly go back to the average rate. The average transfer rate is around 1.4 MBytes /s.</p> <p>The systeme is a modern laptop running ubuntu 8.04 with stock kee (2.6.24.19)</p>
[ { "answer_id": 192107, "author": "Matt J", "author_id": 18528, "author_profile": "https://Stackoverflow.com/users/18528", "pm_score": 2, "selected": false, "text": "fsync()" }, { "answer_id": 2098613, "author": "pierrotlefou", "author_id": 115722, "author_profile": "h...
2008/10/10
[ "https://Stackoverflow.com/questions/191984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11589/" ]
191,998
<p>In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would like to step into the HttpClient code. I've downloaded the source code and tried to attach it in the normal fashion (CTRL-click on the method name and use the Attach Source button). I've tried to attach both as external file and external folder with no success. I've attached source before with no issues and can currently step into Hibernate source code successfully.</p> <p>I've even tried editing the .classpath file directly to add sourcepath manually. Still no luck. Refreshing the project, doing a clean build, closing and re-opening Eclipse do not solve the issue. Frustratingly, Eclipse provides no error message; it just does not attach the source.</p> <p>Here are the entries in .claspath:</p> <pre><code>&lt;!-- Hibernate. Works --&gt; &lt;classpathentry kind="lib" path="/myEAP/EarContent/APP-INF/lib/hibernate.jar" sourcepath="D:/Data/Download/hibernate-3.2.2.ga/hibernate-3.2/src"/&gt; &lt;!-- Commons HttpClient. Will not attach --&gt; &lt;classpathentry kind="lib" path="/myEAP/EarContent/APP-INF/lib/commons-httpclient.jar" sourcepath="D:/Data/Download/commons-httpclient-3.1/src/java"/&gt; </code></pre> <p>I've tried changing the path to D:/Data/Download/commons-httpclient-3.1/src and that does not work either.</p> <p>The directory structure is:</p> <pre><code>D Data Download commons-httpclient-3.1 src java org apache commons httpclient AutoCloseInputStream.java ... (and so forth) </code></pre>
[ { "answer_id": 193385, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 4, "selected": true, "text": "<classpathentry kind=\"lib\" path=\"/blib/java/commons-httpclient-3.1/commons-httpclient-3.1.jar\" sourcepath=\"/blib/java/co...
2008/10/10
[ "https://Stackoverflow.com/questions/191998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995/" ]
192,028
<p>I am trying to use concat_ws inside a group_concat command. With a query, which simplified looks like: </p> <pre><code>SELECT item.title, GROUP_CONCAT( CONCAT_WS( ',', attachments.id, attachments.type, attachments.name ) ) as attachments FROM story AS item LEFT OUTER JOIN story_attachment AS attachments ON item.id = attachments.item_id GROUP BY item.id </code></pre> <p>I get the attachments column as a Blob type. is it it possible to get it as a string instead of Blob?</p>
[ { "answer_id": 192057, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 3, "selected": true, "text": "SELECT item.title, GROUP_CONCAT( CAST(CONCAT_WS(',', attachments.id, \nattachments.type, attachments.name ) as CHAR ) ) as atta...
2008/10/10
[ "https://Stackoverflow.com/questions/192028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
192,048
<p>I understand that an id must be unique within an HTML/XHTML page.</p> <p>For a given element, can I assign multiple ids to it?</p> <pre><code>&lt;div id=&quot;nested_element_123 task_123&quot;&gt;&lt;/div&gt; </code></pre> <p>I realize I have an easy solution with simply using a class. I'm just curious about using ids in this manner.</p>
[ { "answer_id": 192064, "author": "tpower", "author_id": 18107, "author_profile": "https://Stackoverflow.com/users/18107", "pm_score": 2, "selected": false, "text": "name" }, { "answer_id": 192071, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://...
2008/10/10
[ "https://Stackoverflow.com/questions/192048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6349/" ]
192,049
<p>...just like packages do.</p> <p>I use Emacs (maybe, it can offer some kind of solution).</p> <p>For example <code>(defun the-very-very-long-but-good-name () ...)</code> is not to useful later in code. But the name like <code>Fn-15</code> or the first letters abbreviation is not useful too. Is it possible either to have an alias like for packages or to access the documentation string while trying to recall the function's name?</p> <p>In other words, is it possible for functions to mix somehow self-documenting and short names?</p>
[ { "answer_id": 192293, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": -1, "selected": false, "text": "(defmacro ...)" }, { "answer_id": 192336, "author": "Allen", "author_id": 6043, "author_profile": "https://...
2008/10/10
[ "https://Stackoverflow.com/questions/192049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20514/" ]
192,055
<p>I want to create a component that allows us to have compound keyboard shortcuts associated with an arbitrary command, like the Visual Studio IDE and Microsoft Office do.</p> <p>That is, keyboard shortcuts consisting of a sequence of multiple keystrokes, such as <kbd>Ctrl</kbd> + <kbd>W</kbd> + <kbd>C</kbd>. In Visual Studio this opens the class-view. When the first set of the keys is pressed (<kbd>Ctrl</kbd> + <kbd>W</kbd>) the message "(Ctrl + W) was pressed. Waiting for the second key of the chord..." appears in the status bar.</p>
[ { "answer_id": 192170, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 2, "selected": false, "text": "// Handle the KeyDown event to determine the type of character entered into the control.\nprivate void textBox1_KeyDown(object...
2008/10/10
[ "https://Stackoverflow.com/questions/192055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26877/" ]
192,073
<p>What are the differences between pipes in Windows and Linux?</p>
[ { "answer_id": 192187, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 6, "selected": true, "text": "mkfifo pipe.wav\ndecodeMP3 song.mp3 --out pipe.wav &\nencodeAVI video.mpeg pipe.wav --out video.avi\n" }, { "answer_id...
2008/10/10
[ "https://Stackoverflow.com/questions/192073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
192,077
<p>I created a simple class with a DependencyProperty. When setting the value, I observe that ValidateValueCallback is called before CoerceValueCallback.</p> <p>On <a href="http://wpftutorial.net/How+does+a+DependencyProperty+resolve+its+value.htm" rel="nofollow noreferrer">wpftutorial</a> and in other books, it is stated that coercion is called before validation.</p>
[ { "answer_id": 192187, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 6, "selected": true, "text": "mkfifo pipe.wav\ndecodeMP3 song.mp3 --out pipe.wav &\nencodeAVI video.mpeg pipe.wav --out video.avi\n" }, { "answer_id...
2008/10/10
[ "https://Stackoverflow.com/questions/192077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1624/" ]
192,078
<p>Shouldn't this be a pretty straightforward operation? However, I see there's neither a <code>size()</code> nor <code>length()</code> method.</p>
[ { "answer_id": 192094, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 7, "selected": false, "text": "ResultSet rs = ps.executeQuery();\nint rowcount = 0;\nif (rs.last()) {\n rowcount = rs.getRow();\n rs.beforeFirst(); // n...
2008/10/10
[ "https://Stackoverflow.com/questions/192078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
192,080
<p>I have a .asp application where image files (.PDF) are stored in a directory (fed by a copier/scanner). The created file names are stored in a database table. When a query is launched from the web page a link to the file is created. When clicked the image should be displayed. This functionality works 100% in Internet Explorer. No such luck in Firefox (and I have some Firefox users). The created hyperlink looks like this <code>file://Server/Scanner/XYZ.pdf</code></p> <p>The Firefox helps suggest the reason is this: </p> <blockquote> <p>Links to local or network pages do not work. As a security precaution, Firefox forbids sites on the Internet to link to files that are stored in your local computing environment. These files may include files on your computer, mapped network drives, and UNC network paths</p> </blockquote> <p>None of the suggestions for a workaround seem to work (or I am not understanding the steps to create the image display) Any Suggestions?</p>
[ { "answer_id": 192284, "author": "alexandrul", "author_id": 19756, "author_profile": "https://Stackoverflow.com/users/19756", "pm_score": 4, "selected": false, "text": "<a href=\"file://N:/path/to/file.ext\">test</a>" }, { "answer_id": 1946255, "author": "sunny", "author_...
2008/10/10
[ "https://Stackoverflow.com/questions/192080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26883/" ]
192,083
<p>We have PHP 5.2.6 deployed to c:\php and in that folder there is the php.ini file. On Windows, can a website override these settings similar to the way that apache has .htaccess? e.g.</p> <pre><code>DirectoryIndex index.php index.html &lt;IfModule mod_php5.c&gt; php_flag magic_quotes_gpc off php_flag register_globals off &lt;/IfModule&gt; &lt;IfModule mod_php4.c&gt; php_flag magic_quotes_gpc off php_flag register_globals off &lt;/IfModule&gt; </code></pre> <p><strong><em>Update:</em></strong> </p> <p>I was aware of ini_set() but wondered if there was a declarative way to do this in a configuration file in the website rather than in script.</p>
[ { "answer_id": 192093, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 3, "selected": true, "text": "egister_globals" }, { "answer_id": 192361, "author": "ConroyP", "author_id": 2287, "author_profile": ...
2008/10/10
[ "https://Stackoverflow.com/questions/192083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
192,085
<p>I am writing a diagnostic page for SiteScope and one area we need to test is if the connection to the file/media assets are accesible from the web server. One way I think I can do this is load the image via code behind and test to see if the IIS status message is 200. </p> <p>So basically I should be able to navigate to within the site to a folder like this: /media/1/image.jpg and see if it returns 200...if not throw exception.</p> <p>I am struggling to figure out how to write this code.</p> <p>Any help is greatly appreciated.</p> <p>Thanks</p>
[ { "answer_id": 192141, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 7, "selected": true, "text": "HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(\"url\");\nrequest.Method = \"HEAD\";\n\nbool exists;\...
2008/10/10
[ "https://Stackoverflow.com/questions/192085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/648/" ]
192,092
<p>When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.</p> <p>I'm currently <em>fixing</em> the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding paths into stuff like that.</p> <p>I'm looking for the most portable/reliable method for ensuring that the current working directory is the one where the script it is at.</p>
[ { "answer_id": 192112, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 2, "selected": false, "text": "__FILE__" }, { "answer_id": 192145, "author": "eyelidlessness", "author_id": 17964, "author_profile": "ht...
2008/10/10
[ "https://Stackoverflow.com/questions/192092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314/" ]
192,100
<p>.NET Framework 3.5 SP1 installs the .NET Framework 2.0 SP2 and the .NET Framework 3.0 SP2 behind the scenes. These installation packages (especially .NET Framework 2.0 SP2) are not available directly from Microsoft.</p> <p>Is there a way to extract them from the .NET Framework 3.5 SP1 installation package?</p>
[ { "answer_id": 392647, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "FL_FL_NetFx20SP2_x86.exe.3643236F_FC70_11D3_A536_0090278A1BB8" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23372/" ]
192,109
<p>So what I'm looking for here is something like PHP's <a href="http://us2.php.net/print_r" rel="noreferrer">print_r</a> function.</p> <p>This is so I can debug my scripts by seeing what's the state of the object in question.</p>
[ { "answer_id": 192116, "author": "Joe Skora", "author_id": 14057, "author_profile": "https://Stackoverflow.com/users/14057", "pm_score": 5, "selected": false, "text": ">>> import sys\n>>> dir(sys)\n['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', '__stdin__', '_...
2008/10/10
[ "https://Stackoverflow.com/questions/192109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
192,111
<p>In PHP, I am able to use a normal function as a variable without problem, but I haven't figured out how to use a static method. Am I just missing the right syntax, or is this not possible?</p> <p>(EDIT: the first suggested answer does not seem to work. I've extended my example to show the errors returned.)</p> <pre><code>function foo1($a,$b) { return $a/$b; } class Bar { static function foo2($a,$b) { return $a/$b; } public function UseReferences() { // WORKS FINE: $fn = foo1; print $fn(1,1); // WORKS FINE: print self::foo2(2,1); print Bar::foo2(3,1); // DOES NOT WORK ... error: Undefined class constant 'foo2' //$fn = self::foo2; //print $fn(4,1); // DOES NOT WORK ... error: Call to undefined function self::foo2() //$fn = 'self::foo2'; //print $fn(5,1); // DOES NOT WORK ... error: Call to undefined function Bar::foo2() //$fn = 'Bar::foo2'; //print $fn(5,1); } } $x = new Bar(); $x-&gt;UseReferences(); </code></pre> <p>(I am using PHP v5.2.6 -- does the answer change depending on version too?)</p>
[ { "answer_id": 192123, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 6, "selected": true, "text": "<?php\n\nfunction foo1($a,$b) { return $a/$b; }\n\nclass Bar\n{\n public static function foo2($a,$b) { return $a/$b; ...
2008/10/10
[ "https://Stackoverflow.com/questions/192111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
192,117
<p>I am writing in C#.<br> How can i find out which methods/functions I can use in an unmanaged dll that doesn't belong to windows?<br> Exmaple : I have some installed software on my computer, it has a dll, and i want to know what my options are as to creating code to connect to that software?</p>
[ { "answer_id": 12727656, "author": "Mike Perrenoud", "author_id": 1195080, "author_profile": "https://Stackoverflow.com/users/1195080", "pm_score": 0, "selected": false, "text": "Object Explorer" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
192,121
<p>I want to use the DateTime.TryParse method to get the datetime value of a string into a Nullable. But when I try this:</p> <pre><code>DateTime? d; bool success = DateTime.TryParse("some date text", out (DateTime)d); </code></pre> <p>the compiler tells me </p> <blockquote> <p>'out' argument is not classified as a variable</p> </blockquote> <p>Not sure what I need to do here. I've also tried: </p> <pre><code>out (DateTime)d.Value </code></pre> <p>and that doesn't work either. Any ideas?</p>
[ { "answer_id": 192146, "author": "Jason Kealey", "author_id": 20893, "author_profile": "https://Stackoverflow.com/users/20893", "pm_score": 8, "selected": true, "text": "DateTime? d=null;\nDateTime d2;\nbool success = DateTime.TryParse(\"some date text\", out d2);\nif (success) d=d2;\n" ...
2008/10/10
[ "https://Stackoverflow.com/questions/192121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767/" ]
192,122
<p>This may seem a bit trivial, but I have not been able to figure it out. I am opening up a SPSite and then trying to open up a SPWeb under that SPSite. This is working fine on the VPC, which has the same Site Collection/Site hierarchy, but on production, I get an exception telling me that the URL is invalid when I try the SPSite.OpenWeb(webUrl);. I have verified that the URL’s are correct.</p> <p>The Code:</p> <pre><code> try { SPSite scheduleSiteCol = new SPSite(branchScheduleURL); lblError.Text += Environment.NewLine + "Site Collection URL: " + scheduleSiteCol.Url; SPWeb scheduleWeb = scheduleSiteCol.OpenWeb(branchScheduleURL.Replace(scheduleSiteCol.Url, "")); //&lt;--- Throws error on this line SPList scheduleList = scheduleWeb.GetList(branchScheduleURL + "/lists/" + SPContext.Current.List.Title); return scheduleList.GetItemById(int.Parse(testID)); } catch (System.Exception ex) { lblError.Text += Environment.NewLine + ex.ToString(); return null; } </code></pre> <p>Note:<br> branchScheduleURL is actually the whole URL that includes the URL of the Web as well.</p> <p>The output + exception:</p> <blockquote> <p>Site Collection URL: <a href="https://ourSite.com/mocc" rel="nofollow noreferrer">https://ourSite.com/mocc</a> <br>System.ArgumentException: Invalid URL: /internal/scheduletool. at Microsoft.SharePoint.SPSite.OpenWeb(String strUrl, Boolean requireExactUrl) at Microsoft.SharePoint.SPSite.OpenWeb(String strUrl) at MOCCBranchScheduleListWeb.MOCCBranchScheduleListV3.GetConflictListItem(String branchScheduleURL, String testID)System.NullReferenceException: Object reference not set to an instance of an object. at MOCCBranchScheduleListWeb.MOCCBranchScheduleListV3.CheckForConflicts(String[] cfcFlags1, DateTime startTime, DateTime endTime, String[] cfcFlags2)</p> </blockquote> <p>Note:<br><a href="https://ourSite.com/mocc/internal/scheduletool" rel="nofollow noreferrer">https://ourSite.com/mocc/internal/scheduletool</a> is the SPWeb I am trying to open.</p> <p>Am I missing something obvious? Any help would be greatly appreciated.</p> <p>Thanks.</p>
[ { "answer_id": 198885, "author": "Peter Seale", "author_id": 25911, "author_profile": "https://Stackoverflow.com/users/25911", "pm_score": 0, "selected": false, "text": "string webServerRelativeUrl = site.ServerRelativeUrl + \"/internal/scheduletool\"" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22426/" ]
192,124
<p>I need specifically to load a JPG image that was saved as a blob. GDI+ makes it very easy to retrieve images from files but not from databases...</p>
[ { "answer_id": 192139, "author": "Jason Kealey", "author_id": 20893, "author_profile": "https://Stackoverflow.com/users/20893", "pm_score": 0, "selected": false, "text": "public static Image CreateImage(byte[] pict)\n{\n System.Drawing.Image img = null;\n using (System.IO.MemoryStrea...
2008/10/10
[ "https://Stackoverflow.com/questions/192124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4880/" ]
192,126
<p>I have a method that needs to accept an array of country names, and return a list of records that match one of those country names. I'm trying this</p> <pre><code>Public Shared Function GetConcessions(ByVal Countries As String()) As IEnumerable Dim CountryList As String = Utility.JoinArray(Countries) ' turns string array into comma-separated string Return (From t In New Db().Concessions _ Where CountryList Like t.Country _ Select t.ConcessionID, t.Title, t.Country) End Function </code></pre> <p>but I get this error</p> <pre><code> *Only arguments that can be evaluated on the client are supported for the LIKE method </code></pre> <p>In plain SQL, this would be simple:</p> <pre><code> Select ConcessionID,Title from Concessions c where @CountryList like '%' + c.Country + '%' </code></pre> <p>How can I achieve this result in Linq to SQL?</p> <h3>Edit (clarification)</h3> <p>I get the same message with string.Contains. It would be fine with</p> <pre><code>t.Country.contains(CountryList) </code></pre> <p>but I need</p> <pre><code>CountryList.contains(t.Country) </code></pre> <p>and that throws the same error I listed above.</p>
[ { "answer_id": 192167, "author": "sepang", "author_id": 25930, "author_profile": "https://Stackoverflow.com/users/25930", "pm_score": 3, "selected": false, "text": "Where SqlMethods.Like(t.country, \"%Sweden%\")\n" }, { "answer_id": 192172, "author": "tvanfosson", "author...
2008/10/10
[ "https://Stackoverflow.com/questions/192126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
192,128
<p>I am working on an Actionscript 2 project - trying to use the XML object to find a url which is returned as a 302 redirect. Is there a way to do this in actionscript 2?</p> <p>code:</p> <pre><code>var urlone:XML = new XML(); urlone.load("http://mydomain.com/file.py"); urlone.onLoad = function (success) { trace("I want to print the 302 redirect url here, how do I access it?"); }; </code></pre>
[ { "answer_id": 192167, "author": "sepang", "author_id": 25930, "author_profile": "https://Stackoverflow.com/users/25930", "pm_score": 3, "selected": false, "text": "Where SqlMethods.Like(t.country, \"%Sweden%\")\n" }, { "answer_id": 192172, "author": "tvanfosson", "author...
2008/10/10
[ "https://Stackoverflow.com/questions/192128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26888/" ]
192,134
<p>I have to check some code and run it. I have the URL:</p> <pre><code>svn+ssh://myuser@www.myclient.com/home/svn/project/trunk </code></pre> <p>I have a file with their private key. What do I do to get this code?</p>
[ { "answer_id": 192186, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 1, "selected": false, "text": "~/.ssh/" }, { "answer_id": 192221, "author": "ephemient", "author_id": 20713, "author_profile": "htt...
2008/10/10
[ "https://Stackoverflow.com/questions/192134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
192,153
<p>I would like to access the Rails session secret programmatically (I am using it to generate a sign-on token).</p> <p>Here's what I've come up with:</p> <pre><code>ActionController::Base.session.first[:secret] </code></pre> <p>This returns the session secret. However, every time you call ActionController::Base.session it adds another entry to an array so you end up with something like this:</p> <pre><code>[{:session_key=&gt;"_new_app_session", :secret=&gt;"totally-secret-you-guys"}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}] </code></pre> <p>This strikes me as being no good.</p> <p>Is there a better way to access the session secret?</p>
[ { "answer_id": 192270, "author": "whoisjake", "author_id": 2609, "author_profile": "https://Stackoverflow.com/users/2609", "pm_score": 3, "selected": true, "text": "ActionController::Base.session_options_for(request,params[:action])[:secret]\n" }, { "answer_id": 192298, "auth...
2008/10/10
[ "https://Stackoverflow.com/questions/192153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965/" ]
192,200
<p>I have to do a cross site POST (with a redirection, so not using a XMLHTTPRequest), and the base platform is ASP.NET. I don't want to POST all of the controls in the ASP.NET FORM to this other site, so I was considering dynamicly creating a new form element using javascript and just posting that.</p> <p>Has anyone tried this trick? Is there any caveats?</p>
[ { "answer_id": 192212, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": " <asp:TemplateField HeaderText=\"Station\" SortExpression=\"Name\">\n <ItemTemplate>\n <a href=\"javascript:vo...
2008/10/10
[ "https://Stackoverflow.com/questions/192200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
192,203
<p>How do I do this</p> <pre><code>Select top 10 Foo from MyTable </code></pre> <p>in Linq to SQL?</p>
[ { "answer_id": 192209, "author": "David Alpert", "author_id": 8997, "author_profile": "https://Stackoverflow.com/users/8997", "pm_score": 8, "selected": true, "text": "from m in MyTable\ntake 10\nselect m.Foo\n" }, { "answer_id": 192222, "author": "Adam Lassek", "author_i...
2008/10/10
[ "https://Stackoverflow.com/questions/192203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
192,206
<p>Is there a method, or some other light-weight way, to check if a reference is to a disposed object?</p> <p>P.S. - This is just a curiousity (sleep well, not in production code). Yes, I know I can catch the <code>ObjectDisposedException</code> upon trying to access a member of the object.</p>
[ { "answer_id": 192226, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 5, "selected": false, "text": "System.Windows.Forms.Control" }, { "answer_id": 211470, "author": "Scott Dorman", "author_id": 1559, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
192,213
<p>This is the SQL that I want to accomplish:</p> <pre><code>WHERE domain_nm + '\' + group_nm in ('DOMAINNAME\USERNAME1','DOMAINNAME2\USERNAME2') </code></pre> <p>I can't for the life of me find an appropriate Expression for this. And I don't think I can use two expressions as the domain name and the group name need to be concatenated.</p> <p>Thanks!</p>
[ { "answer_id": 214260, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 2, "selected": false, "text": "criteria\n .Add(Expression.In(\"DomainName\", new string[] { \"DOMAINNAME\", \"DOMAINNAME2\" }))\n .Add(Expression.In...
2008/10/10
[ "https://Stackoverflow.com/questions/192213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26896/" ]
192,220
<p>Assume you have a flat table that stores an ordered tree hierarchy:</p> <pre><code>Id Name ParentId Order 1 'Node 1' 0 10 2 'Node 1.1' 1 10 3 'Node 2' 0 20 4 'Node 1.1.1' 2 10 5 'Node 2.1' 3 10 6 'Node 1.2' 1 20 </code></pre> <p>Here's a diagram, where we have <code>[id] Name</code>. Root node 0 is fictional.</p> <pre> [0] ROOT / \ [1] Node 1 [3] Node 2 / \ \ [2] Node 1.1 [6] Node 1.2 [5] Node 2.1 / [4] Node 1.1.1 </pre> <p>What minimalistic approach would you use to output that to HTML (or text, for that matter) as a correctly ordered, correctly indented tree? </p> <p>Assume further you only have basic data structures (arrays and hashmaps), no fancy objects with parent/children references, no ORM, no framework, just your two hands. The table is represented as a result set, which can be accessed randomly. </p> <p>Pseudo code or plain English is okay, this is purely a conceptional question.</p> <p>Bonus question: Is there a fundamentally better way to store a tree structure like this in a RDBMS?</p> <hr> <p><strong>EDITS AND ADDITIONS</strong></p> <p>To answer one commenter's (<a href="https://stackoverflow.com/users/17826/mark-bessey">Mark Bessey</a>'s) question: A root node is not necessary, because it is never going to be displayed anyway. ParentId = 0 is the convention to express "these are top level". The Order column defines how nodes with the same parent are going to be sorted.</p> <p>The "result set" I spoke of can be pictured as an array of hashmaps (to stay in that terminology). For my example was meant to be already there. Some answers go the extra mile and construct it first, but thats okay.</p> <p>The tree can be arbitrarily deep. Each node can have N children. I did not exactly have a "millions of entries" tree in mind, though.</p> <p>Don't mistake my choice of node naming ('Node 1.1.1') for something to rely on. The nodes could equally well be called 'Frank' or 'Bob', no naming structure is implied, this was merely to make it readable.</p> <p><em>I have posted my own solution so you guys can pull it to pieces.</em></p>
[ { "answer_id": 192252, "author": "wcm", "author_id": 2173, "author_profile": "https://Stackoverflow.com/users/2173", "pm_score": 2, "selected": false, "text": "function PrintLevel (int curr, int level)\n //print the indents\n for (i=1; i<=level; i++)\n print a tab\n print...
2008/10/10
[ "https://Stackoverflow.com/questions/192220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18771/" ]
192,228
<p>I'm not much of a coder, but I need to write a simple <em>preg_replace</em> statement in PHP that will help me with a WordPress plugin. Basically, I need some code that will search for a string, pull out the video ID, and return the embed code with the video id inserted into it. </p> <p>In other words, I'm searching for this: </p> <pre><code>[youtube=http://www.youtube.com/watch?v=VIDEO_ID_HERE&amp;hl=en&amp;fs=1] </code></pre> <p>And want to replace it with this (keeping the video id the same): </p> <pre><code>param name="movie" value="http://www.youtube.com/v/VIDEO_ID_HERE&amp;hl=en&amp;fs=1&amp;rel=0 </code></pre> <p>If possible, I'd be forever grateful if you could explain how you've used the various slashes, carets, and Kleene stars in the search pattern, i.e. translate it from grep to English so I can learn. :-)</p> <p>Thanks!<br> Mike</p>
[ { "answer_id": 192239, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "$str = preg_replace('/\\[youtube=.*?v=([a-z0-9_-]+?)&.*?\\]/i', 'param name=\"movie\" value=\"http://www.youtube.com/v/$1&hl=...
2008/10/10
[ "https://Stackoverflow.com/questions/192228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
192,249
<p>Say, I have a script that gets called with this line:</p> <pre><code>./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile </code></pre> <p>or this one:</p> <pre><code>./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile </code></pre> <p>What's the accepted way of parsing this such that in each case (or some combination of the two) <code>$v</code>, <code>$f</code>, and <code>$d</code> will all be set to <code>true</code> and <code>$outFile</code> will be equal to <code>/fizz/someOtherFile</code>?</p>
[ { "answer_id": 192266, "author": "Matt J", "author_id": 18528, "author_profile": "https://Stackoverflow.com/users/18528", "pm_score": 7, "selected": false, "text": "getopt()" }, { "answer_id": 9518714, "author": "Alek", "author_id": 1243005, "author_profile": "https:/...
2008/10/10
[ "https://Stackoverflow.com/questions/192249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
192,256
<p>What would be the best method to implement extra functionality in a database layer that uses Linq-to-SQL? Currently I'm looking at implementing functions for adding information based on presets and similar tasks?</p> <p>Inserts, updates and deletes requires access to the <code>DataContext</code> and in the <code>Table</code> classes you don't have access to the context. I've seen solutions that uses Singletons but it seems like a hack and I wonder if anyone else has run into this problem and what your solutions were? Is there a better way all together to implement similar functionality.</p> <p>The reason for me looking to add this functionality to the database layer is that I have several applications that all use the same database objects and I want to be able to use these functions from all applications so I don't have to rewrite a lot of code.</p> <hr> <p>That's not quite what I meant. I want to be able to do complex actions like updating one table and adding a record to another table based on information from the first one.</p> <p>Say I have selected a Customer record and I want to update this with information, and when this happens I want it to add another record to the "Updates" table to keep track of when updates happened and who did them. This is only an example of course. Things needed to be done can be more complex.</p> <p>Basically I want to add a method to a table object to perform modifications to a specific row in that table and then do inserts and updates on other objects. I know that you can use partial classes and I do that extensively already.</p> <p>Example:</p> <pre><code>db.Customers.Where(c =&gt; c.CustomerID == 5).AddOrder(orderDetails); </code></pre> <p>I feel that I can't really put my problem into words to make it understandable :)</p>
[ { "answer_id": 7253842, "author": "dougajmcdonald", "author_id": 777733, "author_profile": "https://Stackoverflow.com/users/777733", "pm_score": 1, "selected": false, "text": "public static class StringExtensions \n{\n public static int ToInt(this string oString)\n {\n retur...
2008/10/10
[ "https://Stackoverflow.com/questions/192256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26746/" ]
192,260
<p>I am currently working on a website to track projects. In it, it is possible to create Service Level Agreements (SLAs). These are configurable with days of the week that a project can be worked on and also the timespan on each of those days. Eg. on Monday it might be between 08:00 and 16:00 and then on friday from 10:00 to 14:00. They are also configured with a deadline time depending on priority. Eg. a project created with the "Low" priority has a deadline time of two weeks, and a project with "High" priority has a deadline of four hours.</p> <p>The problem I'm having is calculating the deadline AROUND the hours described earlier. Say I create a project on Monday at 14:00 with a "High" priority. That means I have four hours for this project. But because of the working hours, I have two hours on monday (untill 16:00) and then another two hours on Friday. That means the Deadline must be set for Friday at 12:00.</p> <p>I've spent quite some time googling this, and I can find quite a few examples of finding out how many working hours there are between a given start end ending date. I just can't figure out how to convert it into FINDING the ending datetime, given a starting time and an amount of time untill the deadline.</p> <p>The day/timespans are stored in an sql database in the format:</p> <p>Day(Eg. 1 for Monday) StartHour EndHour</p> <p>The StartHour/EndHour are saved as DateTimes, but of course only the time part is important.</p> <p>The way I figure it is, I have to somehow iterate through these times and do some datetime calculations. I just can't quite figure out what those calculations should be, what the best way is.</p> <p>I found <a href="https://stackoverflow.com/questions/5260/what-is-the-best-way-to-wrap-time-around-the-work-day">this Question</a> here on the site as I was writing this. It is sort of what I want and I'm playing with it right now, but I'm still lost on how exactly to make it work around my dynamic work days/hours.</p>
[ { "answer_id": 192307, "author": "Ian Jacobs", "author_id": 22818, "author_profile": "https://Stackoverflow.com/users/22818", "pm_score": 1, "selected": false, "text": "public DateTime getDeadline(SubmitTime, ProjectTimeAllowed)\n{\n if (SubmitTime+ProjectTimeAllowed >= DayEndTime)\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/192260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26841/" ]
192,261
<p>Using something like this:</p> <pre><code>try: # Something... except Exception as excep: logger = logging.getLogger("component") logger.warning("something raised an exception: " + excep) logger.info("something raised an exception: " + excep) </code></pre> <p>I would rather not have it on the error-level cause in my special case it is not an error.</p>
[ { "answer_id": 193153, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 8, "selected": true, "text": "kwargs" }, { "answer_id": 4909282, "author": "Scubahubby", "author_id": 604684, "author_profile": ...
2008/10/10
[ "https://Stackoverflow.com/questions/192261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26905/" ]
192,264
<p>I have a page that is hitting a webservice every 5 seconds to update the information on the page. I'm using the DynamicPopulateExtender from the Ajax Control Toolkit to just populate a panel with some text.</p> <p>What I was wanting to do, is if a certain condition is met, to refresh the page completely. </p> <p>Am I going to be able to do this in the current method that I have? here's my current stuff:</p> <hr> <p>ASP.NET</p> <pre><code>&lt;cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server" ClearContentsDuringUpdate="true" TargetControlID="panelQueue" BehaviorID="dp1" ServiceMethod="GetQueueTable" UpdatingCssClass="dynamicPopulate_Updating" /&gt; </code></pre> <p>Javascript</p> <pre><code>Sys.Application.add_load(function(){updateQueue();}); function updateQueue() { var queueShown = document.getElementById('&lt;%= hiddenFieldQueueShown.ClientID %&gt;').value; if(queueShown == 1) { var behavior = $find('dp1'); if (behavior) { behavior.populate(); setTimeout('updateQueue()', 5000); } } } </code></pre> <p>SERVER (C#)</p> <pre><code>[System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public static string GetQueueTable() { System.Text.StringBuilder builder = new System.Text.StringBuilder(); try { // do stuff } catch (Exception ex) { // do stuff } return builder.ToString(); } </code></pre>
[ { "answer_id": 192393, "author": "Alfred B. Thordarson", "author_id": 3379, "author_profile": "https://Stackoverflow.com/users/3379", "pm_score": 2, "selected": false, "text": "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<head runat=\"server\">\n <title>Untitled Page</title>\n\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/192264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
192,292
<p>The way you would normally include a script is with "source"</p> <p>eg:</p> <p>main.sh:</p> <pre><code>#!/bin/bash source incl.sh echo "The main script" </code></pre> <p>incl.sh:</p> <pre><code>echo "The included script" </code></pre> <p>The output of executing "./main.sh" is:</p> <pre><code>The included script The main script </code></pre> <p>... Now, if you attempt to execute that shell script from another location, it can't find the include unless it's in your path.</p> <p>What's a good way to ensure that your script can find the include script, especially if for instance, the script needs to be portable?</p>
[ { "answer_id": 192305, "author": "Chris Boran", "author_id": 25660, "author_profile": "https://Stackoverflow.com/users/25660", "pm_score": 9, "selected": true, "text": "#!/bin/sh\n\nmy_dir=\"$(dirname \"$0\")\"\n\n\"$my_dir/other_script.sh\"\n" }, { "answer_id": 192306, "auth...
2008/10/10
[ "https://Stackoverflow.com/questions/192292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16258/" ]
192,294
<p>Background: We develop win32 applications, and use the "Thompson Toolkit" on windows to give us a unix-like shell that we use as our command-line.</p> <p>We have a GUI program (with a WinMain and message loop) that we want to write to the console, but printf and so on don't work, even when we launch the program from the console. How can we write to the console from a GUI program? We need to print text there so that an automated build system can display error messages and so on.</p> <p>Thanks.</p>
[ { "answer_id": 4990664, "author": "bkausbk", "author_id": 575491, "author_profile": "https://Stackoverflow.com/users/575491", "pm_score": 1, "selected": false, "text": "AllocConsole" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13500/" ]
192,313
<p>I'm writing a Windows Forms Application in C#.NET</p> <p>On startup, the application displays a splash screen which is running in a separate thread. Whilst the splash screen is showing, the main application is initialising.</p> <p>Once the main application has finished initialising, the main form of the application is displayed, and the splash screen still shows over the top.</p> <p>Everything so far is as expected.</p> <p>Then, the Splash screen is closed, which causes that thread to exit. For some reason, at the point, the main application windows gets sent behind all other open Windows, notably the Windows Explorer window where you clicked the .exe file to run the application in the first place!</p> <p>What could be causing the windows to suddenly jump "behind" like this?</p>
[ { "answer_id": 192523, "author": "Jack Bolding", "author_id": 5882, "author_profile": "https://Stackoverflow.com/users/5882", "pm_score": 0, "selected": false, "text": "private void button1_Click(object sender, System.EventArgs e)\n{\n this.DialogResult = DialogResult.Abort;\n th...
2008/10/10
[ "https://Stackoverflow.com/questions/192313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26906/" ]
192,319
<p>How can I determine the name of the Bash script file inside the script itself?</p> <p>Like if my script is in file <code>runme.sh</code>, then how would I make it to display "You are running runme.sh" message without hardcoding that?</p>
[ { "answer_id": 192337, "author": "Tanktalus", "author_id": 23512, "author_profile": "https://Stackoverflow.com/users/23512", "pm_score": 11, "selected": true, "text": "me=`basename \"$0\"`\n" }, { "answer_id": 192344, "author": "VolkA", "author_id": 25472, "author_pro...
2008/10/10
[ "https://Stackoverflow.com/questions/192319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20390/" ]
192,329
<p>I have boiled down an issue I'm seeing in one of my applications to an incredibly simple reproduction sample. I need to know if there's something amiss or something I'm missing.</p> <p>Anyway, below is the code. The behavior is that the code runs and steadily grows in memory until it crashes with an OutOfMemoryException. That takes a while, but the behavior is that objects are being allocated and are not being garbage collected. </p> <p>I've taken memory dumps and ran !gcroot on some things as well as used ANTS to figure out what the problem is, but I've been at it for a while and need some new eyes.</p> <p>This reproduction sample is a simple console application that creates a Canvas and adds a Line to it. It does this continually. This is all the code does. It sleeps every now and again to ensure that the CPU is not so taxed that your system is unresponsive (and to ensure there's no weirdness with the GC not being able to run). </p> <p>Anyone have any thoughts? I've tried this with .NET 3.0 only, .NET 3.5 and also .NET 3.5 SP1 and the same behavior occurred in all three environments.</p> <p>Also note that I've put this code in a WPF application project as well and triggered the code in a button click and it occurs there too.</p> <pre> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Controls; using System.Windows.Shapes; using System.Windows; namespace SimplestReproSample { class Program { [STAThread] static void Main(string[] args) { long count = 0; while (true) { if (count++ % 100 == 0) { // sleep for a while to ensure we aren't using up the whole CPU System.Threading.Thread.Sleep(50); } BuildCanvas(); } } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static void BuildCanvas() { Canvas c = new Canvas(); Line line = new Line(); line.X1 = 1; line.Y1 = 1; line.X2 = 100; line.Y2 = 100; line.Width = 100; c.Children.Add(line); c.Measure(new Size(300, 300)); c.Arrange(new Rect(0, 0, 300, 300)); } } } </pre> <p>NOTE: the first answer below is a bit off-base since I explicitly stated already that this same behavior occurs during a WPF application's button click event. I did not explicitly state, however, that in that app I only do a limited number of iterations (say 1000). Doing it that way would allow the GC to run as you click around the application. Also note that I explicitly said I've taken a memory dump and found my objects were rooted via !gcroot. I also disagree that the GC would not be able to run. The GC does not run on my console application's main thread, especially since I'm on a dual core machine which means the Concurrent Workstation GC is active. Message pump, however, yes.</p> <p>To prove the point, here's a WPF application version that runs the test on a DispatcherTimer. It performs 1000 iterations during a 100ms timer interval. More than enough time to process any messages out of the pump and keep the CPU usage low.</p> <pre> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Shapes; namespace SimpleReproSampleWpfApp { public partial class Window1 : Window { private System.Windows.Threading.DispatcherTimer _timer; public Window1() { InitializeComponent(); _timer = new System.Windows.Threading.DispatcherTimer(); _timer.Interval = TimeSpan.FromMilliseconds(100); _timer.Tick += new EventHandler(_timer_Tick); _timer.Start(); } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] void RunTest() { for (int i = 0; i &lt; 1000; i++) { BuildCanvas(); } } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static void BuildCanvas() { Canvas c = new Canvas(); Line line = new Line(); line.X1 = 1; line.Y1 = 1; line.X2 = 100; line.Y2 = 100; line.Width = 100; c.Children.Add(line); c.Measure(new Size(300, 300)); c.Arrange(new Rect(0, 0, 300, 300)); } void _timer_Tick(object sender, EventArgs e) { _timer.Stop(); RunTest(); _timer.Start(); } } } </pre> <p>NOTE2: I used the code from the first answer and my memory grew very slowly. Note that 1ms is much slower and less iterations than my example. You have to let it run for a couple minutes before you start to notice growth. After 5 minutes it's at 46MB from a starting point of 30MB. </p> <p>NOTE3: Removing the call to .Arrange completely eliminates the growth. Unfortunately, that call is pretty vital to my use since in many cases I'm creating PNG files from the Canvas (via the RenderTargetBitmap class). Without the call to .Arrange it doesn't layout the canvas at all.</p>
[ { "answer_id": 192421, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 0, "selected": false, "text": "Timer" }, { "answer_id": 193609, "author": "Bradley Grainger", "author_id": 23633, "author_profile...
2008/10/10
[ "https://Stackoverflow.com/questions/192329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13322/" ]
192,332
<p>What I am looking for is a way to call a method after another method has been invoked but before it is entered. Example:</p> <pre><code>public class Test { public void Tracer ( ... ) { } public int SomeFunction( string str ) { return 0; } public void TestFun() { SomeFunction( "" ); } } </code></pre> <p>In the example above I would like to have Tracer() called after SomeFunction() has been invoked by TestFun() but before SomeFunction() is entered. I'd also like to get reflection data on SomeFunction().</p> <hr> <p>I found something interesting in everyone's answers. The <strong>best answer to the question</strong> is to use Castle's DynamicProxy; however, this is not that I'm going to use to solve my problem because it requires adding a library to my project. I have only a few methods that I need to "trace" so I've chosen to go with a modified "core" methodology mixed with the way Dynamic Proxy is implemented. I explain this in my answer to my own question below.</p> <p>Just as a note I'm going to be looking into AOP and the ContextBoundObject class for some other applications.</p>
[ { "answer_id": 192355, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 2, "selected": false, "text": "public int SomeFunction(string str)\n{\n Tracer();\n return SomeFunctionCore(str);\n}\n\nprivate int SomeFunctionCore...
2008/10/10
[ "https://Stackoverflow.com/questions/192332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2415/" ]
192,345
<p>I would like to use Pylons with Elixir, however, I am not sure what is the best way to get about doing this. There are several blog posts (<a href="http://cleverdevil.org/computing/68/" rel="nofollow noreferrer" title="cleverdevil&#39;s technique">cleverdevil</a>, <a href="http://beachcoder.wordpress.com/2007/05/11/using-elixir-with-pylons/" rel="nofollow noreferrer" title="beachcoder&#39;s technique">beachcoder</a>, <a href="http://hoscilo.pypla.net/2007/03/19/sqlalchemy-elixir-and-pylons-round-one/" rel="nofollow noreferrer" title="adam hoscilo&#39;s technique">adam hoscilo</a>) and even an <a href="http://code.google.com/p/tesla-pylons-elixir/" rel="nofollow noreferrer" title="tesla">entire new framework</a> about how to go about doing this; however, I am not certain about the differences between them. Which one is the best to use? Am I going to run into issues using one over the other? </p> <p>I would prefer not to have to use SQLAlchemy directly because of its verbosity and repetitiveness. </p>
[ { "answer_id": 192355, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 2, "selected": false, "text": "public int SomeFunction(string str)\n{\n Tracer();\n return SomeFunctionCore(str);\n}\n\nprivate int SomeFunctionCore...
2008/10/10
[ "https://Stackoverflow.com/questions/192345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12682/" ]
192,366
<p>Is it possible to grab activedirectory credentials for the user on a client machine from within a web application?</p> <p>To clarify, I am designing a web application which will be hosted on a client's intranet. </p> <p>There is a requirement that the a user of the application not be prompted for credentials when accessing the application, and that instead the credentials of the user logged onto the client machine should be grabbed automatically, without user interaction.</p>
[ { "answer_id": 192414, "author": "Sean Hanley", "author_id": 7290, "author_profile": "https://Stackoverflow.com/users/7290", "pm_score": 3, "selected": false, "text": "using System.DirectoryServices;\n\n/// <summary>\n/// Gets the email address, if defined, of a user from Active Director...
2008/10/10
[ "https://Stackoverflow.com/questions/192366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26527/" ]
192,367
<p>I have the following two models:</p> <pre><code>class Activity(models.Model): name = models.CharField(max_length=50, help_text='Some help.') entity = models.ForeignKey(CancellationEntity) ... class Cancellation(models.Model): activity = models.ForeignKey(Activity) date = models.DateField(default=datetime.now().date()) description = models.CharField(max_length=250) ... </code></pre> <p>I would like the Activity model to be aware when a Cancellation related to it is saved (both inserted or updated).</p> <p>What is the best way to go about this?</p>
[ { "answer_id": 192525, "author": "willurd", "author_id": 1943957, "author_profile": "https://Stackoverflow.com/users/1943957", "pm_score": 5, "selected": true, "text": "from django.db.models.signals import post_save\n\nclass Activity(models.Model):\n name = models.CharField(max_length...
2008/10/10
[ "https://Stackoverflow.com/questions/192367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10825/" ]
192,373
<p>Is it possible to programmatically force a full garbage collection run in ActionScript 3.0?</p> <p>Let's say I've created a bunch of Display objects with eventListeners and some of the DO's have been removed, some of the eventListeners have been triggered and removed etc... Is there a way to force garbage collection to run and collect everything that is available to be collected?</p>
[ { "answer_id": 192418, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 6, "selected": true, "text": "System.gc()" }, { "answer_id": 2295438, "author": "FredV", "author_id": 30829, "author_profile": "https://...
2008/10/10
[ "https://Stackoverflow.com/questions/192373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10875/" ]
192,375
<p>When using <code>before_filter :login_required</code> to protect a particular page, the <code>link_to_unless_current</code> method in the application layout template renders the "Login" link for the login page as a hyperlink instead of just text.</p> <p>The "Login" text/link problem only occurs when redirected to the Login Page via the <code>before_filter</code> machinery, otherwise, the <code>link_to_unless_current</code> method operates as expected.</p> <p>It seems that <code>link_to_unless_current</code> is using the old page data as the "current" instead of the login page (when redirecting).</p>
[ { "answer_id": 527112, "author": "Toby Hede", "author_id": 14971, "author_profile": "https://Stackoverflow.com/users/14971", "pm_score": 1, "selected": false, "text": " redirect_to login_url\n" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
192,398
<p>I am selecting from a table that has an XML column using T-SQL. I would like to select a certain type of node and have a row created for each one.</p> <p>For instance, suppose I am selecting from a <em>people</em> table. This table has an XML column for <em>addresses</em>. The XML is formated similar to the following:</p> <pre><code>&lt;address&gt; &lt;street&gt;Street 1&lt;/street&gt; &lt;city&gt;City 1&lt;/city&gt; &lt;state&gt;State 1&lt;/state&gt; &lt;zipcode&gt;Zip Code 1&lt;/zipcode&gt; &lt;/address&gt; &lt;address&gt; &lt;street&gt;Street 2&lt;/street&gt; &lt;city&gt;City 2&lt;/city&gt; &lt;state&gt;State 2&lt;/state&gt; &lt;zipcode&gt;Zip Code 2&lt;/zipcode&gt; &lt;/address&gt; </code></pre> <p>How can I get results like this:</p> <p><strong>Name</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>City</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>State</strong></p> <p>Joe Baker&nbsp;&nbsp;&nbsp;Seattle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WA</p> <p>Joe Baker&nbsp;&nbsp;&nbsp;Tacoma&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WA</p> <p>Fred Jones&nbsp;&nbsp;Vancouver&nbsp;BC</p>
[ { "answer_id": 192445, "author": "Wyatt", "author_id": 26626, "author_profile": "https://Stackoverflow.com/users/26626", "pm_score": -1, "selected": false, "text": "var addresses = dataContext.People.Addresses\n .Elements(\"address\")\n .Select(address => new { \n st...
2008/10/10
[ "https://Stackoverflow.com/questions/192398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3645/" ]
192,413
<p>I have a RichTextBox where I need to update the Text property frequently, but when I do so the RichTextBox "blinks" annoyingly as it refreshes all throughout a method call.</p> <p>I was hoping to find an easy way to temporarily suppress the screen refresh until my method is done, but the only thing I've found on the web is to override the WndProc method. I've employed this approach, but with some difficulty and side effects, and it makes debugging harder, too. It just seems like there's got to be a better way of doing this. Can someone point me to a better solution?</p>
[ { "answer_id": 192423, "author": "BKimmel", "author_id": 13776, "author_profile": "https://Stackoverflow.com/users/13776", "pm_score": -1, "selected": false, "text": "myRichTextBox.SuspendLayout();\nDoStuff();\nmyRichTextBox.ResumeLayout();\n" }, { "answer_id": 192461, "autho...
2008/10/10
[ "https://Stackoverflow.com/questions/192413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
192,417
<p>Personally, I find the range of functionality provided by java.util.Iterator to be fairly pathetic. At a minimum, I'd like to have methods such as:</p> <ul> <li>peek() returns next element without moving the iterator forward</li> <li>previous() returns the previous element</li> </ul> <p>Though there are lots of other possibilities such as first() and last().</p> <p>Does anyone know if such a 3rd party iterator exists? It would probably need to be implemented as a decorator of java.util.Iterator so that it can work with the existing java collections. Ideally, it should be "generics aware".</p> <p>Thanks in advance, Don</p>
[ { "answer_id": 192449, "author": "William", "author_id": 9193, "author_profile": "https://Stackoverflow.com/users/9193", "pm_score": 4, "selected": false, "text": "previous()" }, { "answer_id": 192623, "author": "PierreBdR", "author_id": 7136, "author_profile": "https...
2008/10/10
[ "https://Stackoverflow.com/questions/192417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
192,432
<p>I've tried to use the new <a href="http://groovy.codehaus.org/Grape" rel="noreferrer">Groovy Grape</a> capability in Groovy 1.6-beta-2 but I get an error message;</p> <pre><code>unable to resolve class com.jidesoft.swing.JideSplitButton </code></pre> <p>from the Groovy Console (/opt/groovy/groovy-1.6-beta-2/bin/groovyConsole) when running the stock example;</p> <pre><code>import com.jidesoft.swing.JideSplitButton @Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,)') public class TestClassAnnotation { public static String testMethod () { return JideSplitButton.class.name } } </code></pre> <p>I even tried running the grape command line tool to ensure the library is imported. Like this;</p> <pre><code> $ /opt/groovy/groovy-1.6-beta-2/bin/grape install com.jidesoft jide-oss </code></pre> <p>which does install the library just fine. How do I get the code to run/compile correctly from the groovyConsole?</p>
[ { "answer_id": 194403, "author": "shemnon", "author_id": 8020, "author_profile": "https://Stackoverflow.com/users/8020", "pm_score": 4, "selected": true, "text": "groovy.grape.Grape.initGrape()\n" }, { "answer_id": 194439, "author": "Bob Herrmann", "author_id": 6580, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6580/" ]
192,454
<p>I have TortoiseSVN set up to use KDiff3 as the conflict resolution tool (I find it shows more information useful to the merge than the built-in TortoiseMerge does).</p> <p>When I open a file with Tortoise's "Edit Conflicts" command it shows me the three files and I have to select "Merge->Merge Current File" manually. The problem is that KDiff3 saves the result to <code>source_file.working</code> instead of to <code>source_file</code>. So without doing a Save As, the real file with the conflict doesn't get modified. Is there a way around doing this manual Save As every time?</p> <p>I know this isn't strictly a programming question but it's about an ancillary process common enough to programmers that it should be useful here. I couldn't find the answer to this elsewhere.</p>
[ { "answer_id": 192558, "author": "Owen", "author_id": 4790, "author_profile": "https://Stackoverflow.com/users/4790", "pm_score": 3, "selected": false, "text": "kdiff3.exe" }, { "answer_id": 200657, "author": "Milen A. Radev", "author_id": 15785, "author_profile": "ht...
2008/10/10
[ "https://Stackoverflow.com/questions/192454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
192,456
<p>I would like to set the log file name for a log4j and log4net appender to have the current date. We are doing Daily rollovers but the current log file does not have a date. The log file name format would be </p> <pre><code>logname.2008-10-10.log </code></pre> <p>Anyone know the best way for me to do this?</p> <p>edit: I forgot to mention that we would want to do this in log4net as well. Plus any solution would need to be usable in JBoss.</p>
[ { "answer_id": 192548, "author": "gedevan", "author_id": 20225, "author_profile": "https://Stackoverflow.com/users/20225", "pm_score": 7, "selected": true, "text": "<appender name=\"roll\" class=\"org.apache.log4j.DailyRollingFileAppender\">\n <param name=\"File\" value=\"application....
2008/10/10
[ "https://Stackoverflow.com/questions/192456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387361/" ]
192,527
<p>I've been researching memory mapped files for a project and would appreciate any thoughts from people who have either used them before, or decided against using them, and why?</p> <p>In particular, I am concerned about the following, in order of importance:</p> <ul> <li>concurrency</li> <li>random access</li> <li>performance</li> <li>ease of use</li> <li>portability</li> </ul>
[ { "answer_id": 192672, "author": "bog", "author_id": 20909, "author_profile": "https://Stackoverflow.com/users/20909", "pm_score": 5, "selected": false, "text": "11111111\n22222222\n11112222\n22221111\n" }, { "answer_id": 192674, "author": "Brian Ensink", "author_id": 125...
2008/10/10
[ "https://Stackoverflow.com/questions/192527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10184/" ]
192,539
<p>I have a .NET application that processes around 300,000 records in a batch import, and it takes a few seconds per record so I would like to parallelize this. In the following code, what's the difference between <code>ProcessWithAnsycDelegates()</code> and <code>ProcessWithThreadPool()</code>?</p> <pre><code>public class ResultNotification { public EventHandler event Success; public EventHandler event Fail; internal void Notify(bool sucess) {if (success) Success(); else Fail();} } public static class Processor { public ResultNotification ProcessWithAnsycDelegates(Record record) { var r = new ResultNotification(); Func&lt;Record,bool&gt; processRecord=new RecordProcessor().ProcessRecord; processRecord.BeginInvoke ( record ,ar =&gt; result.Notify(processRecord.EndInvoke(ar)) ,null); return r; } public ResultNotification ProcessWithThreadPool(Record r) { var r = new ResultNotification(); var rp = new RecordProcessor(); ThreadPool.QueueWorkUserItem(_=&gt;result.Notify(rp.ProcessRecord(r))); return r; } } </code></pre>
[ { "answer_id": 192580, "author": "chadmyers", "author_id": 10862, "author_profile": "https://Stackoverflow.com/users/10862", "pm_score": 4, "selected": true, "text": "QueueUserWorkItem()" }, { "answer_id": 194648, "author": "Thomas Bratt", "author_id": 15985, "author_...
2008/10/10
[ "https://Stackoverflow.com/questions/192539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
192,549
<p>I have a controller method that returns a list for a drop down that gets rendered in a partial, but depending on where the partial is being used, the RJS template needs to be different. Can I pass a parameter to the controller that will determine which RJS gets used?</p> <p>Here is the controller method, it is very simple:</p> <pre><code>def services respond_to do |format| format.js { @type = HospitalCriteria.find_by_id(params[:type_id]) @services = @type.children.all } end end </code></pre> <p>And here is the rjs template the gets rendered automatically</p> <pre><code>page.replace_html 'select_service', :partial =&gt; 'hospital/services' page.replace_html 'select_condition', :partial =&gt; 'hospital/conditions' page.replace_html 'select_procedure', :partial =&gt; 'hospital/procedures' page &lt;&lt; 'if ($("chosenType") != null) {' page.replace_html 'chosenType', @type.name page.replace_html 'chosenService', 'Selected Service' page.replace_html 'chosenCondition', 'Selected Condition' page.replace_html 'chosenProcedure', 'Selected Procedure' page &lt;&lt; '}' </code></pre>
[ { "answer_id": 192867, "author": "Mike Breen", "author_id": 22346, "author_profile": "https://Stackoverflow.com/users/22346", "pm_score": 1, "selected": false, "text": "if params[:use_alternate]\n render :template => alternate.rjs and return\nend\n" }, { "answer_id": 192910, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
192,553
<p>I am currently in the process of making a new ASP.net MVC website, and find myself using Html.Encode all over the place, which is good practice, but gets pretty messy. I think a good way to clean this up would be if I could overload an operator to automatically do Html encoding. </p> <p>Previously:</p> <pre><code>&lt;%= Html.Encode( ViewData['username'] ) %&gt; </code></pre> <p>Would be equivalent to:</p> <pre><code>&lt;%=h ViewData['username'] %&gt; </code></pre> <p>Anyone have any ideas how I could do this, maybe using an extension method or something?</p>
[ { "answer_id": 192564, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": -1, "selected": false, "text": "public static String h (this System.Object o, System.Object viewData)\n{\n return Html.Encode(viewData);\n}\n" }, { ...
2008/10/10
[ "https://Stackoverflow.com/questions/192553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24841/" ]
192,570
<p>The project I'm working on uses a window.onerror event handler to report user problems. I've noticed a single user that just cannot seem to load the Google Analytics script. Our site doesn't see a lot of traffic so I'm not sure how widespread this is, but so far it seems to just effect one user. </p> <p>His user agent is: "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17".<br> The error message Firefox gives is: "Error loading script".</p> <p><strong>Additional note</strong>: The site references several other javascript files. However, the analytics reference is the only one to an external domain and the only script reference at the bottom of the page, just before the closing body tag.</p> <p>Has anybody else run across this, or have any idea what could be the issue? Thanks!</p>
[ { "answer_id": 7686057, "author": "Karl Bartel", "author_id": 114926, "author_profile": "https://Stackoverflow.com/users/114926", "pm_score": 3, "selected": false, "text": "[11:35:57.428] uncaught exception: [Exception... \"prompt aborted by user\" nsresult: \"0x80040111 (NS_ERROR_NOT_A...
2008/10/10
[ "https://Stackoverflow.com/questions/192570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423/" ]
192,575
<p>How do I transfer the users of a vBulletin forum to a new installation of IceBB?</p>
[ { "answer_id": 7686057, "author": "Karl Bartel", "author_id": 114926, "author_profile": "https://Stackoverflow.com/users/114926", "pm_score": 3, "selected": false, "text": "[11:35:57.428] uncaught exception: [Exception... \"prompt aborted by user\" nsresult: \"0x80040111 (NS_ERROR_NOT_A...
2008/10/10
[ "https://Stackoverflow.com/questions/192575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5509/" ]
192,584
<p>I have a listbox that is databound to a Collection of objects. The listbox is configured to display an identifier property of each object. I would like to show a tooltip with information specific to the item within the listbox that is being hovered over rather than one tooltip for the listbox as a whole.</p> <p>I am working within WinForms and thanks to some helpful blog posts put together a pretty nice solution, which I wanted to share.</p> <p>I'd be interested in seeing if there's any other elegant solutions to this problem, or how this may be done in WPF.</p>
[ { "answer_id": 192654, "author": "Michael Lang", "author_id": 19452, "author_profile": "https://Stackoverflow.com/users/19452", "pm_score": 5, "selected": true, "text": "private ITypeOfObjectsBoundToListBox DetermineHoveredItem()\n{\n Point screenPosition = ListBox.MousePosition;\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/192584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19452/" ]
192,641
<p>I recently wrote a DLL in C# (.Net 2.0) which contains a class that requires an IP address. A co-worker of mine altered the class to retrieve the IP from a ".dll.config" (XML) file -- This apparently is automatically generated by the "Application Settings" file he created (Settings1.settings). The benefit of this was to allow the end-user to change the IP address in the XML/config file at will.</p> <p>Unfortunately, when I check his code out of the tree and try to compile (or use) this new code, any application calling this DLL only gets the default value, rather than the value from the file.</p> <p>The constructor that calls the config file looks like this:</p> <pre><code> public class form : System.Windows.Forms.Form { public form() { // This call is required by the Windows Form Designer. InitializeComponent(); IP = IPAddress.Parse(Settings1.Default.IPAddress); } } </code></pre> <p>I found <a href="http://social.msdn.microsoft.com/Forums/en-US/clr/thread/f3a4b138-6e6c-42e3-86e8-1f86c90f8fb4/" rel="noreferrer">a reference to this problem on the MSDN forums</a> where a user said:</p> <blockquote> <p>the 'old' values (the ones you define at development time) are hard coded. If the franework isn't able to access or open the config file it will use the defaults instead. This will always happen if you use settings in a dll.</p> </blockquote> <ol> <li><p>Does this mean that I cannot store an external value for a DLL in a config file? (My co-worker has somehow made this work...)</p></li> <li><p>Since my framework appears to be unable to access or open the config file, how do I figure out why it's failing? Or even detect when this happens?</p></li> </ol> <p><b>Decker</b>: That helps a bit. Unfortunately, I am writing this DLL to a specification, so I don't actually have access to the Application's config file. As you'll note above, my co-worker created a "Settings<b>1</b>.settings" file. I didn't understand this at the time, but it seems now that adding the "1" keeps it out of the settings space of any application that calls it. </p> <p>I guess what I'm trying to figure out is why the DLL doesn't seem to find the config file sitting next to it in the same directory. Tracing thru the code step-by-step reveals nothing.</p> <p>As an aside, I can change the "Output Type" of my assembly from "Class Library" to "Windows Application" and add the following lines at the beginning of my DLL code:</p> <pre><code> [STAThread] public static void Main(string[] args) { System.Windows.Forms.Application.Run(new form()); } </code></pre> <p>When I run this, it generates a different config file (a ".exe.config") and that one I can alter and have it pull the new data from the file. So I'm a bit confused. Any ideas?</p>
[ { "answer_id": 192828, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": 3, "selected": false, "text": " [global::System.Configuration.ApplicationScopedSettingAttribute()]\n [global::System.Diagnostics.DebuggerNonUs...
2008/10/10
[ "https://Stackoverflow.com/questions/192641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21244/" ]
192,643
<p>How do I determine if a <code>Nullable(of Enum)</code> is indeed an <code>Enum</code> by means of reflection?</p> <p>I'm working with a method that dynamically populates an object of type <code>T</code> with an <code>IDataReader</code> retrieved from a database call. At its essence, it loops through the datareader's ordinals, and all the properties of <code>T</code> and populates the properties that match the name of the ordinals (also some attribute magic is thrown to change column names). In every other circumstance, it works great, but when I check the property's <code>BaseType</code> for <code>System.Enum</code> I find instead, <code>System.ValueType</code> Thusly, my Enum check fails and the method bombs.</p> <p>[Edit: <code>Type.IsEnum</code> doesn't work how I need it. The main issue here, is that nothing in <code>T</code>'s BaseType hierarchy says that it is an <code>Enum</code>. It's as if making it a <code>Nullable</code> type forfeits my <code>Enum</code> rights.]</p> <p>Any ideas?</p>
[ { "answer_id": 192706, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 4, "selected": true, "text": "PropertyInfo.PropertyType" }, { "answer_id": 192709, "author": "Dan Goldstein", "author_id": 23427, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13611/" ]
192,648
<p>OK, so I'm trying to teach myself the CakePHP framework, and I'm trying to knock up a simple demo app for myself.</p> <p>I have the controllers, views and models all set up and working, but I want to do something slightly more than the basic online help shows.</p> <p>I have a guitars_controller.php file as follows...</p> <pre><code>&lt;?php class GuitarsController extends AppController { var $name = 'Guitars'; function index() { $this-&gt;set('Guitars', $this-&gt;Guitar-&gt;findAll()); $this-&gt;pageTitle = "All Guitars"; } function view($id = null) { $this-&gt;Guitar-&gt;id = $id; $this-&gt;set('guitar', $this-&gt;Guitar-&gt;read()); // Want to set the title here. } } ?&gt; </code></pre> <p>The 'Guitar' object contains an attribute called 'Name', and I'd like to be able to set that as the pageTitle for the individual page views. </p> <p>Can anyone point out how I'd do that, please? </p> <p><strong>NB</strong>: I know that there is general disagreement about where in the application to set this kind of data, but to me, it is data related.</p>
[ { "answer_id": 192657, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "$this->pageTitle = $this->Guitar->Name;\n" }, { "answer_id": 192737, "author": "Paolo Bergantino", "author_i...
2008/10/10
[ "https://Stackoverflow.com/questions/192648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377/" ]
192,649
<p>Ruby can add methods to the Number class and other core types to get effects like this:</p> <pre class="lang-rb prettyprint-override"><code>1.should_equal(1) </code></pre> <p>But it seems like Python cannot do this. Is this true? And if so, why? Does it have something to do with the fact that <em>type</em> can't be modified?</p> <p><em>Rather than talking about different definitions of monkey patching, I would like to just focus on the example above. I have already concluded that it cannot be done as a few of you have answered. But I would like a more detailed explanation of why it cannot be done, and maybe what feature, if available in Python, would allow this.</em></p> <p>To answer some of you: The reason I <em>might</em> want to do this is simply aesthetics/readability.</p> <pre><code> item.price.should_equal(19.99) </code></pre> <p>This reads more like English and clearly indicates which is the tested value and which is the expected value, as supposed to:</p> <pre><code>should_equal(item.price, 19.99) </code></pre> <p>This concept is what <a href="http://rspec.info/" rel="nofollow noreferrer">Rspec</a> and some other Ruby frameworks are based on.</p>
[ { "answer_id": 192681, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": 2, "selected": false, "text": "import TelnetConnection\n" }, { "answer_id": 192703, "author": "Dan Lenski", "author_id": 20789, "au...
2008/10/10
[ "https://Stackoverflow.com/questions/192649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304/" ]
192,653
<p>I'm using .NET 3.5 and I have a class, A, marked as internal sealed partial and it derives from System.Configuration.ApplicationSettingsBase. I then use an instance of this class in the following manner:</p> <pre><code>A A_Instance = new A(); A_Instance.Default.Save(); </code></pre> <p>Why would the Visual C# compiler be complaining:</p> <pre><code>error CS0117: 'A' does not contain a definition for 'Default' </code></pre> <p>?</p>
[ { "answer_id": 192690, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 3, "selected": true, "text": "private static ServerSettings defaultInstance = ((ServerSettings)(global::System.Configuration.ApplicationSettingsBas...
2008/10/10
[ "https://Stackoverflow.com/questions/192653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2836/" ]
192,686
<p>Difficult question. The answer is probably no, if all I found in the Intertubes is right, but it is worth a try. I need to override the <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Esc</kbd> and the <kbd>Ctrl</kbd> + <kbd>Esc</kbd> combinations. It would be good to be able to override the <kbd>Win</kbd> key combinations, but I have a low level hook that does such, I only wish I didn't need it. If I can manage to block the start menu and the task manager entirely by policy, the overrides will no longer be needed but I couldn't find the correct policy to do so.</p>
[ { "answer_id": 43309345, "author": "Michael Z.", "author_id": 4114591, "author_profile": "https://Stackoverflow.com/users/4114591", "pm_score": 0, "selected": false, "text": "RegisterHotKey" } ]
2008/10/10
[ "https://Stackoverflow.com/questions/192686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5954/" ]
192,693
<p>I'm writing a routine that validates data before inserting it into a database, and one of the steps is to see if numeric values fit the precision and scale of a Numeric(x,y) SQL-Server type. </p> <p>I have the precision and scale from SQL-Server already, but what's the most efficient way in C# to get the precision and scale of a CLR value, or at least to test if it fits a given constraint?</p> <p>At the moment, I'm converting the CLR value to a string, then looking for the location of the decimal point with .IndexOf(). Is there a faster way?</p>
[ { "answer_id": 192906, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 5, "selected": true, "text": "System.Data.SqlTypes.SqlDecimal.ConvertToPrecScale( new SqlDecimal (1234.56789), 8, 2)\n" }, { "answer_id": 38383700, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5548/" ]
192,697
<p>How do you fix a names mismatch problem, if the client-side names are keywords or reserved words in the server-side language you are using?</p> <p>The DOJO JavaScript toolkit has a QueryReadStore class that you can subclass to submit REST patterned queries to the server. I'm using this in conjunction w/ the FilteringSelect Dijit.</p> <p>I can subclass the QueryReadStore and specify the parameters and arguments getting passed to the server. But somewhere along the way, a "start" and "count" parameter are being passed from the client to the server. I went into the API and discovered that the QueryReadStore.js is sending those parameter names.</p> <p>I'm using Fiddler to confirm what's actually being sent and brought back. The server response is telling me I have a parameter names mismatch, because of the "start" and "count" parameters. The problem is, I can't use "start" and "count" in PL/SQL.</p> <p>Workaround or correct implementation advice would be appreciated...thx.</p> <p>//I tried putting the code snippet in here, but since it's largely HTML, that didn't work so well.</p>
[ { "answer_id": 452537, "author": "MojoMark", "author_id": 56056, "author_profile": "https://Stackoverflow.com/users/56056", "pm_score": 0, "selected": false, "text": "create or replace package pkg_name\n TYPE plsqltable\n IS\n TABLE OF VARCHAR2 (32000)\n INDEX BY BINARY...
2008/10/10
[ "https://Stackoverflow.com/questions/192697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
192,715
<p>Take this non-compiling code for instance:</p> <pre><code>public string GetPath(string basefolder, string[] extraFolders) { string version = Versioner.GetBuildAndDotNetVersions(); string callingModule = StackCrawler.GetCallingModuleName(); return AppendFolders(basefolder, version, callingModule, extraFolders); } private string AppendFolders(params string[] folders) { string outstring = folders[0]; for (int i = 1; i &lt; folders.Length; i++) { string fixedPath = folders[i][0] == '\\' ? folders[i].Substring(1) : folders[i]; Path.Combine(outstring, fixedPath); } return outstring; } </code></pre> <p>This example is a somewhat simplified version of testing code I am using. Please, I am only interested in solutions having directly to do with the param keyword. I know how lists and other similar things work.</p> <p>Is there a way to "explode" the extraFolders array so that it's contents can be passed into AppendFolders along with other parameters?</p>
[ { "answer_id": 192758, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": false, "text": "AppendFolders(extraFolders);\n" }, { "answer_id": 192797, "author": "MojoFilter", "author_id": 93, ...
2008/10/10
[ "https://Stackoverflow.com/questions/192715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9251/" ]
192,718
<p>I need to run a JNDI provider without the overhead of a J2EE container. I've tried to follow the directions in this <a href="http://www.javaworld.com/javaworld/jw-04-2002/jw-0419-jndi.html" rel="noreferrer">article</a>, which describes (on page 3) exactly what I want to do. Unfortunately, these directions fail. I had to add the jboss-common.jar to my classpath too. Once I did that, I get a stack trace:</p> <pre><code>$ java org.jnp.server.Main 0 [main] DEBUG org.jboss.naming.Naming - Creating NamingServer stub, theServer=null,rmiPort=0,clientSocketFactory=null,serverSocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076[bindAddress=null] Exception in thread "main" java.lang.NullPointerException at org.jnp.server.Main.getNamingInstance(Main.java:301) at org.jnp.server.Main.initJnpInvoker(Main.java:354) at org.jnp.server.Main.start(Main.java:316) at org.jnp.server.Main.main(Main.java:104) </code></pre> <p>I'm hoping to make this work, but I would also be open to other lightweight standalone JNDI providers. All of this is to make ActiveMQ work, and if somebody can suggest another lightweight JMS provider that works well outside of the vm the clients are in without a full blown app server that would work too. </p>
[ { "answer_id": 192936, "author": "KC Baltz", "author_id": 9910, "author_profile": "https://Stackoverflow.com/users/9910", "pm_score": 2, "selected": false, "text": "java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory\n\n# use the following property to confi...
2008/10/10
[ "https://Stackoverflow.com/questions/192718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13816/" ]
192,721
<p>In <a href="https://stackoverflow.com/users/23233/mmalc">@mmalc's</a> <a href="https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa#156288">response</a> to <a href="https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa">this question</a> he states that "In general you should <em>not</em> use accessor methods in dealloc (or init)." Why does mmalc say this?</p> <p>The only really reasons I can think of are performance and avoiding unknown side-effects of @dynamic setters.</p> <p>Discussion?</p>
[ { "answer_id": 192852, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 5, "selected": false, "text": "@implementation Example\n\n-(void) setFoo:(Foo*)foo\n{\n _foo = foo;\n [_observer onPropertyChange:self object:foo];...
2008/10/10
[ "https://Stackoverflow.com/questions/192721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23113/" ]
192,725
<p>I have just started learning Erlang and am trying out some Project Euler problems to get started. However, I seem to be able to do any operations on large sequences without crashing the erlang shell.</p> <p>Ie.,even this:</p> <pre><code>list:seq(1,64000000). </code></pre> <p>crashes erlang, with the error:</p> <p>eheap_alloc: Cannot allocate 467078560 bytes of memory (of type "heap").</p> <p>Actually # of bytes varies of course.</p> <p>Now half a gig is a lot of memory, but a system with 4 gigs of RAM and plenty of space for virtual memory should be able to handle it.</p> <p>Is there a way to let erlang use more memory?</p>
[ { "answer_id": 193804, "author": "Darius Bacon", "author_id": 27024, "author_profile": "https://Stackoverflow.com/users/27024", "pm_score": 5, "selected": true, "text": "-module(lazy).\n-export([seq/2]).\n\nseq(M, N) when M =< N ->\n fun() -> [M | seq(M+1, N)] end;\nseq(_, _) ->\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/192725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
192,736
<p>A word of warning: I'm a n00b to <code>git</code> in general. My team uses feature branches in <code>svn</code>, and I'd like to use <code>git-svn</code> to track my work on a particular feature branch. I've been (roughly) following <a href="http://andy.delcambre.com/2008/03/04/git-svn-workflow.html" rel="noreferrer">Andy Delcambre's post</a> to set up my local <code>git</code> repo, but those instructions seem to have led <code>git</code> to pick the <code>svn</code> branch that had changed most recently as the remote repository; the problem is that's not the branch I care about. How do I control which branch <code>git-svn</code> uses? Or am I approaching this completely wrong?</p> <p>UPDATE: I did use the <code>-T</code>, <code>-b</code>, and <code>-t</code> options (in my case because the <code>svn</code> repo has multiple projects, but I want the <code>git</code> repo to contain only the project I'm working on).</p>
[ { "answer_id": 197453, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 7, "selected": true, "text": "git" }, { "answer_id": 696304, "author": "Sam Mulube", "author_id": 84492, "author_profile": "https://St...
2008/10/10
[ "https://Stackoverflow.com/questions/192736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203/" ]