qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
42,187 | <p>I have read about partial methods in the latest <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx" rel="noreferrer">C# language specification</a>, so I understand the principles, but I'm wondering how people are actually using them. Is there a particular design pattern that benefits from partial methods?</p>
| [
{
"answer_id": 43557,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 6,
"selected": true,
"text": "#region"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] |
42,203 | <p>I'm looking to use SQL to format a number with commas in the thousands, but no decimal (so can't use Money) - any suggestions?</p>
<p>I'm using SQL Server 2005, but feel free to answer for others as well (like MySQL)</p>
| [
{
"answer_id": 42209,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 2,
"selected": false,
"text": "FORMAT()"
},
{
"answer_id": 42224,
"author": "Scott Nichols",
"author_id": 4299,
"author_profile":... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
42,215 | <p>We get the following error;</p>
<pre><code>The request was aborted: Could not create SSL/TLS secure channel
</code></pre>
<p>while using a <code>WebRequest</code> object to make an <code>HTTPS</code> request. The funny thing is that this only happens after a while, and is temporarily fixed when the application is restarted, which suggests that something is being filled to capacity or something. </p>
<p>Has anyone seen this kind of thing before?</p>
| [
{
"answer_id": 32132106,
"author": "Vyacheslav Kinzerskiy",
"author_id": 5250067,
"author_profile": "https://Stackoverflow.com/users/5250067",
"pm_score": 1,
"selected": false,
"text": "System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659/"
] |
42,239 | <p>We're doing an "Amazing Race" kind of event, and thought it would be cool to have CDs that could only play once... like a "this message will self destruct in 5 seconds..." </p>
<p>Any thoughts on how to do this? I was thinking it could be a compiled HTML website that would write a cookie and only play once. I don't want to write to the registry (don't want to depend on windows, don't want to install anything, etc).</p>
<p>I also don't care if it's hackable... This is a one-time fun event, and I don't really care too much if people could remove the cookie or something.</p>
<p>Any other ideas?</p>
| [
{
"answer_id": 42417,
"author": "Domenic",
"author_id": 3191,
"author_profile": "https://Stackoverflow.com/users/3191",
"pm_score": 2,
"selected": false,
"text": "Math.floor(PI * E + 32/(new DateTime()).getYear())"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1753/"
] |
42,246 | <p>I have somewhat interesting development situation. The client and deployment server are inside a firewall without access to the Subversion server. But the developers are outside the firewall and are able to use the Subversion server. Right now the solution I have worked out is to update my local copy of the code and then pull out the most recently updated files using UnleashIT. </p>
<p>The question is how to get just the updated files out of Subversion so that they can be physically transported through the firewall and put on the deployment server.</p>
<p>I'm not worried about trying to change the firewall setup or trying to figure out an easier way to get to the Subversion server from inside the firewall. I'm just interested in a way to get a partial export from the repository of the most recently changed files.</p>
<p>Are there any other suggestions?</p>
<p>Answer found: In addition to the answer I marked as Answer, I've also found the following here to be able to do this from TortoiseSVN:</p>
<p>from <a href="http://svn.haxx.se/tsvn/archive-2006-08/0051.shtml" rel="nofollow noreferrer">http://svn.haxx.se/tsvn/archive-2006-08/0051.shtml</a></p>
<pre><code>* select the two revisions
* right-click, "compare revisions"
* select all files in the list
* right-click, choose "export to..."
</code></pre>
| [
{
"answer_id": 42503,
"author": "Dylan Bennett",
"author_id": 551,
"author_profile": "https://Stackoverflow.com/users/551",
"pm_score": 1,
"selected": false,
"text": "/\n|+-DIR1\n| |- FILEa\n| |- FILEb\n|+-DIR2\n| |- FILEc\n| |- FILEd\n|- FILEe\n|- FILEf\n"
},
{
"answer_i... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3442/"
] |
42,247 | <p>The following code illustrates an object literal being assigned, but with no semicolon afterwards:</p>
<pre><code>var literal = {
say: function(msg) { alert(msg); }
}
literal.say("hello world!");
</code></pre>
<p>This appears to be legal, and doesn't issue a warning (at least in Firefox 3). Is this completely legal, or is there a strict version of JavaScript where this is not allowed?</p>
<p>I'm wondering in particular for future compatibility issues... I would like to be writing "correct" JavaScript, so if technically I need to use the semicolon, I would like to be using it.</p>
| [
{
"answer_id": 42259,
"author": "Kamiel Wanrooij",
"author_id": 4174,
"author_profile": "https://Stackoverflow.com/users/4174",
"pm_score": -1,
"selected": false,
"text": "var foo = \"bar\";\n"
},
{
"answer_id": 42269,
"author": "Travis",
"author_id": 4284,
"author_pr... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] |
42,251 | <p>Has anyone worked much with Microsoft's Managed Extensibility Framework (MEF)? Kinda sounds like it's trying to be all things to all people - It's an add-in manager! It's duck typing! I'm wondering if anyone has an experience with it, positive or negative.</p>
<p>We're currently planning on using an generic IoC implementation ala MvcContrib for our next big project. Should we throw MEF in the mix?</p>
| [
{
"answer_id": 57884,
"author": "Andy S",
"author_id": 3759,
"author_profile": "https://Stackoverflow.com/users/3759",
"pm_score": 3,
"selected": false,
"text": "private IGreetings greetings = CompositionServices.Empty<IGreetings>();\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3759/"
] |
42,254 | <p>I would like to flash a success message on my page.</p>
<p>I am using the jQuery <code>fadeOut</code> method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange.</p>
<p>What I would like to happen is have the element be displayed for five seconds, then fade quickly, and finally be removed.</p>
<p>How can you animate this using jQuery? </p>
| [
{
"answer_id": 42255,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": false,
"text": "setTimeout(function(){$elem.hide();}, 5000);"
},
{
"answer_id": 42261,
"author": "Ricky",
"author_id": ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645/"
] |
42,281 | <p>It seems that IE6 ignores any form of cache invalidation sent via http headers, I've tried setting Pragma to No Cache and setting Cache Expiration to the current time, yet in IE6, hitting back will always pull up a cached version of a page I am working on.</p>
<p>Is there a specific HTTP Header that IE6 does listen too?</p>
| [
{
"answer_id": 43271,
"author": "Hafthor",
"author_id": 4489,
"author_profile": "https://Stackoverflow.com/users/4489",
"pm_score": 4,
"selected": true,
"text": "Cache-Control: private, max-age=0"
},
{
"answer_id": 203450,
"author": "thesmart",
"author_id": 20176,
"au... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
42,286 | <p>It seems like there should be something shorter than this:</p>
<pre><code>private string LoadFromFile(string path)
{
try
{
string fileContents;
using(StreamReader rdr = File.OpenText(path))
{
fileContents = rdr.ReadToEnd();
}
return fileContents;
}
catch
{
throw;
}
}
</code></pre>
| [
{
"answer_id": 42292,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": false,
"text": "string text = File.ReadAllText(\"c:\\file1.txt\");\nFile.WriteAllText(\"c:\\file2.txt\", text);\n"
},
{
"answ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3475/"
] |
42,294 | <p>I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in all browsers. It works if the content pushes the footer down, but that's not always the case. </p>
| [
{
"answer_id": 42301,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 9,
"selected": true,
"text": "<div>"
},
{
"answer_id": 42314,
"author": "Raleigh Buckner",
"author_id": 1153,
"author_profile": "https://... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] |
42,308 | <p>Any good suggestions? Input will be the name of a header file and output should be a list (preferably a tree) of all files including it directly or indirectly.</p>
| [
{
"answer_id": 42513,
"author": "KeithB",
"author_id": 2298,
"author_profile": "https://Stackoverflow.com/users/2298",
"pm_score": 8,
"selected": true,
"text": "-M"
},
{
"answer_id": 1763463,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackover... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45603/"
] |
42,323 | <p>I have the next function:</p>
<pre><code>function setImagesWidth(id,width) {
var images = document.getElementById(id).getElementsByTagName("img");
for(var i = 0; i < images.length;i++) {
// If the real width is bigger than width parameter
images[i].style.width=width;
//}
}
}
</code></pre>
<p>I would like to set the css width attribute of all my img tags to a particular value only when the image real width is bigger than the attribute value. If it is possible, i would like a solution which does not use any particular framework. </p>
<hr>
<p><code>images[i].offsetWidth</code> returns 111 for an image of 109px width. Is this because 1px each side border? </p>
| [
{
"answer_id": 42331,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "var myImage = document.getElementById(\"myImagesId\");\nvar imageWidth = myImage.offsetWidth;\nvar imageHeight = myImag... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] |
42,333 | <p>I'm wondering how to use a VideoDisplay object (defined in MXML) to display video streamed from FMS via a NetStream.</p>
<p>The <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/VideoDisplay.html" rel="noreferrer">Flex3 docs</a> suggest this is possible:</p>
<blockquote>
<p>The Video Display ... supports progressive download over HTTP, streaming from the Flash Media Server, and streaming from a Camera object.</p>
</blockquote>
<p>However, later in the docs all I can see is an attachCamera() method. There doesn't appear to be an attachStream() method like the old Video object has.</p>
<p>It looks like you can play a fixed file served over HTML by using the source property, but I don't see anything about how to attach a NetStream.</p>
<p>The old <a href="http://livedocs.adobe.com/flex/3/langref/flash/media/Video.html" rel="noreferrer">Video</a> object still seems to exist, though it's not based on UIComponent and doesn't appear to be usable in MXML.</p>
<p>I found <a href="http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/" rel="noreferrer">this blog post</a> that shows how to do it with a regular Video object, but I'd much prefer to use VideoDisplay (or something else that can be put directly in the MXML).</p>
| [
{
"answer_id": 762430,
"author": "Ken Smith",
"author_id": 68231,
"author_profile": "https://Stackoverflow.com/users/68231",
"pm_score": 2,
"selected": false,
"text": "// Connect to the video stream in question.\nvar stream:NetStream = new NetStream( chatNC );\nstream.addEventListener( N... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409/"
] |
42,342 | <p>Sometimes IE6 will render the text of a <code><ul></code> list the same color as the background color. If you select it, they show back up, or if you scroll the page up and back down.</p>
<p>It is obviously a rendering bug, but I was wondering if anyone knows of a workaround to make it reliable?</p>
| [
{
"answer_id": 42346,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 0,
"selected": false,
"text": ".mylist {\n line-height: 1.6em;\n}\n"
},
{
"answer_id": 42352,
"author": "Jimmy",
"author_id": 4435,
"... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
42,345 | <p>How can I determine if a string is an IP address? Either <em>IPv4</em> or <em>IPv6</em>?</p>
<p>What is the least and most number of characters?</p>
<p>I assume this would be a <strong>regex</strong> answer.</p>
| [
{
"answer_id": 42359,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b\n"
},
{
"ans... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] |
42,357 | <p>I've seen a few attempted SQL injection attacks on one of my web sites. It comes in the form of a query string that includes the "cast" keyword and a bunch of hex characters which when "decoded" are an injection of banner adverts into the DB.</p>
<p>My solution is to scan the full URL (and params) and search for the presence of "cast(0x" and if it's there to redirect to a static page.</p>
<p>How do you check your URL's for SQL Injection attacks?</p>
| [
{
"answer_id": 42369,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": false,
"text": "// Bad!\nSqlCommand foo = new SqlCommand(\"SELECT FOO FROM BAR WHERE LOL='\" + Request.QueryString[\"LOL\"] + \"'\");\n\n//Go... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
42,383 | <p>I am writing an immutable DOM tree in Java, to simplify access from multiple threads.*</p>
<p>However, it does need to support inserts and updates as fast as possible. And since it is immutable, if I make a change to a node on the N'th level of the tree, I need to allocate at least N new nodes in order to return the new tree.</p>
<p>My question is, would it be dramatically faster to pre-allocate nodes rather than create new ones every time the tree is modified? It would be fairly easy to do - keep a pool of several hundred unused nodes, and pull one out of the pool rather than create one whenever it was required for a modify operation. I can replenish the node pool when there's nothing else going on. (in case it isn't obvious, execution time is going to be much more at a premium in this application than heap space is)</p>
<p>Is it worthwhile to do this? Any other tips on speeding it up?</p>
<p>Alternatively, does anyone know if an immutable DOM library already? I searched, but couldn't find anything.</p>
<p>*Note: For those of you who aren't familiar with the concept of immutability, it basically means that on any operation to an object that changes it, the method returns a copy of the object with the changes in place, rather than the changed object. Thus, if another thread is still reading the object it will continue to happily operate on the "old" version, unaware that changes have been made, rather than crashing horribly. See <a href="http://www.javapractices.com/topic/TopicAction.do?Id=29" rel="nofollow noreferrer">http://www.javapractices.com/topic/TopicAction.do?Id=29</a></p>
| [
{
"answer_id": 42500,
"author": "levand",
"author_id": 3044,
"author_profile": "https://Stackoverflow.com/users/3044",
"pm_score": 0,
"selected": false,
"text": "node.addChild()"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3044/"
] |
42,386 | <p>Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression?</p>
<pre><code>//pseudo-codeish
string s = Coalesce(string1, string2, string3);
</code></pre>
<p>or, more generally,</p>
<pre><code>object obj = Coalesce(obj1, obj2, obj3, ...objx);
</code></pre>
| [
{
"answer_id": 42387,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 2,
"selected": false,
"text": "string a = nullstring ?? \"empty!\";\n"
},
{
"answer_id": 42397,
"author": "Erik van Brakel",
"author_id": 90... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4438/"
] |
42,395 | <p>How do you write the syntax for a While loop?</p>
<h2>C<code>#</code></h2>
<pre><code>int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
</code></pre>
<h2>VB.Net</h2>
<pre><code>Dim i As Integer = 0
While i <> 10
Console.WriteLine(i)
i += 1
End While
</code></pre>
<h2>PHP</h2>
<pre><code><?php
while(CONDITION)
{
//Do something here.
}
?>
<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['fName'];
$_SESSION['lName'] = $row['lName'];
//...
}
?>
</code></pre>
<h2>Python</h2>
<pre><code>i = 0
while i != 10:
print i
i += 1
</code></pre>
| [
{
"answer_id": 42409,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 4,
"selected": true,
"text": "<?php\nwhile(CONDITION)\n{\n//Do something here.\n}\n?>\n"
},
{
"answer_id": 42420,
"author": "Blair Conrad",
... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] |
42,396 | <p>Here's the code from the ascx that has the repeater:</p>
<pre><code><asp:Repeater ID="ListOfEmails" runat="server" >
<HeaderTemplate><h3>A sub-header:</h3></HeaderTemplate>
<ItemTemplate>
[Some other stuff is here]
<asp:Button ID="removeEmail" runat="server" Text="X" ToolTip="remove" />
</ItemTemplate>
</asp:Repeater>
</code></pre>
<p>And in the codebehind for the repeater's databound and events:</p>
<pre><code>Protected Sub ListOfEmails_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ListOfEmails.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim removeEmail As Button = CType(e.Item.FindControl("removeEmail"), Button)
removeEmail.CommandArgument = e.Item.ItemIndex.ToString()
AddHandler removeEmail.Click, AddressOf removeEmail_Click
AddHandler removeEmail.Command, AddressOf removeEmail_Command
End If
End Sub
Sub removeEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("<h1>click</h1>")
End Sub
Sub removeEmail_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
Response.Write("<h1>command</h1>")
End Sub
</code></pre>
<p>Neither the click or command is getting called, what am I doing wrong?</p>
| [
{
"answer_id": 42412,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": true,
"text": "Repeater.ItemCommand"
},
{
"answer_id": 4996126,
"author": "Piotr Latusek",
"author_id": 562786,
"author_p... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] |
42,416 | <p>I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may have been prematurely finalized'.</p>
| [
{
"answer_id": 67689,
"author": "jldugger",
"author_id": 9947,
"author_profile": "https://Stackoverflow.com/users/9947",
"pm_score": 3,
"selected": true,
"text": "apt-cache search libgluezilla\nlibmono-mozilla0.1-cil - Mono Mozilla library\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] |
42,422 | <p>Essentially I want to know if in VB.NET 2005 if using a sqlcommand and then reusing it by using the NEW is wrong. Will it cause a memory leak.</p>
<p>EG:</p>
<pre><code>try
dim mySQL as new sqlcommand(sSQL, cnInput)
// do a sql execute and read the data
mySQL = new sqlcommand(sSQLdifferent, cnInput)
// do sql execute and read the data
catch ...
finally
if mysql isnot nothing then
mysql.dispose
mysql = nothing
end if
</code></pre>
<p>EDIT: put try catch in to avoid the comments about not using them</p>
| [
{
"answer_id": 42445,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 4,
"selected": true,
"text": "Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)\n ' do stuff'\nEnd Using\n\nUsing mysql as SqlCommand = new SqlComm... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2357/"
] |
42,428 | <p>X Windows has special processes called Window Managers that manage the layout of windows and decorations like their title bar, control buttons etc. Such processes use an X Windows API to detect events related to windows sizes and positions.</p>
<p>Are there any consistent ways for writing such processes for Microsoft Windows or Mac OS/X?</p>
<p>I know that in general these systems are less flexible but I'm looking for something that will use public APIs and not undocumented hacks.</p>
| [
{
"answer_id": 42445,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 4,
"selected": true,
"text": "Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)\n ' do stuff'\nEnd Using\n\nUsing mysql as SqlCommand = new SqlComm... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476/"
] |
42,437 | <p>I'm writing a C# POS (point of sale) system that takes input from a keyboard wedge magcard reader. This means that any data it reads off of a mag stripe is entered as if it were typed on the keyboard very quickly. Currently I'm handling this by attaching to the KeyPress event and looking for a series of very fast key presses that contain the card swipe sentinel characters.</p>
<p>Is there a better way to deal with this sort of input? </p>
<p>Edit: The device does simply present the data as keystrokes and doesn't interface through some other driver. Also We use a wide range of these types of devices so ideally a method should work independent of the specific model of wedge being used. However if there is no other option I'll have to make do.</p>
| [
{
"answer_id": 589283,
"author": "Nicholas Piasecki",
"author_id": 32187,
"author_profile": "https://Stackoverflow.com/users/32187",
"pm_score": 2,
"selected": false,
"text": "KeyPress"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2191/"
] |
42,438 | <p>I have some code that uses SMO to populate a list of available SQL Servers and databases. While we no longer support SQL Server 2000, it's possible that the code could get run on a machine that SQL Server 2000 and not have the SMO library installed. I would perfer to check for SMO first and degrade the functionality gracefully instead of blowing up in the user's face. What is best way to detect whether or not SMO is available on a machine?</p>
<p>Every example that I have seen through a quick Google scan was a variation of "look for C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll". The problem with that approach is that it only works with SQL Server 2005. If SQL Server 2008 is the only SQL Server installed then the path will be different.</p>
| [
{
"answer_id": 42577,
"author": "Chris Miller",
"author_id": 206,
"author_profile": "https://Stackoverflow.com/users/206",
"pm_score": 2,
"selected": false,
"text": "private bool CheckForSmo()\n{\n string RegKeyName = @\"Microsoft.SqlServer.Management.Smo.Database\";\n bool result ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/206/"
] |
42,446 | <pre><code>class Foo
{
static bool Bar(Stream^ stream);
};
class FooWrapper
{
bool Bar(LPCWSTR szUnicodeString)
{
return Foo::Bar(??);
}
};
</code></pre>
<p><code>MemoryStream</code> will take a <code>byte[]</code> but I'd <em>like</em> to do this without copying the data if possible.</p>
| [
{
"answer_id": 42605,
"author": "Adam Tegen",
"author_id": 4066,
"author_profile": "https://Stackoverflow.com/users/4066",
"pm_score": 0,
"selected": false,
"text": "\nstatic Stream^ UnicodeStringToStream(LPCWSTR szUnicodeString)\n{\n //validate the input parameter\n if (szUnicodeStr... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] |
42,460 | <p>I'm almost certain I know the answer to this question, but I'm hoping there's something I've overlooked.</p>
<p>Certain applications seem to have the Vista Aero look and feel to their caption bars and buttons even when running on Windows XP. (Google Chrome and Windows Live Photo Gallery come to mind as examples.) I know that one way to accomplish this from WinForms would be to create a borderless form and draw the caption bar/buttons yourself, then overriding <code>WndProc</code> to make sure moving, resizing, and button clicks do what they're supposed to do (I'm not clear on the specifics but could probably pull it off given a day to read documentation.) I'm curious if there's a different, easier way that I'm overlooking. Perhaps some API calls or window styles I've overlooked?</p>
<p>I believe Google has answered it for me by using the roll-your-own-window approach with Chrome. I will leave the question open for another day in case someone has new information, but I believe I have answered the question myself.</p>
| [
{
"answer_id": 44398,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": 3,
"selected": false,
"text": "src\\chrome\\browser\\views\\frame"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2547/"
] |
42,482 | <p>Is there a reasonable way to extract plain text from a Word file that doesn't depend on COM automation? (This is a a feature for a web app deployed on a non-Windows platform - that's non-negotiable in this case.)</p>
<p>Antiword seems like it might be a reasonable option, but it seems like it might be abandoned.</p>
<p>A Python solution would be ideal, but doesn't appear to be available.</p>
| [
{
"answer_id": 43301,
"author": "paulmorriss",
"author_id": 2983,
"author_profile": "https://Stackoverflow.com/users/2983",
"pm_score": 2,
"selected": false,
"text": "RO = PropertyValue('ReadOnly', 0, True, 0)\nHidden = PropertyValue('Hidden', 0, True, 0)\nxDoc = desktop.loadComponentFro... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678/"
] |
42,490 | <p><em>Disclaimer: I'm stuck on TFS and I hate it.</em></p>
<p>My source control structure looks like this:</p>
<ul>
<li>/dev</li>
<li>/releases</li>
<li>/branches</li>
<li>/experimental-upgrade</li>
</ul>
<p>I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merged to experimental-upgrade. Somehow TFS complained that I had changes in both source and target and I had to resolve them. I chose to "Copy item from source branch" for all 5 items.</p>
<p>I check out the experimental-upgrade to a local folder and try to open the main solution file in there. TFS prompts me: </p>
<blockquote>
<p>"Projects have recently been added to this solution. Would you like to get them from source control?</p>
</blockquote>
<p>If I say yes it does some stuff but ultimately comes back failing to load a handful of the projects. If I say no I get the same result.</p>
<p>Comparing my sln in both branches tells me that they are equal.</p>
<p>Can anyone let me know what I'm doing wrong? This should be a straightforward branch/merge operation...</p>
<p>TIA.</p>
<hr>
<p><strong>UPDATE:</strong></p>
<p>I noticed that if I click "yes" on the above dialog, the projects are downloaded to the $/ root of source control... (i.e. out of the dev & branches folders)</p>
<p>If I open up the solution in the branch and remove the dead projects and try to re-add them (by right-clicking sln, add existing project, choose project located in the branch folder, it gives me the error...</p>
<blockquote>
<p>Cannot load the project c:\sandbox\my_solution\proj1\proj1.csproj, the file has been removed or deleted. The project path I was trying to add is this: c:\sandbox\my_solution\branches\experimental-upgrade\proj1\proj1.csproj</p>
</blockquote>
<p>What in the world is pointing these projects <em>outside</em> of their local root? The solution file is identical to the one in the dev branch, and those projects load just fine. I also looked at the vspscc and vssscc files but didn't find anything.</p>
<p>Ideas?</p>
| [
{
"answer_id": 42553,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 3,
"selected": true,
"text": "tf destroy [/keephistory] itemspec1 [;versionspec]\n [itemspec2...itemspecN] [/stopat:versionspec] [/preview]\n ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3381/"
] |
42,499 | <p>I've started working with ASP.net AJAX (finally ☺). and I've got an update panel together with a asp:UpdateProgress. My Problem: The UpdateProgress always forces a line-break, because it renders out as a div-tag.</p>
<p>Is there any way to force it being a span instead? I want to display it on the same line as some other controls without having to use a table or even <em>shudders</em> absolute positioning in CSS.</p>
<p>I'm stuck with ASP.net AJAX 1.0 and .net 3.0 if that makes a difference.</p>
| [
{
"answer_id": 42521,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": -1,
"selected": false,
"text": "<div style=\"display:inline\">stuff</div>\n"
},
{
"answer_id": 43825,
"author": "Steven Williams",
"au... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] |
42,505 | <p>I have a C# singleton class that multiple classes use. Is access through <code>Instance</code> to the <code>Toggle()</code> method thread-safe? If yes, by what assumptions, rules, etc. If no, why <em>and</em> how can I fix it?</p>
<pre><code>public class MyClass
{
private static readonly MyClass instance = new MyClass();
public static MyClass Instance
{
get { return instance; }
}
private int value = 0;
public int Toggle()
{
if(value == 0)
{
value = 1;
}
else if(value == 1)
{
value = 0;
}
return value;
}
}
</code></pre>
| [
{
"answer_id": 42511,
"author": "juan",
"author_id": 1782,
"author_profile": "https://Stackoverflow.com/users/1782",
"pm_score": 0,
"selected": false,
"text": "if(value == 0) { value = 1; }\nif(value == 1) { value = 0; }\nreturn value;\n"
},
{
"answer_id": 42517,
"author": "B... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] |
42,512 | <p>Is it possible to delete an GAE application after it has been created?</p>
<p>I made a mistake while typing the name and now have a dummy application that I haven't been able to remove.</p>
| [
{
"answer_id": 56090825,
"author": "balazs630",
"author_id": 7343596,
"author_profile": "https://Stackoverflow.com/users/7343596",
"pm_score": 3,
"selected": false,
"text": "APIs & Services"
},
{
"answer_id": 61952720,
"author": "iengchen",
"author_id": 4318846,
"auth... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148/"
] |
42,519 | <p>Inspired by <a href="https://devblogs.microsoft.com/oldnewthing/20080902-00/?p=21003" rel="noreferrer">Raymond Chen's post</a>, say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real world stuff.</p>
<pre><code>[1][2][3][4]
[5][6][7][8]
[9][0][1][2]
[3][4][5][6]
</code></pre>
<p>Becomes:</p>
<pre><code>[3][9][5][1]
[4][0][6][2]
[5][1][7][3]
[6][2][8][4]
</code></pre>
<p><strong>Update</strong>: Nick's answer is the most straightforward, but is there a way to do it better than n^2? What if the matrix was 10000x10000?</p>
| [
{
"answer_id": 42535,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 8,
"selected": true,
"text": "int[,] array = new int[4,4] {\n { 1,2,3,4 },\n { 5,6,7,8 },\n { 9,0,1,2 },\n { 3,4,5,6 }\n};\n\nint[,] rotated = ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/736/"
] |
42,531 | <p>Looking for an example that:</p>
<ol>
<li>Launches an EXE</li>
<li>Waits for the EXE to finish.</li>
<li>Properly closes all the handles when the executable finishes.</li>
</ol>
| [
{
"answer_id": 42543,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 5,
"selected": false,
"text": "argv[1]"
},
{
"answer_id": 42544,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "h... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] |
42,566 | <p>I'm in the process of maintaining a Ruby on Rails app and am looking for an easy way to find the hostname or IP address of the box I'm on (since it's a VM and new instances may have different hostnames or IP addresses). Is there a quick and easy way to do this in Ruby on Rails?</p>
<p>Edit: The answer below is correct but the clarification Craig provided is useful (see also provided link in answer):</p>
<blockquote>
<p>The [below] code does NOT make a
connection or send any packets (to
64.233.187.99 which is google). Since UDP is a stateless protocol connect()
merely makes a system call which
figures out how to route the packets
based on the address and what
interface (and therefore IP address)
it should bind to. addr() returns an
array containing the family (AF_INET),
local port, and local address (which
is what we want) of the socket.</p>
</blockquote>
| [
{
"answer_id": 42624,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 5,
"selected": false,
"text": "host = `hostname`.strip # Get the hostname from the shell and removing trailing \\n\nputs host # Output the... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] |
42,581 | <p>The Python docs say:</p>
<blockquote>
<p>re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...</p>
</blockquote>
<p>So what's going on when I get the following unexpected result?</p>
<pre><code>>>> import re
>>> s = """// The quick brown fox.
... // Jumped over the lazy dog."""
>>> re.sub('^//', '', s, re.MULTILINE)
' The quick brown fox.\n// Jumped over the lazy dog.'
</code></pre>
| [
{
"answer_id": 42597,
"author": "Moe",
"author_id": 3051,
"author_profile": "https://Stackoverflow.com/users/3051",
"pm_score": 8,
"selected": true,
"text": "re.sub"
},
{
"answer_id": 2517216,
"author": "Ferran",
"author_id": 301850,
"author_profile": "https://Stackov... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
42,587 | <p>I have heard/read the term but don't quite understand what it means.</p>
<p>When should I use this technique and how would I use it? Can anyone provide a good code sample?</p>
| [
{
"answer_id": 42656,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 7,
"selected": true,
"text": "using System.Linq; \n\nclass DoubleDispatch\n{ \n public T Foo<T>(object arg)\n { \n var method = from m in ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] |
42,627 | <p>I am looking to write some C# code for linux/windows/mac/any other platform, and am looking for best practices for portable code.</p>
<p>Project <a href="http://go-mono.org" rel="noreferrer">mono</a> has some great <a href="http://www.mono-project.com/Category:Porting" rel="noreferrer">porting</a> resources.</p>
<p>What are the best practices for portable C#?</p>
| [
{
"answer_id": 55946,
"author": "Sam Warwick",
"author_id": 3873,
"author_profile": "https://Stackoverflow.com/users/3873",
"pm_score": 4,
"selected": false,
"text": "string myfile = somepath + \"\\\\file.txt\";\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] |
42,648 | <p>How am I supposed to get the <code>IDENTITY</code> of an inserted row?</p>
<p>I know about <code>@@IDENTITY</code> and <code>IDENT_CURRENT</code> and <code>SCOPE_IDENTITY</code>, but don't understand the implications or impacts attached to each.</p>
<p>Can someone please explain the differences and when I would be using each?</p>
| [
{
"answer_id": 42655,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 12,
"selected": true,
"text": "@@IDENTITY"
},
{
"answer_id": 42669,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] |
42,672 | <p>What would be the best way to do an <code>scp</code> or <code>sftp</code> copy in a Unix environment using C?</p>
<p>I'm interested in knowing the best library to use and an example if at all possible. I'm working on a <a href="https://en.wikipedia.org/wiki/Solaris_%28operating_system%29" rel="nofollow noreferrer">Solaris</a> server with the <em><a href="https://en.wikipedia.org/wiki/Sun_Microsystems" rel="nofollow noreferrer">Sun</a> tools</em> installed.</p>
| [
{
"answer_id": 42705,
"author": "Tyler Gooch",
"author_id": 1372,
"author_profile": "https://Stackoverflow.com/users/1372",
"pm_score": 0,
"selected": false,
"text": "int transferFile()\n{\n // Declare the transfer command\n char transferCommand[50] = \"/home/tyler/transferFile.shl\";\... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
42,693 | <p>What's the best way to get user input in a C program where the choices are of a limited number?</p>
<p>Say for example the choices are:</p>
<p>A) Print the list.
B) Add 99 to the end of the list.
C) Delete all duplicates.
5) Reset 5 times.</p>
<p>Entering "A" and then Enter is OK.
Or, just a single keystroke would work as well.</p>
| [
{
"answer_id": 42704,
"author": "David Bryson",
"author_id": 3663,
"author_profile": "https://Stackoverflow.com/users/3663",
"pm_score": 0,
"selected": false,
"text": "int intput()\n{\n char input = 0;\n int ret_val = 0;\n\n read(0, &input, 1);\n\n switch(input) {\n ca... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3807/"
] |
42,703 | <p>I am using sp_send_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8.</p>
<p>Here is the SQL</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@recipients = 'temp@example.com'
, @query = 'DECLARE @string_to_trim varchar(60);SET @string_to_trim = ''1234''; select rtrim(@string_to_trim), ''tom'''
, @query_result_header=0
, @subject = 'see attach'
, @body= 'temp body'
, @profile_name= N'wksql01tAdmin'
, @body_format = 'HTML'
,@query_result_separator = ','
,@query_attachment_filename = 'results.csv'
,@query_no_truncate = '0'
,@attach_query_result_as_file = 1
</code></pre>
<p>I have seen some comments on the internet that this is fixed with sql2005 SP2, but do not find it to be the case.</p>
| [
{
"answer_id": 5783390,
"author": "bushtwig",
"author_id": 588229,
"author_profile": "https://Stackoverflow.com/users/588229",
"pm_score": 0,
"selected": false,
"text": "msdb"
},
{
"answer_id": 14670451,
"author": "Gena",
"author_id": 2036703,
"author_profile": "https... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
42,706 | <p>Is there a down side? I feel almost dependent on it now. Whenever a project gets past a certain size almost feel an allergic reaction to standard patterns and immediately re-wire it with a Dependency Injection framework.</p>
<p>The largest issue I've found is it can be confusing for other developers who are just learning it.</p>
<p>Also, I'd feel much better if it were a part of the language I was using. Though, for Java at least, there are a couple very lightweight libraries which are quite good.</p>
<p>Thoughts? Bad experiences? Or just stop worrying about it?</p>
<hr>
<p>[EDIT] Re: Description of Dependency Injection itself</p>
<p>Sorry for being vague. <a href="http://www.martinfowler.com/articles/injection.html" rel="noreferrer">Martin Fowler</a> probably describes it FAR better than I ever could... no need to waste the effort. </p>
<p>Coincidentally, this confirms one point about it, that it's still not widely practiced and might tend to be a barrier when working with teams if everyone is not up to speed on it. </p>
| [
{
"answer_id": 42739,
"author": "Marcio Aguiar",
"author_id": 4213,
"author_profile": "https://Stackoverflow.com/users/4213",
"pm_score": 2,
"selected": false,
"text": " package dependecyinjection; \n import java.util.ServiceLoader; \n\n public abstract class FooService { \n\n pub... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/758/"
] |
42,710 | <p>I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I want vcs to successfully optimizing the code and also have it be as short/neat as possible. My solution so far:</p>
<pre><code>wire [3:0] a;
wire b;
wire [15:0] c;
assign c = 16'b0100110010111010; //for example but could be any constant
assign b = c[a];
</code></pre>
<p>Having to declare c is ugly and I don't know if vcs will recognize the K-map there. Will this work as well as a case statement or an assignment in conjunctive normal form?</p>
| [
{
"answer_id": 99795,
"author": "Matt J",
"author_id": 18528,
"author_profile": "https://Stackoverflow.com/users/18528",
"pm_score": 2,
"selected": false,
"text": "always_comb //or \"always @*\" if you don't have an SV-enabled tool flow\nbegin \n case(a)\n begin\n 4'b0000: b = 1'b0;... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4454/"
] |
42,721 | <p>For some reason, I can't seem to get CruiseControl.net to checkout code to anywhere but the starteam working folder for a specificed view.</p>
<p>I've tried both overrideViewWorkingDir and overrideFolderWorkingDir, and neither seem to work.</p>
<p>Has anyone been able to do this?</p>
| [
{
"answer_id": 61163,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 0,
"selected": false,
"text": "<sourcecontrol type=\"starteam\">\n <executable>C:\\Program Files\\starbase\\StarTeam 5.4\\stcmd.exe</executable>\n ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
42,762 | <p>Here is some code I could not get to format properly in markdown, this is straight C code, pasted into the text box with the '4 spaces' format to denote code:</p>
<pre><code>#define PRINT(x, format, ...) \
if ( x ) { \
if ( debug_fd != NULL ) { \
fprintf(debug_fd, format, ##__VA_ARGS__); \
} \
else { \
fprintf(stdout, format, ##__VA_ARGS__); \
} \
}
</code></pre>
<p>It seems as though the '\' causes the newlines to be ignored. Ok fine, I am used to this in bash, but if I put '\' the second one doesn't show up. As if the second one is absorbed. Am I missing something?</p>
| [
{
"answer_id": 42764,
"author": "Julio César",
"author_id": 2148,
"author_profile": "https://Stackoverflow.com/users/2148",
"pm_score": 2,
"selected": false,
"text": "#define PRINT(x, format, ...) \\\nif ( x ) { \\\n if ( debug_fd != NULL ) { \\\n fprintf(debug_fd, format, ##VA... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3663/"
] |
42,763 | <p>Does anyone know how many options a drop down list can have? Is it unlimited? How many before performance degrades?</p>
| [
{
"answer_id": 22330536,
"author": "Katesclau",
"author_id": 1014667,
"author_profile": "https://Stackoverflow.com/users/1014667",
"pm_score": 4,
"selected": false,
"text": "for (var i=0; i<10000; i++) {\n var name = \"Option \"+i;\n var sel = document.getElementById(\"list\");\n ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/415/"
] |
42,774 | <p>I'm using <kbd>Ctrl</kbd>+<kbd>Left</kbd> / <kbd>Ctrl</kbd>+<kbd>Right</kbd> in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always returns "undefined".</p>
| [
{
"answer_id": 42807,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": true,
"text": "(function() {\n\nvar myActiveElement;\ndocument.onkeypress = function(event) {\n if ((myActiveElement || document.activeEleme... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394/"
] |
42,778 | <p>Is <a href="http://cpan.uwinnipeg.ca/dist/DBI" rel="noreferrer">CPAN DBI</a> the best database interface to use in Perl for general database use? Are there some better options?</p>
| [
{
"answer_id": 72471,
"author": "8jean",
"author_id": 10011,
"author_profile": "https://Stackoverflow.com/users/10011",
"pm_score": 3,
"selected": false,
"text": "DBI"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] |
42,793 | <p>What techniques do you know\use to create user-friendly GUI ? </p>
<p>I can name following techniques that I find especially useful: </p>
<ul>
<li>Non-blocking notifications (floating dialogs like in Firefox3 or Vista's pop-up messages in tray area)</li>
<li>Absence of "Save" button<br>
MS OneNote as an example.<br>
IM clients can save conversation history automatically</li>
<li>Integrated search<br>
Search not only through help files but rather make UI elements searchable.<br>
Vista made a good step toward such GUI.<br>
<a href="http://www.istartedsomething.com/20070124/scout-office-2007/" rel="nofollow noreferrer">Scout</a> addin Microsoft Office was a really great idea.</li>
<li>Context oriented UI (Ribbon bar in MS Office 2007)</li>
</ul>
<p>Do you implement something like listed techniques in your software?</p>
<p><strong>Edit:</strong><br>
As <a href="https://stackoverflow.com/questions/42793/gui-design-techinques-to-enhance-user-experience#42843">Ryan P</a> mentioned, one of the best way to create usable app is to put yourself in user's place. I totally agree with it, but what I want to see in this topic is specific techniques (like those I mentioned above) rather than general recommendations.</p>
| [
{
"answer_id": 42891,
"author": "wusher",
"author_id": 1632,
"author_profile": "https://Stackoverflow.com/users/1632",
"pm_score": 5,
"selected": false,
"text": " Would you like to save? \n Yes No\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1196/"
] |
42,797 | <p>I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.</p>
<p>A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.</p>
<p>UPDATE: A free/low-cost tool would be great, but cost isn't the only concern. A tool that could actually manage deployment from one environment to the next (dev->staging->production instead of from a development machine to each environment) would also be ideal.</p>
<p>The other big nice-to-have is the ability to only copy changed files - some of our older sites contain hundreds of .asp files.</p>
| [
{
"answer_id": 43186,
"author": "DrFloyd5",
"author_id": 1736623,
"author_profile": "https://Stackoverflow.com/users/1736623",
"pm_score": 2,
"selected": false,
"text": "robocopy.exe\nfor /?\n"
},
{
"answer_id": 380222,
"author": "Simon_Weaver",
"author_id": 16940,
"a... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/729/"
] |
42,814 | <p>How can I get the MAC Address using only the compact framework?</p>
| [
{
"answer_id": 42824,
"author": "Greg Roberts",
"author_id": 4269,
"author_profile": "https://Stackoverflow.com/users/4269",
"pm_score": -1,
"selected": false,
"text": "Dim mc As System.Management.ManagementClass\nDim mo As ManagementObject\nmc = New ManagementClass(\"Win32_NetworkAdapte... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4463/"
] |
42,828 | <p>I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp user pages. Problem occurs when user pages have some complicated forms and stuff and jsf starts kickin' in. </p>
<p>Here is the question: I'm on pure jsp page. I need to access some jsf page that uses session bean. How can I initialize that bean? If I was on jsf page, I could have some commandLink which would prepare data. Only thing I can come up with is having dummy jsf page that will do the work and redirect me to needed jsf page, but that's kind of ugly, and I don't want to end up with 50 dummy pages. I would rather find some mechanism to reinitialize bean that is already in session with some wanted parameters.</p>
<p>Edit: some more details. In this specific situation, I have a tests that are either full or filtered. It's a same test with same logic and everything, except if test is filtered, it should eliminate some questions depending on answers. Upon a clicking a link, it should start a requested test in one of the two modes. Links are parts of main menu-tree and are visible on many sibling jsp pages. My task is to have 4 links: testA full, testA filtered, testB full, testB filtered, that all lead on same jsf page and TestFormBean should be reinitialized accordingly.</p>
<p>Edit: I've researched facelets a bit, and while it won't help me now, I'll definitely keep that in mind for next project.</p>
| [
{
"answer_id": 43549,
"author": "Tim Howland",
"author_id": 4276,
"author_profile": "https://Stackoverflow.com/users/4276",
"pm_score": 2,
"selected": false,
"text": "<input type=\"text\" jsfc=\"#{SomeBean.property}\" class=\"foo\" />\n"
},
{
"answer_id": 63883,
"author": "Er... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433/"
] |
42,830 | <p>I'm using the <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx" rel="nofollow noreferrer">AutoComplete</a> control from the ASP.NET AJAX Control Toolkit and I'm experiencing an issue where the AutoComplete does not populate when I set the focus to the assigned textbox. </p>
<p>I've tried setting the focus in the Page_Load, Page_PreRender, and Page_Init events and the focus is set properly but the AutoComplete does not work. If I don't set the focus, everything works fine but I'd like to set it so the users don't have that extra click. </p>
<p>Is there a special place I need to set the focus or something else I need to do to make this work? Thanks.</p>
| [
{
"answer_id": 42858,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 3,
"selected": true,
"text": "MainSearchBox_SearchTextBox"
},
{
"answer_id": 44006,
"author": "Jason Shoulders",
"author_id": 1953,
... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2034/"
] |
42,863 | <p>Of course the best metric would be a happiness of your users.<br>
But what metrics do you know for GUI usability measurements?<br>
For example, one of the common metrics is a average click count to perform action.
What other metrics do you know? </p>
| [
{
"answer_id": 80040,
"author": "rec",
"author_id": 14022,
"author_profile": "https://Stackoverflow.com/users/14022",
"pm_score": 0,
"selected": false,
"text": "Q: “What percentage of your interface contains stuff that your customers\n want to see?”\n"
}
] | 2008/09/03 | [
"https://Stackoverflow.com/questions/42863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1196/"
] |
42,876 | <p>Why does the following code not work as I was expecting?</p>
<pre><code><?php
$data = array(
array('Area1', null, null),
array(null, 'Section1', null),
array(null, null, 'Location1'),
array('Area2', null, null),
array(null, 'Section2', null),
array(null, null, 'Location2')
);
$root = array();
foreach ($data as $row) {
if ($row[0]) {
$area = array();
$root[$row[0]] =& $area;
} elseif ($row[1]) {
$section = array();
$area[$row[1]] =& $section;
} elseif ($row[2]) {
$section[] = $row[2];
}
}
print_r($root);
</code></pre>
<p>Expected result:</p>
<pre><code>Array(
[Area1] => Array(
[Section1] => Array(
[0] => Location1
)
)
[Area2] => Array(
[Section2] => Array(
[0] => Location2
)
)
)
</code></pre>
<p>Actual result:</p>
<pre><code>Array(
[Area1] => Array(
[Section2] => Array(
[0] => Location2
)
)
[Area2] => Array(
[Section2] => Array(
[0] => Location2
)
)
)
</code></pre>
| [
{
"answer_id": 42885,
"author": "pix0r",
"author_id": 72,
"author_profile": "https://Stackoverflow.com/users/72",
"pm_score": 3,
"selected": true,
"text": "$area = array();\n\n$section = array();\n"
},
{
"answer_id": 42913,
"author": "grom",
"author_id": 486,
"author_... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/486/"
] |
42,894 | <p>Is there any benefit in using a <code><blockquote></code> element over a <code><div></code>? I was looking at a website's markup to learn CSS and I couldn't figure out why the <code><blockquote></code> was being used.</p>
<p>EDIT: Yeah sorry I didn't clarify, it was used to hold the <code><div></code> tag with username as 'text' and an <code>input</code> tag. There was clearly no quote.</p>
| [
{
"answer_id": 42896,
"author": "pix0r",
"author_id": 72,
"author_profile": "https://Stackoverflow.com/users/72",
"pm_score": 3,
"selected": false,
"text": "blockquote"
},
{
"answer_id": 42898,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://S... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438/"
] |
42,934 | <p>It seems that everybody is jumping on the dynamic, non-compiled bandwagon lately. I've mostly only worked in compiled, static typed languages (C, Java, .Net). The experience I have with dynamic languages is stuff like ASP (Vb Script), JavaScript, and PHP. Using these technologies has left a bad taste in my mouth when thinking about dynamic languages. Things that usually would have been caught by the compiler such as misspelled variable names and assigning an value of the wrong type to a variable don't occur until runtime. And even then, you may not notice an error, as it just creates a new variable, and assigns some default value. I've also never seen intellisense work well in a dynamic language, since, well, variables don't have any explicit type.</p>
<p>What I want to know is, what people find so appealing about dynamic languages? What are the main advantages in terms of things that dynamic languages allow you to do that can't be done, or are difficult to do in compiled languages. It seems to me that we decided a long time ago, that things like uncompiled asp pages throwing runtime exceptions was a bad idea. Why is there is a resurgence of this type of code? And why does it seem to me at least, that Ruby on Rails doesn't really look like anything you couldn't have done with ASP 10 years ago?</p>
| [
{
"answer_id": 42955,
"author": "Apocalisp",
"author_id": 3434,
"author_profile": "https://Stackoverflow.com/users/3434",
"pm_score": 7,
"selected": false,
"text": "qsort [] = []\nqsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)\n"
},
{
"answer_id": 4... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] |
42,950 | <p>Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?</p>
<p>If the standard library doesn't support that, does the dateutil package support this?</p>
| [
{
"answer_id": 42997,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 7,
"selected": false,
"text": ">>> import datetime\n>>> datetime.date(2000, 2, 1) - datetime.timedelta(days=1)\ndatetime.date(2000, 1, 31)\n"
},
{... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] |
42,966 | <p>What would be the best way to develop a text box that remembers the last x number of entries that were put into it. This is a standalone app written with C#.</p>
| [
{
"answer_id": 45067,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 3,
"selected": true,
"text": "namespace AutoComplete\n{\n public partial class Main : Form\n {\n //so you don't have to address \"txtMain.Auto... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2066/"
] |
42,980 | <p>Does anyone know how to setup <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial" rel="noreferrer">Mercurial</a> to use <a href="http://www.perforce.com/perforce/products/merge.html" rel="noreferrer">p4merge</a> as the merge/diff tool on OS X 10.5?</p>
| [
{
"answer_id": 54261,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "#!/usr/bin/python\nimport sys\nimport os\n\nos.system('/Applications/p4merge.app/Contents/MacOS/p4merge \"%s\" \"%s\"' % (sys.a... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3547/"
] |
42,984 | <p>I'm behind a firewall at work at the moment and I was testing something that I had deployed to my website, and the work proxy seems to be blocking it somewhat.</p>
<p>Basically I am getting a message of:</p>
<blockquote>
<p>Operation is not valid due to the current state of the object</p>
</blockquote>
<p>I've got it down to my proxy interferring, but I can't see any advanced settings or anything I can set up to go through my proxy to get to my service.</p>
<p>I did a quick google for it, but no joy.</p>
<p>Anyone found a quick way to get around it?</p>
| [
{
"answer_id": 314622,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<system.net> \n <defaultProxy useDefaultCredentials=\"false\">\n <proxy usesystemdefault=\"true\" proxyaddress=\"10.0... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] |
42,990 | <p>I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.</p>
<p>Example:</p>
<pre><code>// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
</code></pre>
<p>Should match anything that starts with "foo" and doesn't end with "bar". I know about the [^...] syntax, but I can't find anything that will do that for a string instead of single characters. </p>
<p>I am specifically trying to do this for Java's regex, but I've run into this before so answers for other regex engines would be great too. </p>
<p>Thanks to @Kibbee for verifying that this works in C# as well. </p>
| [
{
"answer_id": 43010,
"author": "Sam Hasler",
"author_id": 2541,
"author_profile": "https://Stackoverflow.com/users/2541",
"pm_score": 1,
"selected": false,
"text": "foo.*(?!bar) // not correct\n"
},
{
"answer_id": 43016,
"author": "aku",
"author_id": 1196,
"author_pr... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535/"
] |
43,021 | <p>Is there some rare language construct I haven't encountered (like the few I've learned recently, some on Stack Overflow) in C# to get a value representing the current iteration of a foreach loop?</p>
<p>For instance, I currently do something like this depending on the circumstances:</p>
<pre><code>int i = 0;
foreach (Object o in collection)
{
// ...
i++;
}
</code></pre>
| [
{
"answer_id": 43029,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 10,
"selected": true,
"text": "foreach"
},
{
"answer_id": 43035,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
43,044 | <p>I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. </p>
<p>I've found solutions to this problem but they rely on alternative color palettes than RGB.
I would rather just use straight RGB than mapping back and forth. These other solutions also can at most generate only 32 or so pleasing random colors. </p>
<p>Any ideas would be great.</p>
| [
{
"answer_id": 43081,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 0,
"selected": false,
"text": "brightness = sqrt(R^2+G^2+B^2)\n"
},
{
"answer_id": 43235,
"author": "David Crow",
"author_id": 2783,
"aut... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3415/"
] |
43,051 | <p>I have the following C# code:</p>
<pre><code>byte rule = 0;
...
rule = rule | 0x80;
</code></pre>
<p>which produces the error: </p>
<blockquote>
<p><em>Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)</em></p>
</blockquote>
<p>[Update: first version of the question was wrong ... I misread the compiler output]</p>
<p>Adding the cast <strong>doesn't</strong> fix the problem:</p>
<pre><code>rule = rule | (byte) 0x80;
</code></pre>
<p>I need to write it as:</p>
<pre><code>rule |= 0x80;
</code></pre>
<p>Which just seems weird. Why is the <code>|=</code> operator any different to the <code>|</code> operator?</p>
<p>Is there any other way of telling the compiler to treat the constant as a byte?</p>
<hr>
<p><strong>@ Giovanni Galbo</strong> : yes and no. The code is dealing with the programming of the flash memory in an external device, and logically represents a single byte of memory. I could cast it later, but this seemed more obvious. I guess my C heritage is showing through too much!</p>
<p><strong>@ Jonathon Holland</strong> : the 'as' syntax looks neater but unfortunately doesn't appear to work ... it produces:</p>
<blockquote>
<p><em>The as operator must be used with a reference type or nullable type ('byte' is a non-nullable value type)</em> </p>
</blockquote>
| [
{
"answer_id": 43064,
"author": "jmatthias",
"author_id": 2768,
"author_profile": "https://Stackoverflow.com/users/2768",
"pm_score": 4,
"selected": false,
"text": "rule = (byte)(rule | 0x80);\n"
},
{
"answer_id": 43074,
"author": "David J. Sokol",
"author_id": 1390,
... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3631/"
] |
43,111 | <p>I have a self referencing Categories table. Each Category has a CategoryID, ParentCategoryID, CategoryName, etc. And each category can have any number of sub categories, and each of those sub categories can have any number of sub categories, and so and and so forth. So basically the tree can be X levels deep.</p>
<p>Then Products are associated to leaf (sub) Categories. Is there a way to get all the Products for any given Category (which would be all the products associated to all its leaf descendants) using LINQ to SQL? </p>
<p>This feels like a recursive problem. Is it better to used a Stored Procedure instead?</p>
| [
{
"answer_id": 43121,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 2,
"selected": false,
"text": "public IQueryable GetCategories(Category parent)\n{\n var cats = (parent.Categories);\n foreach (Category c in cats... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653/"
] |
43,116 | <p>I've got a utility that outputs a list of files required by a game. How can I run that utility within a C program and grab its output so I can act on it within the same program?</p>
<p>UPDATE: Good call on the lack of information. The utility spits out a series of strings, and this is supposed to be portable across Mac/Windows/Linux. Please note, I'm looking for a programmatic way to execute the utility and retain its output (which goes to stdout).</p>
| [
{
"answer_id": 43120,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 7,
"selected": true,
"text": "popen()"
},
{
"answer_id": 43122,
"author": "David J. Sokol",
"author_id": 1390,
"a... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3830/"
] |
43,126 | <pre><code>public static IList<T> LoadObjectListAll<T>()
{
ISession session = CheckForExistingSession();
var cfg = new NHibernate.Cfg.Configuration().Configure();
var returnList = session.CreateCriteria(typeof(T));
var list = returnList.List();
var castList = list.Cast<typeof(T)>();
return castList;
}
</code></pre>
<p>So, I'm getting a build error where I am casting the "list" element to a generic IList .... can anyone see a glaring error here? </p>
| [
{
"answer_id": 43128,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 3,
"selected": false,
"text": "var castList = list.Cast<typeof(T)>();\n"
},
{
"answer_id": 43131,
"author": "Dale Ragan",
"author_id": 1117,
"... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] |
43,134 | <p>Simple question, but one that I've been curious about...is there a functional difference between the following two commands?</p>
<pre><code>String::class
String.class
</code></pre>
<p>They both do what I expect -- that is to say they return <code>Class</code> -- but what is the difference between using the <code>::</code> and the <code>.</code>?</p>
<p>I notice that on those classes that have constants defined, IRB's auto-completion will return the constants as available options when you press tab after <code>::</code> but not after <code>.</code>, but I don't know what the reason for this is...</p>
| [
{
"answer_id": 43146,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 6,
"selected": true,
"text": "."
},
{
"answer_id": 48046,
"author": "Peeja",
"author_id": 4937,
"author_profile": "https://Stackover... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4142/"
] |
43,157 | <p>I was surprised to find today that I couldn't track down any simple way to write the contents of an <code>InputStream</code> to an <code>OutputStream</code> in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code clearer).</p>
<p>So, given an <code>InputStream</code> <code>in</code> and an <code>OutputStream</code> <code>out</code>, is there a simpler way to write the following?</p>
<pre><code>byte[] buffer = new byte[1024];
int len = in.read(buffer);
while (len != -1) {
out.write(buffer, 0, len);
len = in.read(buffer);
}
</code></pre>
| [
{
"answer_id": 43163,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 7,
"selected": false,
"text": "byte[] buffer = new byte[1024];\nint len;\nwhile ((len = in.read(buffer)) != -1) {\n out.write(buffer, 0, len);\n}\n"
}... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
43,201 | <p>I'm looking for some examples or samples of routing for the following sort of scenario:</p>
<p>The general example of doing things is: {controller}/{action}/{id}</p>
<p>So in the scenario of doing a product search for a store you'd have:</p>
<pre><code>public class ProductsController: Controller
{
public ActionResult Search(string id) // id being the search string
{ ... }
}
</code></pre>
<p>Say you had a few stores to do this and you wanted that consistently, is there any way to then have: {category}/{controller}/{action}/{id}</p>
<p>So that you could have a particular search for a particular store, but use a different search method for a different store?</p>
<p>(If you required the store name to be a higher priority than the function itself in the url)</p>
<p>Or would it come down to:</p>
<pre><code>public class ProductsController: Controller
{
public ActionResult Search(int category, string id) // id being the search string
{
if(category == 1) return Category1Search();
if(category == 2) return Category2Search();
...
}
}
</code></pre>
<p>It may not be a great example, but basically the idea is to use the same controller name and therefore have a simple URL across a few different scenarios, or are you kind of stuck with requiring unique controller names, and no way to put them in slightly different namespaces/directories?</p>
<p>Edit to add:</p>
<p>The other reason I want this is because I might want a url that has the categories, and that certain controllers will only work under certain categories.</p>
<p>IE:</p>
<p>/this/search/items/search+term <-- works</p>
<p>/that/search/items/search+term <-- won't work - because the search controller isn't allowed.</p>
| [
{
"answer_id": 45076,
"author": "crucible",
"author_id": 3717,
"author_profile": "https://Stackoverflow.com/users/3717",
"pm_score": 2,
"selected": false,
"text": " public static void RegisterRoutes(RouteCollection routes)\n {\n routes.IgnoreRoute(\"{resource}.axd/{*pathInfo... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] |
43,218 | <p>I'm working on a C#/ASP.NET project that has all the javascript files in a /Javascript folder. If I refer to the JS file using this syntax: src="/Javascript/jsfile.js" then the file is correctly picked up if the project is deployed to the root of the URL.</p>
<p>However, if this "web site" is deployed to a sub-folder of the main url this won't work. So the solution could be to use relative urls - but there's a problem with that as well because the master pages reference many of the javascript files and these master pages can be used by pages in the root and in subfolders many levels deep.</p>
<p>Does anybody have any ideas for resolving this?</p>
| [
{
"answer_id": 43222,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 5,
"selected": true,
"text": "Page.ClientScript.RegisterClientScriptInclude(\"myJsFile\", Page.ResolveClientUrl(\"~/Javascript/jsfile.js\"))\n"
},
{
"a... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
43,224 | <p>Google is not being my friend - it's been a long time since my stats class in college...I need to calculate the start and end points for a trendline on a graph - is there an easy way to do this? (working in C# but whatever language works for you)</p>
| [
{
"answer_id": 47286,
"author": "matt",
"author_id": 2646,
"author_profile": "https://Stackoverflow.com/users/2646",
"pm_score": 5,
"selected": false,
"text": "public class Statistics\n{\n public Trendline CalculateLinearRegression(int[] values)\n {\n var yAxisValues = new L... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2646/"
] |
43,249 | <p>Is there a graceful way to handle passing a list of ids as a parameter to a stored procedure? </p>
<p>For instance, I want departments 1, 2, 5, 7, 20 returned by my stored procedure. In the past, I have passed in a comma delimited list of ids, like the below code, but feel really dirty doing it. </p>
<p>SQL Server 2005 is my only applicable limitation I think.</p>
<pre><code>create procedure getDepartments
@DepartmentIds varchar(max)
as
declare @Sql varchar(max)
select @Sql = 'select [Name] from Department where DepartmentId in (' + @DepartmentIds + ')'
exec(@Sql)
</code></pre>
| [
{
"answer_id": 43260,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": false,
"text": "SELECT d.[Name]\nFROM Department d\n JOIN dbo.SplitWords(@DepartmentIds) w ON w.Value = d.DepartmentId\n"
},
{
... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1865/"
] |
43,253 | <p>What is the best way to measure exception handling overhead/performance in C++?</p>
<p>Please give standalone code samples.</p>
<p>I'm targeting Microsoft Visual C++ 2008 and gcc.</p>
<p>I need to get results from the following cases:</p>
<ol>
<li>Overhead when there are no try/catch blocks</li>
<li>Overhead when there are try/catch blocks but exceptions are not thrown</li>
<li>Overhead when exceptions are thrown</li>
</ol>
| [
{
"answer_id": 43292,
"author": "Antti Kissaniemi",
"author_id": 2948,
"author_profile": "https://Stackoverflow.com/users/2948",
"pm_score": 3,
"selected": false,
"text": "g++ exception_handling.cpp -o exception_handling [ -O2 ]\n"
}
] | 2008/09/04 | [
"https://Stackoverflow.com/questions/43253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2948/"
] |
43,289 | <p>How can I do this fast?</p>
<p>Sure I can do this:</p>
<pre><code>static bool ByteArrayCompare(byte[] a1, byte[] a2)
{
if (a1.Length != a2.Length)
return false;
for (int i=0; i<a1.Length; i++)
if (a1[i]!=a2[i])
return false;
return true;
}
</code></pre>
<p>But I'm looking for either a <a href="https://en.wikipedia.org/wiki/Standard_Libraries_%28CLI%29#Base_Class_Library" rel="noreferrer">BCL</a> function or some highly optimized proven way to do this.</p>
<pre><code>java.util.Arrays.equals((sbyte[])(Array)a1, (sbyte[])(Array)a2);
</code></pre>
<p>works nicely, but it doesn't look like that would work for x64.</p>
<p>Note my super-fast answer <a href="https://stackoverflow.com/a/8808245/4489">here</a>.</p>
| [
{
"answer_id": 43300,
"author": "gil",
"author_id": 195,
"author_profile": "https://Stackoverflow.com/users/195",
"pm_score": 3,
"selected": false,
"text": "for"
},
{
"answer_id": 43305,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackove... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4489/"
] |
43,290 | <p>In Django's template language, you can use <code>{% url [viewname] [args] %}</code> to generate a URL to a specific view with parameters. How can you programatically do the same in Python code?</p>
<p>What I need is to create a list of menu items where each item has name, URL, and an active flag (whether it's the current page or not). This is because it will be a lot cleaner to do this in Python than the template language.</p>
| [
{
"answer_id": 43312,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 7,
"selected": true,
"text": "{% url %}"
},
{
"answer_id": 55734,
"author": "Garth Kidd",
"author_id": 5700,
"author_profile": "htt... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355/"
] |
43,291 | <p>I know that I can do something like</p>
<pre><code>$int = (int)99; //(int) has a maximum or 99
</code></pre>
<p>To set the variable <code>$int</code> to an integer and give it a value of <code>99</code>. </p>
<p>Is there a way to set the type to something like <code>LongBlob</code> in MySQL for <code>LARGE</code> Integers in PHP?</p>
| [
{
"answer_id": 43295,
"author": "erlando",
"author_id": 4192,
"author_profile": "https://Stackoverflow.com/users/4192",
"pm_score": 4,
"selected": true,
"text": "$int = (int)123;\n"
}
] | 2008/09/04 | [
"https://Stackoverflow.com/questions/43291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
43,320 | <p>One of the things that get me thoroughly confused is the use of <code>session.Flush</code>,in conjunction with <code>session.Commit</code>, and <code>session.Close</code>.</p>
<p>Sometimes <code>session.Close</code> works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of work with several creates/updates/deletes, so that I can choose to rollback if an error occurs.</p>
<p>But sometimes I really get stymied by the logic behind <code>session.Flush</code>. I have seen examples where you have a <code>session.SaveOrUpdate()</code> followed by a flush, but when I remove Flush it works fine anyway. Sometimes I run into errors on the Flush statement saying that the session timed out, and removing it made sure that I didn't run into that error.</p>
<p>Does anyone have a good guideline as to where or when to use a Flush? I've checked out the NHibernate documentation for this, but I still can't find a straightforward answer.</p>
| [
{
"answer_id": 43567,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 9,
"selected": true,
"text": "Close()"
},
{
"answer_id": 44212,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "http... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372/"
] |
43,321 | <p>The default shell in Mac OS X is <code>bash</code>, which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed <em>more stuff</em>, though, and I've heard good things about <code>zsh</code> in this regard. But I don't really have the inclination to spend hours fiddling with settings to improve my command line usage by a tiny amount, since my life on the command line isn't that bad. </p>
<p>(As I understand it, <code>bash</code> can also be configured to auto-complete more cleverly. It's the configuring I'm not all that keen on.)</p>
<p>Will switching to <code>zsh</code>, even in a small number cases, make my life easier? Or is it only a better shell if you put in the time to learn <em>why</em> it's better? (Examples would be nice, too <code>:)</code> )</p>
<hr>
<p>@<a href="https://stackoverflow.com/questions/43321/worth-switching-to-zsh-for-casual-use#43340">Rodney Amato</a>
&
@<a href="https://stackoverflow.com/questions/43321/worth-switching-to-zsh-for-casual-use#43338">Vulcan Eager</a>
give two good reasons to respectively stick to <code>bash</code> and switch to <code>zsh</code>. Looks like I'll have to investigate both! Oh well <code>:)</code></p>
<p>Is there anyone with an opinion from both sides of the argument?</p>
| [
{
"answer_id": 43340,
"author": "Rodney Amato",
"author_id": 4342,
"author_profile": "https://Stackoverflow.com/users/4342",
"pm_score": 7,
"selected": true,
"text": "tar -xzvf bash-completion-20060301.tar.gz\n"
},
{
"answer_id": 83754,
"author": "Matt",
"author_id": 1536... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4161/"
] |
43,322 | <p>Plug-in systems in C++ are hard because the ABI is not properly defined, and each compiler (or version thereof) follows its own rules. However, COM on Windows shows that it's possible to create a minimal plug-in system that allows programmers with different compilers to create plug-ins for a host application using a simple interface.</p>
<p>Let's be practical, and leave the C++ standard, which is not very helpful in this respect, aside for a minute. If I want to write an app for Windows and Mac (and optionally Linux) that supports C++ plug-ins, and if I want to give plug-in authors a reasonably large choice of compilers (say less than 2 year old versions of Visual C++, GCC or Intel's C++ compiler), what features of C++ could I count on?</p>
<p>Of course, I assume that plug-ins would be written for a specific platform.</p>
<p>Off the top of my head, here are some C++ features I can think of, with what I think is the answer:</p>
<ul>
<li>vtable layout, to use objects through abstract classes? (yes)</li>
<li>built-in types, pointers? (yes)</li>
<li>structs, unions? (yes)</li>
<li>exceptions? (no)</li>
<li>extern "C" functions? (yes)</li>
<li>stdcall non-extern "C" functions with built-in parameter types? (yes)</li>
<li>non-stdcall non-extern "C" functions with user-defined parameter types? (no)</li>
</ul>
<p>I would appreciate any experience you have in that area that you could share. If you know of any moderately successful app that has a C++ plug-in system, that's cool too.</p>
<p>Carl</p>
| [
{
"answer_id": 43373,
"author": "Jim Buck",
"author_id": 2666,
"author_profile": "https://Stackoverflow.com/users/2666",
"pm_score": 2,
"selected": false,
"text": "#if defined(IN_THE_PLUGIN)\nvoid MyObject::somefunction() { MyObject_somefunction(this); }\n#endif\n"
},
{
"answer_i... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2095/"
] |
43,324 | <p>I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's great, but it has the following documented limitation:</p>
<blockquote>
<p>Because of a known Flash bug, the Uploader running in Firefox in Windows does not send the correct cookies with the upload; instead of sending Firefox cookies, it sends Internet Explorer’s cookies for the respective domain. As a workaround, we suggest either using a cookieless upload method or appending document.cookie to the upload request.</p>
</blockquote>
<p>So, if a user is using Firefox, I can't rely on cookies to persist their session when they upload a file. I need their session because I need to know who they are! As a workaround, I'm using the Application object thusly:</p>
<pre><code>Guid UploadID = Guid.NewGuid();
Application.Add(Guid.ToString(), User);
</code></pre>
<p>So, I'm creating a unique ID and using it as a key to store the <code>Page.User</code> object in the Application scope. I include that ID as a variable in the POST when the file is uploaded. Then, in the handler that accepts the file upload, I grab the User object thusly:</p>
<pre><code>IPrincipal User = (IPrincipal)Application[Request.Form["uploadid"]];
</code></pre>
<p>This actually works, but it has two glaring drawbacks: </p>
<ul>
<li><p>If IIS, the app pool, or even just the application is restarted between the time the user visits the upload page, and actually uploads a file, their "uploadid" is deleted from application scope and the upload fails because I can't authenticate them.</p></li>
<li><p>If I ever scale to a web farm (possibly even a web garden) scenario, this will completely break. I might not be worried, except I do plan on scaling this app in the future.</p></li>
</ul>
<p>Does anyone have a better way? Is there a way for me to pass the actual ASP.Net session ID in a POST variable, then use that ID at the other end to retrieve the session?</p>
<p>I know I can get the session ID through <code>Session.SessionID</code>, and I know how to use YUI to post it to the next page. What I don't know is how to use that <code>SessionID</code> to grab the session from the state server.</p>
<p>Yes, I'm using a state server to store the sessions, so they persist application/IIS restarts, and will work in a web farm scenario.</p>
| [
{
"answer_id": 43353,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "Session.SessionID"
},
{
"answer_id": 43356,
"author": "Seb Nilsson",
"author_id": 2429,
"author_profile": "h... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2527/"
] |
43,349 | <p>I know that default cron's behavior is to send normal and error output to cron's owner local email box.</p>
<p>Is there other ways to get theses results (for example to send it by email to a bunch of people, to store them somewhere, and so on) ?</p>
| [
{
"answer_id": 43357,
"author": "Vagnerr",
"author_id": 3720,
"author_profile": "https://Stackoverflow.com/users/3720",
"pm_score": 2,
"selected": false,
"text": "* * * * * /path/my/command > /my/email/script 2&>1\n"
},
{
"answer_id": 43360,
"author": "Espo",
"author_id":... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3122/"
] |
43,354 | <p>How do you reference a bitmap on the stage in flash using actionscript 3?</p>
<p>I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. here is how my layers in flash are set out.</p>
<pre><code>layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap
</code></pre>
<p>at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.</p>
<p>but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?</p>
<p>The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.</p>
<p>Any help would be appreciated.</p>
<p><strong>EDIT:</strong></p>
<p>@<a href="https://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#43735">81bronco</a> , I tried this but the instance name is greyed out for graphics, it will only allow me to do it with movieclips and buttons. I half got it to work by turning them into moveclips, and clearing the images in the moveclip out before adding a new one (using something simpler to what <a href="https://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#44347">vanhornRF</a> suggested), but for some odd reason when the mask kicks in the images I cleared out come back for the mask animation.</p>
| [
{
"answer_id": 43477,
"author": "bitbonk",
"author_id": 4227,
"author_profile": "https://Stackoverflow.com/users/4227",
"pm_score": 1,
"selected": false,
"text": "imageHolder.removeChild( imageIndex )\n"
},
{
"answer_id": 44347,
"author": "vanhornRF",
"author_id": 1945,
... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098/"
] |
43,368 | <p>I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain the user from typing more than 20 characters in a related form field.</p>
<p>And I have strong antipathy to ORMs which want to define my database tables, or are based on some hack where every table needs to have extra numeric ID columns because of the ORM.</p>
<p>I've looked a bit into Python database frameworks and I think I can conclude the SQLAlchemy fits best to my mentality.</p>
<p>Now, I need to find a web application framework which fits naturally with SQLAlchemy (or an equivalent) and perhaps even with my appetite for coupling. With "web application framework", I mean products/project such as Pyhons, Django, TurboGears, web2py, etc.</p>
<p>E.g., it should ideally be able to:</p>
<ul>
<li><strong>automatically select a suitable form widget</strong> for data entering a given column if told to do so; e.g., if the column has a foreign key to a column with 10 different values, widget should display the 10 possible values as a dropdown</li>
<li><strong>auto-generate javascript form validation code</strong> which gives the end-user quick error feedback if a string is entered into a field which is about to end up in an INTEGER column, etc</li>
<li>auto-generate a <strong>calendar widget</strong> for data which will end up in a DATE column</li>
<li><strong>hint NOT NULL constraints</strong> as javascript which complains about empty or whitespace-only data in a related input field</li>
<li>generate javascript validation code which matches relevant (simple) <strong>CHECK-constraints</strong></li>
<li>make it easy to <strong>avoid SQL injection</strong>, by using prepared statements and/or validation of externally derived data</li>
<li>make it easy to <strong>avoid cross site scripting</strong> by automatically escape outgoing strings when appropriate</li>
<li><strong>make use of constraint names</strong> to generate somewhat user friendly error messages in case a constrataint is violated</li>
</ul>
<p>All this should happen dynamically, so table adjustments are automatically reflected on the frontend - probably with a caching mechanism, so that all the model introspection wouldn't kill performance. In other words, I don't want to repeat my model definition in an XML file (or alike) when it has already been carefully been defined in my database.</p>
<p>Does such a framework exist for Python (or for any language, for that matter)? If not: Which of the several Python web application frameworks will be least in the way if I were to add parts of the above features myself?</p>
| [
{
"answer_id": 48479,
"author": "Jason",
"author_id": 5036,
"author_profile": "https://Stackoverflow.com/users/5036",
"pm_score": 1,
"selected": false,
"text": "<table>"
},
{
"answer_id": 198348,
"author": "massimo",
"author_id": 24489,
"author_profile": "https://Stac... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4462/"
] |
43,374 | <p>What I have so far is </p>
<pre><code>#!/bin/sh
php_syntax_check()
{
retval=0
for i in $(git-diff-index --name-only --cached HEAD -- | grep -e '\.php$'); do
if [ -f $i ]; then
output=$(php -l $i)
retval=$?
if [ $retval -gt 0 ]; then
echo "=============================================================================="
echo "Unstaging $i for the commit due to the follow parse errors"
echo "$output"
git reset -q HEAD $i
fi
fi
done
if [ $retval -gt 0 ]; then
exit $retval
fi
}
php_syntax_check
</code></pre>
| [
{
"answer_id": 547489,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "#!/usr/bin/php\n<?php /* Your pre-commit check. */ ?>\n"
},
{
"answer_id": 3069175,
"author": "LarryH",
"autho... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4342/"
] |
43,393 | <p>I've come back to using NHibernate after using other technologies (<a href="http://www.lhotka.net/" rel="nofollow noreferrer">CSLA</a> and <a href="http://subsonicproject.com/" rel="nofollow noreferrer">Subsonic</a>) for a couple of years, and I'm finding the querying a bit frustrating, especially when compared to Subsonic. I was wondering what other approaches people are using?</p>
<p>The Hibernate Query Language doesn't feel right to me, seems too much like writing SQL, which to my mind is one of the reason to use an ORM tools so I don't have to, furthermore it's all in XML, which means it's poor for refactoring, and errors will only be discovered at runtime?</p>
<p>Criteria Queries, don't seem fluid enough.</p>
<p>I've <a href="http://jhollingworth.wordpress.com/2008/03/28/subsonic-like-nhibernate-query-generator-button-in-visual-studio/" rel="nofollow noreferrer">read</a> that Ayende's <a href="http://www.ayende.com/projects/downloads/nhibernate-query-generator.aspx" rel="nofollow noreferrer">NHibernate Query Generator</a>, is a useful tool, is this what people are using? What else is out there?</p>
<p>EDIT: Worth a read
<a href="http://www.ayende.com/Blog/archive/2007/03/17/Implementing-Linq-for-NHibernate-A-How-To-Guide--Part.aspx" rel="nofollow noreferrer">http://www.ayende.com/Blog/archive/2007/03/17/Implementing-Linq-for-NHibernate-A-How-To-Guide--Part.aspx</a></p>
| [
{
"answer_id": 48097,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 2,
"selected": false,
"text": "GetProductsForOrder(Order order)"
},
{
"answer_id": 206242,
"author": "tobinharris",
"author_id": 1136215,... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] |
43,422 | <p>For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the database). Is there any way for me to determine if it is going to finish in closer to 5 minutes, 5 hours, or 5 days?</p>
| [
{
"answer_id": 7713657,
"author": "Jay Binks",
"author_id": 987797,
"author_profile": "https://Stackoverflow.com/users/987797",
"pm_score": 4,
"selected": false,
"text": "select count(*) from `myoriginalrable`;\nselect count(*) from `#sql-1e8_11ae5`;\n"
},
{
"answer_id": 12055272... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] |
43,427 | <p>Say I have a site on <a href="http://example.com" rel="noreferrer">http://example.com</a>. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words</p>
<p><a href="http://example.com" rel="noreferrer">http://example.com</a> & <a href="http://example.com/" rel="noreferrer">http://example.com/</a> should be allowed, but
<a href="http://example.com/anything" rel="noreferrer">http://example.com/anything</a> and <a href="http://example.com/someendpoint.aspx" rel="noreferrer">http://example.com/someendpoint.aspx</a> should be blocked.</p>
<p>Further it would be great if I can allow certain query strings to passthrough to the home page:
<a href="http://example.com?okparam=true" rel="noreferrer">http://example.com?okparam=true</a> </p>
<p>but not
<a href="http://example.com?anythingbutokparam=true" rel="noreferrer">http://example.com?anythingbutokparam=true</a></p>
| [
{
"answer_id": 43436,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 0,
"selected": false,
"text": "Disallow: /subdir/\n"
},
{
"answer_id": 43454,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "htt... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] |
43,459 | <p>can anybody recommend some really good resources for how to get Apache authenticating users with Kerberos.</p>
<p>Background reading on Kerberos would also be useful </p>
<p>Thanks</p>
<p>Peter</p>
| [
{
"answer_id": 18693599,
"author": "Tomas Tomecek",
"author_id": 909579,
"author_profile": "https://Stackoverflow.com/users/909579",
"pm_score": 1,
"selected": false,
"text": "mod_auth_kerb"
}
] | 2008/09/04 | [
"https://Stackoverflow.com/questions/43459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720/"
] |
43,466 | <p>I know 'best' is subjective, so according to you, what is the best solution for the following problem:</p>
<p>Given a string of length n (say "abc"), generate all proper subsets of the string. So, for our example, the output would be {}, {a}, {b}, {c}, {ab}, {bc}, {ac}. {abc}.</p>
<p>What do you think?</p>
| [
{
"answer_id": 43474,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "def subsets(s):\n r = []\n a = [False] * len(s)\n while True:\n r.append(\"\".join([s[i] for i in range(le... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/380/"
] |
43,490 | <p>When is this called? More specifically, I have a control I'm creating - how can I release handles when the window is closed. In normal win32 I'd do it during <code>wm_close</code> - is <code>DestroyHandle</code> the .net equivalent?</p>
<hr>
<p>I don't want to destroy the window handle myself - my control is listening for events on another object and when my control is destroyed, I want to stop listening to those events. Eg:</p>
<pre><code>void Dispose(bool disposing) {
otherObject.Event -= myEventHandler;
}
</code></pre>
| [
{
"answer_id": 43499,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "DestroyHandle"
},
{
"answer_id": 43560,
"author": "dan gibson",
"author_id": 4495,
"author_profile": "https:/... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4495/"
] |
43,500 | <p>I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary and an IList. Is there a built-in method to do this?</p>
<p>Edited:
I want to compare two Dictionaries and two ILists, so I think what equality means is clear - if the two dictionaries contain the same keys mapped to the same values, then they're equal.</p>
| [
{
"answer_id": 43505,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 9,
"selected": true,
"text": "Enumerable.SequenceEqual"
},
{
"answer_id": 43506,
"author": "aku",
"author_id": 1196,
"author_profil... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2348/"
] |
43,503 | <p>Is there a way to detect if a flash movie contains any sound or is playing any music?<br>
It would be nice if this could be done inside a webbrowser (actionscript <strong>from another flash object</strong>, javascript,..) and could be done <em>before</em> the flash movie starts playing.</p>
<p>However, I have my doubts this will be possible altogether, so any other (programmable) solution is also appreciated</p>
| [
{
"answer_id": 43519,
"author": "Stu Thompson",
"author_id": 2961,
"author_profile": "https://Stackoverflow.com/users/2961",
"pm_score": 3,
"selected": true,
"text": "FIELD DATA TYPE EXAMPLE DESCRIPTION\n Signature byte[3] “FLV” Alw... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46/"
] |
43,507 | <p>I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?</p>
<p>Is there anything more to be added to the code that goes into a real world application?</p>
<p>What all steps are to be taken to make the application more robust and secure?</p>
<p>Here is a sample source code I got from the web:</p>
<pre><code>function getChats() {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
return;
}
var url="getchat.php?latest="+latest;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function GetXmlHttpObject() {
var xmlHttp=null;
try {
xmlHttp=new XMLHttpRequest();
} catch (e) {
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</code></pre>
| [
{
"answer_id": 43515,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 0,
"selected": false,
"text": "new Ajax.Request('/some_url',\n {\n method:'get',\n onSuccess: function(transport){\n var response = transport.res... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] |
43,511 | <p>I have some classes layed out like this</p>
<pre><code>class A
{
public virtual void Render()
{
}
}
class B : A
{
public override void Render()
{
// Prepare the object for rendering
SpecialRender();
// Do some cleanup
}
protected virtual void SpecialRender()
{
}
}
class C : B
{
protected override void SpecialRender()
{
// Do some cool stuff
}
}
</code></pre>
<p>Is it possible to prevent the C class from overriding the Render method, without breaking the following code?</p>
<pre><code>A obj = new C();
obj.Render(); // calls B.Render -> c.SpecialRender
</code></pre>
| [
{
"answer_id": 43516,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 6,
"selected": true,
"text": "public sealed override void Render()\n{\n // Prepare the object for rendering \n SpecialRender();\n // Do ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3602/"
] |
43,524 | <p>It is slow to load anything other than a small project. It is slow to quit; it can sometimes take minutes. It can be slow to open new files. The record macro feature used to be useful. It is now so slow to start up it's almost always quicker to do it manually!</p>
<hr>
<blockquote>
<p>More info would be helpful. How big are your solutions? What platform are you on. What 3rd party plugins are you running? What else is running on your pc? </p>
</blockquote>
<p>3.2GHz P4 Hyperthreaded, 2GB RAM. Running Outlook, Perforce, IE7, directory browsers. Usually have 1-3 instances of VS running. It's much slower than VC6, say. It seems to take a long time to load projects and close down. I'm interested in if people know reasons why this happens, because of the way VS is written. Is it using .net internally and GC slows it down?</p>
| [
{
"answer_id": 260385,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "#include <stdio.h>\n#include <windows.h>\n\nint main(char argc, char *argv[])\n{\n printf(\"Hello World\\n\");\n return 0;... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3233/"
] |
43,525 | <p>For some strange, bizarre reason, my images in my website just will not display on webkit based languages (such as safari and chrome).</p>
<p>This is the image tag</p>
<pre><code><img src="images/dukkah.jpg" class="imgleft"/>
</code></pre>
<p>Not only does it not display in the website, it wont display when accessed directly at <code>http://kilkin.massiveatom.com/kilkin/images/dukkah.jpg</code></p>
<p>...Why?</p>
| [
{
"answer_id": 37536836,
"author": "Matt",
"author_id": 1318694,
"author_profile": "https://Stackoverflow.com/users/1318694",
"pm_score": 0,
"selected": false,
"text": "$ curl -s http://kilkin.massiveatom.com/kilkin/images/dukkah.jpg\n<html><head></head><body><!-- vbe --></body></html>\n... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.