qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
255,008
<p>What are the ways by which we can reduce the size of the HTML Response sent by an asp.net application?</p> <p>I am using Controls which are not owned by me and it produces output with white spaces. I am interested in Minifying the entire HTML output of the page just like how google does (View source www.google.com) to improve the timing.</p> <p>Is there any Utility classes available for ASP.NET which can do this stuff for me?</p>
[ { "answer_id": 28692638, "author": "Veverke", "author_id": 1219280, "author_profile": "https://Stackoverflow.com/users/1219280", "pm_score": 2, "selected": false, "text": "@{\n ... \n ...\n // anything\n ...\n}\n" } ]
2008/10/31
[ "https://Stackoverflow.com/questions/255008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30594/" ]
255,019
<p>Is there any way to do the equivalent of the following in a JSP without using scriptlet?</p> <pre><code>&lt;% response.setContentType("text/plain"); %&gt; </code></pre> <p>I can't simply use</p> <p>because I need to set the content-type in 2 places (each in a different branch of a ) and the JSP compiler will only allow one such directive.</p> <p>Also, I can't write two separate JSPs and forward to one or the other in a servlet because the JSP is triggered by the container when an authentication failure occurs.</p> <p>Cheers, Don</p>
[ { "answer_id": 255023, "author": "AlexJReid", "author_id": 32320, "author_profile": "https://Stackoverflow.com/users/32320", "pm_score": 2, "selected": false, "text": "<%@ page language=\"java\" contentType=\"text/plain\" %>\n" }, { "answer_id": 255105, "author": "Will Hartun...
2008/10/31
[ "https://Stackoverflow.com/questions/255019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
255,035
<p>How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way.</p>
[ { "answer_id": 255053, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": 7, "selected": true, "text": "import time, datetime\n\nd = datetime.datetime.now()\nprint time.mktime(d.timetuple())\n" }, { "answer_id": 5872022, ...
2008/10/31
[ "https://Stackoverflow.com/questions/255035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
255,041
<p>Is there some way I can define <code>String[int]</code> to avoid using <code>String.CharAt(int)</code>?</p>
[ { "answer_id": 255046, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 5, "selected": true, "text": "operator*" }, { "answer_id": 255051, "author": "Lee Kowalkowski", "author_id": 30945, "author_profile": ...
2008/10/31
[ "https://Stackoverflow.com/questions/255041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4435/" ]
255,056
<p>I have a standard .NET windows service written in C#.</p> <p>Can it install itself without using InstallUtil? Should I use the service installer class? How should I use it?</p> <p>I want to be able to call the following:</p> <pre><code>MyService.exe -install </code></pre> <p>And it will have the same effect as calling:</p> <pre><code>InstallUtil MyService.exe </code></pre>
[ { "answer_id": 255062, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 8, "selected": true, "text": "[RunInstaller(true)]\npublic sealed class MyServiceInstallerProcess : ServiceProcessInstaller\n{\n public MyService...
2008/10/31
[ "https://Stackoverflow.com/questions/255056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20257/" ]
255,063
<p>Would there a more elegant way of writing the following syntax? </p> <pre><code> Thread t0 = new Thread(new ParameterizedThreadStart(doWork)); t0.Start('someVal'); t0.Join(); Thread t1 = new Thread(new ParameterizedThreadStart(doWork)); t1.Start('someDiffVal'); t1.Join(); </code></pre> <p>Presuming we want to pass 20 different values, what would the best way of setting this up be? Looping through and joining at the end?</p> <p>If a new thread isn't instantiated (like below), it errors that the thread can't be restarted. For example:</p> <pre><code> Thread t1 = new Thread(new ParameterizedThreadStart(doWork)); t1.Start('someVal'); t1.Start('someDiffVal'); </code></pre>
[ { "answer_id": 255072, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "List<Thread> threads = new List<Thread>();\n\nforeach (string item in items)\n{\n string copy = item; // Important due...
2008/10/31
[ "https://Stackoverflow.com/questions/255063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30649/" ]
255,071
<p>I've been tasked with implementing a Date/Time selector for several areas of our web project, and instructed to use a control that another developer created as part of it. The control I'm working on is supposed to allow the user to choose a date from a calendar, choose a format for the display of that date (from several pre-defined formats, or with a simple text override) and optionally a time string (which is really just freeform text).</p> <p>The control I was instructed to use is documented here: <a href="http://www.west-wind.com/WebLog/posts/213015.aspx" rel="nofollow noreferrer">http://www.west-wind.com/WebLog/posts/213015.aspx</a>, and uses the DatePicker from jQuery.</p> <p>After I implemented my control and tested it, I began integrating it into the pages which needed Date and/or time inputs. In my testing of those implementations, I discovered a bug: when I include multiple copies of my control on a page, only the first one gets the jQuery calendar. The others are not tied to it.</p> <p>I have tried some of the methods suggested in a seemingly-related question (titled 'duplicating jquery datepicker'), such as calling the '.datepicker()' function on the west-wind control (which renders a textbox) via the $("css-selector").datepicker() syntax, and ASP.NET is guaranteeing unique IDs for all the text boxes.</p> <p>So, in summation, it looks like this:</p> <pre><code>&lt;page&gt; &lt;mycontrol&gt; &lt;west-windjQuerycontrol /&gt; &lt;/mycontrol&gt; &lt;mycontrol&gt; &lt;west-windjQuerycontrol /&gt; &lt;/mycontrol&gt; &lt;/page&gt; </code></pre> <p>Now, the strange part: When there are multiple copies of the west-wind control on the page, without the other user control containing them, they work correctly. Other than the jQuery control, my control has nothing unusual about it: simply labels, textboxes, panels, and dropdowns. Something about bundling the West-Wind jQuery control into a user control seems to be breaking it.</p> <p>Any advice? I've been banging my head against this for a while, hampered by my poor javascript skills and limited exposure to jQuery.</p> <p>As pointed out below, it's hard to say without the HTML. I've included it below.</p> <pre><code>&lt;form name="form1" method="post" action="ControlTest.aspx" id="form1"&gt; &lt;div&gt; &lt;input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /&gt; &lt;input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /&gt; &lt;input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" /&gt; &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTU4NjEzMDEwOQ9kFgICAw9kFgQCAw9kFgRmD2QWAgIDD2QWAgIDDxBkZBYBZmQCAg9kFgICAw9kFgICAQ8QZGQWAWZkAgUPZBYEZg9kFgICAw9kFgICAw8QZGQWAWZkAgIPZBYCAgMPZBYCAgEPEGRkFgFmZGRDjfLpdb+XxaVaQYP2XkPil2Galw==" /&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]&gt; &lt;/script&gt; &lt;script src="/SSO/DE/WebResource.axd?d=jMPpL-KK8_mPj_ssZzGblw2&amp;amp;t=633481894229838141" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/SSO/DE/ScriptResource.axd?d=8KwRIGaNAD3hi2Loz3YV-uxgrdZpGe8nnwH5E3gxLW_lQpnYjRbyIYThTnHtD9rt0&amp;amp;t=633613004148118290" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/SSO/DE/ScriptResource.axd?d=8KwRIGaNAD3hi2Loz3YV-uxgrdZpGe8nnwH5E3gxLW-K0Kuw-pGK1O3mE_r1y3sjKmhHtQjSXeMtYSim0bjyGA2&amp;amp;t=633613004148118290" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/SSO/DE/ScriptResource.axd?d=Id5yAacLMZHF7TWlkgrrid30ZStmsXuLHcF6WQ404YLySP4Itj4qxv2wi9ffbsWQA86oLdnZPWkwDnu4NKxfG1Ue7qdGG1SbOfb4ooHVs7M1&amp;amp;t=633481957084709567" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.'); //]]&gt; &lt;/script&gt; &lt;script src="/SSO/DE/ScriptResource.axd?d=Id5yAacLMZHF7TWlkgrrid30ZStmsXuLHcF6WQ404YLySP4Itj4qxv2wi9ffbsWQhT3MFELBAa2rFJZXnSlYAZIN7RT1npcBxJRsWGjJWIwTF0Es1m0vOd-xYnFqWJKz0&amp;amp;t=633481957084709567" type="text/javascript"&gt;&lt;/script&gt; &lt;div style="margin:25px 10px;width:100%;"&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ Sys.WebForms.PageRequestManager._initialize('stupidThing', document.getElementById('form1')); Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90); //]]&gt; &lt;/script&gt; &lt;div id="datePicker_Div0" class="AdminRowOdd DERow"&gt; &lt;div id="datePicker_Div1" class="DELabel"&gt; &lt;span id="datePicker_DateLabel"&gt;Date&lt;/span&gt; &lt;/div&gt; &lt;div id="datePicker_Div2" class="DEInput datePicker"&gt; &lt;input name="datePicker$DateSelector" type="text" onchange="javascript:setTimeout('__doPostBack(\'datePicker$DateSelector\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="datePicker_DateSelector" style="width:80px;" /&gt; &lt;select name="datePicker$languageSelector" onchange="javascript:setTimeout('__doPostBack(\'datePicker$languageSelector\',\'\')', 0)" id="datePicker_languageSelector"&gt; &lt;option selected="selected" value="en-US"&gt;en-US&lt;/option&gt; &lt;option value="fr-CA"&gt;fr-CA&lt;/option&gt; &lt;option value="fr-FR"&gt;fr-FR&lt;/option&gt; &lt;option value="es-ES"&gt;es-ES&lt;/option&gt; &lt;option value="es-MX"&gt;es-MX&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="datePicker_Div3" class="AdminRowEven DERow"&gt; &lt;div id="datePicker_Div4" class="DELabel"&gt; &lt;span id="datePicker_FormatChoiceLabel"&gt;Choose your display format: &lt;/span&gt; &lt;/div&gt; &lt;div id="datePicker_Div5" class="DEInput"&gt; &lt;select name="datePicker$DateFormatSelector" onchange="javascript:setTimeout('__doPostBack(\'datePicker$DateFormatSelector\',\'\')', 0)" id="datePicker_DateFormatSelector"&gt; &lt;option selected="selected" value="Choose a date first"&gt;Choose a date first&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="datePicker_Div6" class="AdminRowOdd DERow"&gt; &lt;div id="datePicker_Div7" class="DELabel"&gt; &lt;span id="datePicker_FormatOverrideLabel"&gt;Or enter your own text&lt;/span&gt; &lt;/div&gt; &lt;div id="datePicker_Div8" class="DEInput"&gt; &lt;input name="datePicker$DateFormatOverride" type="text" onchange="javascript:setTimeout('__doPostBack(\'datePicker$DateFormatOverride\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="datePicker_DateFormatOverride" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;div id="date1_Div0" class="AdminRowOdd DERow"&gt; &lt;div id="date1_Div1" class="DELabel"&gt; &lt;span id="date1_DateLabel"&gt;Date&lt;/span&gt; &lt;/div&gt; &lt;div id="date1_Div2" class="DEInput datePicker"&gt; &lt;input name="date1$DateSelector" type="text" onchange="javascript:setTimeout('__doPostBack(\'date1$DateSelector\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="date1_DateSelector" style="width:80px;" /&gt; &lt;select name="date1$languageSelector" onchange="javascript:setTimeout('__doPostBack(\'date1$languageSelector\',\'\')', 0)" id="date1_languageSelector"&gt; &lt;option selected="selected" value="en-US"&gt;en-US&lt;/option&gt; &lt;option value="fr-CA"&gt;fr-CA&lt;/option&gt; &lt;option value="fr-FR"&gt;fr-FR&lt;/option&gt; &lt;option value="es-ES"&gt;es-ES&lt;/option&gt; &lt;option value="es-MX"&gt;es-MX&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="date1_Div3" class="AdminRowEven DERow"&gt; &lt;div id="date1_Div4" class="DELabel"&gt; &lt;span id="date1_FormatChoiceLabel"&gt;Choose your display format:&lt;/span&gt; &lt;/div&gt; &lt;div id="date1_Div5" class="DEInput"&gt; &lt;select name="date1$DateFormatSelector" onchange="javascript:setTimeout('__doPostBack(\'date1$DateFormatSelector\',\'\')', 0)" id="date1_DateFormatSelector"&gt; &lt;option selected="selected" value="Choose a date first"&gt;Choose a date first&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="date1_Div6" class="AdminRowOdd DERow"&gt; &lt;div id="date1_Div7" class="DELabel"&gt; &lt;span id="date1_FormatOverrideLabel"&gt;Or enter your own text&lt;/span&gt; &lt;/div&gt; &lt;div id="date1_Div8" class="DEInput"&gt; &lt;input name="date1$DateFormatOverride" type="text" onchange="javascript:setTimeout('__doPostBack(\'date1$DateFormatOverride\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="date1_DateFormatOverride" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWFQLr6MeTCwKb1Zr0AwKVt6utCQKIwaTjAQKdwYzzBwLiwsDhDQKIwdCLBAKHwbCtCgLRr42cCQKi9vj4DgK2lM6kBQLLrsUtAsaboRMC2+2u3QgCzu2GzQ4Cse7K3wQC2+3atQ0C1O26kwMCpdTivwwC1o2X2wsCoubqnQk8I1BK30Q/iVw/rExUww2Cs4bicw==" /&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ jQuery(document).ready( function() { var cal = jQuery('#datePicker_DateSelector').datepicker({yearRange: '-1500:+100',dateFormat: 'm/d/yy'}); } ); Sys.Application.initialize(); //]]&gt; &lt;/script&gt; &lt;/form&gt; </code></pre>
[ { "answer_id": 255072, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "List<Thread> threads = new List<Thread>();\n\nforeach (string item in items)\n{\n string copy = item; // Important due...
2008/10/31
[ "https://Stackoverflow.com/questions/255071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23902/" ]
255,077
<p>I have just installed VMWare Server 2.0 on a fresh Fedora Core 8 install. The ports for the web access console of VMWare are 8222 and 8333 (like the defaults).</p> <p>When I try a remote http access to myserver:8222 it fails. But when I run</p> <pre><code>/sbin/service iptables stop </code></pre> <p>access becomes possibles (although not very satisfactory). Thus, I have updated the conf file as follow</p> <pre><code>cat /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-Firewall-1-INPUT - [0:0] -A INPUT -j RH-Firewall-1-INPUT -A RH-Firewall-1-INPUT -i lo -j ACCEPT -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT -A RH-Firewall-1-INPUT -p 50 -j ACCEPT -A RH-Firewall-1-INPUT -p 51 -j ACCEPT -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited # Custom authorization for VMWare administration -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8222 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8333 -j ACCEPT COMMIT </code></pre> <p>yet, even after reloading the iptables settings it's still not working. Do anyone knows what I am doing wrong?</p>
[ { "answer_id": 255331, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 3, "selected": true, "text": "-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n# Custom authorization for VMWare adminis...
2008/10/31
[ "https://Stackoverflow.com/questions/255077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18858/" ]
255,078
<p>What's the difference between a string and a symbol in Ruby and when should I use one over the other?</p>
[ { "answer_id": 255099, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 8, "selected": true, "text": "irb(main):007:0> :test.object_id\n=> 83618\nirb(main):008:0> :test.object_id\n=> 83618\nirb(main):009:0> :test.object...
2008/10/31
[ "https://Stackoverflow.com/questions/255078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
255,081
<p>I have a situation where another developer is including source files from a project that I maintain in a project that he maintains. The nature of the files is such that each source file registers a "command" in an interpretive environment so all you have to do is link in a new source file to register a new "command". We can't put these files in a static library because, unless the project makes explicit reference to the symbols in the file, the linker will optimise the file away. </p> <p>It seems like a potential solution is to have a file external to both projects that "includes" a list of source file names in both projects. The problem is that I have no idea whether or how this could be done. Suggestions, anyone?</p>
[ { "answer_id": 255090, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 0, "selected": false, "text": "#include" }, { "answer_id": 255159, "author": "Rob Walker", "author_id": 3631, "author_profile": "https...
2008/10/31
[ "https://Stackoverflow.com/questions/255081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19674/" ]
255,098
<p>I am experimenting with calling delegate functions from a delegate array. I've been able to create the array of delegates, but how do I call the delegate?</p> <pre><code>public delegate void pd(); public static class MyClass { static void p1() { //... } static void p2 () { //... } //... static pd[] delegates = new pd[] { new pd( MyClass.p1 ), new pd( MyClass.p2) /* ... */ }; } public class MainClass { static void Main() { // Call pd[0] // Call pd[1] } } </code></pre> <p><strong>EDIT:</strong> The reason for the array is that I need to call the delegate functions by an index as needed. They are not run in response to an event. I see a critical (stupid) error in my code as I had tried to execute the delegate function using the pd[] type rather than the name of the array (delegates).</p>
[ { "answer_id": 255107, "author": "Romain Verdier", "author_id": 4687, "author_profile": "https://Stackoverflow.com/users/4687", "pm_score": 3, "selected": false, "text": "public class MainClass\n{\n static void Main()\n {\n pd[0]();\n pd[1]();\n }\n}\n" }, { ...
2008/10/31
[ "https://Stackoverflow.com/questions/255098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7899/" ]
255,104
<p>I'm working on a WinForms app and I have a user control in it. The buttons in the user control raise events up to the form to be handled by other code. One of the buttons starts some processses that will cause problems if they run simultaneously. I have logic in the code to manage the state so typically a user can't run the process if it's already running. However, if the user double-clicks the button it will start the process twice so quickly that it's tough for me to prevent it.</p> <p>I'm wondering, what's the best way to handle this?</p> <p>I started out by disabling the button in the click event but the second click comes in before the first click causes the button to be disabled. Setting other flags in the code didn't catch it either.</p> <p>I'm considering adding some sort of sync lock on the code that raises the event but I'm wondering if any of you have a better idea. </p> <p>Since this project is mostly complete I'm looking for answers that don't involve a radical rewrite of the app (like implementing the composite application block), however, feel free to post those ideas too since I can use them in my next projects.</p>
[ { "answer_id": 255138, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": 4, "selected": true, "text": "private bool runningExclusiveProcess = false;\n\npublic void onClickHandler(object sender, EventArgs e)\n{\n if (!runn...
2008/10/31
[ "https://Stackoverflow.com/questions/255104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10221/" ]
255,114
<p>Let's make this very easy. What I want:</p> <pre><code>@array = qw/one two one/; my @duplicates = duplicate(@array); print "@duplicates"; # This should now print 'one'. </code></pre> <p>How to print duplicate values of a array/hash?</p>
[ { "answer_id": 255177, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 4, "selected": true, "text": "sub duplicate {\n my @args = @_;\n my %items;\n for my $element(@args) {\n $items{$element}++;\n }...
2008/10/31
[ "https://Stackoverflow.com/questions/255114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33232/" ]
255,133
<p>I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when really it's up. </p> <p>According to the <a href="http://livedocs.adobe.com/flex/2/langref/migration.html" rel="nofollow noreferrer">AS2 to AS3 Migration Guide</a>, I'm supposed to use <code>flash.display.InteractiveObject.setCapture()</code> for this, however it does not exist as far as I can tell. I guess this document is out of date or incorrect. I've found a few posts on the web about how to duplicate this functionality, but they either have their own problems:</p> <ul> <li><a href="http://www.arpitonline.com/blog/?p=33" rel="nofollow noreferrer">This one</a> triggers onReleaseOutside even if there was no corresponding onPress event. </li> <li><a href="http://www.kirupa.com/forum/showpost.php?p=1948182&amp;postcount=204" rel="nofollow noreferrer">This one</a> seems very inefficient, you'll add and remove an event listener every time the mouse is clicked anywhere inside your app.</li> </ul> <p>There has to be an easier way, don't tell me Adobe forgot about this when rewriting Actionscript?</p> <p>Example AS2 code:</p> <pre><code>// Assume myMC is a simple square or something on the stage myMC.onPress = function() { this._rotation = 45; } myMC.onRelease = myMC.onReleaseOutside = function() { this._rotation = 0; } </code></pre> <p>Without the onReleaseOutside handler, if you pressed down on the squre, dragged your mouse outside of it, and released the mouse, then the square would not un-rotate, and appear to be stuck.</p>
[ { "answer_id": 256007, "author": "Ronnie Liew", "author_id": 1987, "author_profile": "https://Stackoverflow.com/users/1987", "pm_score": 2, "selected": false, "text": "flash.events.Event.MOUSE_LEAVE\n" }, { "answer_id": 257441, "author": "Antti", "author_id": 6037, "a...
2008/10/31
[ "https://Stackoverflow.com/questions/255133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14569/" ]
255,147
<p>In python, if I say</p> <pre><code>print 'h' </code></pre> <p>I get the letter h and a newline. If I say </p> <pre><code>print 'h', </code></pre> <p>I get the letter h and no newline. If I say</p> <pre><code>print 'h', print 'm', </code></pre> <p>I get the letter h, a space, and the letter m. How can I prevent Python from printing the space?</p> <p>The print statements are different iterations of the same loop so I can't just use the + operator.</p>
[ { "answer_id": 255154, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 9, "selected": true, "text": "import sys\n\nsys.stdout.write('h')\nsys.stdout.flush()\n\nsys.stdout.write('m')\nsys.stdout.flush()\n" }, { "answ...
2008/10/31
[ "https://Stackoverflow.com/questions/255147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4343/" ]
255,153
<p>how do i determine what a mysql db's charset is set to? in the cli?</p>
[ { "answer_id": 255163, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 4, "selected": true, "text": "SHOW CREATE DATABASE db-name\n" } ]
2008/10/31
[ "https://Stackoverflow.com/questions/255153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18285/" ]
255,170
<p>I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the <a href="http://code.google.com/p/wmd/" rel="noreferrer">WMD</a> one here in Stack&nbsp;Overflow) would be perfect.</p> <p>However, <strong>they do need the ability to have images right-aligned in a given paragraph</strong>.</p> <p>I can't see a way to do that with the current system - is it possible?</p>
[ { "answer_id": 255182, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 9, "selected": true, "text": "<img style=\"float: right;\" src=\"whatever.jpg\">\n\nContinue markdown text...\n" }, { "answer_id": 1228126, ...
2008/10/31
[ "https://Stackoverflow.com/questions/255170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9913/" ]
255,189
<p>If I have a type defined as a <strong>set of</strong> an enumerated type, it's easy to create an empty set with [], but how do I create a <em>full</em> set?</p> <p>EDIT: Yeah, the obvious solution is to use a for loop. That's also a really bad solution if there's another way. Does anyone know of a way that'll work in constant time?</p>
[ { "answer_id": 255321, "author": "Jim McKeeth", "author_id": 255, "author_profile": "https://Stackoverflow.com/users/255", "pm_score": 3, "selected": false, "text": "FillChar(VarSet, SizeOf(VarSet), $FF);\n" } ]
2008/10/31
[ "https://Stackoverflow.com/questions/255189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
255,194
<p>I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models:</p> <pre><code>ClientContact { static hasMany = [owners: Person] static belongsTo = [Person] } Person { static hasMany = [clientContacts: ClientContact] } </code></pre> <p>When I try to retrieve all the <code>ClientContacts</code> with a specific owner (<code>Person</code>), I'm running into some funny issues. I'm using the following query criteria:</p> <pre><code>def query = { owners { eq("id", Long.parseLong(params.ownerId)) } } def criteria = ClientContact.createCriteria() def results = criteria.list(params, query) </code></pre> <p>The problem is when I iterate through each of my <code>ClientContacts</code> in the results, they only have <strong>the one owner</strong> - when in fact, most have many other owners. What gives? I know hibernate/GORM uses lazy fetching, but I thought it would fetch all of the other owners on a <code>ClientContact</code> when I tried to access them.</p> <p>Any thoughts? I would like to continue using the <em>list()</em> function since it provides some nice paging features.</p>
[ { "answer_id": 255295, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 0, "selected": false, "text": "eqId()" }, { "answer_id": 311865, "author": "billjamesdev", "author_id": 13824, "author_profile": "ht...
2008/10/31
[ "https://Stackoverflow.com/questions/255194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21832/" ]
255,202
<p>When I type <code>git diff</code>, I want to view the output with my visual diff tool of choice (SourceGear "diffmerge" on Windows). How do I configure git to do this?</p>
[ { "answer_id": 255212, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 10, "selected": true, "text": "path old-file old-hex old-mode new-file new-hex new-mode\n" }, { "answer_id": 392899, "author": "Milan Gardian", ...
2008/10/31
[ "https://Stackoverflow.com/questions/255202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3891/" ]
255,214
<p>I keep seeing references to the visitor pattern in blogs but I've got to admit, I just don't get it. I read the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="noreferrer">wikipedia article for the pattern</a> and I understand its mechanics but I'm still confused as to when I'd use it.</p> <p>As someone who just recently really <strong>got</strong> the decorator pattern and is now seeing uses for it absolutely everywhere I'd like to be able to really understand intuitively this seemingly handy pattern as well.</p>
[ { "answer_id": 255300, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 8, "selected": false, "text": "class Animal { };\nclass Dog: public Animal { };\nclass Cat: public Animal { };\n" }, { "answer_id"...
2008/10/31
[ "https://Stackoverflow.com/questions/255214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
255,216
<p>So far, I've only been passing javascript strings to my web methods, which get parsed, usually as Guids. but now i have a method that accepts an IList... on the client, i build this array of objects and then attempt to pass it like: </p> <pre><code>$.ajax({ type: 'POST', url: 'personalization.aspx/SetPersonalization', data: "{'backerEntries':" + backerEntries + "}", contentType: 'application/json; charset=utf-8', dataType: 'json', success: postcardManager.SetPersonalizationComplete }); </code></pre> <p>The post: </p> <pre><code>{'backerEntries':[object Object],[object Object],[object Object]} </code></pre> <p>The error response: </p> <pre><code>Invalid JSON primitive: object. </code></pre> <p>For some reason, jquery doesn't seem to convert my array into a json string? Any ideas why? I tried putting [] around the backerEntries, and {}, as well as {[]} just in sheer desperation. Am I missing something obvious here? </p>
[ { "answer_id": 255261, "author": "Duncan", "author_id": 25035, "author_profile": "https://Stackoverflow.com/users/25035", "pm_score": 2, "selected": false, "text": "data:{backerEntries: backerEntries }\n" }, { "answer_id": 255269, "author": "Shog9", "author_id": 811, ...
2008/10/31
[ "https://Stackoverflow.com/questions/255216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6350/" ]
255,278
<p>What would be the best way to determine if an object equals number zero (0) or string.empty in C#?</p> <p><b>EDIT:</b> The object can equal any built-in System.Value type or reference type.</p> <p>Source Code:</p> <pre><code>public void MyMethod(object input1, object input2) { bool result = false; object compare = new object(); if(input != null &amp;&amp; input2 != null) { if(input1 is IComparable &amp;&amp; input2 is IComparable) { //do check for zero or string.empty //if input1 equals to zero or string.empty result = object.Equals(input2); //if input1 not equals to zero or string.empty result = object.Equals(input1) &amp;&amp; object.Equals(input2); //yes not valid, but this is what I want to accomplish } } } </code></pre>
[ { "answer_id": 255292, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 1, "selected": false, "text": "string x = \"Some String\"\nif( string.IsNullOrEmpty(string input) ) { ... }\n" }, { "answer_id": 255339, ...
2008/10/31
[ "https://Stackoverflow.com/questions/255278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
255,302
<p>Hoping some of you TinyXML++ people can help me out. Really, since you recomended to me before I think you owe me ;)</p> <p>I have the following code:</p> <pre><code> //ticpp::Iterator&lt; ticpp::Element &gt; child( "SetPiece" ); ticpp::Iterator&lt; ticpp::Node &gt; child("SetPiece"); GLuint lc_SPieces = 0; for(child = child.begin( this ); child != child.end(); child++ ) { lc_SPieces++; } </code></pre> <p>If I use the top declaration for child I get the error:</p> <blockquote> <p>Unhandled exception at 0x7c812aeb in Drawing.exe: Microsoft C++ exception: __non_rtti_object @ 0x0012f7b4.</p> </blockquote> <p>And I get it in dbgheap.c at this line:</p> <pre><code>pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine); </code></pre> <p>What's weird is it works with Node, and I know that there are elements in there(I checked using the TinyXML iteration methods).</p> <p>Has anyone run into this before?</p>
[ { "answer_id": 285834, "author": "paavo256", "author_id": 34911, "author_profile": "https://Stackoverflow.com/users/34911", "pm_score": 1, "selected": false, "text": "__non_rtti_object" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
255,312
<p>Say i have this PHP code:</p> <pre><code>$FooBar = "a string"; </code></pre> <p>i then need a function like this:</p> <pre><code>print_var_name($FooBar); </code></pre> <p>which prints:</p> <pre><code>FooBar </code></pre> <p>Any Ideas how to achieve this? Is this even possible in PHP?</p>
[ { "answer_id": 255335, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 7, "selected": true, "text": "function print_var_name($var) {\n foreach($GLOBALS as $var_name => $value) {\n if ($value === $var) {\n ...
2008/11/01
[ "https://Stackoverflow.com/questions/255312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
255,317
<p>I have an asp.net page with a button. This button generates and inserts a user control into the page, so many controls could exist on one page. I need to validate that a certain dynamically generated control inside the generated control exists. </p> <p>So..Page has 0 to N Control1’s. Each Control 1 can have 0 to N Control2’s. When SaveButton is clicked on Page, I need to make sure there are at least 1 Control2’s inside every Control1. </p> <p>I’m currently between two options:</p> <p>• Dynamically insert CustomValidators for each control that is generated, each of which would validate one Control1.</p> <p>• Do the validation manually (with jQuery), calling a validation function from SaveButton.OnClientClick.</p> <p>Both are sloppy in their own way – which is why I’m sharing this with you all. Am I missing the easy solution?</p> <p>Thanks in advance.. (btw – anything up to and including .NET 3.5 SP1 is fair game)</p>
[ { "answer_id": 256251, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 4, "selected": true, "text": "public interface IValidatableControl\n{\n bool IsValidControl(); \n}\n" }, { "answer_id": 309401, "...
2008/11/01
[ "https://Stackoverflow.com/questions/255317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33253/" ]
255,337
<p>I want to read and write from serial using events/interrupts. Currently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++?</p> <p>This is my current code:</p> <pre> while(true) { //read if(!ReadFile(hSerial, szBuff, n, &dwBytesRead, NULL)){ //error occurred. Report to user. } //write if(!WriteFile(hSerial, szBuff, n, &dwBytesRead, NULL)){ //error occurred. Report to user. } //print what you are reading printf("%s\n", szBuff); } </pre>
[ { "answer_id": 256251, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 4, "selected": true, "text": "public interface IValidatableControl\n{\n bool IsValidControl(); \n}\n" }, { "answer_id": 309401, "...
2008/11/01
[ "https://Stackoverflow.com/questions/255337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
255,341
<p>It's easy to get the value of a key from a .NET generic Dictionary:</p> <pre><code>Dictionary&lt;int, string&gt; greek = new Dictionary&lt;int, string&gt;(); greek.Add(1, "Alpha"); greek.Add(2, "Beta"); string secondGreek = greek[2]; // Beta </code></pre> <p>But trying to get the keys given a value is not as straightforward because there could be multiple keys:</p> <pre><code>int[] betaKeys = greek.WhatDoIPutHere("Beta"); // expecting single 2 </code></pre>
[ { "answer_id": 255348, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 2, "selected": false, "text": "var key = (from k in yourDictionary where string.Compare(k.Value, \"yourValue\", true) == 0 select k.Key).FirstOrDefault();\...
2008/11/01
[ "https://Stackoverflow.com/questions/255341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22437/" ]
255,370
<p>I am developing Eclipse plugins, and I need to be able to automate the building and execution of the test suite for each plugin. (Using Junit)</p> <p>Test are working within Eclipse, and I can break the plugins into the actual plugin and a fragment plugin for unit testing as described <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.test/testframework.html?view=co" rel="nofollow noreferrer">here</a>, <a href="http://rcpquickstart.com/2007/08/06/running-automated-tests-with-pde-build/" rel="nofollow noreferrer">here</a> and in a couple places <a href="http://eclipsenuggets.blogspot.com/2007/09/6-great-links-for-eclipse-build.html" rel="nofollow noreferrer">here</a>.</p> <p>However, each of the approaches above results in the same issue: The java ant task/commandline command that issues the build or should trigger the test, generates no observable side effects, and returns the value "13". I've tried everything I can find, and I've learned a fair bit about how Eclipse starts up (eg: since v3.3 you can no longer use startup.jar -- it doesn't exist -- but you should use <a href="http://blog.ciscavate.org/2008/11/treat-your-mailing-lists-like-reference-documents-please.html" rel="nofollow noreferrer">org.eclipse.equinox.launcher</a>). Unfortunately, while that is apparently necessary information, it is far from sufficient.</p> <p>I am working with Eclipse 3.4, Junit 4.3.1 (the org.junit4 bundle, but I would much rather use JUnit 4.4. See <a href="https://stackoverflow.com/questions/251791">here</a>.)</p> <p>So, my question is: How exactly do you automate the build and testing of Eclipse plugins? </p> <p><em>Edit:</em> To clarify, I <em>want</em> to use something like ant + cruise control, but I can't even get the unit tests to run <em>at all</em> outside of Eclipse. I say "something like" because there are other technologies that accomplish the same thing, and I am not so picky as to discard a solution that works just because it's using say, Maven or Buckminster, if those technologies make this substantially easier.</p> <p><em>Edit2:</em> The 'Java Result 13' mentioned above seems to be caused by the inability to find the coretestrunner. From the log:</p> <pre><code>java.lang.RuntimeException: Application "org.eclipse.test.coretestapplication" could not be found in the registry. The applications available are: org.eclipse.equinox.app.error, com.rcpquickstart.helloworld.application. at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242) at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212) at org.eclipse.core.launcher.Main.main(Main.java:30) !ENTRY org.eclipse.osgi 2 0 2008-11-04 21:02:10.514 !MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists: !SUBENTRY 1 org.eclipse.osgi 2 0 2008-11-04 21:02:10.515 !MESSAGE Bundle update@plugins/org.eclipse.test_3.2.0/ [34] was not resolved. !SUBENTRY 2 org.eclipse.test 2 0 2008-11-04 21:02:10.516 !MESSAGE Missing required bundle org.apache.ant_0.0.0. !SUBENTRY 2 org.eclipse.test 2 0 2008-11-04 21:02:10.516 !MESSAGE Missing required bundle org.eclipse.ui.ide.application_0.0.0. !SUBENTRY 1 org.eclipse.osgi 2 0 2008-11-04 21:02:10.518 !MESSAGE Bundle update@plugins/org.eclipse.ant.optional.junit_3.2.100.jar [60] was not resolved. !SUBENTRY 2 org.eclipse.ant.optional.junit 2 0 2008-11-04 21:02:10.519 !MESSAGE Missing host org.apache.ant_[1.6.5,2.0.0). !SUBENTRY 2 org.eclipse.ant.optional.junit 2 0 2008-11-04 21:02:10.519 !MESSAGE Missing required bundle org.eclipse.core.runtime.compatibility_0.0.0. </code></pre>
[ { "answer_id": 288064, "author": "jamesh", "author_id": 4737, "author_profile": "https://Stackoverflow.com/users/4737", "pm_score": 4, "selected": false, "text": "uitestapplication" }, { "answer_id": 963808, "author": "liangzan", "author_id": 11927, "author_profile": ...
2008/11/01
[ "https://Stackoverflow.com/questions/255370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3446/" ]
255,393
<p>I'm trying to make a page in php that takes rows from a database, displays them, and then give the viewer a chance to upvote or downvote a specific entry. Here is a snippet:</p> <pre><code>echo("&lt;form action=\"vote.php\" method=\"post\"&gt; \n"); echo("&lt;INPUT type=\"hidden\" name=\"idnum\" value=\"".$row[0]."\"&gt;"); echo("&lt;INPUT type=\"submit\" name=\"up\" value=\"Upvote.\"&gt; \n"); echo("&lt;INPUT type=\"submit\" name=\"down\" value=\"Downvote\"&gt; "); echo("&lt;form/&gt;\n"); </code></pre> <p>The problem is when I hit a submit button, the value for idnum that gets sent is based on the one farthest down it seems. So my questions is, when a submit button is pressed, are the values for all inputs on a page sent?</p>
[ { "answer_id": 255396, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "</form>" }, { "answer_id": 255397, "author": "Kibbee", "author_id": 1862, "author_profile": "https://...
2008/11/01
[ "https://Stackoverflow.com/questions/255393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25680/" ]
255,400
<p>This is a very complicated question concerning how to serialize data via a web service call, when the data is not-strongly typed. I'll try to lay it out as best possible.</p> <p><strong>Sample Storage Object:</strong></p> <pre><code>[Serializable] public class StorageObject { public string Name { get; set; } public string Birthday { get; set; } public List&lt;NameValuePairs&gt; OtherInfo { get; set; } } [Serializable] public class NameValuePairs { public string Name { get; set; } public string Value { get; set; } } </code></pre> <p><strong>Sample Use:</strong></p> <pre><code>[WebMethod] public List&lt;StorageObject&gt; GetStorageObjects() { List&lt;StorageObject&gt; o = new List&lt;StorageObject&gt;() { new StorageObject() { Name = "Matthew", Birthday = "Jan 1st, 2008", OtherInfo = new List&lt;NameValuePairs&gt;() { new NameValuePairs() { Name = "Hobbies", Value = "Programming" }, new NameValuePairs() { Name = "Website", Value = "Stackoverflow.com" } } }, new StorageObject() { Name = "Joe", Birthday = "Jan 10th, 2008", OtherInfo = new List&lt;NameValuePairs&gt;() { new NameValuePairs() { Name = "Hobbies", Value = "Programming" }, new NameValuePairs() { Name = "Website", Value = "Stackoverflow.com" } } } }; return o; } </code></pre> <p><strong>Return Value from Web Service:</strong></p> <pre><code>&lt;StorageObject&gt; &lt;Name&gt;Matthew&lt;/Name&gt; &lt;Birthday&gt;Jan 1st, 2008&lt;/Birthday&gt; &lt;OtherInfo&gt; &lt;NameValuePairs&gt; &lt;Name&gt;Hobbies&lt;/Name&gt; &lt;Value&gt;Programming&lt;/Value&gt; &lt;/NameValuePairs&gt; &lt;NameValuePairs&gt; &lt;Name&gt;Website&lt;/Name&gt; &lt;Value&gt;Stackoverflow.com&lt;/Value&gt; &lt;/NameValuePairs&gt; &lt;/OtherInfo&gt; &lt;/StorageObject&gt; </code></pre> <p><strong>What I want:</strong></p> <pre><code>&lt;OtherInfo&gt; &lt;Hobbies&gt;Programming&lt;/Hobbies&gt; &lt;Website&gt;Stackoverflow.com&lt;/Website&gt; &lt;/OtherInfo&gt; </code></pre> <p><strong>The Reason &amp; Other Stuff:</strong></p> <p>First, I'm sorry for the length of the post, but I wanted to give reproducible code as well. </p> <p>I want it in this format, because I'm consuming the web services from PHP. I want to easily go:</p> <p>// THIS IS IMPORANT</p> <pre><code>In PHP =&gt; "$Result["StorageObject"]["OtherInfo"]["Hobbies"]". </code></pre> <p>If it's in the other format, then there would be no way for me to accomplish that, at all. Additionally, in C# if I am consuming the service, I would also like to be able to do the following:</p> <p>// THIS IS IMPORANT</p> <pre><code>In C# =&gt; var m = ServiceResult[0].OtherInfo["Hobbies"]; </code></pre> <p>Unfortunately, I'm not sure how to accomplish this. I was able to get it this way, by building a custom Dictionary that implemented IXmlSerializer (see <a href="https://stackoverflow.com/questions/67959/c-xml-serialization-gotchas">StackOverflow: IXmlSerializer Dictionary</a>), however, it blew the WSDL schema out of the water. It's also much too complicated, and produced horrible results in my WinFormsTester application!</p> <p>Is there any way to accomplish this ? What type of objects do I need to create ? Is there any way to do this /other than by making a strongly typed collection/ ? Obviously, if I make it strongly typed like this:</p> <pre><code>public class OtherInfo { public string Hobbies { get; set; } public string FavoriteWebsite { get; set; } } </code></pre> <p>Then it would work perfectly, I would have no WSDL issues, I would be able to easily access it from PHP, and C# (.OtherInfo.Hobbies). </p> <p>However, I would completely lose the point of NVP's, in that I would have to know in advance what the list is, and it would be unchangeable.. say, from a Database.</p> <p>Thanks everyone!! I hope we're able to come up with some sort of solution to this. Here's are the requirements again:</p> <ol> <li>WSDL schema should not break</li> <li>Name value pairs (NVP's) should be serialized into attribute format</li> <li>Should be easy to access NVP's in PHP by name ["Hobbies"]</li> <li>Should be easy to access in C# (and be compatible with it's Proxy generator)</li> <li>Be easily serializable</li> <li>Not require me to strongly type the data</li> </ol> <p>Now, I am /completely/ open to input on a better/different way to do this. I'm storing some relatively "static" information (like Name), and a bunch of pieces of data. If there's a better way, I'd love to hear it.</p>
[ { "answer_id": 255411, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": -1, "selected": false, "text": "Dictionary<string,List<string>> OtherInfo" }, { "answer_id": 255424, "author": "Ray Lu", "author_id": ...
2008/11/01
[ "https://Stackoverflow.com/questions/255400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27472/" ]
255,414
<p>I'm trying to write a small script to change the current directory to my project directory:</p> <pre><code>#!/bin/bash cd /home/tree/projects/java </code></pre> <p>I saved this file as proj, added execute permission with <code>chmod</code>, and copied it to <code>/usr/bin</code>. When I call it by: <code>proj</code>, it does nothing. What am I doing wrong?</p>
[ { "answer_id": 255415, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 10, "selected": true, "text": "cd" }, { "answer_id": 255416, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://S...
2008/11/01
[ "https://Stackoverflow.com/questions/255414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
255,419
<p>Trying to write a PowerShell cmdlet that will mute the sound at start, unless already muted, and un-mute it at the end (only if it wasn't muted to begin with). Couldn't find any PoweShell or WMI object I could use. I was toying with using Win32 functions like <a href="http://msdn.microsoft.com/en-us/library/ms706237(VS.85).aspx" rel="noreferrer">auxGetVolume</a> or <a href="http://msdn.microsoft.com/en-us/library/ms706237(VS.85).aspx" rel="noreferrer">auxSetVolume</a>, but couldn't quite get it to work (how to read the values from an IntPtr?).</p> <p>I'm using V2 CTP2. Any ideas folks?</p> <p>Thanks!</p>
[ { "answer_id": 1670848, "author": "user202195", "author_id": 202195, "author_profile": "https://Stackoverflow.com/users/202195", "pm_score": 2, "selected": false, "text": "C:\\utils\\nircmd.exe mutesysvolume 0 # 1 to to unmute, 2 to toggle\n" }, { "answer_id": 12397737, "aut...
2008/11/01
[ "https://Stackoverflow.com/questions/255419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19856/" ]
255,422
<p>I would like to create an HTML table with row colors changing based on position and content. But instead of alternating every row, I'd like to be able to group rows together, so that I can have some XML like this:</p> <pre><code>&lt;itemlist&gt; &lt;item group="0"&gt;Conent...blah blah&lt;/item&gt; &lt;item group="0"&gt;Content...who cares&lt;/item&gt; &lt;item group="1"&gt;Content&lt;/item&gt; &lt;item group="2"&gt;Content&lt;/item&gt; &lt;item group="2"&gt;Content&lt;/item&gt; &lt;/itemlist&gt; </code></pre> <p>And all of the items with group=0 are one color, and items with group=1 are another, and group=2 are either toggled back to the first color, or are their own color.</p> <p>All I can seem to find out there is ways to alternate every row, but I can't seem to "get it" when it comes to actually using the node data to help me make the decision.</p>
[ { "answer_id": 255467, "author": "jmcdowell", "author_id": 2421, "author_profile": "https://Stackoverflow.com/users/2421", "pm_score": 3, "selected": true, "text": "<xsl:template match=\"/\">\n <ul>\n <xsl:apply-templates select=\"itemlist/item\"/>\n </ul>\n</xsl:template>\n...
2008/11/01
[ "https://Stackoverflow.com/questions/255422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33263/" ]
255,423
<p>I seem to remember being able to print out (or locate) the specific switches that each -O&lt;num> option turns on. Can you remind?</p> <p>Thanks!</p>
[ { "answer_id": 255434, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "$ man gcc\n" }, { "answer_id": 255440, "author": "CesarB", "author_id": 28258, "author_pro...
2008/11/01
[ "https://Stackoverflow.com/questions/255423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
255,429
<p>I would like to know if it is possible to determine if a function parameter with a default value was passed in Python. For example, how does dict.pop work?</p> <pre><code>&gt;&gt;&gt; {}.pop('test') Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; KeyError: 'pop(): dictionary is empty' &gt;&gt;&gt; {}.pop('test',None) &gt;&gt;&gt; {}.pop('test',3) 3 &gt;&gt;&gt; {}.pop('test',NotImplemented) NotImplemented </code></pre> <p>How does the pop method determine that the first time a default return value was not passed? Is this something that can only be done in C?</p> <p>Thanks</p>
[ { "answer_id": 255433, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "def isdefarg(*args):\n if len(args) > 0:\n print len(args), \"arguments\"\n else:\n print \"no argume...
2008/11/01
[ "https://Stackoverflow.com/questions/255429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24730/" ]
255,436
<p>Does anyone have any suggestions (or a regular expression) for parsing the HTTP Accept header?</p> <p>I am trying to do some content-type negotiation in ASP.NET MVC. There doesn't seem to be a built in way (which is fine, because there are a lot of schools of thought here), but the parsing is not entirely trivial and I would rather not re-invent the wheel if someone has already done it well and is willing to share.</p>
[ { "answer_id": 255541, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 0, "selected": false, "text": "/([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\/([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)/\n" }, { "answer_id": 49011308,...
2008/11/01
[ "https://Stackoverflow.com/questions/255436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11173/" ]
255,445
<p>Does anyone have a library or JavaScript snippet to validate the check digit of credit cards before the user hits Submit?</p>
[ { "answer_id": 23222562, "author": "alexey", "author_id": 92238, "author_profile": "https://Stackoverflow.com/users/92238", "pm_score": 3, "selected": false, "text": "function validateCardNumber(number) {\n var regex = new RegExp(\"^[0-9]{16}$\");\n if (!regex.test(number))\n ...
2008/11/01
[ "https://Stackoverflow.com/questions/255445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27193/" ]
255,470
<p>As the title describes, what are the different doctypes available and what do they mean? I notice that the layout looks a little different in IE7 when I switch from </p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt; </code></pre> <p>to</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; </code></pre> <p>Are there any others and what are the effects or ramifications?</p> <p>Thanks!</p>
[ { "answer_id": 255474, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 7, "selected": true, "text": "html" }, { "answer_id": 255747, "author": "cic", "author_id": 4771, "author_profile": "https://Stackover...
2008/11/01
[ "https://Stackoverflow.com/questions/255470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2849/" ]
255,476
<p>I'm sure this has been asked before, but I can't find it. </p> <p>What are the benefits/limitations of using a browser-based interface for a stand-alone application vs. using a normal GUI framework?</p> <p>I'm working on a Python program currently implement with wxPython for the GUI. The application is simply user-entry forms and dialogs. I am considering moving to PyQt because of the widgets it has (for future expansion), then I realized I could probably just use a browser to do much of the same stuff.</p> <p>The application currently doesn't require Internet access, though it's a possibility in the future. I was thinking of using <a href="http://karrigell.sourceforge.net/" rel="noreferrer">Karrigell</a> for the web framework if I go browser-based.</p> <hr> <p><strong>Edit</strong> For clarification, as of right now the application would be browser-based, not web-based. All the information would be stored locally on the client computer; no server calls would need to be made and no Internet access required (it may come later though). It would simply be a browser GUI instead of a wxPython/PyQt GUI. Hope that makes sense.</p>
[ { "answer_id": 255514, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "<?php if($_POST[\"email\"] ==\"\"){echo(\"Are you sure you want to continue?); ?>" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
255,509
<p>I've heard that projects developed using TDD are easier to refactor because the practice yields a comprehensive set of unit tests, which will (hopefully) fail if any change has broken the code. All of the examples I've seen of this, however, deal with refactoring implementation - changing an algorithm with a more efficient one, for example. </p> <p>I find that refactoring architecture is a lot more common in the early stages where the design is still being worked out. Interfaces change, new classes are added &amp; deleted, even the behavior of a function could change slightly (I thought I needed it to do this, but it actually needs to do that), etc... But if each test case is tightly coupled to these unstable classes, wouldn't you have to be constantly rewriting your test cases each time you change a design? </p> <p>Under what situations in TDD is it okay to alter and delete test cases? How can you be sure that altering the test cases don't break them? Plus it seems that having to synchronize a comprehensive test suite with constantly changing code would be a pain. I understand that the unit test suite could help tremendously during maintenance, once the software is built, stable, and functioning, but that's late in the game wheras TDD is supposed to help early on as well.</p> <p>Lastly, would a good book on TDD and/or refactoring address these sort of issues? If so, which would you recommend?</p>
[ { "answer_id": 255546, "author": "Pistos", "author_id": 28558, "author_profile": "https://Stackoverflow.com/users/28558", "pm_score": 1, "selected": false, "text": "if definition of correctness changes\n change tests/specs\nend\n\nif definition of correctness does not change\n # no nee...
2008/11/01
[ "https://Stackoverflow.com/questions/255509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32998/" ]
255,511
<p>What's the difference between \n and \r (I know it has something to do with OS), and what's the best way to echo a line break that will work cross platform?</p> <p><strong>EDIT:</strong> In response to Jarod, I'll be using ths to echo a line break in a .txt log file, though I'm sure I'll be using it in the future for things such as echoing HTML makup onto a page.</p>
[ { "answer_id": 255512, "author": "Jarod Elliott", "author_id": 1061, "author_profile": "https://Stackoverflow.com/users/1061", "pm_score": 7, "selected": true, "text": "\\n" }, { "answer_id": 255531, "author": "Andrew Moore", "author_id": 26210, "author_profile": "htt...
2008/11/01
[ "https://Stackoverflow.com/questions/255511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27025/" ]
255,516
<p>I used the method</p> <pre><code>$("#dvTheatres a").hover(function (){ $(this).css("text-decoration", "underline"); },function(){ $(this).css("text-decoration", "none"); } ); </code></pre> <p>Is there a more elegant method?(single line)</p>
[ { "answer_id": 255519, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": false, "text": "#dvTheatres a {\n text-decoration: none;\n}\n\n#dvTheatres a:hover {\n text-decoration: underline;\n}\n" }, { ...
2008/11/01
[ "https://Stackoverflow.com/questions/255516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
255,517
<p>I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL's <code>LIMIT</code> requires a limit as well as an offset. Is there any way to do this?</p>
[ { "answer_id": 271648, "author": "Czimi", "author_id": 3906, "author_profile": "https://Stackoverflow.com/users/3906", "pm_score": 5, "selected": false, "text": "SELECT * FROM somewhere LIMIT 18446744073709551610 OFFSET 5\n" }, { "answer_id": 271650, "author": "Greg", "au...
2008/11/01
[ "https://Stackoverflow.com/questions/255517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23335/" ]
255,527
<p>Is there a practical algorithm that gives "multiplication chains"</p> <p>To clarify, the goal is to produce a multiplication change of an <b>arbitrary and exact </b> length<br> Multiplication chains of length 1 are trivial.</p> <p>A "multiplication chain" would be defined as 2 numbers, {start} and {multiplier}, used in code:</p> <pre><code> Given a pointer to array of size [{count}] // count is a parameter a = start; do { a = a * multiplier; // Really: a = (a * multiplier) MOD (power of 2 *(pointer++) = a; } while (a != {constant} ) // Postcondition: all {count} entries are filled. </code></pre> <p>I'd like to find a routine that takes three parameters<br> 1. Power of 2<br> 2. Stopping {constant}<br> 3. {count} - Number of times the loop will iterate </p> <p>The routine would return {start} and {multiplier}. </p> <p>Ideally, a {Constant} value of 0 should be valid.</p> <p>Trivial example:</p> <pre><code>power of 2 = 256 stopping constant = 7 number of times for the loop = 1 returns {7,1} </code></pre> <p>Nontrivial example: </p> <pre><code>power of 2 = 256 stopping constant = 1 number of times for the loop = 49 returns {25, 19} </code></pre> <p>The maximum {count} for a given power of 2 can be fairly small.<br> For example, 2^4 (16) seems to be limited to a count of 4 </p>
[ { "answer_id": 255537, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "start = constant;\nmultiplier = 1;\n" }, { "answer_id": 255558, "author": "Federico A. Ramponi", "author_...
2008/11/01
[ "https://Stackoverflow.com/questions/255527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24404/" ]
255,534
<p>I got an HTML with the <code>&lt;body onload="window.print()"&gt;</code>. </p> <p>The question I'm trying to ask is:</p> <ul> <li>Is there any way to remove the strings that the web browsers add to the printed page?</li> <li>Such as: <ul> <li>Web site from where the page was printed</li> <li>Page count</li> <li>Title of the web page</li> <li>Date of printing </li> </ul></li> </ul>
[ { "answer_id": 52952161, "author": "SCaffrey", "author_id": 4597306, "author_profile": "https://Stackoverflow.com/users/4597306", "pm_score": 2, "selected": false, "text": "@page {\n margin: 0;\n}\n@media print {\n footer {\n display: none;\n position: fixed;\n bottom: 0;\n }...
2008/11/01
[ "https://Stackoverflow.com/questions/255534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
255,551
<p>I'm using autotools to build a shared object. </p> <p>Using <code>pkglib_LTLIBRARIES</code> in my Makefile.am causes a <code>libtest.la</code> AND <code>libtest.so</code> to be built.</p> <p>I <em>only</em> want it to build/install <code>libtest.so</code>.</p> <p>Is this possible?</p>
[ { "answer_id": 1385147, "author": "William Pursell", "author_id": 140750, "author_profile": "https://Stackoverflow.com/users/140750", "pm_score": 2, "selected": false, "text": "--disable-static" }, { "answer_id": 47289012, "author": "Vadim Kotov", "author_id": 1000551, ...
2008/11/01
[ "https://Stackoverflow.com/questions/255551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
255,553
<p>I've heard that it's possible with extension methods, but I can't quite figure it out myself. I'd like to see a specific example if possible.</p> <p>Thanks!</p>
[ { "answer_id": 255621, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": false, "text": "public class Mixin : ISomeInterface\n{\n private SomeImplementation impl implements ISomeInterface;\n\n public voi...
2008/11/01
[ "https://Stackoverflow.com/questions/255553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
255,569
<p>Which sql data type should we use for number bases primary key:</p> <ol> <li>int</li> <li>bigint</li> <li>numeric</li> <li>float</li> </ol>
[ { "answer_id": 255572, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 7, "selected": true, "text": "int" }, { "answer_id": 489589, "author": "Joe Phillips", "author_id": 20471, "author_profile": "https:...
2008/11/01
[ "https://Stackoverflow.com/questions/255569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
255,571
<p>I am having some trouble manipulating images using CodeIgniter 1.7. With the following code, the image is uploaded correctly. Alas, instead of a new image being made, and then modified; the existing image is modified. Any help?</p> <pre><code>//Upload image first $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|bmp'; $this-&gt;load-&gt;library('upload', $config); $this-&gt;upload-&gt;do_upload(); //Now fix the image $picloc = $this-&gt;upload-&gt;data(); $picloc = $picloc['file_name']; $thumbnail = "thumb_".$picloc; $imagemanip['image_library'] = 'gd2'; $imagemanip['source_image'] = './uploads/'.$picloc; $imagemanip['new_img'] = './uploads/'.$thumbnail; $imagemanip['maintain_ratio'] = TRUE; $imagemanip['width'] = 250; $imagemanip['height'] = 250; $this-&gt;load-&gt;library('image_lib', $imagemanip); $this-&gt;image_lib-&gt;resize(); </code></pre>
[ { "answer_id": 255628, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "$imagemanip['new_img'] = './uploads/'.$thumbnail;\n" }, { "answer_id": 29937507, "author": "Abdulla Nilam", "autho...
2008/11/01
[ "https://Stackoverflow.com/questions/255571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
255,612
<p>I have a class that contains a dynamically allocated array, say</p> <pre><code>class A { int* myArray; A() { myArray = 0; } A(int size) { myArray = new int[size]; } ~A() { // Note that as per MikeB's helpful style critique, no need to check against 0. delete [] myArray; } } </code></pre> <p>But now I want to create a dynamically allocated array of these classes. Here's my current code:</p> <pre><code>A* arrayOfAs = new A[5]; for (int i = 0; i &lt; 5; ++i) { arrayOfAs[i] = A(3); } </code></pre> <p>But this blows up terribly. Because the new <code>A</code> object created (with the <code>A(3)</code> call) gets destructed when the <code>for</code> loop iteration finishes, and this means that the internal <code>myArray</code> of that <code>A</code> instance gets <code>delete []</code>-ed.</p> <p>So I think my syntax must be terribly wrong? I guess there are a few fixes that seem like overkill, which I'm hoping to avoid:</p> <ul> <li>Creating a copy constructor for <code>A</code>.</li> <li>Using <code>vector&lt;int&gt;</code> and <code>vector&lt;A&gt;</code> so I don't have to worry about all this.</li> <li>Instead of having <code>arrayOfAs</code> be an array of <code>A</code> objects, have it be an array of <code>A*</code> pointers.</li> </ul> <p>I would think this is just some beginners thing where there's a syntax that actually works when attempting to dynamically allocate an array of things that have internal dynamic allocation.</p> <p>(Also, style critiques appreciated, since it's been a while since I did C++.)</p> <p><strong>Update for future viewers</strong>: All of the answers below are really helpful. Martin's is accepted because of the example code and the useful "rule of 4," but I really suggest reading them all. Some are good, succinct statements of what's wrong, and some point out correctly how and why <code>vector</code>s are a good way to go.</p>
[ { "answer_id": 255649, "author": "IMil", "author_id": 11185, "author_profile": "https://Stackoverflow.com/users/11185", "pm_score": 4, "selected": false, "text": "typedef std::vector<int> A;\ntypedef std::vector<A> AS;\n" }, { "answer_id": 255681, "author": "Jim Buck", "a...
2008/11/01
[ "https://Stackoverflow.com/questions/255612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3191/" ]
255,624
<p>While using Vim (at home and at work), I often find myself doing similar things repeatedly. For example, I may turn a bunch of CSV text into a series of SQL inserts. I've been using Vim for years, but only recently have I tried to seriously think about how I could improve my productivity while using it.</p> <p>My question is.. Is there a good way (or right way) to store commonly used commands or command sequences? And how is the best way to execute them? It would be nice to be able to use the same script on a live session and also over the command line against some file.</p> <p>I'm hoping that I can store them in a .vim file so that I can hand them to coworkers (who are not as proficient with vim) for them to use.</p>
[ { "answer_id": 255650, "author": "ngn", "author_id": 23109, "author_profile": "https://Stackoverflow.com/users/23109", "pm_score": 2, "selected": false, "text": ".vimrc" }, { "answer_id": 256494, "author": "Aristotle Pagaltzis", "author_id": 9410, "author_profile": "h...
2008/11/01
[ "https://Stackoverflow.com/questions/255624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
255,642
<p>I have a database table named call with columns call_time, location, emergency_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection.</p> <p>I created a function:</p> <pre><code>public static DataTable GetHistory(DateTime from, DateTime to, bool paramedics, bool police, bool firefighters) { string select = "SELECT call_time, location, emergency_type where call_time between @from AND @to AND"; if(paramedics) { select += " emergency_type = 'paramedics' "; } if(paramedics &amp;&amp; police) { select +=" emergency_type = 'paramedics' OR emergency_type = 'police'; } ... } </code></pre> <p>This code however seems very dirty because if there were 30 kinds of emergency there would be 30! combinations and I would get old before writing all if statements.</p> <p>I would appreciate if you shared your practice for retrieving data that meet the selected search conditions if there are many options you can chosse.</p> <p>Thanks!</p>
[ { "answer_id": 255657, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "string select = \"SELECT call_time, location, emergency_type where call_time between @from AND @to AND (1=0\";\n\nif(paramedic...
2008/11/01
[ "https://Stackoverflow.com/questions/255642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22996/" ]
255,644
<p>Today somebody told me that interface implementation in C# is just "Can-Do" relationship, not "Is-A" relationship. This conflicts with my long-time believing in LSP(Liskov Substitution Principle). I always think that all inheritance should means "Is-A" relationship. </p> <p>So, If interface implementation is just a "Can-Do" relationship. What if there is a interface "IHuman" and "IEngineer", and one class "Programmer" inherits from "IHuman" &amp; "IEngineer"? Surely, a "Programmer" Is A "IHuman" and A "IEngineer". </p> <p>If it is just "Can-Do" relationship, does it mean we cannot expect the "Programmer" instance behavior may be different between when treated as a IHuman and treated as IEngineer?</p>
[ { "answer_id": 422110, "author": "Jon Davis", "author_id": 11398, "author_profile": "https://Stackoverflow.com/users/11398", "pm_score": 2, "selected": false, "text": "Foo myFoo = new Foo(); \nreturn myFoo is IBar;\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
255,669
<p>How do I enable assembly bind failure logging (Fusion) in .NET?</p>
[ { "answer_id": 255670, "author": "user32736", "author_id": 32736, "author_profile": "https://Stackoverflow.com/users/32736", "pm_score": 7, "selected": false, "text": "Windows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Fusion]\n\"EnableLog\"=dword:00000001\...
2008/11/01
[ "https://Stackoverflow.com/questions/255669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32736/" ]
255,700
<p>In my website, users have the possibility to store links.</p> <p>During typing the internet address into the designated field I would like to display a suggest/autocomplete box similar to Google Suggest or the Chrome Omnibar.</p> <p>Example:</p> <p>User is typing as URL:</p> <pre><code>http://www.sta </code></pre> <p>Suggestions which would be displayed:</p> <pre><code>http://www.staples.com http://www.starbucks.com http://www.stackoverflow.com </code></pre> <p>How can I achieve this while not reinventing the wheel? :)</p>
[ { "answer_id": 256099, "author": "lacker", "author_id": 2652, "author_profile": "https://Stackoverflow.com/users/2652", "pm_score": 2, "selected": false, "text": "www.yoursite.com/suggest?typed=www.sta\n" }, { "answer_id": 656223, "author": "Justin R.", "author_id": 4593,...
2008/11/01
[ "https://Stackoverflow.com/questions/255700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26763/" ]
255,714
<p>So I've got a Ruby method like this:</p> <pre><code>def something(variable, &amp;block) .... end </code></pre> <p>And I want to call it like this:</p> <pre><code>something 'hello' { do_it } </code></pre> <p>Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works:</p> <pre><code>something 'hello' do do_it end </code></pre> <p>Except there I'm kind of missing the nice look of it being on one line.</p> <p>I can see why this is happening, as it could look like it's a hash being passed as a second variable, but without a comma in between the variables...but I assume that there must be a way to deal with this that I'm missing. Is there?</p>
[ { "answer_id": 255732, "author": "seanbehan", "author_id": 155970, "author_profile": "https://Stackoverflow.com/users/155970", "pm_score": 2, "selected": false, "text": "#to uppercase string\ndef something(my_input)\n yield my_input.upcase\nend\n\n# => \"HELLO WORLD\"\nsomething(\"hello ...
2008/11/01
[ "https://Stackoverflow.com/questions/255714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14873/" ]
255,741
<p>I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS.</p> <p>IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures &amp; functions written in Ada from C++?</p>
[ { "answer_id": 41819129, "author": "Glen", "author_id": 7386272, "author_profile": "https://Stackoverflow.com/users/7386272", "pm_score": 3, "selected": false, "text": " package Ada_Pkg is\n procedure DoSomething (Number : in Integer);\n pragma Export (C, DoSomething, \"...
2008/11/01
[ "https://Stackoverflow.com/questions/255741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
255,771
<p>I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame.</p> <p>Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data once the modal dialog is closed by the user. </p> <p>Is this the best way of passing around data?</p> <p>It doesn't feel right!</p>
[ { "answer_id": 255790, "author": "Samuel", "author_id": 32465, "author_profile": "https://Stackoverflow.com/users/32465", "pm_score": 3, "selected": true, "text": "public string UserName\n{\n get { return userNameTextBox.Text; }\n}\n" }, { "answer_id": 255952, "author": "A...
2008/11/01
[ "https://Stackoverflow.com/questions/255771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1311500/" ]
255,785
<p>Does a tool exist for dynamically altering running javascript in a browser? For example, to change the values of javascript variables during runtime.</p>
[ { "answer_id": 255793, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": -1, "selected": false, "text": "<script type=\"text/javascript\" language=\"javascript\">\n example = function() {alert('first');}\n example();\n eval(\"e...
2008/11/01
[ "https://Stackoverflow.com/questions/255785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
255,797
<p>In what areas of programming would I use state machines ? Why ? How could I implement one ?</p> <p><strong>EDIT:</strong> please provide a practical example , if it's not too much to ask .</p>
[ { "answer_id": 255826, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 2, "selected": false, "text": "http://web.dyfis.net/bzr/isg_state_machine_framework/" }, { "answer_id": 255886, "author": "EvilTeach", ...
2008/11/01
[ "https://Stackoverflow.com/questions/255797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
255,800
<p>I'm making a program which the user build directories (not in windows, in my app) and in these folders there are subfolders and so on; every folder must contain either folders or documents. What is the best data structure to use? Notice that the user may select a subfolder and search for documents in it and in its subfolders. And I don't want to limit the folders or the subfolders levels.</p>
[ { "answer_id": 255841, "author": "Jason", "author_id": 16794, "author_profile": "https://Stackoverflow.com/users/16794", "pm_score": 5, "selected": true, "text": "Root\n Folder1\n Folder2\n Folder3\n Folder4\n Folder5\n Folder6\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29276/" ]
255,815
<p>I have the following line:</p> <pre><code>"14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;)" </code></pre> <p>I parse this by using a simple regexp:</p> <pre><code>if($line =~ /(\d+:\d+)\ssay;(.*);(.*);(.*);(.*)/) { my($ts, $hash, $pid, $handle, $quote) = ($1, $2, $3, $4, $5); } </code></pre> <p>But the ; at the end messes things up and I don't know why. Shouldn't the greedy operator handle "everything"?</p>
[ { "answer_id": 255827, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "(.*)" }, { "answer_id": 255832, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackover...
2008/11/01
[ "https://Stackoverflow.com/questions/255815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33232/" ]
255,830
<p>I'm looking for someone to explain how to drag and drop in javascript, I want a horizontal line with some customizable images in it.</p> <p>I've had a look at the online tutorials for these but find them very hard to use.</p>
[ { "answer_id": 255884, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "print(\"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional...
2008/11/01
[ "https://Stackoverflow.com/questions/255830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
255,846
<p>I'm having a lot of issues with NSDate objects being prematurely deallocated. I suspect that the issues may be related to the way that I deal with the objects returned from NSDate convenience methods. I <em>think</em> that my showDate property declaration in the JKShow class should be "retain", but changing it to assign or copy seems to have no effect on the issue.</p> <pre><code>JKShow *show; NSDate *date; NSMutableArray *list = [[NSMutableArray alloc] init]; // Show 1 show = [[JKShow alloc] init]; //... date = [gregorian dateFromComponents:dateComponents]; show.showDate = date; [list addObject:[show autorelease]]; // Show 2 show = [[JKShow alloc] init]; //... date = [gregorian dateFromComponents:dateComponents]; show.showDate = date; [list addObject:[show autorelease]]; </code></pre> <p><em>UPDATE</em></p> <p>The issue was not in the code copied here. In my <code>JKShow init</code> method I was not retaining the date returned from the <code>NSDate</code> convenience method. Thanks for your help, everyone.</p>
[ { "answer_id": 255931, "author": "Peter Hosey", "author_id": 30461, "author_profile": "https://Stackoverflow.com/users/30461", "pm_score": 0, "selected": false, "text": "list" }, { "answer_id": 255983, "author": "kubi", "author_id": 28422, "author_profile": "https://S...
2008/11/01
[ "https://Stackoverflow.com/questions/255846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28422/" ]
255,852
<p>I've been writing a lot recently about Parallel computing and programming and I do notice that there are a lot of patterns that come up when it comes to parallel computing. Noting that Microsoft already has released a library along with the Microsoft Visual C++ 2010 Community Technical Preview (named Parallel Patterns Library) I'm wondering what are the common parallel programming patterns you have been using and encountering that may be worth remembering? Do you have any idioms you follow and patterns that you seem to keep popping up as you write parallel programs with C++?</p>
[ { "answer_id": 46700626, "author": "Beached", "author_id": 202861, "author_profile": "https://Stackoverflow.com/users/202861", "pm_score": 1, "selected": false, "text": "auto fut = async([]( ){..some work...} ).then( [](result_of_prev ){...more work} ).then... ;\nfut.wait( );\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11274/" ]
255,857
<p>I am trying to insert an image (jpg) in to a word document and the Selection.InlineShapes.AddPicture does not seem to be supported by win32old or I am doing something wrong. Has anyone had any luck inserting images. </p>
[ { "answer_id": 258389, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 1, "selected": false, "text": "require 'win32ole'\n\nbegin\n word = WIN32OLE::new('Word.Application') # create winole Object\n doc = word.Docume...
2008/11/01
[ "https://Stackoverflow.com/questions/255857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
255,862
<p>Netbeans is great but there's no way to wrap text in it (or hopefully I haven't found it yet). Is there any way to do this, and if not, is there any similarly good IDE for Java with this functionality (hopefully free as well).</p>
[ { "answer_id": 4059100, "author": "Sidarta", "author_id": 269056, "author_profile": "https://Stackoverflow.com/users/269056", "pm_score": 6, "selected": false, "text": "-J-Dorg.netbeans.editor.linewrap=true\n" }, { "answer_id": 4975838, "author": "Hoffa", "author_id": 613...
2008/11/01
[ "https://Stackoverflow.com/questions/255862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
255,876
<p>I want to make an MVC route for a list of news, which can be served in several formats.</p> <ul> <li>news -> (X)HTML</li> <li>news.rss -> RSS</li> <li>news.atom -> ATOM</li> </ul> <p>Is it possible to do this (the more general "optional extension" situation crops up in several places in my planned design) with one route? Or do I need to make two routes like this:</p> <pre><code>routes.MapRoute("News-ImplicitFormat", "news", new { controller = "News", action = "Browse", format = "" }); routes.MapRoute("News-ExplicitFormat", "news.{format}" new { controller = "News", action = "Browse" }); </code></pre> <p>It seems like it would be useful to have the routing system support something like:</p> <pre><code>routes.MapRoute("News", "news(.{format})?", new { controller = "News", action = "Browse" }); </code></pre>
[ { "answer_id": 255880, "author": "Doug McClean", "author_id": 11173, "author_profile": "https://Stackoverflow.com/users/11173", "pm_score": 5, "selected": true, "text": "public static void MapRouteWithOptionalFormat(this RouteCollection routes,\n ...
2008/11/01
[ "https://Stackoverflow.com/questions/255876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11173/" ]
255,879
<p>I need some help with WPF binding syntax:</p> <pre><code>public class ApplicationPresenter { public ObservableCollection&lt;Quotes&gt; PriceList {get;} } public class WebSitePricesView { private IApplicationPresenter presenter { get { return (ApplicationPresenter)DataContext; } } // public ObservableCollection&lt;Quotes&gt; PriceList // { // get {return presenter.PriceList; } } } </code></pre> <p>This XAML works fine:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;ObjectDataProvider x:Key="ApplicationPresenterDS" ObjectType="{x:Type local:ApplicationPresenter}" /&gt; &lt;xcdg:DataGridCollectionViewSource x:Key="price_list" Source="{Binding Path=PriceList} /&gt; &lt;/UserControl.Resources&gt; &lt;xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource price_list}} /&gt; </code></pre> <p>However I don't want WebSitePricesView to expose PriceList, I want to bind the DataGridCollectionViewSource directly to ApplicationPresenter.PriceList.</p> <p>This XAML doesn't bind any values to the grid. Obviously I'm doing something wrong in defining the Binding Source for price_list .....</p> <pre><code>&lt;UserControl.Resources&gt; &lt;ObjectDataProvider x:Key="ApplicationPresenterDS" ObjectType="{x:Type local:ApplicationPresenter}" /&gt; &lt;xcdg:DataGridCollectionViewSource x:Key="price_list" Source="{Binding Source={StaticResource ApplicationPresenterDS}, Path=PriceList /&gt; &lt;/UserControl.Resources&gt; &lt;xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource price_list}} /&gt; </code></pre> <p>The debug output for the first successful binding is:</p> <pre><code>Step into: Stepping over method without symbols 'Fenix.App.App' System.Windows.Data Warning: 52 : Created BindingExpression (hash=35059110) for Binding (hash=15586314) System.Windows.Data Warning: 54 : Path: 'PriceList' System.Windows.Data Warning: 56 : BindingExpression (hash=35059110): Default mode resolved to OneWay System.Windows.Data Warning: 57 : BindingExpression (hash=35059110): Default update trigger resolved to PropertyChanged System.Windows.Data Warning: 58 : BindingExpression (hash=35059110): Attach to Xceed.Wpf.DataGrid.DataGridCollectionViewSource.Source (hash=28137373) System.Windows.Data Warning: 60 : BindingExpression (hash=35059110): Use Framework mentor &lt;null&gt; System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source System.Windows.Data Warning: 65 : BindingExpression (hash=35059110): Framework mentor not found System.Windows.Data Warning: 61 : BindingExpression (hash=35059110): Resolve source deferred System.Windows.Data Warning: 91 : BindingExpression (hash=35059110): Got InheritanceContextChanged event from DataGridCollectionViewSource (hash=28137373) System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: WebSitePricesXc (hash=11090012) (OK) System.Windows.Data Warning: 67 : BindingExpression (hash=35059110): DataContext is null System.Windows.Data Warning: 52 : Created BindingExpression (hash=53154844) for Binding (hash=52037308) System.Windows.Data Warning: 54 : Path: '' System.Windows.Data Warning: 56 : BindingExpression (hash=53154844): Default mode resolved to OneWay System.Windows.Data Warning: 57 : BindingExpression (hash=53154844): Default update trigger resolved to PropertyChanged System.Windows.Data Warning: 58 : BindingExpression (hash=53154844): Attach to Xceed.Wpf.DataGrid.DataGridControl.ItemsSource (hash=16991442) System.Windows.Data Warning: 63 : BindingExpression (hash=53154844): Resolving source System.Windows.Data Warning: 66 : BindingExpression (hash=53154844): Found data context element: &lt;null&gt; (OK) System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373) System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item &lt;null&gt; System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with &lt;null&gt;, using accessor {DependencyProperty.UnsetValue} System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from &lt;null&gt; using &lt;null&gt;: &lt;null&gt; System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value &lt;null&gt; System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value &lt;null&gt; A first chance exception of type 'System.FormatException' occurred in mscorlib.dll System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: WebSitePricesXc (hash=11090012) (OK) System.Windows.Data Warning: 74 : BindingExpression (hash=35059110): Activate with root item ApplicationPresenter (hash=22260412) System.Windows.Data Warning: 104 : BindingExpression (hash=35059110): At level 0 - for ApplicationPresenter.PriceList found accessor RuntimePropertyInfo(PriceList) System.Windows.Data Warning: 100 : BindingExpression (hash=35059110): Replace item at level 0 with ApplicationPresenter (hash=22260412), using accessor RuntimePropertyInfo(PriceList) System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=22260412) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=40261689 Count=0) System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=40261689 Count=0) System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=40261689 Count=0) System.Windows.Data Warning: 92 : BindingExpression (hash=53154844): Got PropertyChanged event from DataGridCollectionViewSource (hash=28137373) for View System.Windows.Data Warning: 75 : BindingExpression (hash=53154844): Deactivate System.Windows.Data Warning: 99 : BindingExpression (hash=53154844): Replace item at level 0 with {NullDataItem} System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373) System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item DataGridCollectionView (hash=22444475 Count=0) System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with DataGridCollectionView (hash=22444475 Count=0), using accessor {DependencyProperty.UnsetValue} System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from DataGridCollectionView (hash=22444475 Count=0) using &lt;null&gt;: DataGridCollectionView (hash=22444475 Count=0) System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value DataGridCollectionView (hash=22444475 Count=0) System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value DataGridCollectionView (hash=22444475 Count=0) System.Windows.Data Warning: 91 : BindingExpression (hash=35059110): Got PropertyChanged event from ApplicationPresenter (hash=22260412) System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=22260412) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=6408547 Count=27) System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=6408547 Count=27) System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=6408547 Count=27) System.Windows.Data Warning: 92 : BindingExpression (hash=53154844): Got PropertyChanged event from DataGridCollectionViewSource (hash=28137373) for View System.Windows.Data Warning: 75 : BindingExpression (hash=53154844): Deactivate System.Windows.Data Warning: 99 : BindingExpression (hash=53154844): Replace item at level 0 with {NullDataItem} System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373) System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item DataGridCollectionView (hash=61423861 Count=27) System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with DataGridCollectionView (hash=61423861 Count=27), using accessor {DependencyProperty.UnsetValue} System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from DataGridCollectionView (hash=61423861 Count=27) using &lt;null&gt;: DataGridCollectionView (hash=61423861 Count=27) System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value DataGridCollectionView (hash=61423861 Count=27) System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value DataGridCollectionView (hash=61423861 Count=27) </code></pre> <p>The debug output for the second binding is:</p> <pre><code>Step into: Stepping over method without symbols 'Fenix.App.App' System.Windows.Data Warning: 52 : Created BindingExpression (hash=35059110) for Binding (hash=15586314) System.Windows.Data Warning: 54 : Path: 'PriceList' System.Windows.Data Warning: 56 : BindingExpression (hash=35059110): Default mode resolved to OneWay System.Windows.Data Warning: 57 : BindingExpression (hash=35059110): Default update trigger resolved to PropertyChanged System.Windows.Data Warning: 58 : BindingExpression (hash=35059110): Attach to Xceed.Wpf.DataGrid.DataGridCollectionViewSource.Source (hash=28137373) System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: &lt;null&gt; (OK) System.Windows.Data Warning: 73 : BindingExpression (hash=35059110): Use Data from ObjectDataProvider (hash=61302538) System.Windows.Data Warning: 74 : BindingExpression (hash=35059110): Activate with root item ApplicationPresenter (hash=20390146) System.Windows.Data Warning: 104 : BindingExpression (hash=35059110): At level 0 - for ApplicationPresenter.PriceList found accessor RuntimePropertyInfo(PriceList) System.Windows.Data Warning: 100 : BindingExpression (hash=35059110): Replace item at level 0 with ApplicationPresenter (hash=20390146), using accessor RuntimePropertyInfo(PriceList) System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=20390146) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=12781633 Count=0) System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=12781633 Count=0) System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=12781633 Count=0) System.Windows.Data Warning: 52 : Created BindingExpression (hash=12661120) for Binding (hash=31408037) System.Windows.Data Warning: 54 : Path: '' System.Windows.Data Warning: 56 : BindingExpression (hash=12661120): Default mode resolved to OneWay System.Windows.Data Warning: 57 : BindingExpression (hash=12661120): Default update trigger resolved to PropertyChanged System.Windows.Data Warning: 58 : BindingExpression (hash=12661120): Attach to Xceed.Wpf.DataGrid.DataGridControl.ItemsSource (hash=16991442) System.Windows.Data Warning: 63 : BindingExpression (hash=12661120): Resolving source System.Windows.Data Warning: 66 : BindingExpression (hash=12661120): Found data context element: &lt;null&gt; (OK) System.Windows.Data Warning: 72 : BindingExpression (hash=12661120): Use View from DataGridCollectionViewSource (hash=28137373) System.Windows.Data Warning: 74 : BindingExpression (hash=12661120): Activate with root item DataGridCollectionView (hash=49343907 Count=0) System.Windows.Data Warning: 100 : BindingExpression (hash=12661120): Replace item at level 0 with DataGridCollectionView (hash=49343907 Count=0), using accessor {DependencyProperty.UnsetValue} System.Windows.Data Warning: 97 : BindingExpression (hash=12661120): GetValue at level 0 from DataGridCollectionView (hash=49343907 Count=0) using &lt;null&gt;: Data``GridCollectionView (hash=49343907 Count=0) System.Windows.Data Warning: 76 : BindingExpression (hash=12661120): TransferValue - got raw value DataGridCollectionView (hash=49343907 Count=0) System.Windows.Data Warning: 85 : BindingExpression (hash=12661120): TransferValue - using final value DataGridCollectionView (hash=49343907 Count=0) A first chance exception of type 'System.FormatException' occurred in mscorlib.dll </code></pre>
[ { "answer_id": 256249, "author": "Ian Oakes", "author_id": 21606, "author_profile": "https://Stackoverflow.com/users/21606", "pm_score": 1, "selected": false, "text": "public class Quotes\n{\n public string Description { get; set; }\n public decimal Value { get; set; }\n}\n\npublic...
2008/11/01
[ "https://Stackoverflow.com/questions/255879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30046/" ]
255,898
<p>I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of <code>$1</code> easily:</p> <pre><code>foo $1 args -o $1.ext </code></pre> <p>I want to be able to pass multiple input names to the script. What's the right way to do it? </p> <p>And, of course, I want to handle filenames with spaces in them.</p>
[ { "answer_id": 255913, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 12, "selected": true, "text": "\"$@\"" }, { "answer_id": 256225, "author": "Jonathan Leffler", "author_id": 15168, "author_prof...
2008/11/01
[ "https://Stackoverflow.com/questions/255898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12874/" ]
255,907
<p>In Visual Studio 2008 in a C# WinForms project, there is a button on a form. In the properties view, the property "Font" is set to "Arial Unicode MS".</p> <p>What do I need to put into the property "Text", so I get the unicode character \u0D15 displayed on the button?</p> <p>When I put \u0D15 into the "Text" property, the button displays the six characters "\u0D15" instead of one unicode character.</p> <p>In the following PDF, you can see the unicode character for \u0D15: <a href="http://unicode.org/charts/PDF/U0D00.pdf" rel="noreferrer">http://unicode.org/charts/PDF/U0D00.pdf</a></p>
[ { "answer_id": 255918, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 4, "selected": true, "text": "button1.Text = \"日本\";\n" }, { "answer_id": 67694137, "author": "Ragheed Al-Tayeb", "author_id": 125198...
2008/11/01
[ "https://Stackoverflow.com/questions/255907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33311/" ]
255,916
<p>I use BIRT since early days and still have riddles regarding PDF emitter. </p> <p><strong>Short story</strong>: Can I configure fontsConfig.xml to load fonts from relative path or from jars?</p> <p><strong>Long story:</strong> We are using both FOP and BIRT for generating PDF in our web application. It would be nice to share fonts between libraries. Unfortunately, I can't find a way to do it with BIRT 2.3.1</p> <p>The root of evil is fontsConfig.xml If I configure it like shown below it works fine:</p> <pre><code>&lt;font-paths&gt; &lt;path path="fonts"/&gt; &lt;/font-paths&gt; </code></pre> <p>But path doesn't allow me using neither relative paths not classpath (or I can't find an appropriate way how to configure it). Neither config1 nor config2 works.</p> <p>Config1:</p> <pre><code>&lt;font-paths&gt; &lt;path path="../fonts"/&gt; &lt;/font-paths&gt; </code></pre> <p>Config2:</p> <pre><code>&lt;font-paths&gt; &lt;path path="classpath:fonts"/&gt; &lt;/font-paths&gt; </code></pre> <p>Any thoughts will be appreciated.</p>
[ { "answer_id": 21705054, "author": "hvb", "author_id": 2814025, "author_profile": "https://Stackoverflow.com/users/2814025", "pm_score": 3, "selected": true, "text": "EngineConfig engineConfig = new EngineConfig();\nURL fontsConfigurationURL = new URL(\"file:///path/to/my/fontsConfig.xml...
2008/11/01
[ "https://Stackoverflow.com/questions/255916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19347/" ]
255,927
<p>I'm writing an iOS app with a table view inside a tab view. In my <code>UITableViewController</code>, I implemented <code>-tableView:didSelectRowAtIndexPath:</code>, but when I select a row at runtime, the method isn't being called. The table view is being populated though, so I know that other tableView methods in my controller are being called.</p> <p>Does anyone have any ideas what I may have screwed up to make this happen?</p>
[ { "answer_id": 255961, "author": "Hunter", "author_id": 555, "author_profile": "https://Stackoverflow.com/users/555", "pm_score": 8, "selected": true, "text": "UITableViewDelegate" }, { "answer_id": 4023700, "author": "JackPearse", "author_id": 487612, "author_profile...
2008/11/01
[ "https://Stackoverflow.com/questions/255927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5815/" ]
255,928
<p>The MSI stores the installation directory for the future uninstall tasks.</p> <p>Using the <code>INSTALLPROPERTY_INSTALLLOCATION</code> property (that is <code>"InstallLocation"</code>) works only the installer has set the <code>ARPINSTALLLOCATION</code> property during the installation. But this property is optional and almost nobody uses it.</p> <p>How could I retrieve the installation directory?</p>
[ { "answer_id": 48016963, "author": "eduardomozart", "author_id": 1031340, "author_profile": "https://Stackoverflow.com/users/1031340", "pm_score": 0, "selected": false, "text": "%ProgramFiles(x86)%\\Natural Docs" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/255928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23372/" ]
255,941
<p>Is there anything out there freeware or commercial that can facilitate analysis of memory usage by a PHP application? I know xdebug can produce trace files that shows memory usage by function call but without a graphical tool the data is hard to interpret. </p> <p>Ideally I would like to be able to view not only total memory usage but also what objects are on the heap and who references them similar to <a href="http://www.codework.com/jprofiler/product.htm" rel="noreferrer">Jprofiler</a>.</p>
[ { "answer_id": 329809, "author": "EvilPuppetMaster", "author_id": 20851, "author_profile": "https://Stackoverflow.com/users/20851", "pm_score": 3, "selected": false, "text": "sort -bgrk 3 -o sorted.txt mytracefile.xt \n" }, { "answer_id": 23829872, "author": "Francesco Casula...
2008/11/01
[ "https://Stackoverflow.com/questions/255941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2043539/" ]
255,942
<p>I'm using Castle ActiveRecord for persistence, and I'm trying to write a base class for my persistence tests which will do the following:</p> <ul> <li>Open a transaction for each test case and roll it back at the end of the test case, so that I get a clean DB for each test case without me having to rebuild the schema for each test case.</li> <li>Provide the ability to flush my NHibernate session and get a new one in the middle of a test, so that I know that my persistence operations have really hit the DB rather than just the NHibernate session.</li> </ul> <p>In order to prove that my base class (<code>ARTestBase</code>) is working, I've come up with the following sample tests.</p> <pre><code>[TestFixture] public class ARTestBaseTest : ARTestBase { [Test] public void object_created_in_this_test_should_not_get_committed_to_db() { ActiveRecordMediator&lt;Entity&gt;.Save(new Entity {Name = "test"}); Assert.That(ActiveRecordMediator&lt;Entity&gt;.Count(), Is.EqualTo(1)); } [Test] public void object_created_in_previous_test_should_not_have_been_committed_to_db() { ActiveRecordMediator&lt;Entity&gt;.Save(new Entity {Name = "test"}); Assert.That(ActiveRecordMediator&lt;Entity&gt;.Count(), Is.EqualTo(1)); } [Test] public void calling_flush_should_make_nhibernate_retrieve_fresh_objects() { var savedEntity = new Entity {Name = "test"}; ActiveRecordMediator&lt;Entity&gt;.Save(savedEntity); Flush(); // Could use FindOne, but then this test would fail if the transactions aren't being rolled back foreach (var entity in ActiveRecordMediator&lt;Entity&gt;.FindAll()) { Assert.That(entity, Is.Not.SameAs(savedEntity)); } } } </code></pre> <p>Here is my best effort at the base class. It correctly implements <code>Flush()</code>, so the third test case passes. However it does not rollback the transactions, so the second test fails.</p> <pre><code>public class ARTestBase { private SessionScope sessionScope; private TransactionScope transactionScope; [TestFixtureSetUp] public void InitialiseAR() { ActiveRecordStarter.ResetInitializationFlag(); ActiveRecordStarter.Initialize(typeof (Entity).Assembly, ActiveRecordSectionHandler.Instance); ActiveRecordStarter.CreateSchema(); } [SetUp] public virtual void SetUp() { transactionScope = new TransactionScope(OnDispose.Rollback); sessionScope = new SessionScope(); } [TearDown] public virtual void TearDown() { sessionScope.Dispose(); transactionScope.Dispose(); } protected void Flush() { sessionScope.Dispose(); sessionScope = new SessionScope(); } [TestFixtureTearDown] public virtual void TestFixtureTearDown() { SQLiteProvider.ExplicitlyDestroyConnection(); } } </code></pre> <p>Note that I'm using a custom SQLite provider with an in-memory database. My custom provider, taken from <a href="http://brian.genisio.org/2008/07/active-record-mock-framework.html" rel="nofollow noreferrer">this blog post</a>, keeps the connection open at all times to maintain the schema. Removing this and using a regular SQL Server database doesn't change the behaviour.</p> <p>Is there a way to acheive the required behaviour?</p>
[ { "answer_id": 258313, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 1, "selected": false, "text": "IDbTransaction" }, { "answer_id": 258560, "author": "Alex Scordellis", "author_id": 12006, "author_...
2008/11/01
[ "https://Stackoverflow.com/questions/255942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12006/" ]
255,955
<p>Returning to WinForms in VS2008 after a long time.. Tinkering with a OOD problem in VS2008 Express Edition.</p> <p>I need some controls to be "display only" widgets. The user should not be able to change the value of these controls... the widgets are updated by a periodic update tick event. I vaguely remember there being a ReadOnly property that you could set to have this behavior... can't find it now.</p> <p>The <strong>Enabled</strong> property set to false: grays out the control content. I want the control to look normal. The <strong>Locked</strong> property set to false: seems to be protecting the user from accidentally distorting the control in the Visual Form Designer.</p> <p>What am I missing? </p>
[ { "answer_id": 255965, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 5, "selected": true, "text": " Color clr = textBox1.BackColor;\n textBox1.ReadOnly = true;\n textBox1.BackColor = clr;\n" }, { "answe...
2008/11/01
[ "https://Stackoverflow.com/questions/255955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
255,969
<p>I'm struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby's framework, I must instead write: </p> <pre><code>class MyTest &lt; Test::Unit::TestCase def setup end def test_1 end def test_1 end end </code></pre> <p>But setup and teardown run for every invocation of a test_* method. This is exactly what I don't want. Rather, I want a setup method that runs just once for the whole class. But I can't seem to write my own initialize() without breaking TestCase's initialize.</p> <p>Is that possible? Or am I making this hopelessly complicated?</p>
[ { "answer_id": 256063, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 3, "selected": false, "text": "setup" }, { "answer_id": 256104, "author": "Daniel Beardsley", "author_id": 13216, "author_profi...
2008/11/01
[ "https://Stackoverflow.com/questions/255969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8913/" ]
256,021
<p>I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also creates an html index file with links to each of the snips. So I can click the hyperlink to see the file, make a note in a spreadsheet to indicate if the file is correct or not and then use the back button in the browser to take me back to the index list. </p> <p>I was sitting here wondering if I could somehow create a delete button in the browser next to the hyperlink. My thought is I would click the hyperlink, make a judgment about the file and if it is not one I want to keep then when I get back to the main page I just press the delete button and it is gone from the directory. </p> <p>Does anyone have any idea if this is possible. I am writing this in python but clearly the issue is is there a way to create an htm file with a delete button-I would just use Python to write the commands for the deletion button.</p>
[ { "answer_id": 303086, "author": "PyNEwbie", "author_id": 30105, "author_profile": "https://Stackoverflow.com/users/30105", "pm_score": 1, "selected": true, "text": "def OnDelete(self, event):\n assert self.current, \"invalid delete operation\"\n try:\n os.remove(os.path.joi...
2008/11/01
[ "https://Stackoverflow.com/questions/256021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30105/" ]
256,027
<p>I am developing an application which will be connected to Access database at the beginning and the plan is to switch to MS SQL or SQL Express in the near future. The datatables structures are same for both types of databases and I am trying to avoid duplicating the code and trying to find the way to minimize the code.</p> <p>For example I wrote the following function for retrieving data from Access database:</p> <pre><code>public static DataTable GetActiveCalls() { string select = "SELECT call_id, call_time, msisdn, status FROM call WHERE status = 0 OR status = 1 ORDER by call_id ASC"; OleDbCommand cmd = new OleDbCommand(select, conn); DataTable dt = new DataTable("Active Calls"); OleDbDataAdapter DA = new OleDbDataAdapter(cmd); try { conn.Open(); DA.Fill(dt); } catch (Exception ex) { string sDummy = ex.ToString(); } finally { conn.Close(); } return dt; } </code></pre> <p>and the following code is for SQL Express database:</p> <pre><code>public static DataTable GetActiveCalls() { string select = "SELECT call_id, call_time, msisdn, status FROM call WHERE status = 0 OR status = 1 ORDER by call_id ASC"; SqlCommand cmd = new SqlCommand(select, conn); DataTable dt = new DataTable("Active Calls"); SqlDataAdapter DA = new SqlDataAdapter(cmd); try { conn.Open(); DA.Fill(dt); } catch (Exception ex) { string sDummy = ex.ToString(); } finally { conn.Close(); } return dt; } </code></pre> <p>These two methods are almost the same. The only differences are SqlCommand/OleDbCommand and SqlDataAdapter/OleDbDataAdapter. There are also some methods which take arguments for example:</p> <pre><code>public static void AddMessage(string callID, string content) { string select = "INSERT INTO message(key, direction, content, read, write_time) VALUES (@callId, 0, @content, 0, @insertTime)"; OleDbCommand cmd = new OleDbCommand(select, conn); cmd.Parameters.AddWithValue("callId", callID.ToString()); cmd.Parameters.AddWithValue("content", content); cmd.Parameters.AddWithValue("insertTime", DateTime.Now.ToString()); try { conn.Open(); cmd.ExecuteScalar(); } catch (Exception ex) { string sDummy = ex.ToString(); } finally { conn.Close(); } } </code></pre> <p>In this case SQL query string is also the same for both databases but there is the difference between the type of cmd (SqlCommand/OleDbCommand).</p> <p>I would really appreciate if anyone could give any suggestion about how to avoid duplicating the code and optimize the given problem.</p>
[ { "answer_id": 303086, "author": "PyNEwbie", "author_id": 30105, "author_profile": "https://Stackoverflow.com/users/30105", "pm_score": 1, "selected": true, "text": "def OnDelete(self, event):\n assert self.current, \"invalid delete operation\"\n try:\n os.remove(os.path.joi...
2008/11/01
[ "https://Stackoverflow.com/questions/256027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22996/" ]
256,033
<p>Is std::string size() a O(1) operation?</p> <p>The implementation of STL I'm using is the one built into VC++</p>
[ { "answer_id": 256045, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "size_type __CLR_OR_THIS_CALL size() const\n\n{ // return length of sequence\n\n return (_Mysize);\n\n}\n" }, { "...
2008/11/01
[ "https://Stackoverflow.com/questions/256033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
256,038
<p>I'm using a <code>std::map</code> (VC++ implementation) and it's a little slow for lookups via the map's find method. </p> <p>The key type is <code>std::string</code>.</p> <p>Can I increase the performance of this <code>std::map</code> lookup via a custom key compare override for the map? For example, maybe <code>std::string</code> &lt; compare doesn't take into consideration a simple <code>string::size()</code> compare before comparing its data?</p> <p>Any other ideas to speed up the compare?</p> <p>In my situation the map will always contain &lt; 15 elements, but it is being queried non stop and performance is critical. Maybe there is a better data structure that I can use that would be faster?</p> <p>Update: The map contains file paths.</p> <p>Update2: The map's elements are changing often.</p>
[ { "answer_id": 256089, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 4, "selected": false, "text": "set" }, { "answer_id": 256095, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverf...
2008/11/01
[ "https://Stackoverflow.com/questions/256038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
256,065
<p><strong>NOTE</strong>: I mention the next couple of paragraphs as background. If you just want a TL;DR, feel free to skip down to the numbered questions as they are only indirectly related to this info.</p> <p>I'm currently writing a python script that does some stuff with POSIX dates (among other things). Unit testing these seems a little bit difficult though, since there's such a wide range of dates and times that can be encountered.</p> <p>Of course, it's impractical for me to try to test every single date/time combination possible, so I think I'm going to try a unit test that randomizes the inputs and then reports what the inputs were if the test failed. Statisically speaking, I figure that I can achieve a bit more completeness of testing than I could if I tried to think of all potential problem areas (due to missing things) or testing all cases (due to sheer infeasability), assuming that I run it enough times.</p> <p>So here are a few questions (mainly indirectly related to the above ):</p> <ol> <li>What types of code are good candidates for randomized testing? What types of code aren't? <ul> <li>How do I go about determining the number of times to run the code with randomized inputs? I ask this because I want to have a large enough sample to determine any bugs, but don't want to wait a week to get my results.</li> <li>Are these kinds of tests well suited for unit tests, or is there another kind of test that it works well with?</li> <li>Are there any other best practices for doing this kind of thing?</li> </ul></li> </ol> <h3>Related topics:</h3> <ul> <li><a href="https://stackoverflow.com/questions/32458/random-data-in-unit-tests">Random data in unit tests?</a></li> </ul>
[ { "answer_id": 796933, "author": "mouviciel", "author_id": 45249, "author_profile": "https://Stackoverflow.com/users/45249", "pm_score": 0, "selected": false, "text": "if (a > 0)\n // Do Foo\nelse (if b < 0)\n // Do Bar\nelse\n // Do Foobar\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/256065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
256,073
<p>I'm not sure why I'm getting this error, but shouldn't this code compile, since I'm already checking to see if queue is getting initialized? </p> <pre><code>public static void Main(String[] args) { Byte maxSize; Queue queue; if(args.Length != 0) { if(Byte.TryParse(args[0], out maxSize)) queue = new Queue(){MaxSize = maxSize}; else Environment.Exit(0); } else { Environment.Exit(0); } for(Byte j = 0; j &lt; queue.MaxSize; j++) queue.Insert(j); for(Byte j = 0; j &lt; queue.MaxSize; j++) Console.WriteLine(queue.Remove()); } </code></pre> <p>So if queue is not initialized, then the for loops aren't reachable right? Since the program already terminates with Environment.Exit(0)?</p> <p>Hope ya'll can give me some pointers :)</p> <p>Thanks.</p>
[ { "answer_id": 256078, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 7, "selected": true, "text": "queue" }, { "answer_id": 256375, "author": "Mark Brackett", "author_id": 2199, "author_profile": "ht...
2008/11/01
[ "https://Stackoverflow.com/questions/256073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33324/" ]
256,077
<p>What is the right way to perform some static finallization? </p> <p>There is no static destructor. The <code>AppDomain.DomainUnload</code> event is not raised in the default domain. The <code>AppDomain.ProcessExit</code> event shares the total time of the three seconds (default settings) between all event handlers, so it's not really usable.</p>
[ { "answer_id": 256085, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "AppDomain.ProcessExit" }, { "answer_id": 256278, "author": "Michael Damatov", "author_id": 23372, "au...
2008/11/01
[ "https://Stackoverflow.com/questions/256077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23372/" ]
256,093
<p>I'm trying to use class names to change the color of a link after it has been selected, so that It will remain the new color, but only until another link is selected, and then it will change back.</p> <p>I'm using this code that was posted by Martin Kool in <a href="https://stackoverflow.com/questions/206689/changing-the-bg-color-of-a-selected-link">this</a> question:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; document.onclick = function(evt) { var el = window.event? event.srcElement : evt.target; if (el &amp;&amp; el.className == "unselected") { el.className = "selected"; var siblings = el.parentNode.childNodes; for (var i = 0, l = siblings.length; i &lt; l; i++) { var sib = siblings[i]; if (sib != el &amp;&amp; sib.className == "selected") sib.className = "unselected"; } } } &lt;/script&gt; &lt;style&gt; .selected { background: #f00; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="#" class="selected"&gt;One&lt;/a&gt; &lt;a href="#" class="unselected"&gt;Two&lt;/a&gt; &lt;a href="#" class="unselected"&gt;Three&lt;/a&gt; &lt;/body&gt; </code></pre> <p>It works fine until I try to out the links in a table. Why is this? Be easy, I'm a beginner.</p> <hr> <p>There is no error, the links are changing to the "selected" class, but when another link is selected, the old links are keeping the "selected" class instead of changing to "unselected". Basically, as far as I can tell, it's functioning like a vlink attribute, which is not what I'm going for.</p> <p>And yes, the links are all in different cells, how would you suggest I change the code so that it works correctly?</p> <hr> <p>OK, actually, I spoke too soon.</p> <pre><code>document.onclick = function(evt) { var el = window.event? event.srcElement : evt.target; if (el &amp;&amp; el.className == 'unselected') { var links = document.getElementsByTagName('a'); for (var i = links.length - 1; i &gt;= 0; i--) { if (links[i].className == 'selected') links[i].className = 'unselected'; } el.className = 'selected'; } return false; } </code></pre> <p>This code you gave me works great, visually, it does exactly what I want it to do. However, It makes my links stop working... They change color, but dont link to anything, and then when I remove the script, they work fine. What am I doing wrong/what do I have to change to make this work?</p> <p>Also, I want to do the same thing somewhere else in my website, where the links are all in one <code>&lt;div&gt;</code> tag, separated by <code>&lt;p&gt;</code> tags. How can I make this work?</p>
[ { "answer_id": 256113, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 0, "selected": false, "text": "var siblings = el.parentNode.childNodes;\n" }, { "answer_id": 256143, "author": "Greg", "author_id": 24181...
2008/11/01
[ "https://Stackoverflow.com/questions/256093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,142
<p>When I try to commit the first revision to my git repository (git commit) from Cygwin, I'm getting an error in gvim which says "Unable to open swap file for "foo\.git\COMMIT_EDITMSG" [New Directory]. I think it might be some sort of permission problem, but I've tried removing the read-only flag from the folder, as well as recursively adjusting the owner (using the windows property tab, not chown under Cygwin) to be the account I'm running under, without any luck. If I change the default editor to notepad, I get "The system cannot find the file specified", even though the file (COMMIT_EDITMSG) does exist and even contains:</p> <pre><code># Please enter the commit message for your changes. # (Comment lines starting with '#' will not be included) # etc... </code></pre> <p>How can I troubleshoot this problem further?</p>
[ { "answer_id": 256168, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "git commit" }, { "answer_id": 4774715, "author": "zerox", "author_id": 586454, "author_profile": "htt...
2008/11/01
[ "https://Stackoverflow.com/questions/256142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32539/" ]
256,146
<p>Delphi 2009, among some cool stuff, has also just got Anonymous methods. I've seen the examples, and the blog posts regarding anonymous methods, but I don't get them yet. Can someone explain why I should be excited?</p>
[ { "answer_id": 256167, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 4, "selected": false, "text": "type\n TAnonFunc = reference to procedure;\n TForm2 = class(TForm)\n Memo1: TMemo;\n Button1: TButton;\n B...
2008/11/01
[ "https://Stackoverflow.com/questions/256146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22712/" ]
256,148
<p>This is going to sound like a silly question, but I'm still learning C, so please bear with me. :)</p> <p>I'm working on chapter 6 of K&amp;R (structs), and thus far through the book have seen great success. I decided to work with structs pretty heavily, and therefore did a lot of work early in the chapter with the point and rect examples. One of the things I wanted to try was changing the <code>canonrect</code> function (2nd Edition, p 131) work via pointers, and hence return <code>void</code>.</p> <p>I have this working, but ran into a hiccup I was hoping you guys could help me out with. I wanted <code>canonRect</code> to create a temporary rectangle object, perform its changes, then reassign the pointer it's passed to the temporary rectangle, thus simplifying the code. </p> <p>However, if I do that, the rect doesn't change. Instead, I find myself manually repopulating the fields of the rect I'm passed in, which does work.</p> <p>The code follows:</p> <pre><code>#include &lt;stdio.h&gt; #define min(a, b) ((a) &lt; (b) ? (a) : (b)) #define max(a, b) ((a) &gt; (b) ? (a) : (b)) struct point { int x; int y; }; struct rect { struct point lowerLeft; struct point upperRight; }; // canonicalize coordinates of rectangle void canonRect(struct rect *r); int main(void) { struct point p1, p2; struct rect r; p1.x = 10; p1.y = 10; p2.x = 20; p2.y = 40; r.lowerLeft = p2; // note that I'm inverting my points intentionally r.upperRight = p1; printf("Rectangle, lower left: %d, %d; upper right: %d %d\n\n", r.lowerLeft.x, r.lowerLeft.y, r.upperRight.x, r.upperRight.y); // can't pass a pointer, only a reference. // (Passing pointers results in illegal indirection compile time errors) canonRect(&amp;r); printf("Rectangle, lower left: %d, %d; upper right: %d %d\n\n", r.lowerLeft.x, r.lowerLeft.y, r.upperRight.x, r.upperRight.y); } void canonRect(struct rect *r) { struct rect temp; temp.lowerLeft.x = min(r-&gt;lowerLeft.x, r-&gt;upperRight.x); temp.lowerLeft.y = min(r-&gt;lowerLeft.y, r-&gt;upperRight.y); temp.upperRight.x = max(r-&gt;lowerLeft.x, r-&gt;upperRight.x); temp.upperRight.y = max(r-&gt;lowerLeft.y, r-&gt;upperRight.y); r = &amp;temp; // doesn't work; my passed-in rect remains the same // I wind up doing the following instead, to reassign all // the members of my passed-in rect //r-&gt;lowerLeft = temp.lowerLeft; //r-&gt;upperRight = temp.upperRight; } </code></pre> <p>So here are the questions:</p> <ol> <li>Why does <code>r = &amp;temp;</code> not work? (I <strong>think</strong> this is because I pass in a reference instead of a pointer; am I correct in thinking that references are not modifiable but pointers are?)</li> <li>Why might I get an illegal indirection compile-time error if I try to pass in a pointer to <code>canonRect</code>? (IE, if I had <code>canonRect(*r);</code> in <code>main()</code>.)</li> </ol> <p>I suspect I already know the answer to #1, but #2 perplexes me -- I thought it was legal to pass pointers around.</p> <p>Anyway ... please forgive the C newb.</p>
[ { "answer_id": 256153, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 5, "selected": true, "text": "void canonRect(struct rect *r) {\n struct rect temp;\n temp.lowerLeft.x = min(r->lowerLeft.x, r->upperRight.x);\...
2008/11/01
[ "https://Stackoverflow.com/questions/256148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
256,169
<p>What is the best OS for Java development? People from Sun are pushing the Solaris, yes Solaris have some extra features included in itself such as (dTrace, possibility for Performance tuning the JVM, etc.. ). Some friends of mine, had port their application on solaris, and they said to me that the performances was brilliant. I'm not happy with switching my OS, and use Solaris instead.</p> <p>What were your experiences?</p>
[ { "answer_id": 256670, "author": "bendin", "author_id": 33396, "author_profile": "https://Stackoverflow.com/users/33396", "pm_score": 6, "selected": true, "text": "linux32" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/256169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16039/" ]
256,172
<p>The company I work for has recently been hit with many header injection and file upload exploits on the sites we host and while we have fixed the problem with respect to header injection attacks, we have yet to get the upload exploits under control.</p> <p>I'm trying to set up a plug-and-play-type series of upload scripts to use in-house that a designer can copy into their site's structure, modify a few variables, and have a ready-to-go upload form on their site. We're looking to limit our exposure as much as possible (we've already shut down fopen and shell commands).</p> <p>I've searched the site for the last hour and found many different answers dealing with specific methods that rely on outside sources. What do you all think is the best script-only solution that is specific enough to use as a reliable method of protection? Also, I'd like to keep the language limited to PHP or pseudo-code if possible.</p> <p><strong>Edit:</strong> I've found my answer (posted below) and, while it does make use of the shell command exec(), if you block script files from being uploaded (which this solution does very well), you won't run into any problems.</p>
[ { "answer_id": 18530956, "author": "inf3rno", "author_id": 607033, "author_profile": "https://Stackoverflow.com/users/607033", "pm_score": 6, "selected": false, "text": "MAX_FILE_SIZE" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/256172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25375/" ]
256,195
<p>I'm using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in <code>$(document).ready</code> . For example:</p> <pre><code>$(function() { $('div._Foo').bind("mouseover", function(e) { // Do something exciting }); }); </code></pre> <p>Of course, this works fine the first time the page is loaded, but when the UpdatePanel does a partial page update, it's not run and the mouseover effects don't work any more inside the UpdatePanel. </p> <p>What's the recommended approach for wiring stuff up in jQuery not only on the first page load, but every time an UpdatePanel fires a partial page update? Should I be using the ASP.NET ajax lifecycle instead of <code>$(document).ready</code>?</p>
[ { "answer_id": 256253, "author": "Dan Herbert", "author_id": 392, "author_profile": "https://Stackoverflow.com/users/392", "pm_score": 10, "selected": true, "text": "$(document).ready()" }, { "answer_id": 259168, "author": "Community", "author_id": -1, "author_profile...
2008/11/01
[ "https://Stackoverflow.com/questions/256195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
256,204
<p>I use the <code>:e</code> and <code>:w</code> commands to edit and to write a file. I am not sure if there is "close" command to close the current file without leaving Vim?</p> <p>I know that the <code>:q</code> command can be used to close a file, but if it is the last file, Vim is closed as well; Actually on Mac OS MacVim does quit. Only the Vim window is closed and I could use <kbd>Control</kbd>-<kbd>N</kbd> to open a blank Vim window again. I would like Vim to remain open with a blank screen.</p>
[ { "answer_id": 256206, "author": "Rytmis", "author_id": 266, "author_profile": "https://Stackoverflow.com/users/266", "pm_score": 3, "selected": false, "text": ":enew" }, { "answer_id": 256208, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https:/...
2008/11/01
[ "https://Stackoverflow.com/questions/256204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
256,218
<p>Let's say I have a <code>char* str = "0123456789"</code> and I want to cut the first and the last three letters and print just the middle, what is the simplest, and safest, way of doing it?</p> <p>Now the trick: The portion to cut and the portion to print are of variable size, so I could have a very long char*, or a very small one.</p>
[ { "answer_id": 256223, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 7, "selected": true, "text": "printf()" }, { "answer_id": 256224, "author": "Kyle Cronin", "author_id": 658, "author_profile": ...
2008/11/01
[ "https://Stackoverflow.com/questions/256218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21648/" ]
256,222
<p>I was wondering about the best practices for indicating invalid argument combinations in Python. I've come across a few situations where you have a function like so:</p> <pre><code>def import_to_orm(name, save=False, recurse=False): """ :param name: Name of some external entity to import. :param save: Save the ORM object before returning. :param recurse: Attempt to import associated objects as well. Because you need the original object to have a key to relate to, save must be `True` for recurse to be `True`. :raise BadValueError: If `recurse and not save`. :return: The ORM object. """ pass </code></pre> <p>The only annoyance with this is that every package has its own, usually slightly differing <code>BadValueError</code>. I know that in Java there exists <code>java.lang.IllegalArgumentException</code> -- is it well understood that everybody will be creating their own <code>BadValueError</code>s in Python or is there another, preferred method?</p>
[ { "answer_id": 256235, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 4, "selected": false, "text": "ValueError" }, { "answer_id": 256236, "author": "Markus Jarderot", "author_id": 22364, "author_p...
2008/11/01
[ "https://Stackoverflow.com/questions/256222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
256,228
<p>I'm trying to read data from a photocell resistor and my Arduino Decimila and then graph it in real-time with Processing.</p> <p>Should be painfully simple; but its growing into a little bit of a nightmare for me.</p> <p>code I'm running on my Arduino:</p> <pre class="lang-java prettyprint-override"><code>int photoPin; void setup(){ photoPin = 0; Serial.begin( 9600 ); } void loop(){ int val = int( map( analogRead( photoPin ), 0, 1023, 0, 254 ) ); Serial.println( val ); //sending data over Serial } </code></pre> <p>code I'm running in Processing: </p> <pre class="lang-java prettyprint-override"><code>import processing.serial.*; Serial photocell; int[] yvals; void setup(){ size( 300, 150 ); photocell = new Serial( this, Serial.list()[0], 9600 ); photocell.bufferUntil( 10 ); yvals = new int[width]; } void draw(){ background( 0 ); for( int i = 1; i &lt; width; i++ ){ yvals[i - 1] = yvals[i]; } if( photocell.available() &gt; 0 ){ yvals[width - 1] = photocell.read(); } for( int i = 1; i &lt; width; i++ ){ stroke( #ff0000 ); line( i, yvals[i], i, height ); } println( photocell.read() ); // for debugging } </code></pre> <p>I've tested both bits of code separately and I know that they work. It's only when I try to have the input from the Arduino going to Processing that the problems start.</p> <p>When I view the data in Arduino's "Serial Monitor", I get a nice constant flow of data that seems to look valid.</p> <p>But when I read that same data through Processing, I get a repeating pattern of random values.</p> <p>Halp?</p>
[ { "answer_id": 19803246, "author": "Mateo Sanchez", "author_id": 2741380, "author_profile": "https://Stackoverflow.com/users/2741380", "pm_score": 3, "selected": true, "text": "<iframe id=\"igraph\" src=\"https://plot.ly/~abhishek.mitra.963/1/400/250/\" width=\"400\" height=\"250\" seaml...
2008/11/01
[ "https://Stackoverflow.com/questions/256228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13293/" ]
256,229
<p>I'm building an ASP.NET web application, and all of my strings are stored in a resource file. I'd like to add a second language to my application, and ideally, I'd like to auto-detect the user's browser language (or windows language) and default to that, instead of making them choose something besides English. Currently, I'm handling all the resource population manually, so adding a second resource file and language is trivial from my point of view, if I had an easy way to automatically figure out what language to display.</p> <p>Has anybody done this, or do you have any thoughts about how I might retrieve that value? Since ASP.NET is server-based, I don't seem to have any access to specific browser settings.</p> <p><strong>RESOLUTION</strong>: Here's what I ended up doing. I used a "For Each" to go through "HttpContext.Current.Request.UserLanguages" and search for one I support. I'm actually just checking the left two characters, since we don't support any dialects yet - just English and Spanish. Thanks for all the help!</p>
[ { "answer_id": 256244, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 2, "selected": false, "text": "CultureInfo.CurrentCulture" }, { "answer_id": 256250, "author": "Maxam", "author_id": 15310, "autho...
2008/11/01
[ "https://Stackoverflow.com/questions/256229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8114/" ]
256,234
<p>(If anything here needs clarification/ more detail please let me know.)</p> <p>I have an application (C#, 2.* framework) that interfaces with a third-party webservice using SOAP. I used thinktecture's WSCF add-in against a supplied WSDL to create the client-side implementation. For reasons beyond my control the SOAP message exchange uses WSE2.0 for security (the thinctecture implementation had to be modified to include the WSE2.0 reference). In addition to the 'normal' data package I attach a stored X509 cert and a binary security token from a previous call to a different web service. We are using SSL encryption of some sort - I don't know the details. </p> <p>All the necessary serialization/deserialization is contained in the web service client - meaning when control is returned to me after calling the client the entire XML string contained in the SOAP response is not available to me - just the deserialized components. Don't get me wrong - I think that's good because it means I don't have to do it myself.</p> <p>However, in order for me to have something worth storing/archiving I am having to re-serialize the data at the root element. This seems like a waste of resources since my result was in the SOAP response. </p> <p><strong>Now for my question: How can I get access to a 'clear' version of the SOAP response so that I don't have to re-serialize everything for storage/archiving?</strong></p> <p>Edit- My application is a 'formless' windows app running as a network service - triggered by a WebsphereMQ client trigger monitor. I don't <em>think</em> ASP.NET solutions will apply.</p> <p>Edit - Since the consensus so far is that it doesn't matter whether my app is ASP.NET or not then I will give CodeMelt's (and by extension Chris's) solution a shot.</p>
[ { "answer_id": 256273, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 4, "selected": true, "text": "public class MyClientSOAPExtension : SoapExtension\n{\n\n Stream oldStream;\n Stream newStream;\n\n // Save the ...
2008/11/01
[ "https://Stackoverflow.com/questions/256234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30901/" ]
256,254
<p>I have been researching and playing with functional programming lately, solely to broaden my thinking about programming, because I find thinking "functionally" difficult.</p> <p>I have downloaded Glasgow Haskell and experimented with that.</p> <p>What I am wondering is, what is the best platform for Windows to experiment with FP? I would prefer a JVM based approach, but another post on SO has indicated that a real FP language cannot be implemented on the JVM due to a lack of support for tail recursion. What say you?</p> <p>EDIT: As I've said, I've experimented a fair bit with Haskell; on the advice of one of the answers I've been reviewing the Scala website. Looking over the Scala examples, the code seems more "familiar" (my background is C and Java), but it seems decidedly more OO/procedural and less functional. A huge advantage of Scala would be that it gives me another language tool to use side by side with Java and could become another arrow in my current professional quiver, as opposed to solely being a learning exercise. When I get further into Scala, will the functional aspects become more predominant, or will I tend to end up just writing OO code with some functional influence? In other words, will Haskell challenge my preconceptions harder and faster than Scala?</p>
[ { "answer_id": 256332, "author": "Loopo", "author_id": 32763, "author_profile": "https://Stackoverflow.com/users/32763", "pm_score": 0, "selected": false, "text": "?- bend(your_mind).\nYes\n\n\n?- bend(X).\nX = your_mind\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/256254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8946/" ]