qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
353,485
<p>I am trying to create a Data Source in SharePoint Designer that connects to a SharePoint List via XML Web Services. I have created the Data Source and connected to the list in question. I can view all the data using GetListItems, and I want to filter it using the query parameter.</p> <p>The query parameter takes an XmlNode, and when I put this as the value I get an error:</p> <pre><code>&lt;Query&gt; &lt;Where&gt; &lt;Eq&gt; &lt;FieldRef Name="Title" /&gt; &lt;Value Type="Text"&gt;Foo&lt;/Value&gt; &lt;/Eq&gt; &lt;/Where&gt; &lt;/Query&gt; </code></pre> <p>Of course, I have not entered any tabs or newlines, as I only have a one-line entry field in SharePoint Designer. I receive an error with this query:</p> <blockquote> <p>The server returned a non-specific error when trying to get data from the data source. Check the format and content of your query and try again. If the problem persists, contact the server administrator.</p> </blockquote> <p>I simply want to filter the list items resultset to be those with the Title field of "Foo". Can this be done in SharePoint Designer?</p> <hr> <p>Update: escaping the &lt; and > in this manner also fails:</p> <pre><code>&amp;lt;Query&amp;gt;&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;quot;Title&amp;quot; /&amp;gt;&amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;Foo&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;&amp;lt;/Query&amp;gt; </code></pre> <hr> <p>Update: This appears to be a <a href="http://blogs.msdn.com/sharepointdesigner/archive/2008/06/20/data-source-issues-and-workarounds.aspx" rel="nofollow noreferrer">known issue</a> with SoapDataSource components and SOAP calls. Apparently, they are over-encoding the &lt;'s and >'s before they get submitted. The workaround given is to save the data source without a query parameter, and then to add it to the page and create a filter in the Common Data View Tasks dialog. I was able to get this to work using the following filter string:</p> <pre><code>[@ows_Title = 'Foo'] </code></pre> <p>Unfortunately, this doesn't help me much as I am adding a Data View (showing the data) rather than a DataSource that I can use to point other controls to (like a drop-down list).</p> <p>I'm still looking for a good solution on this that lets me place a datasource using SharePoint Designer.</p>
[ { "answer_id": 354027, "author": "Peter Lillevold", "author_id": 35245, "author_profile": "https://Stackoverflow.com/users/35245", "pm_score": 1, "selected": false, "text": "&lt;Query&gt;&lt;Where&gt;\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1753/" ]
353,486
<p>I'm looking at using ASP.NET for a new SaaS service, but for the love of me I can't seem to figure out how to do account lookups based on subdomains like most SaaS applications (e.g. 37Signals) do.</p> <p>For example, if I offer yourname.mysite.com, then how would I use ASP.NET (MVC specifically) to extract the subdomain so I can load the right template (displaying your company's name and the like)? Can it be done with regular routing?</p> <p>This seems to be a common thing in SaaS so there has to be an easy way to do it in ASP.NET; I know there are plugins that do it for other frameworks like Ruby on Rails.</p>
[ { "answer_id": 368512, "author": "Mark Brittingham", "author_id": 15592, "author_profile": "https://Stackoverflow.com/users/15592", "pm_score": 3, "selected": true, "text": " //------------------------------------------------------------------------------------------------------------...
2008/12/09
[ "https://Stackoverflow.com/questions/353486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40667/" ]
353,489
<p>In my case, I have a number of column names coming from a form. I want to filter to make sure they're all true. Here's how I currently do it:</p> <pre><code>for op in self.cleaned_data['options']: cars = cars.filter((op, True)) </code></pre> <p>Now it <em>works</em> but there are are a possible ~40 columns to be tested and it therefore doesn't appear very efficient to keep querying.</p> <p>Is there a way I can condense this into one filter query?</p>
[ { "answer_id": 353602, "author": "prairiedogg", "author_id": 27462, "author_profile": "https://Stackoverflow.com/users/27462", "pm_score": 3, "selected": false, "text": "op_kwargs = {}\nfor op in self.cleaned_data['options']:\n op_kwargs[op] = True\ncars = CarModel.objects.filter(**op...
2008/12/09
[ "https://Stackoverflow.com/questions/353489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12870/" ]
353,491
<p>Say I have a hierarchy of classes, let's use the classic <code>Shape</code> examples: </p> <p><code>abstract class Shape</code><br> <code>Circle : Shape</code><br> <code>Square : Shape</code> </p> <p>I have a second hierarchy of renderer classes that handle the rendering of shapes in different ways:</p> <p><code>abstract class ShapeRenderer</code><br> <code>HtmlShapeRenderer : ShapeRenderer</code><br> <code>WindowsFormsShapeRenderer : ShapeRenderer</code> </p> <p>Allowing these to vary independently would traditionally involve using the Bridge pattern. Allowing the rendering actions to be extended without modifying the <code>Shape</code> classes would traditionally involve the Visitor pattern.</p> <p>However, both of these focus exclusively on extending the implementation side and not the abstraction side. Say I wanted to add a new <code>Shape</code>, say <code>Triangle</code> - I want to be able to support rendering the <code>Triangle</code> as well. Since both the Visitor and the Bridge pattern rely on "flattening" the abstraction hierarchy into a set of methods, e.g.:</p> <pre><code>public abstract class ShapeRenderer { public abstract void RenderCircle(Circle c); public abstract void RenderSquare(Square s); } </code></pre> <p>The only way to extend the <code>Shape</code> hierarchy is to modify the code of the base <code>ShapeRenderer</code> class, which is a breaking change.</p> <p>Jon, to clarify: Using the Bridge or Visitor allows clients to provide alternative rendering implementations, but requires them to know about all potential Shapes. What I'd like to be able to do is allow clients to <em>also</em> be able to extend the <code>Shape</code> class and <em>require</em> them to provide a rendering implementation for their new class. This way, existing code can work with any type of <code>Shape</code>, without worrying about the particulars of rendering them.</p> <p>Is there a common solution to this sort of problem usable in C#?</p>
[ { "answer_id": 355034, "author": "oz10", "author_id": 14069, "author_profile": "https://Stackoverflow.com/users/14069", "pm_score": 2, "selected": false, "text": "class Triangle : public Shape\n{\n public:\n Triangle( const RenderEngine& whichRenderEngine );\n void render( voi...
2008/12/09
[ "https://Stackoverflow.com/questions/353491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,505
<p>I'm trying to get a JEditorPane to highlight the full width of a displayed line. All the examples I've tried only highlight the textual content. For example if I have content such as this:</p> <pre><code> --------------------------------- |Here is some text | |some more text | --------------------------------- </code></pre> <p>within a JEditorPane represented by the box above, then highlighting the first row highlights only the 'Here is some text' (represented between [ and ] below).</p> <pre><code> --------------------------------- [Here is some text] | |some more text | --------------------------------- </code></pre> <p>I would like it to highlight the full width of the JEditorPane like the following:</p> <pre><code> --------------------------------- [Here is some text ] |some more text | --------------------------------- </code></pre> <p>Is there a way to do this?</p>
[ { "answer_id": 354283, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "paint()" }, { "answer_id": 359811, "author": "Matthew Murdoch", "author_id": 4023, "author_profile": "https:...
2008/12/09
[ "https://Stackoverflow.com/questions/353505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
353,520
<p>Is it possible to post a description/comment variable to the facebook sharer url? It's only possible for url and title as far as I can figure out.</p>
[ { "answer_id": 529285, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "meta" }, { "answer_id": 936769, "author": "Andrew Cox", "author_id": 27907, "author_profile": "https://Sta...
2008/12/09
[ "https://Stackoverflow.com/questions/353520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671/" ]
353,526
<p>On a SQL Server 2005 database, one of our remote developers just checked in a change to a stored procedure that changed a "select scope_identity" to "select @@identity". Do you know of any reasons why you'd use @@identity over scope_identity?</p>
[ { "answer_id": 353547, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 5, "selected": true, "text": "@@IDENTITY" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
353,541
<p>I am using Context.RewritePath() in ASP.NET 3.5 application running on IIS7.</p> <p>I am doing it in application BeginRequest event and everything works file.</p> <p>Requests for /sports are correctly rewritten to default.aspx?id=1, and so on.</p> <p>The problem is that in my IIS log I see GET requests for /Default.aspx?id=1 and not for /sports.</p> <p>This kind of code worked perfectly under IIS6.</p> <p>Using Microsoft Rewrite module is not an option, due to some business logic which has to be implemented.</p> <p>Thanks.</p> <p>EDIT: </p> <p>It seems my handler is too early in the pipeline, but if I move the logic to a later event, than the whole rewrite thing doesn't work (it's too late, StaticFileHandler picks up my request). </p> <p>I googled and googled, asked around, can't believe that nobody has this problem?</p> <p>EDIT:</p> <p>Yikes! Here's what I found on the IIS forum:</p> <p>"This is because in integrated mode, IIS and asp.net share a common pipeline and the RewritePath is now seen by IIS, while in IIS6, it was not even seen by IIS - you can workaround this by using classic mode which would behave like IIS6."</p> <p><strong>Final update</strong>: Please take a look at <a href="https://stackoverflow.com/questions/353541/iis7-rewritepath-and-iis-log-files/579141#579141">my answer below</a>, I've updated it with results after more than a year in production environment.</p>
[ { "answer_id": 558076, "author": "Daniel Richardson", "author_id": 52049, "author_profile": "https://Stackoverflow.com/users/52049", "pm_score": 2, "selected": false, "text": "BeginRequest" }, { "answer_id": 14181017, "author": "ingredient_15939", "author_id": 471597, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269/" ]
353,545
<p>I have a C# program which uses a SQL Server database.I am already using it in a country that uses . as decimal separator. Now I want to use it in another country that uses , as decimal separator.</p> <p>in C# is there some application level setting that I can change or write some code so that I can use the same database and the same program ? or do I have to change my entire code to handle this new decimal separator?</p> <p>I dont know how this works.Basically I think there would be problems in My Sql Queries. example say one of my existing statements is <br></p> <pre><code>insert into tblproducts(productId,Price) values('A12',24.10) </code></pre> <p>now in new country it will become </p> <pre><code>insert into tblproducts(productId,Price) values('A12',24,10) </code></pre> <p>this will raise an error</p> <p>so do I have to change whole code to handle this situation ?</p> <p>Thank you </p>
[ { "answer_id": 353618, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 0, "selected": false, "text": "Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(\"en-US\")\nThread.CurrentThr...
2008/12/09
[ "https://Stackoverflow.com/questions/353545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,550
<p>All the member variables and member functions in my class ClassA are static. </p> <p>If a user is trying (by mistake) to create an object of this class, he receives a warning: "ClassA, local variable never referenced", because all the functions are static, so this object is never referenced. So, I want to prevent the user from trying to create an object of this class. </p> <p>Would it be enough to create a private default (no variables) constructor? Or do I have to also create private copy constructor and private assignment operator (to prevent using the default constructors)? And if I do have to create them too, maybe it would be better just to create some dummy pure virtual function instead, and this will prevent the user from creating an object?</p> <p>Thank you</p>
[ { "answer_id": 353580, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 4, "selected": false, "text": "namespace::function()" }, { "answer_id": 353640, "author": "Johannes Schaub - litb", "author_id": 34509, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
353,558
<p>I have a classes like:</p> <pre><code>[Serializable] public class child { public Parent parent; } [Serializable] public class Parent { public List&lt;child&gt; children; } </code></pre> <p>When I deserialize Parent, I want each of each children to have a reference to it's parent. Question is, where in the deserialization process can I set the child's "parent" pointer? I can't seem to use a custom constructor for child, because deserialization always uses the default constructor. If I implement ISerializable, then it seems that the child objects have already been created by the time the parent is created. Is there another way to achieve this?</p>
[ { "answer_id": 353589, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 0, "selected": false, "text": " public class Connections: List<Connection>\n { public new void Add(Connection connection)\n {\n ...
2008/12/09
[ "https://Stackoverflow.com/questions/353558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,561
<p>How can you create a C# Winforms control which goes out of the bounds of its region? Such as a drop down box. Kind of like if you had a DropDownBox in a Small Sized Panel.</p>
[ { "answer_id": 354326, "author": "Hans Passant", "author_id": 17034, "author_profile": "https://Stackoverflow.com/users/17034", "pm_score": 3, "selected": false, "text": "using System;\nusing System.Drawing;\nusing System.ComponentModel;\nusing System.Windows.Forms;\n\npublic class MyLis...
2008/12/09
[ "https://Stackoverflow.com/questions/353561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28717/" ]
353,569
<p>Can any one explain why the output of this code is only 'hello' and what this code means?</p> <pre><code>( 0, characterArray, 0, characterArray.Length ); </code></pre> <p>The output is showing:</p> <p><PRE>The character array is: hello</PRE></p> <p>The code follows:</p> <pre><code>string string1 = "hello there"; char[] characterArray = new char[ 5 ]; string1.CopyTo( 0, characterArray, 0, characterArray.Length ); Console.Write( "\nThe character array is: " ); for ( int i = 0; i &lt; characterArray.Length; i++ ) Console.Write( characterArray[ i ] ); </code></pre>
[ { "answer_id": 353583, "author": "AaronS", "author_id": 26932, "author_profile": "https://Stackoverflow.com/users/26932", "pm_score": 4, "selected": true, "text": "public void CopyTo(\n int sourceIndex,\n char[] destination,\n int destinationIndex,\n int count\n)\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,571
<p>I just got done working through the Django tutorials for the second time, and am understanding things much more clearly now. However, I'm still unclear how apps inside a site interact with one another.</p> <p>For example, lets say I'm writing a blog application (a rather popular activity, apparently). Blog posts and comments tend to go together, and yet they are distinct enough that they should be built into separate apps, as is the general philosophy of Djano development.</p> <p>Consider the following example. In reality I would not actually write the comment app myself, as good code for that already exists on the web, but this is for demonstration/practice purposes:</p> <p><strong>mysite/blog/models.py</strong></p> <pre><code>from django.db import models class post(models.Model): title = models.CharField(max_length=200) author = models.CharField(max_length=200) content = models.TextField() </code></pre> <p><strong>mysite/comments/models.py</strong></p> <pre><code>from django.db import models from mysite.blog.models import post class comment(models.Model): id = models.AutoField() post = models.ForeignKey(post) author = models.CharField(max_length=200) text = models.TextField() </code></pre> <p>Is what I wrote above, importing a model from another app and setting it as a foreign key, how Django apps interact? Or is there a different/better method for the apps that comprise a site to interact?</p> <p><strong>Update</strong><br> Per the recommendation in one response, I'm reading the documentation for contrib.contenttypes. If I'm reading this correctly, I could rewrite my example comment app like this: </p> <pre><code>from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contentypes import generic class comment(models.Model): id = models.AutoField() author = models.CharField(max_length=200) text = models.TextField() content_type = models.ForeignKey(ContentType) content_object = generic.GenericForeignKey(content_type, id) </code></pre> <p>Would this be correct?</p>
[ { "answer_id": 353615, "author": "muhuk", "author_id": 42188, "author_profile": "https://Stackoverflow.com/users/42188", "pm_score": 2, "selected": false, "text": "django.contrib.admin" }, { "answer_id": 353667, "author": "prairiedogg", "author_id": 27462, "author_pro...
2008/12/09
[ "https://Stackoverflow.com/questions/353571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33383/" ]
353,596
<p>I've copied a Dataset from one csproj to another, and the new project gets the following compile warning: "The custom tool 'MSDataSetGenerator' failed while processing the file 'Client.xsd'."</p> <p>In researching this warning I discovered that if I opened a VS cmd prompt and run XSD.exe on the xsd file directly I get more info. It says: "Error: Can only generate one of classes or datasets."</p> <p>The command line flag that fixes this is to run: XSD /d {xsdfilename}</p> <p>If I run that on the cmd line it generates the dataset code just fine. But I can't figure out how to make Visual Studio do that. Anyone know?</p>
[ { "answer_id": 67321806, "author": "live-love", "author_id": 436341, "author_profile": "https://Stackoverflow.com/users/436341", "pm_score": 2, "selected": false, "text": "Error: Can only generate one of classes or datasets.\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29021/" ]
353,601
<p>I have a command-line process I would like to automate and capture in C#.</p> <p>At the command line, I type:</p> <pre><code>nslookup </code></pre> <p>This launches a shell which gives me a > prompt. At the prompt, I then type:</p> <pre><code>ls -a mydomain.local </code></pre> <p>This returns a list of local CNAMEs from my primary DNS server and the physical machines they are attached to.</p> <p>What I would like to do is automate this process from C#. If this were a simple command, I would just use Process.StartInfo.RedirectStandardOutput = true, but the requirement of a second step is tripping me up.</p>
[ { "answer_id": 353624, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "ProcessStartInfo si = new ProcessStartInfo(\"nslookup\");\nsi.RedirectStandardInput = true;\nsi.RedirectStandardOutput = true;\...
2008/12/09
[ "https://Stackoverflow.com/questions/353601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5287/" ]
353,614
<pre><code>int x; printf("hello %n World\n", &amp;x); printf("%d\n", x); </code></pre>
[ { "answer_id": 353674, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 2, "selected": false, "text": "int len;\nchar *thing = \"label of unknown length\";\nchar *value = \"value value value\"\nchar *value2=\"seco...
2008/12/09
[ "https://Stackoverflow.com/questions/353614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
353,617
<p>Let's say we have a solution with the following structure:</p> <ul> <li>Project.DAL - Data access layer, depends on a lower-level library, e.g. Oracle.DataAccess w/copy local = true </li> <li>Project.BLL - Business logic layer, references Project.DAL as project </li> <li>Project.UI - UI layer, compiles to executable, references Project.BLL, default project</li> </ul> <p>When Project.UI is compiled, VS is smart enough to copy Project.DAL.dll to the output directory, but it's not smart enough to figure out that I wanted Oracle.DataAccess to be copied to the output directory as well for distribution to clients.</p> <p>Can anyone explain why this is so? Is it because it sees Oracle.DataAccess in the GAC and assumes that clients will have it in the GAC as well?</p> <p>It's not that big of a deal, but it's kinda annoying that every time I add a new assembly reference, I have to remember to set it to copy local and add an item to copy it in my build script as well. </p>
[ { "answer_id": 2828191, "author": "Shaun", "author_id": 276874, "author_profile": "https://Stackoverflow.com/users/276874", "pm_score": 4, "selected": false, "text": "<ProjectReference Include=\"..\\SomeProject.csproj\">\n <Project>{11111111-1111-1111-1111-111111111111}</Project>\n <Na...
2008/12/09
[ "https://Stackoverflow.com/questions/353617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
353,632
<p>Where I work, people mostly think that objects are best initialised using C++-style construction (with parentheses), whereas primitive types should be initialised with the = operator:</p> <pre><code>std::string strFoo( "Foo" ); int nBar = 5; </code></pre> <p>Nobody seems to be able to explain why they prefer things this way, though. I can see that <code>std::string = "Foo";</code> would be inefficient because it would involve an extra copy, but what's wrong with just banishing the <code>=</code> operator altogether and using parentheses everywhere?</p> <p>Is it a common convention? What's the thinking behind it?</p>
[ { "answer_id": 353649, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": false, "text": "std::string strFooA(\"Foo\"); // Calls std::string(const char*) constructor\nstd::string strFoo = \"Foo\"; // Call...
2008/12/09
[ "https://Stackoverflow.com/questions/353632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
353,678
<p>I have some data that has a detail table. I want the data to be presented in a ListView. I want the detail data to appear as a nested ListView when you select an item in the original list. I can't seem to figure out how to get the data binding to work.</p> <p>Here's what I have so far, (the problem is the <code>{Binding Path=FK_History_HistoryItems}</code>):</p> <pre><code>&lt;ListView Name="lstHistory" ItemsSource="{Binding Source={StaticResource History}}" SelectionChanged="lstHistory_SelectionChanged"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Name" Width="100" /&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Description}" Header="Description" Width="150" /&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Total, Converter={StaticResource moneyConvert}}" Header="Total" Width="100" /&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Converter={StaticResource categoryAggregate}}" Header="Categories" Width="100" /&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;ListView.Resources&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListViewItem}"&gt; &lt;Border&gt; &lt;StackPanel&gt; &lt;Border Name="presenter" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt; &lt;GridViewRowPresenter /&gt; &lt;/Border&gt; &lt;Border Name="details" Visibility="Collapsed" Margin="5" BorderBrush="Black" BorderThickness="2"&gt; &lt;StackPanel Margin="5"&gt; &lt;ListView ItemsSource="{Binding Path=FK_History_HistoryItems}"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Ammount}" Header="Ammount" Width="100" /&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Category}" Header="Category" Width="100" /&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter TargetName="details" Property="Visibility" Value="Visible" /&gt; &lt;Setter TargetName="presenter" Property="Background" Value="Navy"/&gt; &lt;Setter TargetName="presenter" Property="TextElement.Foreground" Value="White" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ListView.Resources&gt; &lt;/ListView&gt; </code></pre>
[ { "answer_id": 353925, "author": "Bryan Anderson", "author_id": 21186, "author_profile": "https://Stackoverflow.com/users/21186", "pm_score": 1, "selected": false, "text": "<ListView ItemsSource=\"{Binding ElementName=lstHistory, Path=SelectedItem}\">\n" }, { "answer_id": 497702,...
2008/12/09
[ "https://Stackoverflow.com/questions/353678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42911/" ]
353,684
<p>I'm writing a mapping application that I am writing in python and I need to get the lat/lon centroid of N points. Say I have two locations</p> <pre><code>a.lat = 101 a.lon = 230 b.lat = 146 b.lon = 200 </code></pre> <p>Getting the center of two points is fairly easy using a euclidean formula. I would like to be able to do it for more then two points.</p> <p>Fundamentally I'm looking to do something like <a href="http://a.placebetween.us/" rel="noreferrer">http://a.placebetween.us/</a> where one can enter multiple addresses and find a the spot that is equidistant for everyone.</p>
[ { "answer_id": 353732, "author": "pdemarest", "author_id": 40332, "author_profile": "https://Stackoverflow.com/users/40332", "pm_score": 2, "selected": false, "text": "Is the center of (0,359) and (0, 1) at (0,0) or (0,180)?\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33966/" ]
353,698
<p>I need to be able to change a user's password from a cron task or from an ssh session. Is there an easy way to do that with a bash script? If not, what's the easiest way to do it in Cocoa?</p>
[ { "answer_id": 353704, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": true, "text": "passwd" }, { "answer_id": 44683538, "author": "toma", "author_id": 4797324, "author_profile": "https://Stac...
2008/12/09
[ "https://Stackoverflow.com/questions/353698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
353,706
<p>Beyond the official documentation, are there any recommended resources for learning to build jQuery plugins. I'm particularly interested in building plugins for the UI libary. </p> <p>I've been looking at the source for some of the official ones, but I've found they all look quite different from each other. Many are not well commented and it is difficult to tell what blocks of code are part of the essential structure and what is specific to a particular plugin.</p> <p>If there aren't yet any good resources for this, can anyone clue me in on what basic structure I should be starting with when writing a plugin from scratch?</p>
[ { "answer_id": 354071, "author": "Nathan Long", "author_id": 4376, "author_profile": "https://Stackoverflow.com/users/4376", "pm_score": 3, "selected": true, "text": " $(this).highlight({\n foreground: 'red'\n });\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
353,715
<p>i have a frame that instantiates another frame but i don't want to use the close(x) button on the instantiated frame., so i created a button. how do i code that this button can be used to close the instantiated frame without quitting the JVM.</p>
[ { "answer_id": 430762, "author": "Tom", "author_id": 8969, "author_profile": "https://Stackoverflow.com/users/8969", "pm_score": 3, "selected": false, "text": "jFrame.setVisible(false);\n" }, { "answer_id": 1743011, "author": "shenol", "author_id": 185614, "author_pro...
2008/12/09
[ "https://Stackoverflow.com/questions/353715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,721
<p>I have a WebApplication project, a business logic project, and a WebDeployment project for the web app. </p> <p>When I build solution, the deployment "Release" bin contains 1 dll for each of the projects - so I get one for MyWeb.dll, MyWebBusiness.dll, and MyWebDeploy.dll. </p> <p>When I try to run the site, it sees the same type in both MyWeb.dll and MyWebDeploy.dll and chokes.</p> <p>Error message: CS0433: The type 'AV' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\53d45622\6c032bd2\assembly\dl3\33f3c6b2\abc9430a_285ac901\MyWeb.DLL' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\53d45622\6c032bd2\assembly\dl3\631e5302\0231160d_285ac901\MyWebDeploy.DLL'</p>
[ { "answer_id": 14181544, "author": "Rohit Naik", "author_id": 1952705, "author_profile": "https://Stackoverflow.com/users/1952705", "pm_score": 0, "selected": false, "text": "<compilation ... batch=\"false\"/>\n\n ...\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44698/" ]
353,746
<p>This question deals with concurrency issues, for suggestions on how to display a busy icon see this question: <a href="https://stackoverflow.com/questions/205631/javascript-loadingbusy-indicator-or-transparent-div-over-page-on-event-click">Javascript - loading/busy indicator or transparent div over page on event click</a></p> <p>When a user initiates an AJAX request on a page it's useful to show some kind of "working" or busy icon or progress indicator. If there is only one long-running process this can be handled in a relatively straightforward way:</p> <pre><code>function do_action() { show_busy_icon(); long_running_asynchronous_process(function() { // Callback function run when process finishes hide_busy_icon(); }); } </code></pre> <p>However, if multiple asynchronous processes are running on the page, using on/off methods wouldn't work. The first process to finish switches off the icon even though there are additional processes running.</p> <p>So, <strong>how do you handle displaying an indicator, on a web page, that is on when there are one or more processes running, and off when there are no processes running?</strong></p> <p>I imagine it would be possible to maintain a count of the number of processes running. <code>hide_busy_icon()</code> only hides the icon if the process count is 0. That seems kinda prone to failure. Perhaps there's a better/simpler way that I'm not seeing.</p> <p>Thanks for your ideas and suggestions!</p> <p>Edit: After working with the solution in the marked answer for a while, I'm happy to say it works very well. The only issue I've run into are cases where my own scripts call functions of scripts I don't control. Unless those functions allow callbacks to be supplied there's no way to update the process-count when they begin and end.</p> <p>An example of where this can occurs is adding a set of markers to a Google map. Once my script calls the Google maps function the busy icon disappears, while the markers are still being loaded.</p> <p>I'm not sure of a good way to handle this. </p>
[ { "answer_id": 354143, "author": "savetheclocktower", "author_id": 25720, "author_profile": "https://Stackoverflow.com/users/25720", "pm_score": 1, "selected": false, "text": "Ajax.activeRequestCount" }, { "answer_id": 10206151, "author": "Henrik", "author_id": 1331076, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238/" ]
353,757
<p>I've recently gotten charged with designing and implementing a source code version control, testing, and deployment scheme at the company I work.</p> <p>Personally I've worked with Subversion for a few years on my own projects. But I've never dealt with it at this big scale. Hence I thought I'd ask here if anyone has any comments or suggestions about the following setup I've deviced:</p> <ul> <li>Trunk is used as the main development tree, as it should be</li> <li>Remote servers (testing and production) check out code from the SVN repo. <ul> <li>Testing servers check out trunk.</li> <li>Production servers checkout the "production" branch.</li> </ul></li> <li>Once trunk is deemed ready for production, it's merged into two branches, "stable", and "production".</li> <li>The stable branch is a stepping stone to the production branch. If bugs are found once the new code goes live on the production server, the stable branch is used for fixing the bugs, and also testing the bug fixes.</li> <li>Once fixed, changes are merged into the production branch, and also back into trunk where development has kept on going like normal adding new features and whatever independently of any bug fixes that were needed.</li> </ul> <p>This way, development doesn't have to halt on trunk whenever there's a production release, as bug fixes aren't dependent on trunk. Also, there's always a "read-only" branch where the latest stable and most-bug free code is available, even in the middle of heavy bug fixing.</p> <p>If anybody has any suggestions, comments, or otherwise, I'd greatly appreciate it :)</p>
[ { "answer_id": 354143, "author": "savetheclocktower", "author_id": 25720, "author_profile": "https://Stackoverflow.com/users/25720", "pm_score": 1, "selected": false, "text": "Ajax.activeRequestCount" }, { "answer_id": 10206151, "author": "Henrik", "author_id": 1331076, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42146/" ]
353,772
<p>i have the following jquery code. </p> <p>basically i will have several overlapped divs and a list of links on the right of all those overlapped divs. when hovering over a link, the link's assigned div will fade in.</p> <p>I have the following code and it works (it uses the default windows' sample pictures), but if someone can think of a way to optimize it or make it generic, i'd appreciate it.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery-1.2.6.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#trigger1").mouseover(function() { $(".contentdiv").addClass("inactive"); $("#divsunset").removeClass("inactive"); $(".inactive").fadeOut(500); $("#divsunset").fadeIn(500); }); $("#trigger2").mouseover(function() { $(".contentdiv").addClass("inactive"); $("#divwinter").removeClass("inactive"); $(".inactive").fadeOut(500); $("#divwinter").fadeIn(500); }); $("#trigger3").mouseover(function() { $(".contentdiv").addClass("inactive"); $("#divbh").removeClass("inactive"); $(".inactive").fadeOut(500); $("#divbh").fadeIn(500); }); $("#trigger4").mouseover(function() { $(".contentdiv").addClass("inactive"); $("#divwl").removeClass("inactive"); $(".inactive").fadeOut(500); $("#divwl").fadeIn(500); }); }); &lt;/script&gt; &lt;style&gt; #divsunset { position: absolute; top: 5px; left: 5px; } #divwinter { position: absolute; top: 5px; left: 5px; } #divbh { position: absolute; top: 5px; left: 5px; } #divwl { position: absolute; top: 5px; left: 5px; } #links { position: absolute; top: 800px; left: 700px; } .inactive { } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="divsunset" class="contentdiv"&gt; &lt;img src="Sunset.jpg" /&gt; &lt;/div&gt; &lt;div id="divwinter" class="contentdiv"&gt; &lt;img src="Winter.jpg" /&gt; &lt;/div&gt; &lt;div id="divbh" class="contentdiv"&gt; &lt;img src="bh.jpg" /&gt; &lt;/div&gt; &lt;div id="divwl" class="contentdiv"&gt; &lt;img src="wl.jpg" /&gt; &lt;/div&gt; &lt;br /&gt; &lt;div id="links"&gt; &lt;a href="#" id="trigger1"&gt;Show Sunset&lt;/a&gt; &lt;a href="#" id="trigger2"&gt;Show Winter&lt;/a&gt; &lt;a href="#" id="trigger3"&gt;Show Blue Hills&lt;/a&gt; &lt;a href="#" id="trigger4"&gt;Show Waterlillies&lt;/a&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <p>Thank you Matt, TM and kRON, your responses really helped.</p> <p>I dont feel I explained myself totally, but TM provided the answer I was looking for.</p> <p>I wanted to follow DRY and the code TM provided helped me best this time since it did not require for me to alter my markup, just the jQuery code.</p> <p>Again, thanks a lot. Its amazing how quickly I got the answer. Keep up the great work.</p>
[ { "answer_id": 353809, "author": "TM.", "author_id": 12983, "author_profile": "https://Stackoverflow.com/users/12983", "pm_score": 4, "selected": true, "text": "document.ready()" }, { "answer_id": 353835, "author": "Filip Dupanović", "author_id": 44041, "author_profil...
2008/12/09
[ "https://Stackoverflow.com/questions/353772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34683/" ]
353,773
<p>How can I determine when the control key is held down during button click in a C# Windows program? I want one action to take place for Ctrl/Click and a different one for Click.</p>
[ { "answer_id": 353816, "author": "lesscode", "author_id": 18482, "author_profile": "https://Stackoverflow.com/users/18482", "pm_score": 3, "selected": false, "text": "private void button1_Click(object sender, EventArgs e) {\n MessageBox.Show(Control.ModifierKeys.ToString());\n}\n" }...
2008/12/09
[ "https://Stackoverflow.com/questions/353773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536/" ]
353,786
<p>I have this function in my head:</p> <pre><code>&lt;head&gt; window.onload = function(){ var x = new Array(0,2,3,4,5,6,7,8); var y = new Array(20,10,40,30,60,50,70,10); drawGraph(y,x); } &lt;/head&gt; </code></pre> <p>Can I declare the function drawGraph() somewhere in the body? Do I need to declare it before it is called?</p>
[ { "answer_id": 608288, "author": "Dscoduc", "author_id": 51949, "author_profile": "https://Stackoverflow.com/users/51949", "pm_score": 0, "selected": false, "text": "function addLoadEvent(func) {\n var oldonload = window.onload;\n if (typeof window.onload != 'function') {\n wi...
2008/12/09
[ "https://Stackoverflow.com/questions/353786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
353,788
<p>Is there an similar property like System.getProperty("java.home") that will return the JDK directory instead of the JRE directory? I've looked <a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getProperties()" rel="nofollow noreferrer">https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getProperties()</a> and there doesn't seem to be anything for the JDK.</p>
[ { "answer_id": 353860, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 2, "selected": false, "text": "java.home" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19026/" ]
353,793
<p>Can I use a query in MSSQL to get the .mdf and .ldf filename/location for a specific database?</p>
[ { "answer_id": 353807, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 2, "selected": false, "text": "SELECT * FROM sys.master_files\n" }, { "answer_id": 685068, "author": "GvS", "author_id": 11492, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
353,800
<p>I'm wondering if storing the data in viewstate is a good idea for this given problem. He's a simplified example of what I am trying to achieve, firstly we have a Repeater control:</p> <pre><code>&lt;asp:Repeater id="Repeater1" runat="server"&gt; &lt;ItemTemplate&gt; &lt;asp:TextBox id="Name" runat="server" /&gt; &lt;asp:TextBox id="Age" runat="server" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;asp:TextBox id="NewPersonName" runat="server" /&gt; &lt;asp:TextBox id="NewPersonAge" runat="server" /&gt; &lt;asp:Buttin id="Button1" runat="server" Text="Add" OnClick"Button1_Click"/&gt; </code></pre> <p>To keep things simple I'll forego the databinding code, as this is working it loads in the current list of people and ages and binds perfectly.</p> <p>The problem is with the bottom 3 controls, what I want is for the user to be able to type in a new entry, click the add button and this would then be added to the Repeater, but not persisted to the database.</p> <p>The user should be able to add multiple names to the list and then click a Save button to commit all the new names in one click rather than committing for each entry.</p>
[ { "answer_id": 353807, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 2, "selected": false, "text": "SELECT * FROM sys.master_files\n" }, { "answer_id": 685068, "author": "GvS", "author_id": 11492, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44702/" ]
353,803
<p>How can I get a PHP function go to a specific website when it is done running?</p> <p>For example:</p> <pre><code>&lt;?php //SOMETHING DONE GOTO(http://example.com/thankyou.php); ?&gt; </code></pre> <p>I would really like the following...</p> <pre><code>&lt;?php //SOMETHING DONE GOTO($url); ?&gt; </code></pre> <p>I want to do something like this:</p> <pre><code>&lt;?php //SOMETHING DONE THAT SETS $url header('Location: $url'); ?&gt; </code></pre>
[ { "answer_id": 353839, "author": "Bullines", "author_id": 27870, "author_profile": "https://Stackoverflow.com/users/27870", "pm_score": 4, "selected": false, "text": "<?php\n // SOMETHING DONE\n\n header('Location: http://stackoverflow.com');\n?>\n" }, { "answer_id": 353840, ...
2008/12/09
[ "https://Stackoverflow.com/questions/353803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33194/" ]
353,804
<p>I'm working on a database that tracks files and dependencies in projects. Briefly, I have two main tables; the PROJECTS table lists project names and other properties, the FILES table lists files. Every file entry points to a project as a foreign key set to CASCADE, so if I delete a project record from the database, all the file records disappear as well. So far, so good.</p> <p>Now I have an additional DEPENDENCIES table. Each record in the dependency table is two files, specifying that the first file depends on the second. Again these are foreign keys, the first is set to CASCADE (so if I delete a file entry, this record is deleted), but the second is set to RESTRICT (so I am not allowed to delete a file entry if any other files depend on it). Again, everything seems good.</p> <p>Unfortunately it seems I can no longer delete a project with a single SQL delete statement! The delete tries to cascade-delete the files, but if any of these appear in the DEPENDENCIES table, the RESTRICT foreign key prevents the delete (even though that record in the dependencies table will be removed because the other column is CASCADE). The only workaround I have is to calculate an exact order to delete the files so none of the dependency record constraints are violated, and remove the file records one at a time before attempting to remove the project.</p> <p>Is there any way to set up my database schema so a single SQL delete from the projects table will correctly cascade the other deletes? I'm using Firebird 2.1, but I don't know if that makes any difference - it seems like there ought to be a way to make this work?</p>
[ { "answer_id": 353913, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "PROJECTS" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8415/" ]
353,808
<p>How do I implement this method (see below)? I'm new to Objective-C and I'm just not getting it right.</p> <p>From: <a href="http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html" rel="nofollow noreferrer">http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html</a></p> <blockquote> <p>By default databases have a quota of 0; this quota must be increased before any database will be stored on disk.</p> <p><strong>WebKit clients should implement the WebUIDelegate method <code>- webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:</code> and increase the quota as desired when that method is called.</strong> This method is defined in WebUIDelegatePrivate.h. It was added too late in the previous release cycle to make it into a non-private header. It would be worthwhile to file a bug about moving this call to WebUIDelegate.h so that it is part of the official API.</p> </blockquote> <p>John</p>
[ { "answer_id": 354258, "author": "Jeff", "author_id": 8597, "author_profile": "https://Stackoverflow.com/users/8597", "pm_score": 1, "selected": false, "text": "- (void)webView:(WebView *)sender frame:(WebFrame *)frame\nexceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin\n...
2008/12/09
[ "https://Stackoverflow.com/questions/353808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8597/" ]
353,817
<p>Java and C# support the notion of classes that can't be used as base classes with the <code>final</code> and <code>sealed</code> keywords. In C++ however there is no good way to prevent a class from being derived from which leaves the class's author with a dilemma, should every class have a virtual destructor or not?</p> <hr> <p><strong>Edit:</strong> Since C++11 this is no longer true, you can specify that a class is <a href="http://en.cppreference.com/w/cpp/language/final" rel="noreferrer"><code>final</code></a>.</p> <hr> <p>On the one hand giving an object a virtual destructor means it will have a <code>vtable</code> and therefore consume 4 (or 8 on 64 bit machines) additional bytes per-object for the <code>vptr</code>.</p> <p>On the other hand if someone later derives from this class and deletes a derived class via a pointer to the base class the program will be ill-defined (due to the absence of a virtual destructor), and frankly optimizing for a pointer per object is ridiculous. </p> <p>On the <a href="http://en.wikipedia.org/wiki/Gripping_hand" rel="noreferrer">gripping hand </a> having a virtual destructor (arguably) advertises that this type is meant to be used polymorphically.</p> <p>Some people think you need an explicit reason to not use a virtual destructor (as is the subtext of <a href="https://stackoverflow.com/questions/300986">this question</a>) and others say that you should use them only when you have reason to believe that your class is to be derived from, what do <em>you</em> think?</p>
[ { "answer_id": 353856, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": false, "text": "virtual" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
353,841
<p>I'm new to the forum and very new to silverlight. Myself and my coworker are working on a custom application. We are building a menu system that will only display buttons if that useris in an assigned role. A new property was created to allow roles to be defined, and for testing purposes we are simply trying to assign that value, which is a string, to a textblock's text property. Some code is attached.</p> <p>This is one of the items to be added to the collection. the allowedroles property is passing the string, this can be seen via the debugger. </p> <pre><code>&lt;MenuButton:VerticalButtonCollection x:Key="VerticalButtonsDS" d:IsDataSource="True"&gt; &lt;MenuButton:VerticalButton AllowedRoles="test, test2"&gt; &lt;TextBlock Text="{Binding AllowedRoles}"&gt;&lt;/TextBlock&gt; &lt;/MenuButton:VerticalButton&gt; &lt;/MenuButton:VerticalButtonCollection&gt; Code for the allowed roles property Public Shared ReadOnly AllowedRolesProperty As DependencyProperty = DependencyProperty.Register("AllowedRoles", GetType(String), GetType(mButton), New PropertyMetadata(New PropertyChangedCallback(AddressOf onAllowedRolesChanged))) Public Shared Sub onAllowedRolesChanged(ByVal d As DependencyObject, ByVal args As DependencyPropertyChangedEventArgs) Dim sender As mButton = CType(d, mButton) sender.AllowedRoles = CStr(args.NewValue) End Sub </code></pre> <p>The items are displayed in a list box, there are no errors, but binding does not work. I even attempted to do the binding in the listbox's data template. I appologize if this is confusing, I dont' know how to post something like this in easy to understand pieces.</p> <p>Thanks</p>
[ { "answer_id": 353856, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": false, "text": "virtual" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44713/" ]
353,842
<p>In C#, I'm trying to build an extension method for StringBuilder called AppendCollection() that would let me do this:</p> <pre><code>var sb1 = new StringBuilder(); var sb2 = new StringBuilder(); var people = new List&lt;Person&gt;() { ...init people here... }; var orders = new List&lt;Orders&gt;() { ...init orders here... }; sb1.AppendCollection(people, p =&gt; p.ToString()); sb2.AppendCollection(orders, o =&gt; o.ToString()); string stringPeople = sb1.ToString(); string stringOrders = sb2.ToString(); </code></pre> <p>stringPeople would end up with a line for each person in the list. Each line would be the result of p.ToString(). Likewise for stringOrders. I'm not quite sure how to write the code to make the lambdas work with generics.</p>
[ { "answer_id": 353858, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "public static string Print<T>(this IEnumerable<T> col, Func<T,string> printer)\n{\n var sb = new StringBuilder();\n forea...
2008/12/09
[ "https://Stackoverflow.com/questions/353842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
353,843
<p>I'm trying to search multiple attributes in XML :</p> <pre><code>&lt;APIS&gt; &lt;API Key="00001"&gt; &lt;field Username="username1" UserPassword="password1" FileName="Filename1.xml"/&gt; &lt;field Username="username2" UserPassword="password2" FileName="Filename2.xml"/&gt; &lt;field Username="username3" UserPassword="password3" FileName="Filename3.xml"/&gt; &lt;/API&gt; &lt;/APIS&gt; </code></pre> <p>I need to check if in the "field" the Username AND UserPassword values are both what I am comparing with my Dataset values, is there a way where I can check multiple attributes (AND condition) without writing my own logic of using Flags and breaking out of loops. </p> <p>Is there a built in function of XMLDoc that does it? Any help would be appreciated! </p>
[ { "answer_id": 353944, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 6, "selected": true, "text": "/APIS/API/field[@Username='username1' and @UserPassword='password1']\n" }, { "answer_id": 354951, "author": "Di...
2008/12/09
[ "https://Stackoverflow.com/questions/353843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24958/" ]
353,882
<pre><code>&lt;asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoAddProperty" Text="Add Property to TIV" /&gt; &lt;asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoRemoveProperty" Text="Remove Property from TIV" /&gt; &lt;asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoChangeProperty" Text="Change Property Values" /&gt; </code></pre> <p>I was thinking about implementing a custom <code>validator</code>, and using a client <code>JavaScript</code> function to reference the RadioButton ID, (I'm using web forms, not mvc),</p> <pre><code>something like.. if(document.getElementById(&lt;%= rdoAddProperty.ClientId %&gt;).checked == true) &amp;&amp; ... </code></pre> <p>Anyone know of a way to do it without knowing the clientId?</p>
[ { "answer_id": 353917, "author": "Bullines", "author_id": 27870, "author_profile": "https://Stackoverflow.com/users/27870", "pm_score": 3, "selected": true, "text": "<script type=\"text/javascript\" language=\"javascript\">\n function Validate()\n {\n var l_elemsRadios = doc...
2008/12/09
[ "https://Stackoverflow.com/questions/353882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44595/" ]
353,901
<p>Is there a generic container implementing the 'set' behaviour in .NET?</p> <p>I know I could just use a <code>Dictionary&lt;T, Object&gt;</code> (and possibly add <code>nulls</code> as values), because its keys act as a set, but I was curious if there's something ready-made.</p>
[ { "answer_id": 353924, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 5, "selected": true, "text": "HashSet<T>" }, { "answer_id": 19141521, "author": "Cristian Diaconescu", "author_id": 11545, "author_pro...
2008/12/09
[ "https://Stackoverflow.com/questions/353901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
353,912
<p>I need help getting my head around the difference between my current OOP notion of state, and the way it would be done in a functional language like Haskell or Clojure. </p> <p>To use a hackneyed example, let's say we're dealing with simplified bank account objects/structs/whatever. In an OOP language, I'd have some class holding a reference to a BankAccount, which would have instance variables for things like interest rate, and methods like setInterestRate() which change the object's state and generally return nothing. In say Clojure, I'd have a bank-account struct (a glorified hashmap), and special functions that take a bank-account parameter and other info, and return a new struct. So instead of changing the state of the original object, I now have a new one being returned with the desired modifications. </p> <p>So... what do I do with it? Overwrite whatever variable was referencing the old bank-account? If so, does that have advantages over the state-changing OOP approach? In the end, in both cases it seems one has a variable that references the object with the necessary changes. Retarded as I am, I have only a vague concept of what's going on. </p> <p>I hope that made sense, thanks for any help!</p>
[ { "answer_id": 354017, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 2, "selected": false, "text": " b__\n | \na -> [6|] -+-> [5|] -> [4|] -> [3|] -> [2|] -> [1|x]\n" }, { "answer_id": 355040, "...
2008/12/09
[ "https://Stackoverflow.com/questions/353912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38803/" ]
353,926
<p>Anyone know what the C# "M" syntax means?</p> <pre><code>var1 = Math.Ceiling(hours / (40.00M * 4.3M)); </code></pre>
[ { "answer_id": 353939, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": false, "text": "decimal" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/353926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/300930/" ]
353,948
<p>Data table structure is:<br> id1,id2,id3,id4,... (some other fields).<br> I want to create summary query to find out how many times some ID value is used in every column.</p> <p>Data<br> 1,2,3,4,2008<br> 2,3,5,1,2008<br> 1,3,2,5,2007<br> 1,2,3,6,2007<br> 3,1,2,5,2007<br></p> <p>For value 1, the result should be<br> 1,0,0,1,2008<br> 2,1,0,0,2007<br></p> <p>How to accomplish this with one query (in MySQL).</p>
[ { "answer_id": 353971, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "DECLARE @look_for AS int\nSET @look_for = 1\n\nSELECT SUM(CASE WHEN id1 = @look_for THEN 1 ELSE 0 END) AS id1_count\n ...
2008/12/09
[ "https://Stackoverflow.com/questions/353948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44715/" ]
353,953
<p>I am trying to create a new website on a remote server via msbuild (I like to call it "msdeploy"). I've downloaded and used the SDC tasks, the MSBuildExtension tasks and the MSBuildCommunity tasks but I simply can't get it right.</p> <p>I figure that WebDirectorySetting (from MSBuild.Community.Tasks.IIS) is my best bet but I can't find the right SettingName to pass.</p> <p>I'd like to use some sort of MSBuild task to accomplish this but maybe it just doesn't exist. Custom VBS or WMI are my last resort...</p> <p>Thanks</p>
[ { "answer_id": 2886859, "author": "Eduardo Xavier", "author_id": 107452, "author_profile": "https://Stackoverflow.com/users/107452", "pm_score": 0, "selected": false, "text": "<WebDirectoryCreate\n ServerName=\"$(DeployServerName)\" \n VirtualDirectoryName=\"MyVirualSiteName...
2008/12/09
[ "https://Stackoverflow.com/questions/353953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44714/" ]
353,982
<p>because i read that one of the advantages of <a href="http://en.wikipedia.org/wiki/WS-Discovery" rel="nofollow noreferrer">WS-Discovery</a> that it "Support both SOAP 1.1 and SOAP 1.2 Envelopes" so what?</p>
[ { "answer_id": 2886859, "author": "Eduardo Xavier", "author_id": 107452, "author_profile": "https://Stackoverflow.com/users/107452", "pm_score": 0, "selected": false, "text": "<WebDirectoryCreate\n ServerName=\"$(DeployServerName)\" \n VirtualDirectoryName=\"MyVirualSiteName...
2008/12/09
[ "https://Stackoverflow.com/questions/353982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459737/" ]
354,002
<p>I have 2 tables (A and B) with the same primary keys. I want to select all row that are in A and not in B. The following works:</p> <pre><code>select * from A where not exists (select * from B where A.pk=B.pk); </code></pre> <p>however it seems quite bad (~2 sec on only 100k rows in A and 3-10k less in B)</p> <p>Is there a better way to run this? Perhaps as a left join?</p> <pre><code>select * from A left join B on A.x=B.y where B.y is null; </code></pre> <p>On my data this seems to run slightly faster (~10%) but what about in general?</p>
[ { "answer_id": 354059, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 6, "selected": false, "text": "SELECT A.* \nfrom A left join B on \n A.x = B.y\n where B.y is null\n" }, { "answer_id": 34264638, "au...
2008/12/09
[ "https://Stackoverflow.com/questions/354002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
354,005
<p><strong><code>oPanel = CType(Master.FindControl("panelSearch"), Panel)</code></strong></p> <p>This code resides on my masterpage's back-end (<strong><code>theMaster.master.vb</code></strong>), but I get a "Cannot refer to an instance member from within a shared class or shared member initializer without an explicit instance of the class"</p> <p>the function it resides in IS shared, I just can't remember for the life of me what I need to do to make this work.</p> <p>thanks!</p>
[ { "answer_id": 354032, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "Shared" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
354,008
<pre><code>SELECT pe.prodtree_element_id prodID, pe.prodtree_element_name_s, li.line_name, av2.value FROM prodtree_element pe LEFT JOIN prodtree_link pl ON pe.prodtree_element_id = pl.to_prodtree_node_id LEFT JOIN line li ON pe.line_code = li.line_code INNER JOIN attribute_values av ON av.attribute_definition_id = #statusCode# LEFT JOIN attribute_values av2 ON pe.prodtree_element_id = av.prodtree_element_id WHERE pe.prodtree_element_func_type &lt;&gt; 'WIZARD' AND pe.prodtree_element_topo_type = 'NODE' </code></pre> <p>"#statusCode#" is a static id that matches an id in the attribute definition table (let's say 22 for the sake of argument). The problem is, the query has some massive trouble finishing in any sane amount of time. The bigger problem is, I kinda need it to finish earlier, but the number of records is enormous that it has to draw back (around 30-50,000). I need data from multiple tables, which is where it starts to slow down. This is just a piece of what I need, I also need an entire other tables worth of data matching the current "prodtree_elment_id".</p> <p>I'm using ColdFusion but even running the query directly in SQL Server 2005 creates the 15-30+ minute wait for this query (if it even finishes). Is there any conceivable way to speed up this query to take at most 5 minutes or less?</p>
[ { "answer_id": 354028, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": " INNER JOIN attribute_values av\n ON av.attribute_definition_id = #statusCode# \n" }, { "answer_id": 354...
2008/12/09
[ "https://Stackoverflow.com/questions/354008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16631/" ]
354,010
<p>Ok, so we have a bunch of tables that are named like this:</p> <pre><code>training_data_001 training_data_002 training_data_003 training_data_004 training_data_005 </code></pre> <p>And then to find those we look at a field in another table, let's just call it master.training_type.</p> <p>Anyway, I was wondering if anyone knew of a way to do a weird table name based join with this kind of data. Something like this:</p> <pre><code>SELECT foo FROM master WHERE id = ? INNER JOIN training_data_${master.training_type} ON foo.id = training_data_${master.training_type}.foo_id </code></pre> <p>I know that I can do this on the client side, but it would be nice to have the db do it.</p> <p>Also note: it's SQL Server.</p> <p><strong>Update</strong>: I decided to just do it on the client side. Thanks anyway everyone.</p> <p>Thanks!</p> <p>-fREW</p>
[ { "answer_id": 354013, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 2, "selected": false, "text": "EXEC (@stringvar)" }, { "answer_id": 354102, "author": "TheSoftwareJedi", "author_id": 18941, "author_prof...
2008/12/09
[ "https://Stackoverflow.com/questions/354010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12448/" ]
354,019
<p>I have a UI-dialog something like this: You must choose a book from a list. Optionally, you can either choose a publisher (another class) from a list or enter the publisher-name as as a string. </p> <p>I think this gives me 3 types as the output from the dialog.</p> <ol> <li>book</li> <li>book with publisher-class</li> <li>book with publisher-string</li> </ol> <p>How would you model this in objects? It seems to me that the having a book base-class, and then two subclasses for publisher and publisher name is the correct choice. Are there any alternatives, perhaps favoring composition that would give a better model?</p> <hr> <p>I'll try to explain a bit more. A book doesn't need to have a publisher. The publisher object is not the same as a publisher-name entered as a string.</p> <p>You must<br> -choose a book from an existing list </p> <p>You can one of the following<br> -choose a publisher from an existing list or<br> -you can enter a publisher name or<br> -you can fill nothing about the publisher </p>
[ { "answer_id": 354220, "author": "Eric", "author_id": 42461, "author_profile": "https://Stackoverflow.com/users/42461", "pm_score": 0, "selected": false, "text": "Class Book\n{\n public string Name;\n public List<Publisher> publishers = new List<Publishers>;\n\n Book()\n {\n ...
2008/12/09
[ "https://Stackoverflow.com/questions/354019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44726/" ]
354,037
<p>I am looking for a way to determine what the Name/IP Address of the domain controller is for a given domain that a client computer is connected to.</p> <p>At our company we have a lot of small little networks that we use for testing and most of them have their own little domains. As an example, one of the domains is named "TESTLAB". I have an Windows XP workstation that is a member of the TESTLAB domain and I am trying to figure out the name of the domain controller so that I can go and look to see what users have been defined for the domain. In our lab there is a mix of Windows Server 2000 and Windows Server 2003 (and in reality probably a couple of NT 4 Servers) so it would be nice to find a solution that would work for both.</p> <p>Looking on the Internet, it looks like there are various utilities, such as Windows Power Shell or nltest, but these all require that you download and install other utilities. I was hoping to find a way to find the domain controller without having to install anything additional.</p> <p><strong>EDIT</strong> If I wanted to write a program to find the domain controller or the users in the current domain, how would I go about doing that?</p>
[ { "answer_id": 354128, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": false, "text": "using (PrincipalContext context = new PrincipalContext(ContextType.Domain))\n{\n string controller = context.Connect...
2008/12/09
[ "https://Stackoverflow.com/questions/354037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34508/" ]
354,038
<p>How do I check if a string represents a numeric value in Python?</p> <pre><code>def is_number(s): try: float(s) return True except ValueError: return False </code></pre> <p>The above works, but it seems clunky.</p> <hr /> <p><sub>If what you are testing comes from user input, it is <em>still</em> a string <em>even if it represents</em> an <code>int</code> or a <code>float</code>. See <a href="https://stackoverflow.com/questions/20449427/">How can I read inputs as numbers?</a> for converting the input, and <a href="https://stackoverflow.com/questions/23294658/">Asking the user for input until they give a valid response</a> for ensuring that the input represents an <code>int</code> or <code>float</code> (or other requirements) before proceeding.</sub></p>
[ { "answer_id": 354073, "author": "Zoomulator", "author_id": 44563, "author_profile": "https://Stackoverflow.com/users/44563", "pm_score": 11, "selected": false, "text": "isdigit()" }, { "answer_id": 1139186, "author": "Community", "author_id": -1, "author_profile": "h...
2008/12/09
[ "https://Stackoverflow.com/questions/354038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40115/" ]
354,044
<p>A quick search for currency regex brings up <a href="https://regexlib.com/Search.aspx?k=currency&amp;c=-1&amp;m=-1&amp;ps=20" rel="noreferrer">a lot of results</a>.</p> <p>The problem I have in choosing one is that regex is difficult to verify without testing all the edge cases. Does anyone have a regex for U.S. currency that has been <em>thoroughly tested</em>?</p> <p>My only requirement is that the matched string is U.S. currency and parses to <code>System.Decimal</code>:</p> <pre> [ws][sign][digits,]digits[.fractional-digits][ws] Elements in square brackets ([ and ]) are optional. The following table describes each element. ELEMENT DESCRIPTION ws Optional white space. sign An optional sign. digits A sequence of digits ranging from 0 to 9. , A culture-specific thousands separator symbol. . A culture-specific decimal point symbol. fractional-digits A sequence of digits ranging from 0 to 9. </pre>
[ { "answer_id": 354216, "author": "Keng", "author_id": 730, "author_profile": "https://Stackoverflow.com/users/730", "pm_score": 8, "selected": true, "text": "Match; JGsoft:\n^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*\\.[0-9]{2}$\n" }, { "answer_id": 354276, "author": "Community", "a...
2008/12/09
[ "https://Stackoverflow.com/questions/354044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23566/" ]
354,045
<p>I am considering writing two limited precision alternatives to BigDecimal, namely DecimalInt and DecimalLong. These would be capable of dealing with numbers within the real bounds of int and long with an arbitrary number of decimal places, creatable in both mutable and immutable form. My plan is to make DecimalInt support +/-999,999,999 to +/- 0.999999999 and DecimalLong the same, but with up to 18 digits.</p> <p>This would be done by maintaining a decimal digit count value of 0-9 for DecimalInt and 0-18 for DecimalLong along side the actual value stored as a scaled int or long. The normal use would be for small numbers of decimals such as for money and stock prices, typically 2-4 decimal places.</p> <p>The essential requirements are (a) lean footprint (2 classes, plus OverflowException), and (b) full support of all basic operations plus all of Math that makes sense.</p> <p>Googling for results did not return any obvious hits - they all seemed to pertain to arbitrary decimals.</p> <p>My questions are: Has this already been done? Are there hidden subtleties in this which is why it has not already been done? Has anyone heard rumors of Java supporting a decimal type like DotNet's.</p> <p>EDIT: This is different from BigDecimal because it should be (a) a hell of a lot more efficient to not deal with an array of ints, and (b) it won't wrap BigInteger so it will be leaner on memory too, and (c) it will have a mutable option so it will be faster there as well. In summary - less overhead for the simple use cases like "I want to store a bank balance without the overhead of BigDecimal and the inaccuracy of double".</p> <p>EDIT: I intend on doing all the math using int or long to avoid the classic problem of: 1586.60-708.75=877.8499999999999 instead of 877.85</p>
[ { "answer_id": 4261922, "author": "Peter Lawrey", "author_id": 57695, "author_profile": "https://Stackoverflow.com/users/57695", "pm_score": 0, "selected": false, "text": "System.out.printf(\"%.2f%n\", 1586.60-708.75);\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8946/" ]
354,050
<p>I am trying to passing in 3 pointers to a DLL function. I have:</p> <pre> { $code=1; $len=100; $str=" " x $len; $function = new Win32::API(DLLNAME,'dllfunction','PPP','V'); $function->Call($code,$str,$len); } </pre> <p>The DLL is defined as <code>void dllfunction(int* a, char* str, int* len);</code> The DLL will modify all the variables pointed by the three pointers.</p> <p>However, I am segfaulting when I run this. The documentation for <a href="http://search.cpan.org/dist/Win32-API" rel="nofollow noreferrer">Win32::API</a> specified that I should use actual variable name instead of the Perl variable references. Can anyone tell me what I am missing? Thanks.</p> <p>*more information:</p> <p>I added <code>printf()</code> in the DLL to print out the address of the three pointers, and <code>printf</code> in Perl to print out the reference of the three variables. And I get the following</p> <p>DLL : Code = 0x10107458 Error = 0x10046b50 str = 0x10107460</p> <p>Perl : Code = 0x101311b8 Error = 0x101312a8 str = 0x10131230</p> <p>Any idea why the DLL is getting the wrong addresses?</p> <p>****More information</p> <p>After much debugging, I found out that this is happening when returning from the DLL function. I added printf("done\n"); as the very last line of this DLL function, and this does output, then the program segfaults. I guess its happening in Win32::API? Has anyone experienced this?</p> <p>Also, I am able to access the initial variables of all the three variables from the DLL. So the pointer is passed correctly, but for some reason it causes a segfault when returning from the DLL. Maybe it's segfaulting when trying to copy the new data into the Perl variable?</p>
[ { "answer_id": 354135, "author": "Harper Shelby", "author_id": 21196, "author_profile": "https://Stackoverflow.com/users/21196", "pm_score": 0, "selected": false, "text": "$function->Call(\\$code, \\$str, \\$len)\n" }, { "answer_id": 354248, "author": "Harper Shelby", "au...
2008/12/09
[ "https://Stackoverflow.com/questions/354050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44730/" ]
354,057
<p>I am begging to use jquery. I have the following call that works in IE7 but not FF 3.0.4. But if I change the <code>null</code> to <code>{}</code> it works fine. Is null not valid for this case and I just got lucky that it worked in IE or is this an error with jquery.</p> <pre><code>$.post("complexitybar.ashx?a=init&amp;vc=" + validationCode, null, loadInitialValues, "json"); </code></pre>
[ { "answer_id": 354079, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 1, "selected": false, "text": "null" }, { "answer_id": 354093, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "htt...
2008/12/09
[ "https://Stackoverflow.com/questions/354057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24500/" ]
354,068
<p>I have an application that is using Windows Authentication and a SqlRoleProvider for user authentication and role management respectively. It is working fine with my test users that I have added to the database as defaults. The application requires users to login (using Windows credentials) and then be able to use this internal application as a basic "user". If the user needs to be added to a high level role, an admin would be responsible for this after the first log in.</p> <p>With that said, how would I add a user to the default role when they first log in? Logically, I know that I would need to call Roles.IsUserInRole() and then add them if they are not; however, where would I do this? I'm having trouble locating which event in the Global.asax to use.</p> <p>Thanks</p> <p><strong>EDIT:</strong> To expand the scenario a bit, I'm not using a full membership provider system due to requirements on writing new providers to allow the connection string to be stored outside of the web.config. I am not using any form of registration or login page and letting the Windows Integrated Authentication in IIS handle the authentication aspects while my enhanced SqlRoleProvider manages the user roles. The system is working fine for users that I have setup roles via hard coded tests. I am just looking for a way to add new users (who would be authenticated by IIS) to be immediately added to a default "Users" role. I think I found it; however, am now examining ways to make it not fire upon every request for performance reasons.</p>
[ { "answer_id": 354105, "author": "CheGueVerra", "author_id": 17787, "author_profile": "https://Stackoverflow.com/users/17787", "pm_score": 0, "selected": false, "text": "user = Membership.GetUser()\nif (user != null)\n{\n // default role \n string[] defaultRoles = {\"MyRole\"};\n\n Ad...
2008/12/09
[ "https://Stackoverflow.com/questions/354068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28540/" ]
354,070
<p>After reading it, this is <em>not</em> a duplicate of <a href="https://stackoverflow.com/questions/44917/explicit-vs-implicit-sql-joins">Explicit vs Implicit SQL Joins</a>. The answer may be related (or even the same) but the <strong>question</strong> is different.</p> <hr> <p>What is the difference and what should go in each?</p> <p>If I understand the theory correctly, the query optimizer should be able to use both interchangeably.</p>
[ { "answer_id": 354094, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 11, "selected": true, "text": "SELECT *\nFROM Orders\nLEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID\nWHERE Orders.ID = 12345\n" }, { "...
2008/12/09
[ "https://Stackoverflow.com/questions/354070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
354,097
<p>When I add a # in insert mode on an empty line in Vim while editing python files, vim moves the # to the beginning of the line, but I would like the # to be inserted at the tab level where I entered it.</p> <p>For example, when writing this in vim</p> <pre><code>for i in range(10): # </code></pre> <p>the # does not stay there where I entered it.</p> <p>It is moved like so, by vim.</p> <pre><code>for i in range(10): # </code></pre> <p>Does anyone know of a configuration item in vim that would change this?</p> <p>If it helps, I am using Ubuntu 8.10.</p>
[ { "answer_id": 354422, "author": "Paul D. Eden", "author_id": 3045, "author_profile": "https://Stackoverflow.com/users/3045", "pm_score": 6, "selected": true, "text": "set smartindent\n" }, { "answer_id": 385388, "author": "too much php", "author_id": 28835, "author_p...
2008/12/09
[ "https://Stackoverflow.com/questions/354097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3045/" ]
354,110
<p>Being fairly new to JavaScript, I'm unable to discern when to use each of these.</p> <p>Can anyone help clarify this for me?</p>
[ { "answer_id": 354118, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 5, "selected": false, "text": "indexOf" }, { "answer_id": 354123, "author": "ng.mangine", "author_id": 37784, "author_profile": "https:/...
2008/12/09
[ "https://Stackoverflow.com/questions/354110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30433/" ]
354,136
<p>How do I create the default for a generic in VB? in C# I can call:</p> <pre><code>T variable = default(T); </code></pre> <ol> <li>How do I do this in VB?</li> <li>If this just returns null (C#) or nothing (vb) then what happens to value types?</li> <li>Is there a way to specify for a custom type what the default value is? For instance what if I want the default value to be the equivalent to calling a parameterless constructor on my class.</li> </ol>
[ { "answer_id": 354142, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 6, "selected": true, "text": "Dim variable As T\n' or '\nDim variable As T = Nothing\n' or '\nDim variable As New T()\n" }, { "answer_id": 3...
2008/12/09
[ "https://Stackoverflow.com/questions/354136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
354,139
<p>When using Google Reader and browsing RSS entries in the "Expanded" view, entries will automatically be marked as 'read' once a certain percentage of the div is visible on the screen (difficult to tell what percentage has to be visible in the case of Google Reader). So, as I scroll down line-by-line, the javascript code can determine that a) the entry is being rendered in the visible window and b) a certain amount is visible and when those conditions are met, the state is toggled to read.</p> <p>Does anyone have any idea how that feature is implemented? Specifically, does anyone here know how to tell if a div has scrolled into view an how much of the div is visible?</p> <p>As an aside, I'm using jQuery, so if anyone has any jQuery-specific examples, they would be much appreciated.</p>
[ { "answer_id": 365937, "author": "Yoni", "author_id": 36071, "author_profile": "https://Stackoverflow.com/users/36071", "pm_score": 0, "selected": false, "text": "viewportOffset" }, { "answer_id": 46545607, "author": "Jordan Stubblefield", "author_id": 7768341, "autho...
2008/12/09
[ "https://Stackoverflow.com/questions/354139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40123/" ]
354,167
<p>In its enthusiasm to <a href="http://www.postgresql.org/docs/current/interactive/textsearch-intro.html" rel="nofollow noreferrer">stemm tokens into lexemes</a>, PostgreSQL Full Text Search engine also reduce proper nouns. For instance:</p> <pre><code>essais=&gt; select to_tsquery('english', 'bortzmeyer'); to_tsquery ------------ 'bortzmey' essais=&gt; select to_tsquery('english', 'balling'); to_tsquery ------------ 'ball' (1 row) </code></pre> <p>At least for the first one, I'm sure it is not in the english dictionary! What is the better way to avoid this spurious stemming?</p>
[ { "answer_id": 73913128, "author": "Justin Tanner", "author_id": 609, "author_profile": "https://Stackoverflow.com/users/609", "pm_score": 0, "selected": false, "text": "english" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
354,171
<p>I am pretty new to both Struts and Spring. I need to know how to access a Spring Service in a Struts ActionForm. Even a pointer in the right direction would be appreciated.</p>
[ { "answer_id": 354205, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 1, "selected": false, "text": "<listener>\n <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n</listener>\n" }...
2008/12/09
[ "https://Stackoverflow.com/questions/354171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
354,182
<p>Given Microsoft FORTRAN 5.1 and Microsoft C/C++ 14.0, along with the linker that comes with that version of FORTRAN (that must be used for other dependencies) how do I create a C function and call it from the FORTRAN application? </p>
[ { "answer_id": 594694, "author": "KitsuneYMG", "author_id": 86515, "author_profile": "https://Stackoverflow.com/users/86515", "pm_score": 2, "selected": true, "text": "program ftest\nuse iso_c_bindings\nimplicit none\ninterface\nfunction saythis(a) ! should be subroutine if saythis retur...
2008/12/09
[ "https://Stackoverflow.com/questions/354182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5070/" ]
354,188
<p>Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string.</p> <p>On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. All of this works fine. </p> <p>On the <code>detailsView</code> page, I have it autogenerating a <code>new record</code> link that uses postback to show the blank insert form to be filled out.</p> <p>The only problem is, I have no idea how to link to the <code>insert</code> view of the <code>DetailsView</code> from an external page. Am I missing something?</p>
[ { "answer_id": 355319, "author": "Dhaust", "author_id": 242, "author_profile": "https://Stackoverflow.com/users/242", "pm_score": 3, "selected": true, "text": "If Not idValue Is Nothing Then \n yourDetailsViewName.ChangeMode(DetailsViewMode.Insert)\nEnd If\n" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22452/" ]
354,194
<p>After upgrading a few gems via terminal on my mac, I have created a new rails project backed up by a mysql database. Upon starting the app, the regular welcome aboard page appears. </p> <p>Here's the problem - I tried clicking the link entitled "About your application's environment", I receive the following output in my browser:</p> <pre><code>MissingSourceFile in Rails/infoController#properties no such file to load -- mysql </code></pre> <p>I also receive this output in the terminal</p> <pre><code>The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET] Processing Rails::InfoController#properties (for 127.0.0.1 at 2008-12-09 20:41:41) [GET] MissingSourceFile (no such file to load -- mysql): ... </code></pre> <p>As it says, I tried issuing "gem install mysql" after stopping the application, only to be greeted by this chunk of jargon which I am unable to comprehend:</p> <pre><code>WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and /usr/bin aren't both writable. WARNING: You don't have /Users/mymac/.gem/ruby/1.8/bin in your PATH, gem executables will not run. Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib Gem files will remain installed in /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7 for inspection. Results logged to /Users/mymac/.gem/ruby/1.8/gems/mysql-2.7/gem_make.out </code></pre> <p>Clearly there is something wrong with my mysql installation, as I have also tried running the rake command to create the database, which prompted me with the following.</p> <pre><code>!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql (See full trace by running task with --trace) </code></pre> <p>However, when I run "mysql --version" at the command line, mysql is installed!</p> <pre><code>mysql Ver 14.12 Distrib 5.0.67, for apple-darwin9.4.0 (i686) using readline 5.1 </code></pre> <p>I also tried issuing "sudo gem install mysql", however that was also to no avail:</p> <pre><code>sudo gem install mysql Password: Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out </code></pre> <p>I also tried issuing "sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config" as instructed by bradheintz, which seemed to have installed ok, but after trying to view the application environment again, no ajaxy dropdown occurs and the rails app stops completely! The following output is printed just before the application decides to die on me lol.</p> <pre><code>dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Expected in: dynamic lookup dyld: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Expected in: dynamic lookup Trace/BPT trap </code></pre> <p>If anyone can understand what's going on here, and how to go about resolving this problem, I'd be very grateful :)</p>
[ { "answer_id": 354197, "author": "bradheintz", "author_id": 40093, "author_profile": "https://Stackoverflow.com/users/40093", "pm_score": 3, "selected": false, "text": "sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config" }, { "answer_id": 355133, ...
2008/12/09
[ "https://Stackoverflow.com/questions/354194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2294/" ]
354,195
<p>I'm finding that hitting the "Refresh" button on my browser will temporarily screw up the ViewState for controls inside an UpdatePanel.</p> <p>Here's my situation : I made a custom WebControl that stores values in the ViewState. I put this control inside an UpdatePanel. When I hit the "refresh" button on my browser, it will temporarily wipe out the values in ViewState. However, on the next postback, the values that were in the ViewState before I hit "refresh" magically reappear. </p> <p>This behavior screws up my webcontrol. After I hit "refresh," the control is returned to its initial state, since the ViewState is empty and IsPostBack is set to false. However, when I click on one of the postback controls within my WebControl, the WebControl will reload with the same values that were in ViewState before I hit "refresh." </p> <p>Strangely, this only happens when I'm using AJAX. When my control is outside of an UpdatePanel, Firefox gives me it's standard message, "To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier (Resend) (Cancel)." This is fine, because at least the behavior is consistent. However, I absolutely must use AJAX for this project.</p> <p>So this is what I would like to do - I want to make the "refresh" behavior consistent. It would be best if hitting "refresh" didn't affect the ViewState at all. But if it has to wipe out the ViewState, that's fine, as long as the ViewState STAYS wiped out. None of this stuff with values disappearing and reappearing.</p> <p>Oh yeah, and here's my example code :</p> <pre><code>using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace TestControls { public class TestControl : WebControl { int _clickCount; bool _mustUpdate; protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); _clickCount = ((int)ViewState["clickCount"]); _mustUpdate = ((bool)ViewState["mustUpdate"]); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); Controls.Clear(); ControlCreator(); } private void ControlCreator() { Label tempLabel = new Label(); LiteralControl tempLiteral = new LiteralControl("&lt;br/&gt;&lt;br/&gt;"); LinkButton tempLink = new LinkButton(); tempLink.ID = "testLink"; tempLink.Text = "Click me!"; tempLink.Click += new EventHandler(tempLink_Click); tempLabel.ID = "testLabel"; tempLabel.Text = _clickCount.ToString(); Controls.Add(tempLabel); Controls.Add(tempLiteral); Controls.Add(tempLink); } void tempLink_Click(object sender, EventArgs e) { _clickCount++; _mustUpdate = true; } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (_mustUpdate) { Controls.Clear(); ControlCreator(); _mustUpdate = false; } } protected override object SaveViewState() { ViewState["clickCount"] = _clickCount; ViewState["mustUpdate"] = _mustUpdate; return base.SaveViewState(); } } } </code></pre>
[ { "answer_id": 354608, "author": "BlackMael", "author_id": 19377, "author_profile": "https://Stackoverflow.com/users/19377", "pm_score": 1, "selected": false, "text": " protected override void LoadViewState(object savedState)\n {\n if (savedState != null)\n {\n ...
2008/12/09
[ "https://Stackoverflow.com/questions/354195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44701/" ]
354,201
<p>That's the question... Do you think ASP.Net is a technology suitable for high-load sites? Do you know any populer sites -apart from stackoverflow, of course- built with this technology? Thanks.</p>
[ { "answer_id": 354206, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 6, "selected": true, "text": "HttpHandler" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2166249/" ]
354,221
<p>What is the most efficient algorithm for grouping identical items together in an array, given the following:</p> <ol> <li>Almost all items are duplicated several times.</li> <li>The items are not necessarily integers or anything else that's similarly simple. The range of the keys is not even well-defined, let alone small. In fact, the keys can be arbitrary structs. This rules out the most simple forms of counting sort.</li> <li>We care about both asymptotic and non-asymptotic properties, and n may be small sometimes. However, when n is small, performance is still important because this function may be called several million times in a loop on millions of small datasets. This rules out any expensive hash function or using a complex data structure that needs to perform lots of memory allocations.</li> <li>The data may be sorted in arbitrary order as long as all identical items are grouped together.</li> </ol> <p>If this is confusing, here's an example, assuming such a function is named groupIdentical:</p> <pre><code>uint[] foo = [1,2,3,2,1,5,4,5]; uint[] bar = groupIdentical(foo); // One possibile correct value for bar: // bar == [2,2,1,1,3,4,5,5]. // Another possible correct answer: // bar == [1,1,2,2,5,5,4,3]. </code></pre> <p>However, as a reminder, we cannot assume that the data is composed as integers.</p> <p>Edit: Thank you for the answers. My main problem with hashing was that hash tables perform memory allocations to frequently. What I ended up doing was writing my own hash table that uses a region allocator that I had around to get around this problem. Works well.</p>
[ { "answer_id": 354265, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 0, "selected": false, "text": "uint[] bucket = new int[10];\nforeach(uint val in foo) {\n ++bucket[val];\n}\n\nuint bar_i = 0;\nuint[] bar = new int...
2008/12/09
[ "https://Stackoverflow.com/questions/354221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
354,224
<p>Using Firebird, I want to combine the results of two queries using UNION ALL, then sort the resulting output on a given column.</p> <pre><code>(select C1, C2, C3 from T1) union all (select C1, C2, C3 from T2) order by C3 </code></pre> <p>The parentheses came from valid syntax for other databases, and are needed to make sure the arguments to UNION ALL (an operation that's defined to work on tables - i.e. an <em>unordered</em> set of records) don't try to be ordered individually. However I couldn't get this syntax to work in Firebird--how can it be done?</p>
[ { "answer_id": 354242, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 6, "selected": true, "text": "SELECT C1, C2, C3\nFROM (\n select C1, C2, C3 from T1\n union all \n select C1, C2, C3 from T2\n)\norder by C3\n...
2008/12/09
[ "https://Stackoverflow.com/questions/354224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8415/" ]
354,226
<p>I want to be able to run my SqlDataProvider against an oracle stored procedure. I can use Microsoft's Oracle Provider but that wouldn't allow me to call a stored procedure. has anyone been able to get this to work? I particularly want to be able to use declarative data binding. I have been able to programatically create a DataTable but I want to do this declaratively in the .aspx. </p>
[ { "answer_id": 366442, "author": "user46119", "author_id": 46119, "author_profile": "https://Stackoverflow.com/users/46119", "pm_score": 2, "selected": false, "text": "using (OracleConnection conn = new OracleConnection(\"connection string here\"))\n{\n conn.Open();\n\n OracleComma...
2008/12/09
[ "https://Stackoverflow.com/questions/354226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
354,254
<p><s><a href="https://stackoverflow.com/questions/354160/what-do-you-do-while-your-codes-compiling#354176">An answer</a></s> <strong>(see below)</strong> to one of the questions right here on Stack&nbsp;Overflow gave me an idea for a great little piece of software that could be invaluable to coders everywhere.</p> <p>I'm imagining RAM drive software, but with one crucial difference - it would mirror a real folder on my hard drive. More specifically - the folder which contains the project I'm currently working on. This way any builds would be nearly instantaneous (or at least a couple orders of magnitude faster). The RAM drive would synchronize its contents with the hard disk drive in background using only idle resources.</p> <p>A quick Google search revealed nothing, but perhaps I just don't know how to Google. Perhaps someone knows of such a software? Preferably free, but reasonable fees might be OK too.</p> <p><b>Added:</b> Some solutions have been suggested which I discarded in the very beginning. They would be (in no particular order):</p> <ul> <li><b>Buy a faster hard disk drive (<a href="http://en.wikipedia.org/wiki/Solid-state_drive" rel="noreferrer">SSD</a> maybe or 10K RPM).</b> I don't want a hardware solution. Not only software has the potential to be cheaper (freeware, anyone?), but it can also be used in environments where hardware modifications would be unwelcome if not impossible - say, at the office.</li> <li><b>Let OS/HDD do the caching - it knows better how to use your free RAM.</b> The OS/HDD have generic cache algorithms that cache everything and try to predict which data will be most needed in the future. They have no idea that for me the priority is my project folder. And as we all know quite well - they don't really cache it much anyway. ;)</li> <li><b>There are plenty of RAM drives around; use one of those.</b> Sorry, that would be reckless. I need my data to be synchronized back to the HDD whenever there is a bit of free time. In the case of a power failure I could bear losing the last five minutes of work, but not everything since my last checkin.</li> </ul> <p><b>Added 2:</b> An idea that came up - use a normal RAM drive plus a background folder synchronizer (but I do mean <b>background</b>). Is there any such thing?</p> <p><b>Added 3:</b> Interesting. I just tried out a simple RAM drive at work. The rebuild time drops from ~14&nbsp;secs to ~7&nbsp;secs (not bad), but incremental build is still at ~5&nbsp;secs - just like on the HDD. Any ideas why? It uses <code>aspnet_compiler</code> and <code>aspnet_merge</code>. Perhaps they do something with other temp files elsewhere?</p> <p><b>Added 4:</b> Oh, nice new set of answers! :) OK, I've got a bit more info for all you naysayers. :)</p> <p>One of the main reasons for this idea is not the above-mentioned software (14&nbsp;secs build time), but another one that I didn't have access at the time. This other application has a 100&nbsp;MB code base, and its full build takes about 5 minutes. Ah yes, it's in <a href="http://en.wikipedia.org/wiki/Embarcadero_Delphi" rel="noreferrer">Delphi 5</a>, so the compiler isn't too advanced. :) Putting the source on a RAM drive resulted in a BIG difference. I got it below a minute, I think. I haven't measured. So for all those who say that the OS can cache stuff better - I'd beg to differ.</p> <p><strong>Related Question:</strong> </p> <blockquote> <p><a href="https://stackoverflow.com/questions/501718/ram-disk-for-speed-up-ide">RAM disk for speed up IDE</a></p> </blockquote> <p><strong>Note on first link:</strong> The question to which it links has been deleted because it was a duplicate. It asked:</p> <blockquote> <p>What do you do while your code’s compiling?</p> </blockquote> <p>And the answer by <a href="https://stackoverflow.com/users/9476/dmitri-nesteruk">Dmitri Nesteruk</a> to which I linked was:</p> <blockquote> <p>I compile almost instantly. Partly due to my projects being small, partly due to the use of RAM disks.</p> </blockquote>
[ { "answer_id": 354553, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 4, "selected": false, "text": "~/code" }, { "answer_id": 354733, "author": "composer", "author_id": 44811, "author_profile": "https://Stac...
2008/12/09
[ "https://Stackoverflow.com/questions/354254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41360/" ]
354,263
<p>Is there a CPAN module that can read a string like this:</p> <pre><code>"[[&lt;asdf&gt;, &lt;foo&gt;], (abc, def, ghi), ({'jkl'})]" </code></pre> <p>...and parse it into some sort of tree structure that's easy to walk and pretty-print?</p>
[ { "answer_id": 354388, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 0, "selected": false, "text": "eval" }, { "answer_id": 354821, "author": "brian d foy", "author_id": 2766176, "author_profile": "ht...
2008/12/09
[ "https://Stackoverflow.com/questions/354263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
354,264
<p>So regular expressions seem to match on the longest possible match. For instance:</p> <pre><code>public static void main(String[] args) { String s = "ClarkRalphKentGuyGreenGardnerClarkSupermanKent"; Pattern p = Pattern.compile("Clark.*Kent", Pattern.CASE_INSENSITIVE); Matcher myMatcher = p.matcher(s); int i = 1; while (myMatcher.find()) { System.out.println(i++ + ". " + myMatcher.group()); } } </code></pre> <p>generates output</p> <ol> <li>ClarkRalphKentGuyGreenGardnerClarkSupermanKent</li> </ol> <p>I would like this output</p> <ol> <li>ClarkRalphKent</li> <li>ClarkSupermanKent</li> </ol> <p>I have been trying Patterns like: </p> <pre><code> Pattern p = Pattern.compile("Clark[^((Kent)*)]Kent", Pattern.CASE_INSENSITIVE); </code></pre> <p>that don't work, but you see what I'm trying to say. I want the string from Clark to Kent that doesn't contain any occurrences of Kent.</p> <p>This string:</p> <p>ClarkRalphKentGuyGreenGardnerBruceBatmanKent</p> <p>should generate output </p> <ol> <li>ClarkRalphKent</li> </ol>
[ { "answer_id": 354289, "author": "Gareth Davis", "author_id": 31480, "author_profile": "https://Stackoverflow.com/users/31480", "pm_score": 4, "selected": true, "text": "Clark.+?Kent" }, { "answer_id": 354291, "author": "Adrian Pronk", "author_id": 41861, "author_prof...
2008/12/09
[ "https://Stackoverflow.com/questions/354264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34410/" ]
354,288
<p>I'm having a problem using CSS's <code>display:inline</code> property with the <code>list-style-image:</code> property on <code>&lt;li&gt;</code> tags. Basically, I want to output the following:</p> <pre><code>* Link 1 * Link 2 </code></pre> <p>where <code>*</code> represents an image.</p> <p>I'm doing this with the following bit of HTML:</p> <pre><code>&lt;ol class="widgets"&gt; &lt;li class="l1"&gt;Link 1&lt;/li&gt; &lt;li class="l2"&gt;Link 2&lt;/li&gt; &lt;/ol&gt; </code></pre> <p>which is styled with the following bit of CSS:</p> <pre><code>ol.widgets { list-style-type:none; } ol.widgets li { display:inline; margin-left:10px; } ol.widgets li.l1 { list-style-image:url(image1.gif); } ol.widgets li.l2 { list-style-image:url(image2.gif); } </code></pre> <p>The problem is that when the list items are displayed inline, the images associated with the list items do not appear. They <em>do</em> appear if I take out the <code>display:inline</code> property on the <code>&lt;li&gt;</code> tag.</p> <p>Is there a way to make the images appear even when the list items are displayed inline, or is that just impossible?</p>
[ { "answer_id": 354297, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 6, "selected": true, "text": "float: left" }, { "answer_id": 354304, "author": "flamingLogos", "author_id": 8161, "author_profile": ...
2008/12/09
[ "https://Stackoverflow.com/questions/354288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28804/" ]
354,309
<p>I am trying to do some simple formatting stuff with 'sed' in linux, and i need to use a regex to trim a string after the 15th character, and append a '...' to the end. Something like this:</p> <pre><code>before: this is a long string that needs to be shortened after: this is a long ... </code></pre> <p>Can anyone please show me how i could write this as a regex, and if possible explain how it works so that i might learn regex a little better?</p>
[ { "answer_id": 354318, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": true, "text": "echo \"This is a test with more than 15 characters\" | sed \"s/\\(.\\{15\\}\\).\\+$/\\1…/\"\n" }, { "answer_id...
2008/12/09
[ "https://Stackoverflow.com/questions/354309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
354,312
<p>When you run <code>git branch -r</code> why the blazes does it list <code>origin/HEAD</code>? For example, there's a remote repo on GitHub, say, with two branches: master and awesome-feature. If I do <code>git clone</code> to grab it and then go into my new directory and list the branches, I see this:</p> <pre><code>$ git branch -r origin/HEAD origin/master origin/awesome-feature </code></pre> <p>Or whatever order it would be in (alpha? I'm faking this example to keep the identity of an innocent repo secret). So what's the <code>HEAD</code> business? Is it what the last person to <code>push</code> had their <code>HEAD</code> pointed at when they pushed? Won't that always be whatever it was they <code>push</code>ed? <code>HEAD</code>s move around... why do I care what someone's <code>HEAD</code> pointed at on another machine?</p> <p>I'm just getting a handle on remote tracking and such, so this is one lingering confusion. Thanks!</p> <p>EDIT: I was under the impression that dedicated remote repos (like GitHub where no one will ssh in and work on that code, but only pull or push, etc) didn't and shouldn't have a HEAD because there was, basically, no working copy. Not so?</p>
[ { "answer_id": 354617, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": -1, "selected": false, "text": "git push origin HEAD\n" }, { "answer_id": 357062, "author": "Paul", "author_id": 23356, "author_profil...
2008/12/09
[ "https://Stackoverflow.com/questions/354312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9619/" ]
354,313
<p>How can I force the input's onchange script to run <em>before</em> the RangeValidator's script? </p> <p>I want to prevent a failed validation when the user enters a dollar sign or comma.</p> <pre><code>function cleanUp(str) { re = /^\$|,/g; return str.replace(re, ""); // remove "$" and "," } &lt;input type="text" id="salary" runat="server" onchange="this.value=cleanUp(this.value)" /&gt; &lt;asp:RangeValidator ID="salaryValidator" runat="server" ErrorMessage="Invalid Number" ControlToValidate="salary" Type="Double" /&gt; </code></pre> <p><strong>UPDATE:</strong> <br /> I decided to use a CustomValidator that checks the range and uses a currency RegEx. Thanks Michael Kniskern.</p> <pre><code>function IsCurrency(sender, args) { var input = args.Value; // Check for currency formatting. // Expression is from http://regexlib.com/REDetails.aspx?regexp_id=70 re = /^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$/; isCurrency = input.match(re); if (isCurrency) { // Convert the string to a number. var number = parseFloat(CleanUp(input)); if (number != NaN) { // Check the range. var min = 0; var max = 1000000; if (min &lt;= number &amp;&amp; max &gt;= number) { // Input is valid. args.IsValid = true; return; } } } // Input is not valid if we reach this point. args.IsValid = false; return; } function CleanUp(number) { re = /^\$|,/g; return number.replace(re, ""); // remove "$" and "," } &lt;input type="text" id="salary" runat="server" /&gt; &lt;asp:CustomValidator ID="saleryValidator" ControlToValidate="salary" runat="server" ErrorMessage="Invalid Number" ClientValidationFunction="IsCurrency" /&gt; </code></pre>
[ { "answer_id": 1752683, "author": "Giablo", "author_id": 213361, "author_profile": "https://Stackoverflow.com/users/213361", "pm_score": 0, "selected": false, "text": "\\." }, { "answer_id": 5188190, "author": "Eric Eggers", "author_id": 528733, "author_profile": "htt...
2008/12/09
[ "https://Stackoverflow.com/questions/354313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23566/" ]
354,329
<p>I'm trying to set an invalid value to -1.. But I don't like magic numbers.. Anyone know where to find a set of common constants. I'm working in VS6 (ish). </p> <p>I'm trying to read a file from across a network, and I need a bad value for the total file size,so I know if I got valid info on it.. 0 is a valid size so I can't use that. </p> <p>Harper Shelby HIT THE NAIL ON THE HEAD.. Just a little thumb. He mentioned the win32 constants.. which is exactly what I was thinking about.. Now to find a link :)</p>
[ { "answer_id": 354343, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": true, "text": "#define BAD_VALUE -1\n" }, { "answer_id": 354347, "author": "Harper Shelby", "author_id": 21196, "...
2008/12/09
[ "https://Stackoverflow.com/questions/354329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31325/" ]
354,330
<p>I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone can give me an answer as to whether it is or not. And I'm looking for more of an answer than just yes or no. I'd like to know why. If you can say,"This is basically this problem 'x' which is/is not NP-Complete. (wikipedia link)"</p> <p>(No this is not homework)</p> <p>Is there a way to determine if two points are connected on an arbitrary non-directed graph. e.g., the following</p> <pre><code>Well | | A | +--B--+--C--+--D--+ | | | | | | | | E F G H | | | | | | | | +--J--+--K--+--L--+ | | M | | House </code></pre> <p>Points A though M (no 'I') are control points (like a valve in a natural gas pipe) that can be either open or closed. The '+'s are nodes (like pipe T's), and I guess the Well and the House are also nodes as well.</p> <p>I'd like to know if I shut an arbitrary control point (e.g., C) whether the Well and House are still connected (other control points may also be closed). E.g., if B, K and D are closed, we still have a path through A-E-J-F-C-G-L-M, and closing C will disconnect the Well and the House. Of course; if just D was closed, closing only C does not disconnect the House.</p> <p>Another way of putting this, is C a bridge/cut edge/isthmus?</p> <p>I could treat each control point as a weight on the graph (either 0 for open or 1 for closed); and then find the shortest path between Well and House (a result >= 1 would indicate that they were disconnected. There's various ways I can short circuit the algorithm for finding the shortest path too (e.g., discard a path once it reaches 1, stop searching once we have ANY path that connects the Well and the House, etc.). And of course, I can also put in some artificial limit on how many hops to check before giving up.</p> <p>Someone must have classified this kind of problem before, I'm just missing the name.</p>
[ { "answer_id": 354366, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 5, "selected": false, "text": "Create two sets of nodes: toDoSet and doneSet\nAdd the source node to the toDoSet \nwhile (toDoSet is not empty) {\n...
2008/12/09
[ "https://Stackoverflow.com/questions/354330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685/" ]
354,349
<p>Is it possible to change the auto-increment offset on a pre-existing table with JavaDB? </p> <p>I'm having a problem where inserting new records usually (but not always) fails with an error complaining about using an existing key (my auto-increment column). To populate this database, I took a dump from another database (MySQL) and used a JavaDB stored procedure to insert them all into the corresponding JavaDB table. My theory is that inserting these records copied the existing IDs from the MySQL table. Now the auto-increment functionality is dishing out existing IDs. I figure explicitly setting the offset to some high number will allow the auto-increment to work again.</p>
[ { "answer_id": 354517, "author": "Tim Frey", "author_id": 1471, "author_profile": "https://Stackoverflow.com/users/1471", "pm_score": 1, "selected": true, "text": "ALTER TABLE tbl ALTER COLUMN col SET INCREMENT BY x\n" }, { "answer_id": 4225357, "author": "cweiske", "auth...
2008/12/09
[ "https://Stackoverflow.com/questions/354349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1471/" ]
354,354
<p>I'm using StructureMap in my project and when the application finishes running I need to call the Dispose() method on all of the Singleton instances inside the ObjectFactory that implement IDisposable.</p> <p>I cannot find anyway to do it via the StructureMap API.</p> <p>Another thought I had was to get a reference to every instance and call it myself, but I cannot figure out how to loop through all of the instances.</p>
[ { "answer_id": 354517, "author": "Tim Frey", "author_id": 1471, "author_profile": "https://Stackoverflow.com/users/1471", "pm_score": 1, "selected": true, "text": "ALTER TABLE tbl ALTER COLUMN col SET INCREMENT BY x\n" }, { "answer_id": 4225357, "author": "cweiske", "auth...
2008/12/09
[ "https://Stackoverflow.com/questions/354354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
354,369
<p>In C# how do I still show the headers of a gridview, even with the data source is empty. </p> <p>I am not auto generating the columns as they are all predefined. </p> <p>Currently what I am doing is the following.</p> <p>Get a DataTable back from a stored procedure, then set the DataSource of the gridview, and then call DataBind().</p> <p>This works fine when I have data, but when no rows are returned then I just get a blank spot where the grid should be.</p> <p><strong>Edit: Thanks all for the .NET 4+ property. I asked this back in the .NET 3.5 days. This is much easier now. :)</strong></p>
[ { "answer_id": 354391, "author": "Joshua Hudson", "author_id": 6232, "author_profile": "https://Stackoverflow.com/users/6232", "pm_score": 5, "selected": false, "text": "//Check to see if we get rows back, if we do just bind.\n\nif (dtFunding.Rows.Count != 0)\n{\n grdFunding.DataSourc...
2008/12/09
[ "https://Stackoverflow.com/questions/354369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6232/" ]
354,374
<p>I have a project that uses a class library for the business layer functionality (database access, etc.). A web application sits on top of this. I have a web service that I would like to call in the class library. Every time I add a 'service reference' (I am using VS2008) to the class library, everything seems to work OK. The name of the web service is 'EmployeeService'. However, when I try to access it from code, intellisense gives me options like: </p> <p>'EmployeeServiceSoap'</p> <p>'EmployeeServiceSoapChannel'</p> <p>'EmployeeServiceSoapClient'</p> <p>and lots of '...Request'</p> <p>'...RequestBody'</p> <p>'...RequestResponse' types. </p> <p>I can't access my EmployeeService class even if I write it anyway the compiler will complain. Any ideas? Thanks for any help...</p>
[ { "answer_id": 354424, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": false, "text": "EmployeeServiceSoapClient" } ]
2008/12/09
[ "https://Stackoverflow.com/questions/354374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
354,385
<p>I would like to create a view similar to the "Now Playing" page on the iPhone and have 3 lines of text in the Navigation bar.</p> <p>The only way I could find to do this was:</p> <pre><code>UINavigationBar *bar = [self.navigationController navigationBar]; label = [[UILabel alloc] initWithFrame:CGRectMake(60, 2, 200, 14)]; label.tag = SONG_TAG; label.backgroundColor = [UIColor clearColor]; label.font = [UIFont boldSystemFontOfSize:14]; label.adjustsFontSizeToFitWidth = NO; label.textAlignment = UITextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.highlightedTextColor = [UIColor blackColor]; [bar addSubview:label]; [label release]; //Create album label label = [[UILabel alloc] initWithFrame:CGRectMake(60, 17, 200, 12)]; label.tag = ALBUM_TAG; label.backgroundColor = [UIColor clearColor]; label.font = [UIFont systemFontOfSize:12]; label.adjustsFontSizeToFitWidth = NO; label.textAlignment = UITextAlignmentCenter; label.highlightedTextColor = [UIColor blackColor]; label.textColor = HEXCOLOR(0xA5A5A5ff); [bar addSubview:label]; [label release]; //Create artist label label = [[UILabel alloc] initWithFrame:CGRectMake(60, 30, 200, 12)]; label.tag = ARTIST_TAG; label.backgroundColor = [UIColor clearColor]; label.font = [UIFont systemFontOfSize:12]; label.adjustsFontSizeToFitWidth = NO; label.textAlignment = UITextAlignmentCenter; label.highlightedTextColor = [UIColor blackColor]; label.textColor = HEXCOLOR(0xA5A5A5ff); [bar addSubview:label]; [label release]; </code></pre> <p>The problem with this is I have to remove them when the view changes. So, in -viewWillDisappear I have:</p> <pre><code>UILabel *label; label = (UILabel *)[self.navigationController.navigationBar viewWithTag:SONG_TAG]; [label removeFromSuperview]; label = (UILabel *)[self.navigationController.navigationBar viewWithTag:ALBUM_TAG]; [label removeFromSuperview]; label = (UILabel *)[self.navigationController.navigationBar viewWithTag:ARTIST_TAG]; [label removeFromSuperview]; </code></pre> <p>I think the way to do this is make a custom view that has the 3 labels in it, and add this to the title view. (here's the catch - you can only add 1 label or view to the title view spot on the nav bar)</p> <pre><code>self.navigationItem.titleView = newViewIMadeWithThreeLabels </code></pre>
[ { "answer_id": 369966, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];\nbtn.frame = CGRectMake(0, 0, 320, 60);\n\nUILabel *label;\...
2008/12/09
[ "https://Stackoverflow.com/questions/354385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
354,386
<p>I have a Windows Mobile application using the compact framework (NETCF) that I would like to respond to someone pressing the send key and have the phone dial the number selected in my application. Is there a way using the compact framework to trap the send key? I have looked at several articles on capturing keys, but I have not found one that includes the "Send" key.</p> <p><strong>Update</strong>:</p> <p>I found an article describing SetWindowsHookEx as an undocumented API on Windows Mobile. If this is the case then I really don't want to use it.</p> <p><a href="http://blogs.msdn.com/raffael/archive/2008/05/12/setwindowshookex-on-windows-mobile.aspx" rel="nofollow noreferrer">SetWindowsHookEx on Windows Mobile</a></p> <p>After doing more searching I found out that the "Send" key is called the "Talk" key in Windows Mobile lingo. I then found a blog post about using the SHCMBM_OVERRIDEKEY message to signal the OS to send my app a WM_HOTKEY message when the user presses the Talk key.</p> <p><a href="http://blogs.msdn.com/windowsmobile/archive/2005/09/02/460327.aspx" rel="nofollow noreferrer">Jason Fuller Blog post about using the Talk button</a></p> <p>The blog post and the documentation it points to seem like exactly what I'm looking for. I'm unable to find a working example, and I find a lot of people unable to make it work. It also looks like VK_TTALK is not supported in SmartPhones. I would love to hear from someone that actually has this working on both Smartphones and PocketPC phones.</p>
[ { "answer_id": 554375, "author": "Shane Powell", "author_id": 23235, "author_profile": "https://Stackoverflow.com/users/23235", "pm_score": 3, "selected": true, "text": "SendMessage(SHFindMenuBar(window_hwnd), \n SHCMBM_OVERRIDEKEY, \n VK_TTALK, \n MAKELP...
2008/12/09
[ "https://Stackoverflow.com/questions/354386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/791/" ]
354,393
<p>** Dup: <a href="https://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x">What&#39;s the difference between X = X++; vs X++;?</a> **</p> <p>So, even though I know you would never actually do this in code, I'm still curious:</p> <pre><code>public static void main(String[] args) { int index = 0; System.out.println(index); // 0 index++; System.out.println(index); // 1 index = index++; System.out.println(index); // 1 System.out.println(index++); // 1 System.out.println(index); // 2 } </code></pre> <p>Note that the 3rd <code>sysout</code> is still <code>1</code>. In my mind the line <code>index = index++;</code> means "set index to index, then increment index by 1" in the same way <code>System.out.println(index++);</code> means "pass index to the println method then increment index by 1".</p> <p>This is not the case however. Can anyone explain what's going on?</p>
[ { "answer_id": 354398, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 3, "selected": true, "text": "a = function() {\n var old_value = a;\n a++;\n return old_value;\n}\n" }, { "answer_id": 354404, "author": "C...
2008/12/09
[ "https://Stackoverflow.com/questions/354393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
354,407
<p>I totally understand the MVP pattern now, but I still struggle to see where views and presenters are instantiated. I have seen some examples where the presenter is newed up in the view, but is this correct. After reading a blog post of Jeremy Miller about communicating between View and Presenter he had a function on the Presenter to attach the presenter to the view.</p> <p>My question is then this: Where should views and presenters be created? Also where in winforms and webforms.</p>
[ { "answer_id": 354485, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https://Stackoverflow.com/users/21849", "pm_score": 2, "selected": false, "text": "main" }, { "answer_id": 14389890, "author": "nawfal", "author_id": 661933, "author_profile": "https...
2008/12/09
[ "https://Stackoverflow.com/questions/354407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12230/" ]
354,408
<p>It seems like when you have a WinForms .NET application, and a ComboBox (set to the "DropDown" style), and that ComboBox has multiple items in it that are identical, weird things happen. Specifically, the index of the selected item can change <em>without</em> firing the SelectedIndexChanged event. </p> <p>Of course, this causes mass confusion and weird, obscure errors, which is what I've been pulling my hair out over lately.</p> <p>Here's a simple example you can use to see what I'm talking about:</p> <ul> <li>Make a new .NET WinForms project (I use VB.NET, but feel free to translate - it's simple enough).</li> <li>Drop a ComboBox, a button, and a TextBox (set MultiLine=True) onto the form.</li> <li>Use the following code to load the ComboBox with 3 identical items and to print some status messages when the SelectedIndexChanged event fires, and to see what the currently selected index is (via a button):</li> </ul> <pre><code>Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = TextBox1.Text & vbNewLine & "ComboBox SelectedIndexChanged event fired." & vbNewLine & _ "SelectedIndex is: " & ComboBox1.SelectedIndex End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ComboBox1.Items.Add("John Doe") ComboBox1.Items.Add("John Doe") ComboBox1.Items.Add("John Doe") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = TextBox1.Text & vbNewLine & _ "Button clicked." & vbNewLine & _ "SelectedIndex is: " & ComboBox1.SelectedIndex End Sub</code></pre> <p>Run the project and select an item from the ComboBox (say, the middle one). Then, click the ComboBox's drop-down arrow, but DON'T SELECT ANYTHING. Click the Button (Button1 by default) and see what it says.</p> <p>Unless I've lost my mind, here's what you should see:</p> <pre>ComboBox SelectedIndexChanged event fired. SelectedIndex is: 1 Button clicked. SelectedIndex is: 0</pre> <p>In other words, the SELECTED INDEX HAS CHANGED but without the SelectedIndexChanged event firing!</p> <p>This only happens when the items in the ComboBox are identical. If they're different, this doesn't happen. (It also doesn't happen if the ComboBox's "DropDown" style is set to "DropDownList.")</p> <p>I suspect this may be a bug in the .NET framework itself and not something I can fix, but on the off chance that anyone else has any ideas on what to do here (or what I might be doing wrong!), please chime in! I'm at a loss to explain this behavior or work around it (I expect the SelectedIndex to stay the same unless, y'know, you actually CHANGE it by selecting something else!)</p>
[ { "answer_id": 355012, "author": "Eric Rosenberger", "author_id": 41624, "author_profile": "https://Stackoverflow.com/users/41624", "pm_score": 5, "selected": true, "text": "CBN_SELCHANGE" }, { "answer_id": 923031, "author": "Community", "author_id": -1, "author_profi...
2008/12/09
[ "https://Stackoverflow.com/questions/354408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5956/" ]
354,414
<p>Can anybody help me to build an XSD file to validate XMLs like these:</p> <pre><code>[test] [a/] [b/] [a/] [b/] [/test] [test] [a/] [a/] [b/] [/test] </code></pre> <p>Basically, I can have any number of <code>&lt;a&gt;</code> and/or <code>&lt;b&gt;</code> nodes without any other rule (can't use <code>&lt;xs:sequence&gt;</code>).</p>
[ { "answer_id": 354908, "author": "MotoWilliams", "author_id": 2730, "author_profile": "https://Stackoverflow.com/users/2730", "pm_score": 2, "selected": true, "text": "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n <xs:element name=\"test\">\n <xs:complexType>\n <xs...
2008/12/09
[ "https://Stackoverflow.com/questions/354414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44769/" ]
354,415
<p>I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created my project from the template, it created a "Tests" project as well and put some controller tests for the AccountController in a folder inside this project. I've added other controllers and associated tests. Howerver, when I right-click on a method in a controller and use the "Create Unit Tests" dialog it fails to create the unit test stub in my existing test class in the project. It creates a new test class file with the same name at the root of the test project, but doesn't insert the test stub. If I move the controller tests up one level from the controllers folder in the test project it works fine.</p> <p>Does anyone else see this behavior or is it something related to my particular set up? I wouldn't have noticed, but the project segregated the tests in a separate folder, which I thought was a good idea. Now that I'm trying to use it, I either have to create new tests by hand or undo the segregation. If it's just me, any ideas on where to adjust the behavior to fix it?</p> <p>I have <code>Visual C# test project</code> selected as default in options, with <code>Unit Test</code> as the only file included.</p>
[ { "answer_id": 354908, "author": "MotoWilliams", "author_id": 2730, "author_profile": "https://Stackoverflow.com/users/2730", "pm_score": 2, "selected": true, "text": "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n <xs:element name=\"test\">\n <xs:complexType>\n <xs...
2008/12/09
[ "https://Stackoverflow.com/questions/354415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12950/" ]
354,419
<p>I'm migrating to Nhibernate 2.0 GA but have some trouble with setting cache expirations in memcached provider.</p> <p>I see in the NHibernate.Caches.MemCache sources that there is a property for expiration and a default value for 300 seconds. </p> <p>There are also properties for cache regions but the config section handler does not seem to map them.</p> <p>Is there some other way cache expiration times are set that is not provider specific --</p> <p>Here is functional web config section (without an expiration settings obviously).</p> <pre><code>&lt;memcache&gt; &lt;memcached host="127.0.0.1" port="11211"/&gt; &lt;!-- or multiples --&gt; &lt;/memcache&gt; &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt; &lt;session-factory&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="connection.provider" &gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt; &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2000Dialect&lt;/property&gt; &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt; &lt;!-- &lt;property name="hibernate.cache.provider_class" value="NHibernate.Caches.MemCache.MemCacheProvider,NHibernate.Caches.MemCache" /&gt; --&gt; &lt;property name="connection.connection_string"&gt;Data Source=stage2.ripple6.com;Initial Catalog=r6stage;User Id=sa;Password=mworld7650;Application Name=Hibernate;&lt;/property&gt; &lt;property name="connection.isolation"&gt;ReadCommitted&lt;/property&gt; &lt;property name="cache.use_second_level_cache"&gt;true&lt;/property&gt; &lt;property name="cache.provider_class"&gt;NHibernate.Caches.MemCache.MemCacheProvider,NHibernate.Caches.MemCache&lt;/property&gt; &lt;property name="default_schema" &gt;r6stage.dbo&lt;/property&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre>
[ { "answer_id": 444445, "author": "jozefsevcik", "author_id": 11472, "author_profile": "https://Stackoverflow.com/users/11472", "pm_score": -1, "selected": true, "text": "<property name=\"expiration\" >YOUR_INTERVAL_IN_SECONDS</property>\n" }, { "answer_id": 5933302, "author":...
2008/12/09
[ "https://Stackoverflow.com/questions/354419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43853/" ]
354,421
<p>I'm wondering where I find the source to show how the operator ** is implemented in Python. Can someone point me in the right direction? </p>
[ { "answer_id": 354626, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 6, "selected": true, "text": "PyObject *\nPyNumber_Power(PyObject *v, PyObject *w, PyObject *z)\n{\n return ternary_op(v, w, z, NB_SLOT(nb_power),...
2008/12/09
[ "https://Stackoverflow.com/questions/354421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
354,442
<p>Before I write my own I will ask all y'all.</p> <p>I'm looking for a C++ class that is almost exactly like a STL vector but stores data into an array on the stack. Some kind of STL allocator class would work also, but I am trying to avoid any kind of heap, even static allocated per-thread heaps (although one of those is my second choice). The stack is just more efficient.</p> <p>It needs to be almost a drop in replacement for current code that uses a vector.</p> <p>For what I was about to write myself I was thinking of something like this:</p> <pre><code>char buffer[4096]; stack_vector&lt;match_item&gt; matches(buffer, sizeof(buffer)); </code></pre> <p>Or the class could have buffer space allocated internally. Then it would look like:</p> <pre><code>stack_vector&lt;match_item, 256&gt; matches; </code></pre> <p>I was thinking it would throw std::bad_alloc if it runs out of space, although that should not ever happen.</p> <p><strong>Update</strong></p> <p>Using Chromium's stack_container.h works great! </p> <p>The reason I hadn't thought of doing it this way myself is that I have always overlooked the allocator object parameter to the STL collection constructors. I have used the template parameter a few times to do static pools but I'd never seen code or written any that actually used the object parameter. I learned something new. Very cool!</p> <p>The code is a bit messy and for some reason GCC forced me to declare the allocator as an actual item instead of constructing it into vector's allocator parameter. It went from something like this:</p> <pre><code>typedef std::pair&lt; const char *, const char * &gt; comp_list_item; typedef std::vector&lt; comp_list_item &gt; comp_list_type; comp_list_type match_list; match_list.reserve(32); </code></pre> <p>To this:</p> <pre><code>static const size_t comp_list_alloc_size = 128; typedef std::pair&lt; const char *, const char * &gt; comp_list_item; typedef StackAllocator&lt; comp_list_item, comp_list_alloc_size &gt; comp_list_alloc_type; typedef std::vector&lt; comp_list_item, comp_list_alloc_type &gt; comp_list_type; comp_list_alloc_type::Source match_list_buffer; comp_list_alloc_type match_list_alloc( &amp;match_list_buffer ); comp_list_type match_list( match_list_alloc ); match_list.reserve( comp_list_alloc_size ); </code></pre> <p>And I have to repeat that whenever I declare a new one. But it works just like I wanted.</p> <p>I noticed that stack_container.h has a StackVector defined and I tried using it. But it doesn't inherit from vector or define the same methods so it wasn't a drop-in replacement. I didn't want to rewrite all the code using the vector so I gave up on it.</p>
[ { "answer_id": 354481, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 7, "selected": true, "text": "std::vector" }, { "answer_id": 354818, "author": "Michael Burr", "author_id": 12711, "au...
2008/12/09
[ "https://Stackoverflow.com/questions/354442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13422/" ]
354,445
<p>Is there an easy method to restore a minimized form to its previous state, either Normal or Maximized? I'm expecting the same functionality as clicking the taskbar (or right-clicking and choosing restore).</p> <p>So far, I have this, but if the form was previously maximized, it still comes back as a normal window.</p> <pre><code>if (docView.WindowState == FormWindowState.Minimized) docView.WindowState = FormWindowState.Normal; </code></pre> <p>Do I have to handle the state change in the form to remember the previous state?</p>
[ { "answer_id": 354493, "author": "jeffm", "author_id": 1544, "author_profile": "https://Stackoverflow.com/users/1544", "pm_score": 3, "selected": false, "text": "SendMessage(docView.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);\n" }, { "answer_id": 1398956, "author": "Community", ...
2008/12/09
[ "https://Stackoverflow.com/questions/354445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44770/" ]
354,449
<p>Anyone know the <code>&lt;%= %&gt;</code> or <code>Response.Write()</code> code for getting the version of .Net my web app is running on?</p>
[ { "answer_id": 354460, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 5, "selected": true, "text": "System.Environment.Version" }, { "answer_id": 623246, "author": "Community", "author_id": -1, "author_profil...
2008/12/09
[ "https://Stackoverflow.com/questions/354449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
354,473
<p>What's the best way to load HTML markup for a custom jQuery UI widget?</p> <p>So far, I've seen elements simply created using strings (i.e. <code>$(...).wrap('&lt;div&gt;&lt;/div&gt;')</code>) which is fine for something simple. However, this makes it extremely difficult to modify later for more complex elements.</p> <p>This seems like a fairly common problem, but I also know that the jQuery UI library is new enough that there may not be a widely accepted solution for this. Any ideas?</p>
[ { "answer_id": 354537, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 4, "selected": true, "text": "var newDiv = $(\"<div></div>\"); //Create a new element and save a reference\nnewDiv.attr(\"id\",\"someid\").appendTo...
2008/12/09
[ "https://Stackoverflow.com/questions/354473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]