qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
412,598
<p>I am likely to be working on a few projects soon where I will need to take data from a file and input that data programmatically into another third-party (not my own) application. One problem: I have no idea how to do this.I will need to enter data (like times on a time sheet, for exampls) Can anyone steer me in the right direction to acquire this skill?</p> <p>ADDITIONAL SPECS: I wrote the original post late at night so may not have been as detailed as I should have. Here is an example: My client has an ERP app that they use to collect time stamps from the line workers as they perform their jobs and get projects out the door throughout the day. This app does NOT have an API I can use to feed data into. I have heard of a guy who was able to actually push data onto the screen in this app's windows and controls programmatically, such that the data was able to be collected into, say, an Excel worksheet, then effectively uploaded into this app. Sort of a reverse screen-scrape. It's not pretty like an API would be, but it works.</p> <p>I've seen app's interact with other apps in a similar way. One good example I can think of is SnagIt, the screenshot utility. You can order it to screen capture a window in a particular app, and as you move your mouse around that window, the controls under the pointer will outline in red to indicate which control it will capture for you. I think that is interesting, and probably just a step away from actually being able to type text <em>into</em> such a control.</p> <p>Thanks for the comments and answers so far, I'm pursuing them all.</p>
[ { "answer_id": 412608, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 3, "selected": false, "text": "c:\\> someapp.exe arg1 arg2\n System(\"C:\\\\>someapp.exe arg1 arg2\");\n Excel.Application excelApp = new Exce...
2009/01/05
[ "https://Stackoverflow.com/questions/412598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45606/" ]
412,611
<p>I have the following use case, a struct with some boolean and int variables</p> <pre><code>struct a { int field1; bool field2; bool field3; }; </code></pre> <p>I am refactoring this code, and writing a constructor for the struct , the problem is the default initialization of fields.</p> <p>I am not criticizing any language construct here, but ideally I would want null to be part of the language itself </p> <p>i mean I should be able to define for struct a as</p> <pre><code>a : field1(null.int), field2(null.bool), field3(null.bool) {} </code></pre> <p>C++ does not allow it since null.int or null.bool are not defined. Is the only way to do in C++ is </p> <pre><code>a: field1(-1), field2(false), field3(false) {} </code></pre>
[ { "answer_id": 412614, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "struct a {\n a():field1(), field2(), field3() { }\n int field1;\n bool field2;\n bool field3;\n}...
2009/01/05
[ "https://Stackoverflow.com/questions/412611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
412,613
<p>We have a HEAD branch, and a feature branch that was created off the HEAD branch. I develop on the feature branch, and constantly merge changes from HEAD to my branch.</p> <p>When I'm finished with the feature, I try to merge it back to HEAD. This is supposed to be a 0-pain operation, as all conflicts were already resolved on previous merges to the feature branch. However, it never is.</p> <p>I end up copying the entire content of my branch and overwriting the HEAD branch with it. This has been the situation in Team Foundation System 2005 and 2008. Is it a bug or am I doing something wrong?</p>
[ { "answer_id": 412614, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "struct a {\n a():field1(), field2(), field3() { }\n int field1;\n bool field2;\n bool field3;\n}...
2009/01/05
[ "https://Stackoverflow.com/questions/412613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
412,615
<p>which method do you prefer for creating dynamic sql queries? formating or streaming? Is it just preference or there any reason one is better than other?Or any special library you use to it.</p> <p>EDIT: Please answer in case of c++.</p>
[ { "answer_id": 412639, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 2, "selected": false, "text": "PreparedStatement statement = connection.prepareStatement(\"SELECT * FROM Table WHERE ID = ?\");\nstatement.setInt(1, 17);\n...
2009/01/05
[ "https://Stackoverflow.com/questions/412615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
412,626
<p>I have created a own installer for my application(c#). During the installation process, i will ask the end-user for the install location. My problem is how to pass that install location(user input) to the installer. The installer always trying to install at c:\progam files[mfr name][product name].</p> <p>please help me</p>
[ { "answer_id": 412638, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 2, "selected": false, "text": "string targetDir = Context.Parameters[\"TARGETDIR\"];\n" }, { "answer_id": 412673, "author": "tafa", ...
2009/01/05
[ "https://Stackoverflow.com/questions/412626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,632
<p>I would like to access information on the logical drives on my computer using C#. How should I accomplish this? Thanks!</p>
[ { "answer_id": 412644, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 7, "selected": true, "text": "using System;\nusing System.IO;\n\nclass Info {\n public static void Main() {\n DriveInfo[] drives = DriveI...
2009/01/05
[ "https://Stackoverflow.com/questions/412632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51578/" ]
412,634
<p>I've browsed through the CreateFile documentation... still wondering how should I use P/Invoke to call CreateFile and to read the boot sector, to display out the .MBR?</p> <p>Any reference code for this portion? Thank you in advance!</p>
[ { "answer_id": 412658, "author": "Baget", "author_id": 34369, "author_profile": "https://Stackoverflow.com/users/34369", "pm_score": 1, "selected": false, "text": "\"\\\\.\\PHYSICALDRIVE0\"" }, { "answer_id": 412663, "author": "Treb", "author_id": 22114, "author_profi...
2009/01/05
[ "https://Stackoverflow.com/questions/412634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51579/" ]
412,649
<p>I'm trying to test the performance of our webapp with JMeter. The login procedure includes some external dependencies that can't be reproduced during the test, so I've programmed an alternate login. As this alternate login request is not part of the normal workflow I would like to exclude the login request from the JMeter results because the response time is pretty high compared to the other normal requests.</p> <p>Is there a way to collect results only for a set of requests, ignoring the rest?</p>
[ { "answer_id": 808131, "author": "BlackGaff", "author_id": 98711, "author_profile": "https://Stackoverflow.com/users/98711", "pm_score": 5, "selected": true, "text": "Test Plan\n- Thread Group\n---- Simple Controller - Login ONLY\n---- Simple Controller - Rest of Script\n--------- Listen...
2009/01/05
[ "https://Stackoverflow.com/questions/412649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34009/" ]
412,653
<p>I have a DependencyObject in C# that is used in an array. Example shown below:</p> <pre><code>private KeywordTag[] tags = new KeywordTag[] { new KeywordTag { Tag = "test", IncidenceCount = 2076 }, new KeywordTag { Tag = "oi", IncidenceCount = 2052 }, new KeywordTag { Tag = "hmm", IncidenceCount = 1887 }, new KeywordTag { Tag = "grr", IncidenceCount = 1414 }, new KeywordTag { Tag = "thanks", IncidenceCount = 1166 }} </code></pre> <p>How would I convert this code to VB.NET?</p> <p>Thanks!</p>
[ { "answer_id": 412669, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 2, "selected": false, "text": "Private tags() As KeywordTag = { New KeywordTag { Tag = \"test\", IncidenceCount = 2076 }, New KeywordTag { Tag = \...
2009/01/05
[ "https://Stackoverflow.com/questions/412653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46304/" ]
412,655
<p>I am using:</p> <pre><code>[ajax.ajaxmethod()] public void fnName() </code></pre> <p>containing: </p> <pre><code>response.redirect("sample.aspx"); </code></pre> <p>or:</p> <pre><code>server.transfer("sample.aspx"); </code></pre> <p>both are not working... what is the solution?</p> <p>in that block, I tried to call javascript function as</p> <pre><code>scriptmanager.registerstartupscript(page,gettype(),"sample","javascriptfunction()",true); </code></pre> <p>it's also not working..</p>
[ { "answer_id": 412835, "author": "Thomas Hansen", "author_id": 29746, "author_profile": "https://Stackoverflow.com/users/29746", "pm_score": 1, "selected": false, "text": "AjaxManager.Instance.WriterAtBack.Write(\"window.location='foo.aspx';\");\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,660
<p>From my experience the major ORM frameworks for .NET (<a href="http://nhforge.org" rel="nofollow noreferrer">NHibernate</a>, <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" rel="nofollow noreferrer">LinqToSql</a>, <a href="http://msdn.microsoft.com/en-us/library/aa697427%28VS.80%29.aspx" rel="nofollow noreferrer">Entity Framework</a>) work best when they keep track of loaded objects. This works fine for simple client-server applications, but when using three- or more tier architecture with Web Services in a Service Oriented Archtitecture, this is not possible. Eventually, by writing a lot of code to do the tracking yourself it could be done, but isn't ORM supposed to simplify DB access? </p> <p>Is the idea to use ORM in service oriented architecture good at all? </p>
[ { "answer_id": 412672, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 1, "selected": false, "text": "DataContract" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51569/" ]
412,687
<p>I have an xml that has text within "word" elements e.g</p> <pre><code>&lt;word&gt;Police&lt;/word&gt; &lt;word&gt;confirmed&lt;/word&gt; &lt;word&gt;they are&lt;/word&gt; &lt;word&gt;questioning&lt;/word&gt; &lt;word&gt;a&lt;/word&gt; &lt;word&gt;man&lt;/word&gt; </code></pre> <p>The problem is when I apply the xslt the text appears like "Policeconfirmedthey arequestioningaman".</p> <p>Here is the xslt snippet that does this transform</p> <pre><code>&lt;Paragraph&gt; &lt;xsl:for-each select="./speaker/segment"&gt; &lt;xsl:value-of select="./nbest"/&gt; &lt;/xsl:for-each&gt; &lt;/Paragraph&gt; </code></pre> <p>Can anyone offer any help as to how I can display this as "Police confirmed they are questioning a man"?</p> <p>Many thanks.</p>
[ { "answer_id": 412727, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "<xsl:template match=\"//words\">\n <xsl:for-each select=\"word\">\n <xsl:value-of select=\".\"/>\n <!-- Check word'...
2009/01/05
[ "https://Stackoverflow.com/questions/412687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44649/" ]
412,691
<p>I'm going to generate an <code>asp:CheckBoxList</code> using this code </p> <pre><code>&lt;% System.Collections.Generic.List&lt;QuizzEngine.Common.Question&gt; qList = (System.Collections.Generic.List&lt;QuizzEngine.Common.Question&gt;)Session[QuizzEngine.Common.SessionKeys.QuesionsList]; int navigator = (int)Session[QuizzEngine.Common.SessionKeys.Navigator]; if (True) { %&gt; &lt;'asp:CheckBoxList ID="cblistAnswers" runat="server" &lt;'Width="139px"style="text-align: left" AutoPostBack="False"&gt; &lt;'asp:ListItem Value="1"&gt;Me&lt;'/asp:ListItem&gt; &lt;'/asp:CheckBoxList&gt; &lt;% cblistAnswers.Items.Clear(); foreach (QuizzEngine.Common.Answer answer in qList[navigator].QuestionAllAnswers) { ListItem i = new ListItem(); i.Attributes.Add("runat", "server"); i.Value = answer.AnswerId.ToString(); i.Text = answer.AnswerText; cblistAnswers.Items.Add(i); } %&gt; </code></pre> <p>Only the <code>ListItem</code> I added in the markup :</p> <pre><code>&lt;'asp:ListItem Value="1"&gt;Me&lt;'/asp:ListItem&gt; </code></pre> <p>appears, the other items I added dynamically doesn't appear, what I should do?</p>
[ { "answer_id": 412796, "author": "karlis", "author_id": 49034, "author_profile": "https://Stackoverflow.com/users/49034", "pm_score": -1, "selected": false, "text": "i.Attributes.Add(\"runat\", \"server\");\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32718/" ]
412,717
<p>I want to use <strong><a href="http://testng.org/" rel="noreferrer">testng</a></strong> with the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/" rel="noreferrer">Surefire plug-in</a> of <a href="http://en.wikipedia.org/wiki/Apache_Maven" rel="noreferrer">Maven</a>. The idea is to tag some tests with a group <code>integrationTest</code> and run the plug-in twice: for goal <code>test</code> excluding the group <code>integrationTest</code> and for goal <code>integration-test</code> including the group <code>integrationTest</code> only.</p> <p>I found some <a href="http://docs.codehaus.org/pages/viewpage.action?pageId=62120" rel="noreferrer">material</a> for running the plug-in for both goals and that works, but the group for the second run does not work (no test is executed).</p> <p>Here is the plug-in configuration in the build element of my <code>pom.xml</code>:</p> <pre><code> &lt;plugin&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;excludedGroups&gt;integrationTest&lt;/excludedGroups&gt; &lt;reportFormat&gt;brief&lt;/reportFormat&gt; &lt;trimStackTrace&gt;true&lt;/trimStackTrace&gt; &lt;useFile&gt;false&lt;/useFile&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;integration-test&lt;/id&gt; &lt;phase&gt;integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;test&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;groups&gt;integrationTest&lt;/groups&gt; &lt;excludedGroups/&gt; &lt;reportsDirectory&gt;${project.build.directory}/surefire-reports/integration&lt;/reportsDirectory&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>Any idea? <code>mvn integration-test</code> runs all unit tests as expected (excluding the group <code>integrationTest</code>) but the second test run just writes:</p> <blockquote> <p>Running TestSuite<br> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.562 sec</p> </blockquote> <p>The Result of <code>mvn test</code> is as expected, tests run and group <code>integrationTest</code> is ignored.</p>
[ { "answer_id": 415858, "author": "Arne Burmeister", "author_id": 12890, "author_profile": "https://Stackoverflow.com/users/12890", "pm_score": 5, "selected": true, "text": "<excludedGroups/> <excludedGroups>integrationTest</excludedGroups> <excludedGroups>none</excludedGroups>" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12890/" ]
412,725
<p>Does anyone have any ideas on how to read the MSDTC configuration on the current machine? I am specifically trying to check that the user has performed the following steps:</p> <ol> <li><p>Open Component Management (Start > All Programs > Administrative Tools > Component Services) </p></li> <li><p>Double-click on Component Services, then expand Computers. Right-click on My Computer and select Properties</p></li> <li><p>On the MSDTC tab, click the Security Configuration button, and configure the properties as follows:</p></li> <li><p>Network DTC Access: Checked</p></li> <li><p>Allow Remote Clients: Checked </p></li> <li><p>Allow Inbound: Checked </p></li> <li><p>Allow Outbound: Checked </p></li> <li><p>Incoming Caller Authentication Required: Selected</p></li> </ol> <p>It's part of a small component I need to write to validate end-user configuration. I don't think I would attempt to fix it if it were wrong: just point the user at the help file - so only read only is needed.</p>
[ { "answer_id": 412974, "author": "Magnus Johansson", "author_id": 3584, "author_profile": "https://Stackoverflow.com/users/3584", "pm_score": 1, "selected": true, "text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSDTC\\Security\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24064/" ]
412,734
<p>I am using country and state dropdowns in my form. Whenever the user selects the country in the dropdown, the respective states of the country will populate in the states dropdown. I am populating the states in the dropdown using AJAX call. The problem is that the states get populated in Mozilla but it doesn't work in IE. I guess there is some problem in jQuery while loading the states in the states dropdown. The jQuery code i am using is </p> <pre><code>$('select#edit-country').change(function(e) { $.getJSON("loadContactUsStates",{id: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i &lt; j.length; i++) { options += '&lt;option value="' + j[i].optionValue + '"&gt;' + j[i].optionDisplay + '&lt;/option&gt;'; } &lt;!-----I guess the problem is with the below line------------------&gt; $("select#edit-state").html(options); })//end json }); </code></pre>
[ { "answer_id": 412794, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 0, "selected": false, "text": "$(\"#edit-state\").append(options)" }, { "answer_id": 2670937, "author": "Stefan Kendall", "author_id": 78...
2009/01/05
[ "https://Stackoverflow.com/questions/412734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,740
<p>I'm trying to mimic the following Java code:</p> <pre><code>int[][] multi; // DIMENSIONS ARE UNKNOWN AT CREATION TIME // LATER ON... multi = new int[10][]; multi[5] = new int[20]; multi[5][11] = 66; // LATER ON... multi = null; // PROPER WAY OF FREEING EVERYTHING </code></pre> <p>I've came out with the following Objective-C version:</p> <pre><code>int* *multi; // multi = malloc(10 * sizeof(int*)); multi[5] = (int *) malloc(20 * sizeof(int)); multi[5][11] = 66; // free(multi[5]); free(multi); </code></pre> <p>So first, I'd like to hear if it's the best way to go. And mostly: I can't find a way to free memory in some "automatic" fashion, i.e. the following code is causing run-time exceptions on the IPhone:</p> <pre><code>for (int i = 0; i &lt; 10; i++) { if (multi[i] != NULL) free(multi[i]); } </code></pre>
[ { "answer_id": 412749, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 0, "selected": false, "text": "multi" }, { "answer_id": 412779, "author": "Jason Coco", "author_id": 34218, "author_profile": "...
2009/01/05
[ "https://Stackoverflow.com/questions/412740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50335/" ]
412,748
<p>I am looking for an ORM to use with .net, I need to be able to do full graph serialization to Xml on the entitys the ORM generates. My own research leads me towards using the WCF and the Entity Framework to achieve this, Is this the best option or is there a simpler way ?</p>
[ { "answer_id": 412786, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "DataContractSerializer XmlSerializer Serialization Mode Unidirectional DataContractSerializer" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,750
<p>I have to make column charts in Excel using VBA only (no user input).</p> <p>I want to format the labels of the x-axis so that the alignment for every label becomes -270 degrees. This can be done manually by changing the "Custom angle" property in the "Alignment" tab of the "Format Axis" Dialog.</p> <p>I recorded a macro but Excel does not seem to be recording the alignment step.</p>
[ { "answer_id": 412762, "author": "Artelius", "author_id": 31945, "author_profile": "https://Stackoverflow.com/users/31945", "pm_score": 3, "selected": true, "text": "ActiveSheet.ChartObjects(\"Chart 1\").Activate\nActiveChart.Axes(xlCategory).Select\nSelection.TickLabels.Orientation = xl...
2009/01/05
[ "https://Stackoverflow.com/questions/412750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51590/" ]
412,753
<p>I'm trying to create a SharePoint web part that will display all the users in a certain active directory or SharePoint security group.</p> <p>So for example on the home page for a department called Human Resources, the web part will list all the people who belong to the AD or SharePoint group called HR.</p> <p>It's been suggested to me that there is no relationship between the users table in SharePoint and the security groups, which I find hard to understand? If users belong to a group you would suspect there is a relationship.</p> <p>Many Thanks for any suggestions</p>
[ { "answer_id": 2802078, "author": "arindam", "author_id": 337180, "author_profile": "https://Stackoverflow.com/users/337180", "pm_score": 0, "selected": false, "text": "webpart" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12318/" ]
412,760
<p>There's something I'm just not getting about .NET remoting. Well, two things actually:</p> <ol> <li><p>Why is the emphasis back on classes that inherit from MarshalByRef instead of interfaces ala the original COM style (which I liked)?</p></li> <li><p>Why is it that .NET remoting always forces you to effectively create some sort of object pool instead of allowing you to associate specific <em>instances</em> with a URL?</p></li> </ol> <p>Server code:</p> <pre><code>RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingTypes.Server), "MyURL", WellKnownObjectMode.Singleton); </code></pre> <p>Client code:</p> <pre><code>RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingTypes.Server), "MyURL", WellKnownObjectMode.Singleton); </code></pre> <p>But suppose I want to create the "Server" instance myself and then just bind it to an endpoint?</p> <pre><code>RemotingTypes.Server myInstance = new RemotingTypes.Server(); </code></pre> <p>What now? How can I associate "myInstance" with the URL "MyURL" ?</p>
[ { "answer_id": 412792, "author": "nickd", "author_id": 2373, "author_profile": "https://Stackoverflow.com/users/2373", "pm_score": 0, "selected": false, "text": "RemotingTypes.Server myInstance = (RemotingTypes.Server) Activator.GetObject(typeof(RemotingTypes.Server), MyUrl);\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34685/" ]
412,771
<p>I seem to run into this very often. I need to build a Hash from an array using an attribute of each object in the array as the key.</p> <p>Lets say I need a hash of example uses ActiveRecord objecs keyed by their ids Common way:</p> <pre><code>ary = [collection of ActiveRecord objects] hash = ary.inject({}) {|hash, obj| hash[obj.id] = obj } </code></pre> <p>Another Way:</p> <pre><code>ary = [collection of ActiveRecord objects] hash = Hash[*(ary.map {|obj| [obj.id, obj]}).flatten] </code></pre> <p>Dream Way: I could and might create this myself, but is there anything in Ruby or Rails that will this?</p> <pre><code>ary = [collection of ActiveRecord objects] hash = ary.to_hash &amp;:id #or at least hash = ary.to_hash {|obj| obj.id} </code></pre>
[ { "answer_id": 412904, "author": "ewalshe", "author_id": 47429, "author_profile": "https://Stackoverflow.com/users/47429", "pm_score": 3, "selected": false, "text": "class Array\n def to_hash(&block)\n Hash[*self.map {|e| [block.call(e), e] }.flatten]\n end\nend\n\nary = [collection...
2009/01/05
[ "https://Stackoverflow.com/questions/412771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
412,772
<p>I'm using CXF 2.1 to generate java code from a wsdl, but I'm getting the following error:</p> <pre><code>WSDLToJava Error: Rpc/encoded wsdls are not supported in JAXWS 2.0 org.apache.cxf.tools.common.ToolException: Rpc/encoded wsdls are not supported in JAXWS 2.0 at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.checkSupported(JAXWSDefinitionBuilder.java:141) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:87) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:127) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:232) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:103) at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:173) </code></pre> <p>How do I fix this error, can I use a previous version of CXF or anything else to fix it?</p>
[ { "answer_id": 415326, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 6, "selected": false, "text": "java org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL \n <soap:body use=\"encoded\"\n encodingStyle=\"http...
2009/01/05
[ "https://Stackoverflow.com/questions/412772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,777
<p>Hi all is it possible to rewrite query: </p> <p><code>select userid from User where userid not in(select userid from UserRole where roleid in(8));</code></p> <p>as Join?</p> <p>the problem is that one user may have several roles<br> thank you in advance. </p> <pre> mysql> desc User; +--------------------+-------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+-------------------+------+-----+---------+----------------+ | userId | int(11) | NO | PRI | NULL | auto_increment | | userName | varchar(50) | YES | | NULL | | </pre> <p>...and other user related columns </p> <pre> mysql> desc UserRole; +--------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------+------+-----+---------+-------+ | userId | int(11) | NO | PRI | 0 | | | roleId | int(11) | NO | PRI | 0 | | +--------+---------+------+-----+---------+-------+ </pre>
[ { "answer_id": 412782, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 1, "selected": true, "text": "select userid from User \nleft outer join\n(select userid, roleid from UserRole where roleid in(8)) v\non User.userid ...
2009/01/05
[ "https://Stackoverflow.com/questions/412777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51598/" ]
412,784
<p>I've got a small app that searches for and stores the names of a large number of files at start-up. I'm splitting this search into several Thread objects that each search one directory, and push results back to the main thread.</p> <p>When the app loads, I go through each thread and load it:</p> <pre><code>foreach(Thread t in m_threads) { t.Start(); while(!t.IsAlive){} } </code></pre> <p>When I begin this app in the debugger, it loads and the threads quickly find all the files. However if I start outside the debugger it freezes. Attaching the debugger to the process I can see that IsAlive never returns true.</p> <p>I'm new to C# threading so does anyone have any idea what's going wrong, or how I can more easily debug what's happening?</p>
[ { "answer_id": 412800, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 1, "selected": false, "text": "IsAlive()" }, { "answer_id": 412856, "author": "Oliver Friedrich", "author_id": 44532, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/412784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11801/" ]
412,785
<p>I'm reading a .gz file from some slow source (like FTP Server) and am processing the received data right away. Looks something like this:</p> <pre><code>FtpWebResponse response = ftpclientRequest.GetResponse() as FtpWebResponse; using (Stream ftpStream = response.GetResponseStream()) using (GZipStream unzipped = new GZipStream(ftpStream, CompressionMode.Decompress)) using (StreamReader linereader = new StreamReader(unzipped)) { String l; while ((l = linereader.ReadLine()) != null) { ... } } </code></pre> <p>My problem is showing an accurate progress bar. In advance I can get the compressed .gz file size, but I got no clue how large the content would be uncompressed. Reading the file line by line I know quite well how many uncompressed bytes I read, but I don't know how this does relate to the compressed file size.</p> <p>So, is there any way to get from GZipStream how far the file pointer is advanced into the compressed file? I only need the current position, the gz file size I can fetch before reading the file.</p>
[ { "answer_id": 412874, "author": "Petar Petrov", "author_id": 42377, "author_profile": "https://Stackoverflow.com/users/42377", "pm_score": 0, "selected": false, "text": "public static readonly byte[] symbols = new byte[8 * 1024];\n\npublic static void Decompress(FileInfo inFile, FileInf...
2009/01/05
[ "https://Stackoverflow.com/questions/412785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
412,789
<p>I am experimenting with Beep function on Windows:</p> <pre><code>#include &lt;windows.h&gt; ... Beep(frequency, duration); </code></pre> <p>The computer then beeps with some frequency for some duration. How would I do this on a Linux computer?</p> <p>Edit: It IS important to output different frequencies.</p>
[ { "answer_id": 412797, "author": "Schwartser", "author_id": 50435, "author_profile": "https://Stackoverflow.com/users/50435", "pm_score": -1, "selected": false, "text": "char beep[] = {7, ”};\nprintf(“%c”, beep);\n Beep(587,500);\n" }, { "answer_id": 412922, "author": "Commun...
2009/01/05
[ "https://Stackoverflow.com/questions/412789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9095/" ]
412,813
<p>I often use an <code>ArrayList</code> instead of a 'normal' <code>array[]</code>.</p> <p>I feel as if I am cheating (or being lazy) when I use an <code>ArrayList</code>, when is it okay to use an <code>ArrayList</code> over an array?</p>
[ { "answer_id": 412821, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 7, "selected": true, "text": "List<T>" }, { "answer_id": 412827, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https:/...
2009/01/05
[ "https://Stackoverflow.com/questions/412813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
412,823
<p>Should an API provide Rect::contains(Point) or Point::is_inside(Rect) or both? or Math::contains(Point, Rect) cause it's symmetric?</p> <p>The same Q goes for LineSegment::contains(Point), Rect::fully_contains(Circle) etc.</p>
[ { "answer_id": 412836, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 4, "selected": true, "text": "Rect::contains(Point) Point LineSegment Circle Rect" }, { "answer_id": 412840, "author": "Frederick The Fool",...
2009/01/05
[ "https://Stackoverflow.com/questions/412823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,828
<p>What is wrong with <code>rs</code> definition in first where section?</p> <pre><code>palindrome :: [a] -&gt; [a] palindrome xs = con xs rs where con a b = rev (rev a []) b rs = rev xs -- here where rev [] rs = rs rev (x:xs) rs = rev xs (x:rs) </code></pre> <p>I'm just learning Haskell but its syntax rules confuse me. The error message is</p> <pre><code>[1 of 1] Compiling Main ( pelindrome.hs, interpreted ) pelindrome.hs:5:8: parse error on input `rs' </code></pre>
[ { "answer_id": 412858, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 5, "selected": true, "text": "where rev palindrome :: [a] -> [a]\npalindrome xs = con xs rs\n where con a b = rev (rev a []) b\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/412828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49197/" ]
412,833
<p>I have a C# program that I would like to sell and I want to offer a 14 day trial, I understand that all piracy prevention schemes are overcome so I don't want to waste much time doing this. Could anyone offer any suggestion and even some sample code?</p> <p>Thanks</p>
[ { "answer_id": 33778347, "author": "Debayan Paul", "author_id": 5576236, "author_profile": "https://Stackoverflow.com/users/5576236", "pm_score": -1, "selected": false, "text": "system(\"echo %time%\");\n main(){\n system(\"echo %time%\");\n getch();\n}\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,839
<p>Can anyone point me to a site, or give me some wisdom on how you go about choosing names for interfaces, classes and perhaps even methods and properties relating to what that object or method does?</p> <p>This is specifically for Microsoft development, so Java-esque "doGet" and so on isn't really used, however some general rules that cross language barriers must (I would've thought) exist.</p> <p>An example might help: I have 4 choices of names for an interface:</p> <pre><code>IGroupedItem IGroupableItem IDataEntity IGroupedEntity </code></pre> <p>They all contain an adjective and the noun, or just a noun. Looking at the .NET framework it seems like there must be some kind of ruleset for this, for consistency? Aside from the obvious verbs for methods.</p> <p><strong>Edit:</strong> Though the example is an interface, I'm not limiting this to just interfaces. The general guideline is classes are nouns, methods verbs, properties nouns. I suppose what I mean is choice of the synonym. Is throwing "Entity" everywhere wrong</p>
[ { "answer_id": 412848, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": "IGroupableItem\n" }, { "answer_id": 63220144, "author": "themefield", "author_id": 2909851, "author_pro...
2009/01/05
[ "https://Stackoverflow.com/questions/412839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21574/" ]
412,859
<p>I currently have a library of UserControls which I use in a lot of our web applications. I would like to update these controls so that I can use IOC to help seperate the logic.</p> <p>So I would have something similar to the following on the web page itself:</p> <pre><code>&lt;prefix:ControlName ID="myControl" runat="server" property="value1" /&gt; </code></pre> <p>And the control would have a constructor similar to:</p> <pre><code>public ControlName (IControlLogic logic) </code></pre> <p>Then ideally the IOC container would handle the injection. Can this be done? If so what libraries offer this? If you have any links that you know of that discuss this they would be great thanks.</p> <p>Thanks in advance</p>
[ { "answer_id": 608593, "author": "nicknystrom", "author_id": 73348, "author_profile": "https://Stackoverflow.com/users/73348", "pm_score": 2, "selected": false, "text": "public class ServiceProviderBuilder : ControlBuilder\n{\n public override void ProcessGeneratedCode(System.CodeDom....
2009/01/05
[ "https://Stackoverflow.com/questions/412859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26081/" ]
412,864
<p>I have a Visual Studio solution that comprises of several projects and are separated into different directories.</p> <p>In my C# or VB.NET code, I want to determine the base directory (or the directory that the solution is in). </p> <p>A dirty solution would be to call the directory <code>parent.parent.parent</code> until I find a file *.sln, but I also have several solutions in other directories that I don't want to be returned.</p> <p>I am just wondering if there is a cleaner method, maybe part of <code>System.Diagnostics.Debugger</code> or similar?</p> <p>I look forward to your reply, thanks.</p>
[ { "answer_id": 412900, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 0, "selected": false, "text": "$(SolutionDir)" }, { "answer_id": 412930, "author": "Belliez", "author_id": 51604, "author_profile": "h...
2009/01/05
[ "https://Stackoverflow.com/questions/412864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51604/" ]
412,875
<p>How do I split a number by the decimal point in php?</p> <p>I've got $num = 15/4; which turns $num into 3.75. I would like to split out the 3 and the 75 parts, so $int = 3 and $dec = 75. My non-working code is:</p> <pre><code>$num = 15/4; // or $num = 3.75; list($int, $dec) = split('.', $num); </code></pre> <p>but that results in empty $int and $dec.</p> <p>Thanks in advance.</p>
[ { "answer_id": 412883, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 3, "selected": false, "text": "$num = 15/4; // or $num = 3.75;\nlist($int, $dec) = explode('.', $num);\n" }, { "answer_id": 412886, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/412875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51608/" ]
412,910
<p>Is there a way to detect when a specific device is plugged into a usb port, what I would like to happen is when I plug my laptop into my docking station it run up several apps to account for my different keyboard, mouse and monitors. Specifically I have an issue with some software for my G15 keyboard stopping media player closing properly.</p> <p>Hopefully in .NET but if not any suggestions appreciated.</p>
[ { "answer_id": 412883, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 3, "selected": false, "text": "$num = 15/4; // or $num = 3.75;\nlist($int, $dec) = explode('.', $num);\n" }, { "answer_id": 412886, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/412910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
412,919
<p>I wrote this snippet of code and I assume <code>len</code> is tail-recursive, but a stack overflow still occurs. What is wrong?</p> <pre><code>myLength :: [a] -&gt; Integer myLength xs = len xs 0 where len [] l = l len (x:xs) l = len xs (l+1) main = print $ myLength [1..10000000] </code></pre>
[ { "answer_id": 412981, "author": "mattiast", "author_id": 8272, "author_profile": "https://Stackoverflow.com/users/8272", "pm_score": 4, "selected": false, "text": "len len [1..100000] 0\n-> len [2..100000] (0+1)\n-> len [3..100000] (0+1+1)\n len l len (x:xs) l = l `seq` len xs (l+1)\n" ...
2009/01/05
[ "https://Stackoverflow.com/questions/412919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49197/" ]
412,929
<p>I'm looking for creative uses of monads to learn from. I've read somewhere that monads have been used for example in AI, but being a monad newbie, I fail to see how.</p> <p>Please include a link to the source code and sample usages. No <a href="https://web.archive.org/web/20100928141543/http://www.haskell.org/all_about_monads/html/introII.html" rel="noreferrer">standard monads</a> please.</p>
[ { "answer_id": 415168, "author": "luqui", "author_id": 33796, "author_profile": "https://Stackoverflow.com/users/33796", "pm_score": 3, "selected": false, "text": "infinite-search a (a -> Bool) -> Maybe a" }, { "answer_id": 872225, "author": "cjs", "author_id": 107294, ...
2009/01/05
[ "https://Stackoverflow.com/questions/412929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21239/" ]
412,933
<p>I am planning a high performance e-commerce project in asp.net and need help in selecting the optimal data retrieval model for the product catalog.</p> <p>Some details,</p> <ul> <li>products in 10-20 categories</li> <li>1000-5000 products in every category </li> <li>products listed with name, price, brand and image, 15-40 on every page </li> <li>products needs to be listed without table-tags </li> <li>product info in 2-4 tables that will be joined together (product images not stored in db) </li> <li>webserver and sql database on different hardware </li> <li>ms sql 2005 on shared db-server (pretty bad performance to start with...) </li> <li>enable users to search products combining different criteria such as pricerange, brand, with/without image.</li> </ul> <p>My questions are, </p> <ul> <li>what technique shall I use to retrieve the products? </li> <li>what technique shall I use to present the products? </li> <li>what cache strategy do you recomend? </li> <li>how do I solve filtering, sortering, pageing in the most efficient way? </li> <li>do you have any recomendations for more reading on this subject?</li> </ul> <p>Thanks in advance!</p>
[ { "answer_id": 415168, "author": "luqui", "author_id": 33796, "author_profile": "https://Stackoverflow.com/users/33796", "pm_score": 3, "selected": false, "text": "infinite-search a (a -> Bool) -> Maybe a" }, { "answer_id": 872225, "author": "cjs", "author_id": 107294, ...
2009/01/05
[ "https://Stackoverflow.com/questions/412933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51624/" ]
412,939
<p>Can any script or setting be written (autorun file?) to <strong>disable formatting of a USB Flashdrive?</strong> <em>(Win XP, via Windows Explorer > Format)</em></p> <p>I'm aware of <a href="http://www.sizzledcore.com/2008/07/19/how-to-write-protect-your-usb-flash-drive/" rel="nofollow noreferrer">write-protection</a>, but I don't want to completely prevent modifying files, instead something like what a <a href="http://www.experts-exchange.com/Microsoft/Windows_Security/Q_22533362.html" rel="nofollow noreferrer">Group Policy setting</a> could do?</p> <p><strong>Edit:</strong> Really what I'm asking for is a <strong>registry setting</strong> or else that I can modify on USB drive startup to tell Win XP not to format drive X:</p>
[ { "answer_id": 415168, "author": "luqui", "author_id": 33796, "author_profile": "https://Stackoverflow.com/users/33796", "pm_score": 3, "selected": false, "text": "infinite-search a (a -> Bool) -> Maybe a" }, { "answer_id": 872225, "author": "cjs", "author_id": 107294, ...
2009/01/05
[ "https://Stackoverflow.com/questions/412939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
412,943
<p>(code examples are python)<br /> Lets assume we have a list of percentages that add up to 100:</p> <pre><code>mylist = [2.0, 7.0, 12.0, 35.0, 21.0, 23.0] </code></pre> <p>Some values of mylist may be changed, others must stay fixed.<br /> Lets assume the first 3 (2.0, 7.0, 12.0) must stay fixed and the last three (35.0, 21.0, 23.0) may be changed.</p> <pre><code>fix = mylist[:3] vari = mylist[3:] </code></pre> <p>The goal is to add a new item to mylist, while sum(mylist) stays 100.0 and vari<br /> items keep their relations to each other. For that we need to substract a CERTAIN<br /> PERCENTAGE from each vari item. Example: lets assume we want to add 4.0 to mylist.<br /> Using an ugly aproximation loop I found out that i need to substract ca. 5.0634%<br /> of each vari item (CERTAIN PERCENTAGE = 5.0634):</p> <pre><code>adjusted =[] for number in vari: adjusted.append(number-(number*(5.0634/100.0))) adjusted.extend(fix) adjusted.append(4.0) </code></pre> <p>adjusted now contains my desired result.</p> <h1>My question is how to calculate CERTAIN PERCENTAGE ;.)</h1>
[ { "answer_id": 412979, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": true, "text": "def adjustAppend( v, n ):\n weight= -n/sum(v)\n return [ i+i*weight for i in v ] + [n]\n sum(v) == sum( v + [n] )\n s...
2009/01/05
[ "https://Stackoverflow.com/questions/412943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51627/" ]
412,944
<p>I am modeling a class diagram. An attribute of a class is an enumeration. How do I model this? Normally you do something like this:</p> <pre><code>- name : string </code></pre> <p>But how does one do this with an enum?</p>
[ { "answer_id": 412962, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "enum" }, { "answer_id": 412964, "author": "James B", "author_id": 2951, "author_profile": "https://St...
2009/01/05
[ "https://Stackoverflow.com/questions/412944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
412,946
<p>If you cache data from your database in ASP.NET session then you will speed up subsequent requests for that data (note: depending on the serialization/deserialization cost of the data concerned), at the expense of memory load in IIS.</p> <p>(OK, this is probably a simplification of the reality of the situation - feel free to correct or refine my statement above)</p> <p>Do you use any rules (simple rules of thumb or otherwise) to decide when it is appropriate to cache in Session?</p> <h2>Update</h2> <p>Can use of Session <strong>for storing read-only data</strong> without <em>very well thought out</em> rationale simply be considered another case of <a href="http://en.wikiquote.org/wiki/Donald_Knuth" rel="nofollow noreferrer">Premature Optimization</a>? (and therefore, bad)</p>
[ { "answer_id": 412962, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "enum" }, { "answer_id": 412964, "author": "James B", "author_id": 2951, "author_profile": "https://St...
2009/01/05
[ "https://Stackoverflow.com/questions/412946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
412,951
<p>I am programming a simulations for single neurons. Therefore I have to handle a lot of Parameters. Now the Idea is that I have two classes, one for a SingleParameter and a Collection of parameters. I use property() to access the parameter value easy and to make the code more readable. This works perfect for a sinlge parameter but I don't know how to implement it for the collection as I want to name the property in Collection after the SingleParameter. Here an example:</p> <pre><code>class SingleParameter(object): def __init__(self, name, default_value=0, unit='not specified'): self.name = name self.default_value = default_value self.unit = unit self.set(default_value) def get(self): return self._v def set(self, value): self._v = value v = property(fget=get, fset=set, doc='value of parameter') par1 = SingleParameter(name='par1', default_value=10, unit='mV') par2 = SingleParameter(name='par2', default_value=20, unit='mA') # par1 and par2 I can access perfectly via 'p1.v = ...' # or get its value with 'p1.v' class Collection(object): def __init__(self): self.dict = {} def __getitem__(self, name): return self.dict[name] # get the whole object # to get the value instead: # return self.dict[name].v def add(self, parameter): self.dict[parameter.name] = parameter # now comes the part that I don't know how to implement with property(): # It shoule be something like # self.__dict__[parameter.name] = property(...) ? col = Collection() col.add(par1) col.add(par2) col['par1'] # gives the whole object # Now here is what I would like to get: # col.par1 -&gt; should result like col['par1'].v # col.par1 = 5 -&gt; should result like col['par1'].v = 5 </code></pre> <hr> <p>Other questions that I put to understand property():</p> <ul> <li><a href="https://stackoverflow.com/questions/428264" title="Why do managed attributes just work for class attributes and not for instance attributes in python?">Why do managed attributes just work for class attributes and not for instance attributes in python?</a></li> <li><a href="https://stackoverflow.com/questions/432786/" title="setting class attributes with setattr()">How can I assign a new class attribute via __dict__ in python?</a></li> </ul>
[ { "answer_id": 412997, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": "getattr setattr" }, { "answer_id": 413010, "author": "Abgan", "author_id": 46308, "author_profile": "ht...
2009/01/05
[ "https://Stackoverflow.com/questions/412951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51200/" ]
412,954
<p>In <a href="https://stackoverflow.com/questions/381267/looped-pushback-against-resize-iterator">this</a> thread some one commented that the following code should only be used in 'toy' projects. Unfortunately he hasn't come back to say why it's not of production quality so I was hoping some one in the community may be able to either assure me the code is ok (because I quite like it) or identify what is wrong.</p> <pre><code>template&lt; class T1, class T2&gt; void hexascii( T1&amp; out, const T2&amp; in ) { out.resize( in.size() * 2 ); const char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7','8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; T1::iterator outit = out.begin(); for( T2::const_iterator it = in.begin(); it != in.end(); ++it ) { *outit++ = hexDigits[*it &gt;&gt; 4]; *outit++ = hexDigits[*it &amp; 0xF]; } } template&lt;class T1, class T2&gt; void asciihex( T1&amp; out, const T2&amp; in ) { size_t size = in.size; assert( !(size % 2) ); out.resize( size / 2 ); T1::iterator outit = out.begin(); for( T2::const_iterator it = in.begin(); it != in.end(); it += 2, ++outit ) { *outit = ((( (*it &gt; '9' ? *it - 0x07 : *it) - 0x30) &lt;&lt; 4) &amp; 0x00f0) + (((*(it+1) &gt; '9' ? *(it+1) - 0x07 : *(it+1)) - 0x30) &amp; 0x000f); } } </code></pre> <p>Edit: Thanks for your help guys, you've made some big improvements. I've written functions in the two suggested styles from your answers. Some rough testing suggests the second method is marginally faster than the first, but IMO this is outweighed by the improved readability of the first.</p> <pre><code>template&lt;class T1&gt; void asciihex2( T1&amp; out, const std::string&amp; in ) { dassert( sizeof(T1::value_type)==1 ); size_t size = in.size(); assert( !(size % 2) ); out.resize( size / 2 ); T1::iterator outit = out.begin(); for( size_t i = 0; i &lt; in.size(); i += 2 ) { int tmp; sscanf( in.c_str() + i, "%02X", &amp;tmp ); *outit++ = tmp; } } template&lt;class T1&gt; void asciihex3( T1&amp; out, const std::string&amp; in ) { dassert( sizeof(T1::value_type)==1 ); size_t size = in.size(); assert( !(size % 2) ); out.resize( size / 2 ); T1::iterator outit = out.begin(); const char hexDigits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; for( std::string::const_iterator it = in.begin(); it != in.end(); it += 2, ++outit ) { *outit = (hexDigits[(*it - 0x30) &amp; 0x1f] &lt;&lt; 4) + hexDigits[((*(it+1) - 0x30) &amp; 0x1f)]; } } </code></pre> <p>Some of the assumptions surronding this code: 1: They are not intended as a generic, but are used in an anonymous name space to translate data for a specific class. 2: The templating is required as two separate container types are being used (one being std::vector, the other a similar byte array type container from a third party library. 3: The purpose is to be able to convert binary data of indeterminate length into strings and back again (0x1234abcd &lt;-> "1234abcd") 4: assert traps errors in both debug and release modes 5: by the time these functions are called the size of the string will already have been checked, assert is used to terminate processing if something serious has gone wrong 6: It needs some commenting</p> <p>Any other ideas appreciated.</p>
[ { "answer_id": 412983, "author": "unknownuser", "author_id": 42914, "author_profile": "https://Stackoverflow.com/users/42914", "pm_score": 3, "selected": false, "text": "*outit = ((( (*it > '9' ? *it - 0x07 : *it) - 0x30) << 4) & 0x00f0) + \n (((*(it+1) > '9' ? *(it+1) - 0x07...
2009/01/05
[ "https://Stackoverflow.com/questions/412954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38892/" ]
412,960
<p>I hope you'll forgive me for thinking that configuring a DNS server would be easy. It turns out it is quite hard... especially if you never did it before.</p> <p>To recap a little, I previously asked if someone could recommend a personal DNS server for Windows XP for use in a development project.</p> <p>My basic wish is to host a DNS server that represents the following lookup table:</p> <pre><code> Address | IP ------------------+-------------- *.devdomain1.dev | 192.168.10.2 *.devdomain2.dev | 192.168.10.2 </code></pre> <p>Do you know how to setup this in BIND 9? Or maybe there is an easier solution that I've overlooked. I know I could add the individual subdomains in my HOSTS file but since we have a lot of subdomains which has to be maintained on several dev machines I would rather have a simple wildcard setup.</p>
[ { "answer_id": 412972, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": true, "text": "devdomain2.dev. IN SOA localhost. johannesh.devdomain2.dev. (\n 1102522753\n 10800\n 3600\n 60...
2009/01/05
[ "https://Stackoverflow.com/questions/412960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46316/" ]
412,982
<p>Really stuck on trying to write code to unzip a file or directory on the iPhone.</p> <p>Below is some sample code that I'm using to try and unzip a simple text file. </p> <p>It unzips the file but its corrupt.</p> <pre><code>(void)loadView { NSString *DOCUMENTS_FOLDER = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *path = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"sample.zip"]; NSString *unzipeddest = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"test.txt"]; gzFile file = gzopen([path UTF8String], "rb"); FILE *dest = fopen([unzipeddest UTF8String], "w"); unsigned char buffer[CHUNK]; int uncompressedLength = gzread(file, buffer, CHUNK); if(fwrite(buffer, 1, uncompressedLength, dest) != uncompressedLength || ferror(dest)) { NSLog(@"error writing data"); } else{ } fclose(dest); gzclose(file); } </code></pre>
[ { "answer_id": 1284210, "author": "Carl Coryell-Martin", "author_id": 87661, "author_profile": "https://Stackoverflow.com/users/87661", "pm_score": 4, "selected": false, "text": "#import <zlib.h>\n#define CHUNK 16384\n\n\n NSLog(@\"testing unzip of database\");\n start = [NSDate date];...
2009/01/05
[ "https://Stackoverflow.com/questions/412982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51630/" ]
413,013
<p>I'm still struggling a bit with OOP concepts and dependency injection so bear with me.</p> <p>I have generated my Linq2Sql model with a User table and now I would like to be able to send a confirmation email to this user so I created a partial class file for my User object and I felt it was natural to add a SendConfirmationEmail() method to the User class. This method will use a MailService to send the actual email and I would like to use dependency injection to pass in the service so I created a constructor overload on the User object like this</p> <pre><code>public User(IMailService service) : this() { _service = service; } </code></pre> <p>The SendConfirmationEmail method would look like this</p> <pre><code>public void SendConfirmationEmail() { _service.SendMail(params...); } </code></pre> <p>I realize this is a kind of poor mans dependency injection and I hope to switch to a dependency injection framework later as I am getting more grips on this. </p> <p>The problem for me is that I need to make a reference from my model dll to my service dll which does not seem right and because I am unsure of how nice my linq2sql generated entities plays with Dependency injection frameworks and OOP concepts (I think ninject looks most promising). </p> <p>I was hoping someone with a bit more experience than me could tell I'm if I am going in the right direction with this. I know I can make it work but I would like to educate my self in doing it in the correct way in the same step.</p>
[ { "answer_id": 413148, "author": "Michael Meadows", "author_id": 7643, "author_profile": "https://Stackoverflow.com/users/7643", "pm_score": 1, "selected": false, "text": "_service" }, { "answer_id": 413158, "author": "Cohen", "author_id": 34474, "author_profile": "ht...
2009/01/05
[ "https://Stackoverflow.com/questions/413013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29519/" ]
413,015
<p>I have a bash script file which starts with a function definition, like this:</p> <pre><code>#!/bin/bash # ..... # ..... function test { ... ... } ... ... </code></pre> <p>I use vim 7.2, and I have set <code>g:sh_fold_enabled=1</code> such that folding is enabled with bash. The problem is that the folding of the function test is not ended correctly, i.e. it lasts until the end of file. It looks something like this:</p> <pre><code>#!/bin/bash # ..... # ..... +-- 550 lines: function test {---------------------------------------- ~ ~ </code></pre> <p>The function itself is just about 40 lines, and I want something that lookes like this ("images" say more than a thousend words, they say...):</p> <pre><code>#!/bin/bash # ..... # ..... +-- 40 lines: function test {---------------------------------------- ... ... ... ~ ~ </code></pre> <p>Does anyone know a good solution to this problem?</p>
[ { "answer_id": 414586, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 0, "selected": false, "text": "function test {\n ...\n}\n}\n" }, { "answer_id": 447738, "author": "Karl Yngve Lervåg", "author_id...
2009/01/05
[ "https://Stackoverflow.com/questions/413015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51634/" ]
413,017
<p>My code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { font-family:"Verdana",Arial,Helvetica,sans-serif; } .myfont { font-family:"Verdana",Arial,Helvetica,sans-serif; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt; Hello &lt;select&gt; &lt;option&gt; Hello &lt;/option&gt; &lt;/select&gt; &lt;select class="myfont"&gt; &lt;option&gt; Hello &lt;/option&gt; &lt;/select&gt; &lt;/body&gt;</code></pre> </div> </div> </p> <p>Why is the first <code>&lt;select&gt;</code> element not inheriting the <code>font-family</code> property from the specification for <code>&lt;body&gt;</code>?</p> <p>If I have to change the font for a <code>&lt;select&gt;</code> why do I have to copy the style?</p>
[ { "answer_id": 413026, "author": "James B", "author_id": 2951, "author_profile": "https://Stackoverflow.com/users/2951", "pm_score": 5, "selected": true, "text": "select {\n font-family: inherit;\n}\n" }, { "answer_id": 415491, "author": "AmbroseChapel", "author_id": 242...
2009/01/05
[ "https://Stackoverflow.com/questions/413017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48625/" ]
413,050
<p>How can I remove the "xmlns:..." namespace information from each XML element in C#?</p>
[ { "answer_id": 413088, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 4, "selected": true, "text": "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n <xsl:output method=\"xml\" indent=\...
2009/01/05
[ "https://Stackoverflow.com/questions/413050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34022/" ]
413,053
<p>I have a small (500kb) swing applet that displays very simple/limited set of small HTML page(s) inside it with JEditorPane, however this does not seem to work 100% fluently, some customers get a blank page displayed without any java exceptions. The page works OK from my machine. I need a more reliable way to show HTML page to all our users. </p> <p>Any ideas if there is a small + free class to use instead of JEditorPane OR is there an easy fix to make it more reliable (non blank)</p> <pre><code>private JEditorPane m_editorPane = new JTextPane(); m_editorPane.setEditable( false); m_editorPane.setBackground(new Color(239 ,255, 215)); m_editorPane.setBounds(30,42,520,478 ); m_editorPane.setDoubleBuffered(true); m_editorPane.setBorder(null); m_editorPane.registerEditorKitForContentType("text/html", "com.xxxxx.SynchronousHTMLEditorKit"); m_editorPane.setPage(ResourceLoader.getURLforDataFile(param.trim())); </code></pre>
[ { "answer_id": 413111, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 2, "selected": false, "text": "JEditorPane" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
413,055
<p>I have an application that works some what similar to how iPhone's Contact application works. When we add a new Contact user is directed to a view only screen with Contact information. If we select "All Contacts" from the navigation bar, user is navigated to list of all contacts where the recently added contact is in view.</p> <p>We can move the view to a particular row using:</p> <pre><code> [itemsTableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionBottom]; </code></pre> <p>... but it's not working. I'm calling this right after calling:</p> <pre><code> [tableView reloadData]; </code></pre> <p>I think I'm not suppose to call <code>selectRowAtIndexPath:animated:scrollPosition</code> method here. But if not here, then where?</p> <p>Is there any delegate method that gets called after the following method?</p> <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; </code></pre>
[ { "answer_id": 413433, "author": "Dan Morgan", "author_id": 51420, "author_profile": "https://Stackoverflow.com/users/51420", "pm_score": 0, "selected": false, "text": "- (void)textFieldDidBeginEditing:(UITextField *)textField {\n\n //Show the navButtons\n [self navButtonAnimation]...
2009/01/05
[ "https://Stackoverflow.com/questions/413055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49739/" ]
413,071
<p>Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year's resolution is to not try and learn regex again - <em>So this year to save me from tears I'll give it to Stack Overflow</em>. (Last Christmas remix).</p> <p>I want to pass in a string in this format <code>{getThis}</code>, and be returned the string <code>getThis</code>. Could anyone be of assistance in helping to stick to my new year's resolution?</p> <hr> <p>Related questions on Stack Overflow:</p> <ul> <li><a href="https://stackoverflow.com/questions/346567/how-can-one-turn-regular-quotes-i-e-into-latex-tex-quotes-i-e">How can one turn regular quotes (i.e. &#39;, &quot;) into LaTeX/TeX quotes (i.e. `&#39;, ``&#39;&#39;)</a></li> <li><a href="https://stackoverflow.com/questions/1237/regex-to-pull-out-a-section-a-substing-from-a-string-between-two-tags">Regex: To pull out a sub-string between two tags in a string</a></li> <li><a href="https://stackoverflow.com/questions/328387/regex-to-replace-all-n-in-a-string-but-no-those-inside-code-code-tag">Regex to replace all \n in a String, but no those inside [code] [/code] tag</a></li> </ul>
[ { "answer_id": 413077, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 8, "selected": false, "text": "/{(.*?)}/\n /{([^}]*)}/\n" }, { "answer_id": 413085, "author": "Kev", "author_id": 16777, "author_pro...
2009/01/05
[ "https://Stackoverflow.com/questions/413071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37196/" ]
413,084
<p>In SQL you can run a ISNULL(null,'') how would you do this in a linq query?</p> <p>I have a join in this query:</p> <pre><code>var hht = from x in db.HandheldAssets join a in db.HandheldDevInfos on x.AssetID equals a.DevName into DevInfo from aa in DevInfo.DefaultIfEmpty() select new { AssetID = x.AssetID, Status = xx.Online }; </code></pre> <p>but I have a column that has a bit type that is non nullable (xx.online) how can I set this to false if it is null?</p>
[ { "answer_id": 413231, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 5, "selected": false, "text": "?? Nullable true xx.Online var hht = from x in db.HandheldAssets\n join a in db.HandheldDevInfos on x.AssetID e...
2009/01/05
[ "https://Stackoverflow.com/questions/413084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49971/" ]
413,095
<p>I've got a copy of the Word document "C# Language Specification Version 1.2" and was wondering in which framework this was introduced. I can't remember there is something like .NET Framework 1.2</p>
[ { "answer_id": 413106, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "foreach Dispose IDisposable" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
413,110
<p>In .NET I have already tried the configuration below successfully:</p> <pre><code> &lt;system.net&gt; &lt;connectionManagement&gt; &lt;add address="*" maxconnection="100"/&gt; &lt;/connectionManagement&gt; &lt;/system.net&gt; </code></pre> <p>Using 100 concurrent HttpWebRequest they answered almost simultaneously (less than a second).</p> <p>I wonder why some people wrote in some forums that Windows XP and Windows Server 2008 limits this number to 15 or 20. They are right?</p>
[ { "answer_id": 929973, "author": "Peter Stuer", "author_id": 110945, "author_profile": "https://Stackoverflow.com/users/110945", "pm_score": 4, "selected": false, "text": "10 2 25 50.000+ IIS6 WS03SP1 x64 4GB" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
413,114
<p>I'm wondering if I should bother at all about the markup language, as long as i produce valid markup.</p> <p>I've read articles that point out HTML is the best choice and they come directly from the horse's mouth (the browsers implementors!):</p> <ul> <li><a href="http://webkit.org/blog/68/understanding-html-xml-and-xhtml/" rel="noreferrer">http://webkit.org/blog/68/understanding-html-xml-and-xhtml/</a></li> <li><a href="https://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ" rel="noreferrer">https://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ</a></li> </ul> <p>Other articles, by James Bennet, make another point that if you're not serving XHTML as XML then you don't want XHTML but HTML.</p> <ul> <li><a href="http://www.b-list.org/weblog/2008/jun/18/html/" rel="noreferrer">http://www.b-list.org/weblog/2008/jun/18/html/</a></li> <li><a href="http://www.b-list.org/weblog/2008/jun/21/xhtml/" rel="noreferrer">http://www.b-list.org/weblog/2008/jun/21/xhtml/</a></li> </ul> <p>So i thought that if i wanted to trigger Standard Compliant Mode i should just use HTML strict validation. But that's not the case anymore with at least the most modern browsers (aka everything but IE6): if you have valid XHTML Strict you still trigger Standard Compliant Mode, hence, as long as i produce valid markup, why bother?</p>
[ { "answer_id": 413468, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 2, "selected": false, "text": "document.write innerHTML" }, { "answer_id": 413637, "author": "jshirley", "author_id": 16381, "author_p...
2009/01/05
[ "https://Stackoverflow.com/questions/413114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192337/" ]
413,131
<p>Is there a viable alternative to Hibernate? Preferably something that doesn't base itself on JPA.</p> <p>Our problem is that we are building a complex (as in, many objects refer to each other) stateful RIA system. It seems as Hibernate is designed to be used mainly on one-off applications - JSF and the like.</p> <p>The problem is mainly that of lazy loading. Since there can be several HTTP requests between the initialization and actually loading lazy collections, a session per transaction is out of the question. A long-lived session (one per application) doesn't work well either, because once a transaction hits a snag and throws an exception, the whole session is invalidated, thus the lazy loaded objects break. Then there's all kinds of stuff that just don't work for us (like implicit data persisting of data from outside an initialized transaction).</p> <p>My poor explanations aside, the bottom line is that Hibernate does magic we don't like. It seems like TopLink isn't any better, it also being written on top of EJB.</p> <p>So, a stateless persistence layer (or even bright-enough object-oriented database abstraction layer) is what we would need the most.</p> <p>Any thoughts, or am I asking for something that doesn't exist?</p> <p><strong>Edit:</strong> I'm sorry for my ambiguous terminology, and thank you all for your corrections and insightful answers. Those who corrected me, you are all correct, I meant JPA, not EJB.</p>
[ { "answer_id": 413152, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "EntityManager.refresh()" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2238/" ]
413,137
<p>I have two strings and I would like to mix the characters from each string into one bigger string, how can I do this in PHP? I can swap chars over but I want something more <strong>complicated</strong> since it could be guessed.</p> <p>And please don't say md5() is enough and irreversible. :)</p> <pre><code>$string1 = '9cb5jplgvsiedji9mi9o6a8qq1';//session_id() $string2 = '5d41402abc4b2a76b9719d911017c592';//md5() </code></pre> <p>Thank you for any help.</p> <p>EDIT: Ah sorry Rob. It would be great if there is a solution where it was just a function I could pass two strings to, and it returned a string. </p> <p>The returned string must contain both of the previous strings. Not just a concatination, but the characters of each string are mingled into one bigger one.</p>
[ { "answer_id": 413151, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": true, "text": "$salt=\"secret\";\n$hash=sha1($string1.$string2.$salt);\n$separator=\"_\";\n$str=$string1.$separator.$string2.$separator.$...
2009/01/05
[ "https://Stackoverflow.com/questions/413137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
413,139
<p>I'm thinking about implementing JSON parser for Delphi. What should a good JSON parser do? Any ideas for requirements? I believe it should at least output and process JSON... Looking at XML parsers, should it be more DOM or SAX-like?</p>
[ { "answer_id": 415363, "author": "Wouter van Nifterick", "author_id": 38813, "author_profile": "https://Stackoverflow.com/users/38813", "pm_score": 2, "selected": false, "text": "program test_usage;\n{$IFDEF FPC}\n {$MODE OBJFPC}{$H+}\n{$ELSE}\n {$APPTYPE CONSOLE}\n{$ENDIF}\n\nuses\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/413139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15733/" ]
413,150
<p>I created a model ruby script/generate model Article (simple enuff)</p> <p>Here is the migration file create_articles.rb:</p> <pre><code>def self.up create_table :articles do |t| t.column :user_id, :integer t.column :title, :string t.column :synopsis, :text, :limit =&gt; 1000 t.column :body, :text, :limit =&gt; 20000 t.column :published, :boolean, :default =&gt; false t.column :created_at, :datetime t.column :updated_at, :datetime t.column :published_at, :datetime t.column :category_id, :integer end def self.down drop_table :articles end end </code></pre> <p>When I run the rake:db migrate command I receive an error rake aborted! "Uninitialized constant CreateArticles." </p> <p>Does anyone know why this error keeps happening? </p>
[ { "answer_id": 413273, "author": "thetacom", "author_id": 51323, "author_profile": "https://Stackoverflow.com/users/51323", "pm_score": 7, "selected": false, "text": "#20090106022023_create_articles.rb\nclass CreateArticles < ActiveRecord::Migration \n def self.up\n create_table :a...
2009/01/05
[ "https://Stackoverflow.com/questions/413150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50477/" ]
413,157
<p>This sounds very simple, but I am frustrated for the past few hours to get this done. I am not able to see "Macros" sub menu under "Tools" menu in Visual Studio 2008. </p> <p>I go to Tools->Customize->Commands. Select Tools under Categories and click Rearrange Commands. Instead of showing me the Tools Menu it shows me Files. </p> <p>Am I doing something wrong? Or is it a bug in VS 2008?</p>
[ { "answer_id": 413273, "author": "thetacom", "author_id": 51323, "author_profile": "https://Stackoverflow.com/users/51323", "pm_score": 7, "selected": false, "text": "#20090106022023_create_articles.rb\nclass CreateArticles < ActiveRecord::Migration \n def self.up\n create_table :a...
2009/01/05
[ "https://Stackoverflow.com/questions/413157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2622856/" ]
413,171
<p>If you have a for loop such as:</p> <pre><code>For Each s As String In stringList ..do stuff.. Next </code></pre> <p>is there some sort of (hidden) iterator or do I have to add an external integer to keep count:</p> <pre><code>Dim i As Integer For Each s As String In stringList ..do stuff.. i += 1 Next </code></pre>
[ { "answer_id": 413186, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 4, "selected": true, "text": "for" }, { "answer_id": 413190, "author": "ZombieSheep", "author_id": 377, "author_profile": "https:...
2009/01/05
[ "https://Stackoverflow.com/questions/413171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
413,174
<p>when is it appropriate to use an array over a Generic List(of T) in .NET</p> <p>I have struggled to see any benefit an array provides over the Generic List but get the feeling I may be missing something. Performance is one thing that struck me as one potential bottleneck ? </p> <p>Thanks</p>
[ { "answer_id": 413207, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "MyChildClass[] MyParentClass[] List<MyChildClass> List<MyParentClass>" }, { "answer_id": 413238, "author":...
2009/01/05
[ "https://Stackoverflow.com/questions/413174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11802/" ]
413,208
<h3>Duplicate:</h3> <blockquote> <p><a href="https://stackoverflow.com/questions/318923/how-to-indent-a-selection-in-gvim-win32">How to indent a selection in gvim (win32)?</a></p> <p><a href="https://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi">How do I indent multiple lines quickly in vi?</a></p> </blockquote> <p>Using vim under linux I can indent a block of code using the VISUAL mode and pressing ">". In vim under Windows this does not happen.</p> <p>This is what happens:</p> <ul> <li>Press V, the VIM enter in the VISUAL mode</li> <li>Press 'Down', the VIM exit for the VISUAL mode. I can't select anything in VISUAL mode.</li> </ul> <p>Alternatively, if I use the SELECT mode for selecting code the ">" does not indent it.</p>
[ { "answer_id": 413230, "author": "R. Martinho Fernandes", "author_id": 46642, "author_profile": "https://Stackoverflow.com/users/46642", "pm_score": 2, "selected": false, "text": ":map <Up> k\n:map <Down> j\n:map <Left> h\n:map <Right> l\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36131/" ]
413,214
<p>Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites.</p> <p>For example if I have the hierarchy:</p> <p>code.branchone<br/> code.branchone.aaa<br/> code.branchone.bbb<br/> code.branchtwo<br/> code.branchtwo.aaa<br/> code.branchtwo.bbb<br/></p> <p>Is it possible to:</p> <ol> <li>Run all tests in code.branchone and in descendent packages</li> <li>Run all tests in say code.branchone.aaa and code.branchtwo.bbb</li> </ol> <p>The problem I see with manually creating test suites is that when new tests come along you may forget to add them.</p>
[ { "answer_id": 14923130, "author": "span", "author_id": 1068167, "author_profile": "https://Stackoverflow.com/users/1068167", "pm_score": 5, "selected": false, "text": "package tests;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.Sui...
2009/01/05
[ "https://Stackoverflow.com/questions/413214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8633/" ]
413,218
<p>I'm trying to formalise the usage of the "out" keyword in c# for a project I'm on, particularly with respect to any public methods. I can't seem to find any best practices out there and would like to know what is good or bad.</p> <p>Sometimes I'm seeing some methods signatures that look like this:</p> <pre><code>public decimal CalcSomething(Date start, Date end, out int someOtherNumber){} </code></pre> <p>At this point, it's just a feeling, this doesn't sit well with me. For some reason, I'd prefer to see:</p> <pre><code>public Result CalcSomething(Date start, Date end){} </code></pre> <p>where the result is a type that contains a decimal and the someOtherNumber. I think this makes it easier to read. It allows Result to be extended or have properties added without breaking code. It also means that the caller of this method doesn't have to declare a locally scoped "someOtherNumber" before calling. From usage expectations, not all callers are going to be interested in "someOtherNumber".</p> <p>As a contrast, the only instances that I can think of right now within the .Net framework where "out" parameters make sense are in methods like TryParse(). These actually make the caller write simpler code, whereby the caller is primarily going to be interested in the out parameter. </p> <pre><code>int i; if(int.TryParse("1", i)){ DoSomething(i); } </code></pre> <p>I'm thinking that "out" should only be used if the return type is bool and the expected usages are where the "out" parameters will always be of interest to the caller, by design. </p> <p>Thoughts?</p>
[ { "answer_id": 413236, "author": "peSHIr", "author_id": 50846, "author_profile": "https://Stackoverflow.com/users/50846", "pm_score": 6, "selected": true, "text": "out out out" }, { "answer_id": 413244, "author": "yfeldblum", "author_id": 12349, "author_profile": "htt...
2009/01/05
[ "https://Stackoverflow.com/questions/413218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
413,221
<p>I've created a web deployment project using the template for Visual Studio 2008 for a ASP.NET 3.5 web application (not web site).</p> <p>I compiled the project which created the files needed for deployment. I copied the resulting folders (bin, static files and all folders with the aspx placeholders etc.) to a staging server where I wanted to test the application.</p> <p>If I <strong>don't</strong> flag the option <strong>"Allow this precompiled site to be updatable"</strong>, I get this error message on every page I load in the browser:</p> <pre> System.Web.HttpException file PAGENAME.aspx has not been pre-compiled, and cannot be requested. </pre> <p>the last line in the stack trace:</p> <pre> System.Web.Compilation.BuildManager.GetVPathBuildResultInternal( VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +8756366 </pre> <p>If I check the option, everything is fine (I guess because the actual aspx/ascx are still there in their original form).</p> <p>Any idea what I am missing here? Is there some setting or special file I forgot to copy?</p> <p><em>Thank you!</em></p> <p>Notes:</p> <ul> <li>I have a few references to third-party assemblies</li> <li>I've checked the bin folder on the staging server. It contains the precompiled assembly which contains all classes (I used Reflector to analyze the assembly).</li> </ul>
[ { "answer_id": 413254, "author": "Richard L", "author_id": 51017, "author_profile": "https://Stackoverflow.com/users/51017", "pm_score": 4, "selected": true, "text": ".compiled" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6461/" ]
413,237
<p>I have a problem with uninitialized proxies in nhibernate</p> <p><strong>The Domain Model</strong></p> <p>Let's say I have two parallel class hierarchies: Animal, Dog, Cat and AnimalOwner, DogOwner, CatOwner where Dog and Cat both inherit from Animal and DogOwner and CatOwner both inherit from AnimalOwner. AnimalOwner has a reference of type Animal called OwnedAnimal.</p> <p>Here are the classes in the example:</p> <pre><code>public abstract class Animal { // some properties } public class Dog : Animal { // some more properties } public class Cat : Animal { // some more properties } public class AnimalOwner { public virtual Animal OwnedAnimal {get;set;} // more properties... } public class DogOwner : AnimalOwner { // even more properties } public class CatOwner : AnimalOwner { // even more properties } </code></pre> <p>The classes have proper nhibernate mapping, all properties are persistent and everything that can be lazy loaded is lazy loaded.</p> <p>The application business logic only let you to set a Dog in a DogOwner and a Cat in a CatOwner.</p> <p><strong>The Problem</strong></p> <p>I have code like this:</p> <pre><code>public void ProcessDogOwner(DogOwner owner) { Dog dog = (Dog)owner.OwnedAnimal; .... } </code></pre> <p>This method can be called by many diffrent methods, in most cases the dog is already in memory and everything is ok, but rarely the dog isn't already in memory - in this case I get an nhibernate "uninitialized proxy" but the cast throws an exception because nhibernate genrates a proxy for Animal and not for Dog.</p> <p>I understand that this is how nhibernate works, but I need to know the type without loading the object - or, more correctly I need the uninitialized proxy to be a proxy of Cat or Dog and not a proxy of Animal.</p> <p><strong>Constraints</strong></p> <ul> <li>I can't change the domain model, the model is handed to me by another department, I tried to get them to change the model and failed.</li> <li>The actual model is much more complicated then the example and the classes have many references between them, using eager loading or adding joins to the queries is out of the question for performance reasons.</li> <li>I have full control of the source code, the hbm mapping and the database schema and I can change them any way I want (as long as I don't change the relationships between the model classes).</li> <li>I have many methods like the one in the example and I don't want to modify all of them.</li> </ul> <p>Thanks,<br> Nir</p>
[ { "answer_id": 559406, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 0, "selected": false, "text": "((INHibernateProxy)proxy).HibernateLazyInitializer.PersistentClass\n" }, { "answer_id": 755903, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/413237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3509/" ]
413,242
<p>If I want my app to behave differently on a jailbroken iPhone, how would I go about determining this?</p>
[ { "answer_id": 413951, "author": "wisequark", "author_id": 33159, "author_profile": "https://Stackoverflow.com/users/33159", "pm_score": 8, "selected": true, "text": "NSString *filePath = @\"/Applications/Cydia.app\";\nif ([[NSFileManager defaultManager] fileExistsAtPath:filePath])\n{\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/413242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6694/" ]
413,243
<p>How do you size your form in vb6 so that form lower border is at top of taskbar</p>
[ { "answer_id": 413951, "author": "wisequark", "author_id": 33159, "author_profile": "https://Stackoverflow.com/users/33159", "pm_score": 8, "selected": true, "text": "NSString *filePath = @\"/Applications/Cydia.app\";\nif ([[NSFileManager defaultManager] fileExistsAtPath:filePath])\n{\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/413243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6164/" ]
413,247
<p>In my analysis of the newer web platforms/applications, such as Drupal, Wordpress, and Salesforce, many of them create their software based on the concept of modularization: Where developers can create new extensions and applications without needing to change code in the "core" system maintained by the lead developers. In particular, I know Drupal uses a "hook" system, but I don't know much about the engine or design that implements it.</p> <p>If you were to go down a path of creating an application and you wanted a system that allowed for modularization, where do you start? Is this a particular <strong>design pattern</strong> that everyone knows about? Is there a <strong>handbook</strong> that this paradigm tends to subscribe to? Are their any <strong>websites</strong> that discuss this type of development from the ground-up?</p> <p>I know some people point directly to OOP, but that doesn't seem to be the same thing, entirely.</p> <p>This particular system I'm planning leans more towards something like Salesforce, but it is not a CRM system.</p> <p><em>For the sake of the question, please <strong>ignore the Buy vs. Build argument</strong>, as that consideration is already in the works. Right now, I'm researching the build aspect.</em></p>
[ { "answer_id": 413317, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": true, "text": "function renderBackground() {\n foreach (Plugin p in getRegisteredPlugins()) {\n if (p.rendersBackground) p...
2009/01/05
[ "https://Stackoverflow.com/questions/413247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51482/" ]
413,262
<p>What is a common real life use for <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.disableprocessing.aspx" rel="noreferrer">Dispatcher.DisableProcessing</a> in WPF? Can I use it to suspend rendering and layout when I build a complex UI in code?</p>
[ { "answer_id": 413448, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 3, "selected": false, "text": "Dispatcher * CLR locks will not pump messages internally.\n" }, { "answer_id": 32488848, "author": "Jeffre...
2009/01/05
[ "https://Stackoverflow.com/questions/413262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
413,297
<p>Where can i find the manual for for MySQL 5.0 syntax? What i would need is the manual that corresponds to my MySQL server version (MySQL 5.0)?</p> <p>Considering this: I am using MySQL 5.0 and NaviCat for GUI. If i run this query:</p> <pre><code>CREATE TABLE `genres` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `genre_name` VARCHAR( 25 ) NOT NULL `description` VARCHAR( 100 ) NOT NULL ) ENGINE = innodb; </code></pre> <p>-> Navicat gives me a check your syntax error, and so does the sql prompt..</p> <p>Where can i find info about SQL 5.0 syntax? I've tried the SQL site and Googled it but no luck. Maybe i am truly an idiot ;-)</p>
[ { "answer_id": 413314, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "`genre_name` VARCHAR( 25 ) NOT NULL,\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50477/" ]
413,300
<p>Calling all Visual Studio gurus — when I'm working on a .ascx or .aspx file in a c# web project, the <strong>events</strong> do not show up in the properties panel unless I switch into the design view from the code view. Is this an intentional functionality of Visual Studio? Both VS2005 and VS2008 seem to work this way.</p> <p>And is there any way to get the events to show up in the properties panel all the time?</p>
[ { "answer_id": 413315, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 2, "selected": false, "text": "this. override protected void OnInit(EventArgs e)\n{\n this.Load += new System.EventHandler(this.Page_Load);\n this.myButton...
2009/01/05
[ "https://Stackoverflow.com/questions/413300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27497/" ]
413,333
<p>I need to retrieve, in my Win32 standalone program, <strong>a list of currently installed Internet Explorer add-ons</strong> (Browser Helper Objects), and - if possible - their enabled/disabled status.</p> <p>Since anti-spyware programs (or e.g. <a href="https://technet.microsoft.com/cs-cz/sysinternals/bb963902" rel="nofollow noreferrer">Autoruns</a>) can get this list from somewhere, is there a simple way to request this list <strong>programatically</strong>?</p> <p><strong>EDIT</strong>: Thanks to @<a href="https://stackoverflow.com/users/48003/stefan">Stefan</a>, who pointed me to the right registry keys (<strong>all HKLM</strong>):</p> <pre><code>// BHOs HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\Browser Helper Objects // IE toolbars HKLM\Software\Microsoft\Internet Explorer\Toolbar // IE extensions HKLM\Software\Microsoft\Internet Explorer\Extensions </code></pre>
[ { "answer_id": 413836, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": 4, "selected": true, "text": "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\explorer\\Browser Helper Objects\n HKLM\\Software\\Microsoft\\Internet E...
2009/01/05
[ "https://Stackoverflow.com/questions/413333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19746/" ]
413,349
<p>I have a pretty sizeable object graph that I have serialized to a file via the DataContractSerializer. I now want to present a list of these files to the user to choose from. In this list, I want to show some of the details about the file, which are properties of the root object. I don't want to load the whole graph into memory, since I'm only interested in displaying properties of the root node.</p> <p>Does anyone know a way to control the "depth" of the deserialization so that I can just pull the root object from the file and skip over the children? I'd rather avoid treating the file as raw XML, since I'm not doing any raw XML manipulations anywhere else, and that would be one more branch of code that I have to keep in sync.</p> <p>My only idea right now is to create a compatible "summary" object containing only the properties I'm interested in, and none of the children, and deserialize the file into that. This should skip the children since they are not relevant to the summary object.</p> <p>Is there a better way to accomplish this?</p> <p><strong>Update/Clarification</strong>: Attributes are not the answer I'm looking for. For one thing, they'll prevent the "extra" properties from ending up in the file when the object was first serialized. </p> <p>Second, they're more permanent than what I'm trying to do. Eventually, I do want to deserialize the entire file, just not at this point. I'm trying to show a summary list of files that the user will choose from for import. During the import, I'm going to need all the children and grandchildren. It's just overkill during step 1. These are potentially large files, so fully deserializing several of them just so I can display their header information isn't going to work.</p> <p>Hopefully that clears up any confusion about the original question.</p>
[ { "answer_id": 413746, "author": "foson", "author_id": 22539, "author_profile": "https://Stackoverflow.com/users/22539", "pm_score": 1, "selected": false, "text": "class Program\n{\n static void Main(string[] args)\n {\n Person a = new Person();\n Person b = new Perso...
2009/01/05
[ "https://Stackoverflow.com/questions/413349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1763/" ]
413,363
<p>I am trying to work out a code sample to demonstrate the debugging functionality in Visual Studio 2008 with C#. I'm trying to build a code sample which would have a 'not so obvious' mistake in it, which would result in unexpected output. </p> <p>A non working example would be:</p> <pre><code>static void Main(string[] args) { int a, b; a = args[0]; b = args[1]; if (a = b) Console.WriteLine("They are equal!"); else if (a &lt; b) Console.WriteLine("Number 1 is smaller!"); else Console.WriteLine("Number 1 is larger!"); } </code></pre> <p>Something like this would not be too obvious when just reading over the code, but it could easily be detected with debugging.</p> <p>I'm looking for such an example which would work in Visual Studio 2008 with C#.</p> <p>Thanks for the help!</p>
[ { "answer_id": 413373, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 3, "selected": true, "text": "string a = \"foo\";\na.Replace(\"foo\", \"bar\");\nConsole.WriteLine(a);\n" }, { "answer_id": 413404, "author": "M4N", ...
2009/01/05
[ "https://Stackoverflow.com/questions/413363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
413,367
<p>I'm creating a GUID for use in a Classic ASP application, by using TypeLib. However, even a simple test such as writing the GUID out to the screen is giving me problems - it prints the GUID but ignores everything after it (e.g. HTML tags, additional words, anything).</p> <p>Here's the rudimentary code to test this:</p> <pre><code>Set typeLib = Server.CreateObject("Scriptlet.TypeLib") myGuid = typeLib.Guid Response.Write myGuid &amp; " is the new GUID" Set typeLib = Nothing </code></pre> <p>This will display something like <em>{9DDB27D1-F034-41D7-BB88-D0D811DB91CE}</em> and that's it; the rest of the text is ignored and isn't written out. However, if I hard-code that GUID value and reference it from a variable, the rest of the text appears just fine. I've tried explicit conversion to a String value before displaying, but it still happens.</p>
[ { "answer_id": 413403, "author": "Schwartser", "author_id": 50435, "author_profile": "https://Stackoverflow.com/users/50435", "pm_score": -1, "selected": false, "text": "Response.Write myGuid.ToString(\"D\")\n" }, { "answer_id": 413460, "author": "Wayne Molina", "author_i...
2009/01/05
[ "https://Stackoverflow.com/questions/413367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40667/" ]
413,397
<p>I came across some Enumerators that inherited <code>uint</code>. I couldn't figure out why anyone would do this.</p> <p>Example:</p> <pre><code>Enum myEnum : uint { ... } </code></pre> <p>Any advantage or specific reason someone would do this? Why not just leave it as defaultint?</p>
[ { "answer_id": 413635, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 1, "selected": false, "text": " /// <summary>\n /// There was an HTTP error in issuing the request.\n /// </summary>\n HttpError = 0xFFF...
2009/01/05
[ "https://Stackoverflow.com/questions/413397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
413,425
<p>I am creating an ATL 8.0 based ActiveX control in C++ using Visual Studio 2008. I need to create a sub-window and attach it to the ActiveX control. </p> <p>How do I get access to the HWND that is owned by the ActiveX control?</p> <p>Which ATL function can I override in order to use the HWND after the control's window has been created?</p>
[ { "answer_id": 414666, "author": "Brian", "author_id": 16457, "author_profile": "https://Stackoverflow.com/users/16457", "pm_score": -1, "selected": false, "text": "GetActiveXHwnd()" }, { "answer_id": 420521, "author": "Ashley Davis", "author_id": 25868, "author_profi...
2009/01/05
[ "https://Stackoverflow.com/questions/413425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25868/" ]
413,426
<p>Made solution change: I am trying to display a html table of data.. In my controller I start an object as null and then pass the object as a reference to update the object based on the info in the DB like so "user control named(Indexcontrol.ascx)":</p> <pre><code> List&lt;dataob&gt; data = null; dataManager target = new dataManager(); //pass the parameter to a stored procedure and update it target.LoadFromDatabase(ref data); this.ViewData.Model =data; return View("Index"); </code></pre> <p>I am trying to see how to display a table once the information is in the data object using a similar route all this is in the user control</p> <pre><code> &lt;tbody &gt; &lt;% foreach (businesslayer.dataob m in ViewData.Model) { %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= m.ID%&gt;&lt;/td&gt; &lt;td&gt;&lt;%= m.Date %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= m.Description %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/tbody&gt; </code></pre> <p>I figured out the problem....since I had the table attribute set to runat=server thats what gave me the error..don't know why but it did</p>
[ { "answer_id": 413466, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 0, "selected": false, "text": "<% foreach (dataob m in (IEnumerable<dataob>) ViewData[\"data\"]) { %>\n" }, { "answer_id": 413486, "autho...
2009/01/05
[ "https://Stackoverflow.com/questions/413426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39809/" ]
413,439
<p>I have a webpage that implements a set of tabs each showing different content. The tab clicks do not refresh the page but hide/unhide contents at the client side.</p> <p>Now there is a requirement to change the page title according to the tab selected on the page ( for SEO reasons ). Is this possible? Can someone suggest a solution to dynamically alter the page title via javascript without reloading the page?</p>
[ { "answer_id": 413445, "author": "Kev", "author_id": 16777, "author_profile": "https://Stackoverflow.com/users/16777", "pm_score": 6, "selected": false, "text": "document.title = 'test'" }, { "answer_id": 413447, "author": "lc.", "author_id": 44853, "author_profile": ...
2009/01/05
[ "https://Stackoverflow.com/questions/413439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12129/" ]
413,443
<p>How can I hide a menu item under certain conditions in MFC? <br> I'm not interested in just graying it out.</p>
[ { "answer_id": 413612, "author": "Serge Wautier", "author_id": 12379, "author_profile": "https://Stackoverflow.com/users/12379", "pm_score": 5, "selected": true, "text": " ON_UPDATE_COMMAND_UI(ID_MYMENUITEM, OnUpdateMyMenuItem)\n void CMainFrame::OnUpdateMyMenuItem(CCmdUI *pCmdUI)\n{\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/413443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48369/" ]
413,446
<p>I need to store some values in the database, distance, weight etc.<br> In my model, I have field that contains quantity of something and <code>IntegerField</code> with choices option, that determines what this quantity means (length, time duration etc). </p> <p>Should I create a model for units and physical quantity or should I use <code>IntegerField</code> that contains the type of unit? </p>
[ { "answer_id": 413549, "author": "sastanin", "author_id": 25450, "author_profile": "https://Stackoverflow.com/users/25450", "pm_score": 1, "selected": false, "text": "[value]&nbsp;[unit]" }, { "answer_id": 413600, "author": "S.Lott", "author_id": 10661, "author_profil...
2009/01/05
[ "https://Stackoverflow.com/questions/413446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42371/" ]
413,453
<p>The problem is I need to ignore the stray Letters in the numbers: e.g. 19A or B417</p>
[ { "answer_id": 413546, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 0, "selected": false, "text": " Select Case Cast(Substring(Reverse(Address), PatIndex('%[0-9]%',\n Reverse(Address)), 1) as Integer)...
2009/01/05
[ "https://Stackoverflow.com/questions/413453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15918/" ]
413,464
<p>I'm seeking some examples of how people implement validation logic in the Zend Framework.</p> <p>My ideal implementation would keep the validation outside the controller and allow validating "Confirm password" fields and file uploads.</p>
[ { "answer_id": 413488, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 3, "selected": false, "text": "Zend_Form Zend_Form_Element class Form_Login extends Zend_Form\n{\n public function init() {\n $this->setMethod('post...
2009/01/05
[ "https://Stackoverflow.com/questions/413464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51692/" ]
413,477
<p>I was looking into Valgrind to help improve my C coding/debugging when I discovered it is only for Linux - I have no other need or interest in moving my OS to Linux so I was wondering if there is a equally good program for Windows.</p>
[ { "answer_id": 1353846, "author": "tgs_stdio", "author_id": 165595, "author_profile": "https://Stackoverflow.com/users/165595", "pm_score": 4, "selected": false, "text": "new" }, { "answer_id": 1503615, "author": "Patrice Bernassola", "author_id": 178488, "author_prof...
2009/01/05
[ "https://Stackoverflow.com/questions/413477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49262/" ]
413,483
<p>There is a directed graph (not necessarily connected) of which one or more nodes are distinguished as sources. Any node accessible from any one of the sources is considered 'lit'. Now suppose one of the edges is removed. The problem is to determine the nodes that were previously lit and are not lit anymore.</p> <p>An analogy like city electricity system may be considered, I presume.</p>
[ { "answer_id": 413510, "author": "Frans-Willem", "author_id": 34014, "author_profile": "https://Stackoverflow.com/users/34014", "pm_score": 1, "selected": false, "text": "A -> B >- D\n \\-> C >-/\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22186/" ]
413,490
<p>I've been trying to collect analytics for my website and realized that Google analytics was not setup to capture data for visitors to www.example.com (it was only setup for example.com). I noticed that many sites will redirect me to www.example.com when I type only example.com. However, stackoverflow does exactly the opposite (redirects www.stackoverflow.com to just stackoverflow.com).</p> <p>So, I've decided that in order to get accurate analytics, I should have my web server redirect all users to either www.example.com, or example.com. Is there a reason to do one or the other? Is it purely personal preference? What's the deal with www? I never type it in when I type domains in my browser.</p>
[ { "answer_id": 413494, "author": "Alex Fort", "author_id": 12624, "author_profile": "https://Stackoverflow.com/users/12624", "pm_score": 3, "selected": false, "text": "http://somedomain.com http://www.somedomain.com" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/413490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30479/" ]
413,493
<p>The system I am using has <code>gnuplot</code> installed in <code>/usr/bin</code>. I don't have root, but I needed a newer version of <code>gnuplot</code>, so I installed it to <code>$HOME/usr/bin</code>.</p> <p>I added <code>$HOME/usr/bin</code> to my path, but it still executes the one in <code>/usr/bin</code> if I just use the gnuplot command. I'd rather not have to specify <code>$HOME/usr/bin/gnuplot</code> every time I have to use it. </p> <p>How do I tell Linux to use the one in my home directory, and not the one in <code>/usr/bin</code>? </p>
[ { "answer_id": 413498, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 6, "selected": true, "text": "${HOME}/usr/bin export PATH=\"${HOME}/usr/bin:$PATH\"\n" }, { "answer_id": 413499, "author": "MSalters", "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/413493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/723/" ]
413,505
<p>I want to test an "Adapter" object that when it receives an xml message, it digest it to a Message object, puts message ID + CorrelationID both with timestamps and forwards it to a Client object.=20 A message can be correlated to a previous one (e.g. m2.correlationID =3D m1.ID).</p> <p>I mock the Client, and check that Adapter successfully calls "client.forwardMessage(m)" twice with first message with null correlationID, and a second with a not-null correlationID.</p> <p>However, I would like to precisely test that the correlationIDs are set correctly, by grabing the IDs (e.g. m1.ID).</p> <p>But I couldn't find anyway to do so.</p> <p>There is a <a href="http://jira.codehaus.org/browse/JMOCK-163" rel="nofollow noreferrer">jira</a> about adding the feature, but no one commented and it is unassigned.</p> <p>Is this really unimplemented?</p> <p>I read about the alternative of redesigning the Adapter to use an IdGenerator object, which I can stub, but I think there will be too many objects.=20 Don't you think it adds unnecessary complexity to split objects to a so fine granularity?</p> <p>Thanks, and I appreciate any comments :-)</p> <p>Tayeb</p>
[ { "answer_id": 844866, "author": "bm212", "author_id": 81187, "author_profile": "https://Stackoverflow.com/users/81187", "pm_score": 1, "selected": false, "text": "import org.hamcrest.Description;\nimport org.hamcrest.TypeSafeMatcher;\n\npublic class HasCorrelationId extends TypeSafeMatc...
2009/01/05
[ "https://Stackoverflow.com/questions/413505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
413,535
<p>My code looks like this</p> <pre><code>NSNumber *inputToNumber = [NSNumber numberWithFloat:[textField.text floatValue]]; </code></pre> <p>the value from the textfield is actually a telephone number. It's stored in NSNumber as an annoying (2.0)78966e+08</p> <p>How can I just get NSNumber to store it as 0207896608?</p>
[ { "answer_id": 413628, "author": "Jules", "author_id": 40078, "author_profile": "https://Stackoverflow.com/users/40078", "pm_score": -1, "selected": false, "text": "NSNumber *inputToNumber = [NSNumber numberWithInt:[textField.text intValue]];\n" }, { "answer_id": 413737, "aut...
2009/01/05
[ "https://Stackoverflow.com/questions/413535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51420/" ]
413,558
<p>Even when on the page, the EnableViewState property is disabled, I am still seeing some viewstate existing on the page:</p> <pre><code>"&lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="VkBAB3n5LZYtY+nTzk1vEu1P/6QLf4qzFIKzpFRJe3DMf8UseUA/1RsO409HJX4QhkROSP0umoJvatjK/q+jXA==" /&gt;" </code></pre> <p>My question is why?</p>
[ { "answer_id": 413620, "author": "erikkallen", "author_id": 47161, "author_profile": "https://Stackoverflow.com/users/47161", "pm_score": 3, "selected": false, "text": "class MyPage : Page {\n private class DummyPageStatePersister : PageStatePersister {\n public DummyPageStateP...
2009/01/05
[ "https://Stackoverflow.com/questions/413558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32372/" ]
413,568
<p>Anyone know of a way to reliably take a snapshot of a WPF window? The <a href="http://msdn.microsoft.com/en-us/library/ms535695.aspx" rel="noreferrer">PrintWindow</a> api works well for "standard" win32 windows but since WPF uses DirectX, PrintWindow fails to capture an image. I think that one would need to grab the front buffer for the DirectX object associated with the window, but I am not sure how to do that.</p> <p>Thanks!</p>
[ { "answer_id": 3519332, "author": "Sean Campbell", "author_id": 377944, "author_profile": "https://Stackoverflow.com/users/377944", "pm_score": 1, "selected": false, "text": "private void PrintWindow(PrintDialog pdPrint, \n System.Windows.Window wWin, \n ...
2009/01/05
[ "https://Stackoverflow.com/questions/413568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38791/" ]
413,573
<p>I have the following HTML </p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;style&gt; .box { border:solid black 1px; padding:0px; margin:0px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;input class="box" style="width:300px;" /&gt;&lt;br /&gt; &lt;input class="box" style="width:150px;" /&gt; &lt;input class="box" style="width:150px;" /&gt;&lt;br /&gt; &lt;input class="box" style="width:100px;" /&gt; &lt;input class="box" style="width:100px;" /&gt; &lt;input class="box" style="width:100px;" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The idea is that the textboxes should finish pixel perfect on the right hand side.</p> <p>I will eventually add spacing on rows 2 and 3 enlarging the widths to compensate, but for the moment I would like to get this simple sample to render.</p> <p>So <strong>how can I remove the margins of these textboxes such that the align properly?</strong></p>
[ { "answer_id": 413584, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": false, "text": "float: left; .box {\n padding:0px;\n margin:0px;\n float: left;\n}\n" }, { "answer_id": 413608, "author": ...
2009/01/05
[ "https://Stackoverflow.com/questions/413573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
413,597
<p>Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. </p> <p>The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations?</p> <p>One catch - I'm stuck using Java 1.4, so I can't do anything with annotations. </p>
[ { "answer_id": 413712, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 4, "selected": true, "text": "java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;acti...
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
413,603
<p>I am trying to make a livesearch with Django and jQuery. What I've done is make the javascript ask for some data with the getJSON function, then I've set up a view in Django that returns a JSON response automated by the Django serializer.</p> <p>And this works well, it returns a json response with the text/javascript content-type. To avoid sending all the data, (alot that i dont need) i did this:</p> <p><code> response.write(serializers.serialize("json", soknad_list, fields=('name', 'image', 'genre'))) </code></p> <p>But for instance, the 'genre' field is a manyToMany field, so is it possible to get the values from genre.all.0 for instance and not just the genre ID?</p> <p>And the model has a function <code>get_absolute _url</code>, is it possible to include this in the JSON response, if so how?</p> <p>So i guess my question is, is it possible to include stuff other than the raw field data in the JSON response, if not, how would you go about solving my problem?</p>
[ { "answer_id": 421057, "author": "bruno desthuilliers", "author_id": 41316, "author_profile": "https://Stackoverflow.com/users/41316", "pm_score": 2, "selected": false, "text": "from django.utils import simplejson\nfrom django.utils import datetime_safe\nfrom django.utils.functional impo...
2009/01/05
[ "https://Stackoverflow.com/questions/413603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42546/" ]
413,618
<p>I'm looking for a kind of array data-type that can easily have items added, without a performance hit.</p> <ul> <li>System.<strong>Array</strong> - <code>Redim Preserve</code> copies entire RAM from old to new, as slow as amount of existing elements</li> <li>System.Collections.<strong>ArrayList</strong> - good enough?</li> <li>System.Collections.<strong>IList</strong> - good enough?</li> </ul>
[ { "answer_id": 413671, "author": "Juliet", "author_id": 40516, "author_profile": "https://Stackoverflow.com/users/40516", "pm_score": 5, "selected": true, "text": "List<int> nums = new List<int>(3); // creates a resizable array\n // which can hold 3 elem...
2009/01/05
[ "https://Stackoverflow.com/questions/413618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]