qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
47,066 | <p>I am writing a C program in Linux. Commands like execv() require a path in the form of a C string. Is there a command that will return the current path in the form of a C-style string?</p>
| [
{
"answer_id": 47071,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": true,
"text": "#include <unistd.h>\n\nchar *getcwd(char *buf, size_t size);\n"
},
{
"answer_id": 47074,
"author": "Andreas ... | 2008/09/05 | [
"https://Stackoverflow.com/questions/47066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159/"
] |
47,078 | <p>We are currently using the ExtJS tree view in an application - a requirement has arisen requiring a user to select multiple nodes (which the tree view supports currently through a pluggable selection model) - but you can not then drag the multiple selections to another part of the tree.</p>
<p>Does anyone know of an ajax control (commercial or non-commercial) that supports multiple-selection drag / drop - or a example of enabling this functionality in ExtJS?</p>
| [
{
"answer_id": 3988952,
"author": "Benoit",
"author_id": 483194,
"author_profile": "https://Stackoverflow.com/users/483194",
"pm_score": 2,
"selected": true,
"text": "..new Ext.tree.TreePanel({\n ...\n selModel : new Ext.tree.MultiSelectionModel()\n ...\n})\n"
}
] | 2008/09/05 | [
"https://Stackoverflow.com/questions/47078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4843/"
] |
47,087 | <p>Here are a few possibilities to get the conversation started:</p>
<ol>
<li>Escape all input upon initialization.</li>
<li>Escape each value, preferably when generating the SQL.</li>
</ol>
<p>The first solution is suboptimal, because you then need to unescape each value if you want to use it in anything other than SQL, like outputting it on a web page.</p>
<p>The second solution makes much more sense, but manually escaping each value is a pain.</p>
<p>I'm aware of <a href="http://en.wikipedia.org/wiki/SQL_injection#Using_Parameterized_Statements" rel="noreferrer">prepared statements</a>, however I find <a href="http://www.php.net/manual/en/book.mysqli.php" rel="noreferrer">MySQLi</a> cumbersome. Also, separating the query from the inputs concerns me, because although it's crucial to get the order correct it's easy to make a mistake, and thus write the wrong data to the wrong fields.</p>
| [
{
"answer_id": 47108,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": -1,
"selected": false,
"text": "$_GET"
}
] | 2008/09/05 | [
"https://Stackoverflow.com/questions/47087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
47,089 | <p>About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over http I would response.redirect("<a href="https://example.com" rel="noreferrer">https://example.com</a>")</p>
<p>Is there a better way -- ideally some setting in the web.config?</p>
| [
{
"answer_id": 47095,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 9,
"selected": true,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n <system.webServer>\n <rewrite>\n <rules>... | 2008/09/05 | [
"https://Stackoverflow.com/questions/47089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4846/"
] |
47,104 | <p>Can anyone explain this behavior or how to get around it?</p>
<p>If you execute this query:</p>
<pre><code>select *
from TblA
left join freetexttable ( TblB, *, 'query' ) on TblA.ID = [Key]
inner join DifferentDbCatalog.dbo.TblC on TblA.ID = TblC.TblAID
</code></pre>
<p>It will be very very very slow.</p>
<p>If you change that query to use two inner joins instead of a left join, it will be very fast. If you change it to use two left joins instead of an inner join, it will be very fast.</p>
<p>You can observe this same behavior if you use a sql table variable instead of the freetexttable as well. </p>
<p>The performance problem arises any time you have a table variable (or freetexttable) and a table in a different database catalog where one is in an inner join and the other is in a left join.</p>
<p>Does anyone know why this is slow, or how to speed it up?</p>
| [
{
"answer_id": 47128,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": false,
"text": "SELECT * \nFROM TblA\nINNER JOIN DifferentDbCatalog.dbo.TblC on TblA.ID = TblC.TblAID\nLEFT JOIN freetexttable ( TblB, ... | 2008/09/05 | [
"https://Stackoverflow.com/questions/47104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4407/"
] |
47,107 | <p>Is there a way to disallow publishing of debug builds with ClickOnce?</p>
<p>I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while. </p>
<p>We're publishing the build from within Visual Studio.</p>
| [
{
"answer_id": 865822,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 3,
"selected": false,
"text": "<Choose>\n <When Condition=\" '$(Configuration)'=='Debug' \">\n <Exec Command=\"C:\\foo.bat\" Continue... | 2008/09/05 | [
"https://Stackoverflow.com/questions/47107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3641/"
] |
47,144 | <p>In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments, in which I catch <code>ThreadAbortedException</code>, do <code>Thread.ResetAbort()</code> and die beautifully (that is, the thread).</p>
<p>The problem is that, in the time window in which aborting is possible, there are some tasks that need to be done from start to finish once initiated, and, so, I fear TAE. Locks don't provide a solution for this, and, although finally blocks do, I don't find it elegant to wrap important code in the following manner:</p>
<pre><code>try {
} finally {
// vital code
}
</code></pre>
<p>However, I didn't find any other solution.</p>
<p>Is this another way to delay the interference of <code>ThreadAbortException</code> until the end of the block?</p>
| [
{
"answer_id": 47150,
"author": "Corey",
"author_id": 1595,
"author_profile": "https://Stackoverflow.com/users/1595",
"pm_score": 2,
"selected": false,
"text": "Thread.BeginCriticalRegion()\n\n//do important stuff here\n\nThread.EndCriticalRegion()\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4850/"
] |
47,169 | <p>I'd like to enable/disable some other controls based on how many items are in my <code>ListView</code> control. I can't find any event that would do this, either on the <code>ListView</code> itself or on the <code>ListViewItemCollection</code>. Maybe there's a way to generically watch any collection in C# for changes?</p>
<p>I'd be happy with other events too, even ones that sometimes fire when the items don't change, but for example the <code>ControlAdded</code> and <code>Layout</code> events didn't work :(.</p>
| [
{
"answer_id": 47178,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 0,
"selected": false,
"text": "Public Class MyListViewItemCollection\n Inherits ListView.ListViewItemCollection\n\n Public Event ItemAdded(ByVal Item A... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] |
47,177 | <p>I would like to monitor the following system information in Java:</p>
<ul>
<li>Current CPU usage** (percent)</li>
<li>Available memory* (free/total)</li>
<li><p>Available disk space (free/total)</p>
<p>*Note that I mean overall memory available to the whole system, not just the JVM.</p></li>
</ul>
<p>I'm looking for a cross-platform solution (Linux, Mac, and Windows) that doesn't rely on my own code calling external programs or using JNI. Although these are viable options, I would prefer not to maintain OS-specific code myself if someone already has a better solution.</p>
<p>If there's a free library out there that does this in a reliable, cross-platform manner, that would be great (even if it makes external calls or uses native code itself).</p>
<p>Any suggestions are much appreciated.</p>
<p>To clarify, I would like to get the current CPU usage for the whole system, not just the Java process(es).</p>
<p>The SIGAR API provides all the functionality I'm looking for in one package, so it's the best answer to my question so far. However, due it being licensed under the GPL, I cannot use it for my original purpose (a closed source, commercial product). It's possible that Hyperic may license SIGAR for commercial use, but I haven't looked into it. For my GPL projects, I will definitely consider SIGAR in the future.</p>
<p>For my current needs, I'm leaning towards the following:</p>
<ul>
<li>For CPU usage, <code>OperatingSystemMXBean.getSystemLoadAverage() / OperatingSystemMXBean.getAvailableProcessors()</code> (load average per cpu)</li>
<li>For memory, <code>OperatingSystemMXBean.getTotalPhysicalMemorySize()</code> and <code>OperatingSystemMXBean.getFreePhysicalMemorySize()</code></li>
<li>For disk space, <code>File.getTotalSpace()</code> and <code>File.getUsableSpace()</code></li>
</ul>
<p>Limitations:</p>
<p>The <code>getSystemLoadAverage()</code> and disk space querying methods are only available under Java 6. Also, some JMX functionality may not be available to all platforms (i.e. it's been reported that <code>getSystemLoadAverage()</code> returns -1 on Windows).</p>
<p>Although originally licensed under GPL, it <a href="http://forums.hyperic.com/jiveforums/thread.jspa?threadID=11426&tstart=0" rel="noreferrer">has been changed</a> to <a href="http://support.hyperic.com/display/SIGAR/Home#Home-license" rel="noreferrer">Apache 2.0</a>, which can generally be used for closed source, commercial products.</p>
| [
{
"answer_id": 47199,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 6,
"selected": false,
"text": "import java.lang.management.ManagementFactory;\nimport java.lang.management.OperatingSystemMXBean;\nimport java.lang.re... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2783/"
] |
47,198 | <p>If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?</p>
<p>I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current version seems to be working fine. What version would hit the sweet spot but still allow me to enjoy the newest and coolest language enhancements?</p>
| [
{
"answer_id": 47201,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 2,
"selected": false,
"text": "from __future__ import *\n"
},
{
"answer_id": 47264,
"author": "Christopher Mahan",
"author_id": 479,... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] |
47,203 | <p>When should I choose one or the other? What are the implications regarding space and (full-text) indexing?</p>
<p>BTW: I'm currently using SQL Server 2005 planing to upgrade to 2008 in the following months.</p>
<p>Thanks</p>
| [
{
"answer_id": 47214,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 5,
"selected": true,
"text": "varbinary(max)"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148/"
] |
47,207 | <p>Can i print out a url <code>/admin/manage/products/add</code> of a certain view in a template?</p>
<p>Here is the rule i want to create a link for</p>
<pre><code>(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
</code></pre>
<p>I would like to have /manage/products/add in a template without hardcoding it. How can i do this?</p>
<p><strong>Edit:</strong> I am not using the default admin (well, i am but it is at another url), this is my own</p>
| [
{
"answer_id": 47212,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 2,
"selected": false,
"text": "{% url create_object %}\n"
},
{
"answer_id": 47213,
"author": "Cristian",
"author_id": 680,
"author_... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
47,217 | <p>I've got a DataSet in VisualStudio 2005. I need to change the datatype of a column in one of the datatables from <code>System.Int32</code> to <code>System.Decimal</code>. When I try to change the datatype in the <code>DataSet Designer</code> I receive the following error:</p>
<blockquote>
<p>Property value is not valid. Cannot change DataType of a column once
it has data.</p>
</blockquote>
<p>From my understanding, this should be changing the datatype in the schema for the DataSet. I don't see how there can be any data to cause this error.</p>
<p>Does any one have any ideas?</p>
| [
{
"answer_id": 1905709,
"author": "Are",
"author_id": 231880,
"author_profile": "https://Stackoverflow.com/users/231880",
"pm_score": 6,
"selected": true,
"text": "DefaultValue"
},
{
"answer_id": 34353698,
"author": "ldam",
"author_id": 1492861,
"author_profile": "htt... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123/"
] |
47,239 | <p>Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by hand. For example, given the following class:</p>
<pre><code>class Foo
{
private string property1;
public string Property1
{
get { return property1; }
set { property1 = value; }
}
private int property2;
public int Property2
{
get { return property2; }
set { property2 = value; }
}
}
</code></pre>
<p>I'd expect the following SQL:</p>
<pre><code>CREATE TABLE Foo
(
Property1 VARCHAR(500),
Property2 INT
)
</code></pre>
<p>I'm also wondering how you could handle complex types. For example, in the previously cited class, if we changed that to be :</p>
<pre><code>class Foo
{
private string property1;
public string Property1
{
get { return property1; }
set { property1 = value; }
}
private System.Management.ManagementObject property2;
public System.Management.ManagementObject Property2
{
get { return property2; }
set { property2 = value; }
}
}
</code></pre>
<p></p>
<p>How could I handle this?</p>
<p>I've looked at trying to auto-generate the database scripts by myself using reflection to enumerate through each class' properties, but it's clunky and the complex data types have me stumped.</p>
| [
{
"answer_id": 47251,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "CREATE TABLE MiscTypes /* may have to include standard types as well */\n ( TypeID INT,\n TypeName VARCHAR(...)\n )\n\n... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4550/"
] |
47,309 | <p>I'm trying to install <a href="http://godi.camlcity.org/godi/index.html" rel="noreferrer">GODI</a> on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what I'm missing.</p>
<pre><code>$ ./bootstrap --prefix /home/nlucaroni/godi
$ ./bootstrap_stage2
.: 1: godi_confdir: not found
Error: Command fails with code 2: /bin/sh
Failure!
</code></pre>
<p>I had added the proper directories to the path, and they show up with a quick <code>echo $path</code>, and <code>godi_confdir</code> reported as being:</p>
<pre><code> /home/nlucaroni/godi/etc
</code></pre>
<p>(...and the directory exists, with the godi.conf file present). So, I can't figure out why <code>./bootstrap_stage2</code> isn't working.</p>
| [
{
"answer_id": 47655,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 2,
"selected": false,
"text": "which godi_confdir"
},
{
"answer_id": 47678,
"author": "nlucaroni",
"author_id": 157,
"author_profil... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157/"
] |
47,329 | <p>I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"):</p>
<pre><code>"Default.aspx?page=1"
"Default.aspx?page=2"
"Default.aspx?someother=true&page=2"
</code></pre>
<p>etc.</p>
<p>Is there a simple helper method that I can use in the Render method ... uhmm ... like:</p>
<pre><code>Page.ClientScript.SomeURLBuilderMethodHere(this,"page","1");
Page.ClientScript.SomeURLBuilderMethodHere(this,"page","2");
</code></pre>
<p>That will take care of generating a correct URL, maintain existing query string items and not create duplicates eg. page=1&page=2&page=3?</p>
<p>Rolling up my own seems like such an unappealing task.</p>
| [
{
"answer_id": 47344,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 2,
"selected": true,
"text": " /// <summary>\n /// Set a parameter value in a query string. If the parameter is not found in the passed in query ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3263/"
] |
47,338 | <p>I have a problem with a sample routing with the preview 5 of asp.net mvc.</p>
<p>In the AccountController I have 2 actions: </p>
<pre><code>public ActionResult Delete()
public ActionResult Delete(string username)
</code></pre>
<p>While trying to look for Account/Delete or Account/Delete?username=davide the ControllerActionInvoker throws a exception saying that Delete request is ambiguous between my tow actions methods.</p>
<p>The default route in the global.asax hasn't been changed.</p>
<p>Shouldn't the action invoker understand what's the method to call looking in the parameters list?</p>
<p>Using the preview 4 I hadn't these kind of problem performing the same operation.</p>
<p>Any idea?</p>
| [
{
"answer_id": 49187,
"author": "crucible",
"author_id": 3717,
"author_profile": "https://Stackoverflow.com/users/3717",
"pm_score": 0,
"selected": false,
"text": "public ActionResult Delete(string id)\n{\n if(string.IsNullOrEmpty(id)) return EmptyID();\n\n // Continue normal Delet... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1812/"
] |
47,363 | <p>What is the command to list all triggers in a MySQL database?</p>
| [
{
"answer_id": 47364,
"author": "Harry",
"author_id": 4704,
"author_profile": "https://Stackoverflow.com/users/4704",
"pm_score": 9,
"selected": true,
"text": "show triggers;\n"
},
{
"answer_id": 7257460,
"author": "sunil",
"author_id": 921665,
"author_profile": "http... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4704/"
] |
47,387 | <p>I've been hearing about triggers, and I have a few questions.<br />
What are triggers?<br />
How do I set them up?<br />
Are there any precautions, aside from typical SQL stuff, that should be taken?</p>
| [
{
"answer_id": 47391,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 0,
"selected": false,
"text": "CREATE TRIGGER triggerName [BEFORE|AFTER] [INSERT|UPDATE|DELETE|REPLACE] ON tableName FOR EACH ROW SET stuffToDoHERE;\n"
},... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
47,400 | <p>With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).</p>
<p>One of the main issues with testing forms is that only a few controls have a <code>hwnd</code> handle and other controls only get one they have focus, which makes automation quite opaque since you cant get a list of controls on a form to act on.</p>
<p>Any experience to share?</p>
| [
{
"answer_id": 70572,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 4,
"selected": false,
"text": "AfterUpdate"
},
{
"answer_id": 6959038,
"author": "mwolfe02",
"author_id": 154439,
"author_pr... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] |
47,402 | <p>Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.</p>
<p>Example input and output:</p>
<pre><code>>>> reverse_words("this is a string")
'string a is this'
</code></pre>
<p>It should be O(N) time and O(1) space (<code>split()</code> and pushing on / popping off the stack are not allowed).</p>
<p>The puzzle is taken from <a href="http://halcyon.usc.edu/~kiran/msqs.html#programming" rel="noreferrer" title="Microsoft Interview Questions">here</a>.</p>
| [
{
"answer_id": 47416,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 1,
"selected": false,
"text": "reverse input string\nreverse each word (you will need to find word boundaries)\n"
},
{
"answer_id": 47423,
"author":... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279/"
] |
47,413 | <p>It's common to have a table where for example the the fields are account, value, and time. What's the best design pattern for retrieving the last value for each account? Unfortunately the last keyword in a grouping gives you the last physical record in the database, not the last record by any sorting. Which means IMHO it should never be used. The two clumsy approaches I use are either a subquery approach or a secondary query to determine the last record, and then joining to the table to find the value. Isn't there a more elegant approach?</p>
| [
{
"answer_id": 47431,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": 2,
"selected": true,
"text": "select * \nfrom table \nwhere account+time in (select account+max(time) \n from table \n ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4873/"
] |
47,420 | <p>I'm using the d programing language to write a program, and I'm trying to use ddbg to debug it. When there is an exception, I want to have the program break whenever there is an exception thrown so that I can inspect the stack.</p>
<p>Alternatively, is there another debugger that works with d? Is there another way to get a stack trace when there is an exception?</p>
| [
{
"answer_id": 47974,
"author": "user4891",
"author_id": 4891,
"author_profile": "https://Stackoverflow.com/users/4891",
"pm_score": 0,
"selected": false,
"text": "onex break\nonex b\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4891/"
] |
47,427 | <p>Many websites, including this one, add what are apparently called <em>slugs</em> - descriptive but as far as I can tell useless bits of text - to the end of URLs.</p>
<p>For example, the URL the site gives for this question is:</p>
<p><a href="https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls"><code>https://stackoverflow.com/questions/47427/why-do-some-websites-add-slugs-to-the-end-of-urls</code></a></p>
<p>But the following URL works just as well:</p>
<p><a href="https://stackoverflow.com/questions/47427/"><code>https://stackoverflow.com/questions/47427/</code></a></p>
<p>Is the point of this text just to somehow make the URL more user friendly or are there some other benefits? </p>
| [
{
"answer_id": 47451,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": 3,
"selected": false,
"text": "https://stackoverflow.com/questions/47427/"
},
{
"answer_id": 47585,
"author": "billpg",
"author_id": 3568,
"... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3171/"
] |
47,432 | <p>This free collection library comes from IT University of Copenhagen.</p>
<p><a href="http://www.itu.dk/research/c5/" rel="noreferrer">http://www.itu.dk/research/c5/</a></p>
<p>There is a video with one of the authors on Channel 9. I am trying to learn how to use these collections and I was wondering whether anyone has more experiences or what are your thoughts on this specific collection library for .NET. Do you like the way they are designed, do you like their performance and what were your major problems with them ?</p>
| [
{
"answer_id": 209387,
"author": "Marcus Griep",
"author_id": 28645,
"author_profile": "https://Stackoverflow.com/users/28645",
"pm_score": 3,
"selected": false,
"text": "System.Collections.Generic"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4694/"
] |
47,433 | <p>Consider the following 2 queries:</p>
<pre><code>select tblA.a,tblA.b,tblA.c,tblA.d
from tblA
where tblA.a not in (select tblB.a from tblB)
select tblA.a,tblA.b,tblA.c,tblA.d
from tblA left outer join tblB
on tblA.a = tblB.a where tblB.a is null
</code></pre>
<p>Which will perform better? My assumption is that in general the join will be better except in cases where the subselect returns a very small result set.</p>
| [
{
"answer_id": 57744,
"author": "Martynnw",
"author_id": 5466,
"author_profile": "https://Stackoverflow.com/users/5466",
"pm_score": 1,
"selected": false,
"text": "exists"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] |
47,436 | <p>What is the shortcut key for <em>Run to cursor</em> in Visual Studio 2008?</p>
| [
{
"answer_id": 70101220,
"author": "Teoman shipahi",
"author_id": 929902,
"author_profile": "https://Stackoverflow.com/users/929902",
"pm_score": 0,
"selected": false,
"text": "Ctrl + Shift + P\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3854/"
] |
47,447 | <p>I am trying to create a horizontal menu with the elements represented by <code><span></code>'s. The menu itself (parent <code><div></code>) has a fixed width, but the elements number is always different.</p>
<p>I would like to have child <code><span></code>'s of the same width, independently of how many of them are there.</p>
<p>What I've done so far: added a <code>float: left;</code> style for every span and specified its percentage width (percents are more or less fine, as the server knows at the time of the page generation, how many menu items are there and could divide 100% by this number). This works, except for the case when we have a division remainder (like for 3 elements), in this case I have a one-pixel hole to the right of the parent <code><div></code>, and if I rounding the percents up, the last menu element is wrapped. I also don't really like style generation on the fly, but if there's no other solution, it's fine.</p>
<p>What else could I try?</p>
<p>It seems like this is a very common problem, however googling for "child elements of the same width" didn't help.</p>
| [
{
"answer_id": 47465,
"author": "Xian",
"author_id": 4642,
"author_profile": "https://Stackoverflow.com/users/4642",
"pm_score": 2,
"selected": false,
"text": "<div>\n<span class=\"first-in-row\">/<span><span></span><span></span><span class=\"first-in-row\"><span></span><span></span>...\... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3894/"
] |
47,475 | <p>If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?</p>
<p>ie </p>
<pre><code>[Test]
public void ShouldValidateUserNameIsLessThan100Characters() {}
</code></pre>
<p>verse </p>
<pre><code>[Test]
public void UserNameTestValidation1() {}
</code></pre>
| [
{
"answer_id": 47477,
"author": "zappan",
"author_id": 4723,
"author_profile": "https://Stackoverflow.com/users/4723",
"pm_score": 1,
"selected": false,
"text": "UserNameLengthValidate()\n"
},
{
"answer_id": 47478,
"author": "Adrian Mouat",
"author_id": 4332,
"author_... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4642/"
] |
47,483 | <p>I have a user script that would be much more useful if it could dynamically change some of its execution dependent on what the user wanted. Passing simple switches would easily solve this problem but I don't see any way to do it.</p>
<p>I also tried embedding a keyword in the script name, but <em>Xcode</em> copies the script to a guid-looking filename before execution, so that won't work either.</p>
<p>So does anyone know of a way to call a user script with some sort of argument? (other that the normal <code>%%%var%%%</code> variables)</p>
<hr />
<h3>EDIT:</h3>
<p>User scripts are accessible via the script menu in Xcode's menubar (between the Window and Help menus). My question is not about "run script" build phase scripts. My apologies for leaving that somewhat ambiguous.</p>
| [
{
"answer_id": 47619,
"author": "vt.",
"author_id": 3905,
"author_profile": "https://Stackoverflow.com/users/3905",
"pm_score": 0,
"selected": false,
"text": "#!/bin/bash\nresult=$( osascript << END\ntell app \"System Events\"\n set a to display dialog \"What shall be the result?\" defa... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4233/"
] |
47,487 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/30170/avoiding-repeated-constants-in-css">Avoiding repeated constants in CSS</a> </p>
</blockquote>
<p>We have some "theme colors" that are reused in our CSS sheet.</p>
<p>Is there a way to set a variable and then reuse it?</p>
<p>E.g.</p>
<pre><code>.css
OurColor: Blue
H1 {
color:OurColor;
}
</code></pre>
| [
{
"answer_id": 47505,
"author": "Tim Sullivan",
"author_id": 722,
"author_profile": "https://Stackoverflow.com/users/722",
"pm_score": 3,
"selected": false,
"text": "$blue: #3bbfce;\n$margin: 16px;\n\n.content-navigation {\n border-color: $blue;\n color:\n darken($blue, 9%);\n}\n\n.... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] |
47,519 | <p>I have a fairly standards compliant XHTML+CSS site that looks great on all browsers on PC and Mac. The other day I saw it on FF3 on Linux and the letter spacing was slightly larger, throwing everything out of whack and causing unwanted wrapping and clipping of text. The CSS in question has</p>
<pre><code>font-size: 11px;
font-family: Arial, Helvetica, sans-serif;
</code></pre>
<p>I know it's going with the generic sans-serif, whatever that maps to. If I add the following, the text scrunches up enough to be close to what I get on the other platforms:</p>
<pre><code>letter-spacing: -1.5px;
</code></pre>
<p>but this would involve some nasty server-side OS sniffing. If there's a pure CSS solution to this I'd love to hear it.</p>
<p>The system in question is Ubuntu 7.04 but that is irrelevant as I'm looking to fix it for at least the majority of, if not all, Linux users. Of course asking the user to install a font is not an option!</p>
| [
{
"answer_id": 47531,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 3,
"selected": false,
"text": "ems"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3206/"
] |
47,521 | <p>Here is a sample code to retrieve data from a database using the yield keyword that I found in a few place while googling around :</p>
<pre><code>public IEnumerable<object> ExecuteSelect(string commandText)
{
using (IDbConnection connection = CreateConnection())
{
using (IDbCommand cmd = CreateCommand(commandText, connection))
{
connection.Open();
using (IDbDataReader reader = cmd.ExecuteReader())
{
while(reader.Read())
{
yield return reader["SomeField"];
}
}
connection.Close();
}
}
}
</code></pre>
<p>Am I correct in thinking that in this sample code, the connection would not be closed if we do not iterate over the whole datareader ? </p>
<p>Here is an example that would not close the connection, if I understand yield correctly..</p>
<pre><code>foreach(object obj in ExecuteSelect(commandText))
{
break;
}
</code></pre>
<p>For a db connection that might not be catastrophic, I suppose the GC would clean it up eventually, but what if instead of a connection it was a more critical resource?</p>
| [
{
"answer_id": 47746,
"author": "Joel Gauvreau",
"author_id": 4789,
"author_profile": "https://Stackoverflow.com/users/4789",
"pm_score": 2,
"selected": false,
"text": "class Program\n{\n static void Main(string[] args)\n {\n foreach (int v in getValues())\n {\n ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4789/"
] |
47,535 | <p>Updating an old ASP/Access site for a client - I need SQL to add a column to an existing table and set a default value. Doesn't work - any ideas?</p>
<p>This works fine</p>
<pre><code>ALTER TABLE documents ADD COLUMN membersOnly NUMBER
</code></pre>
<p>I want this to work:</p>
<pre><code>ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0
</code></pre>
<p>Have googled and seen instructions for default values work for other field types but I want to add number. Thanks!</p>
| [
{
"answer_id": 47552,
"author": "zappan",
"author_id": 4723,
"author_profile": "https://Stackoverflow.com/users/4723",
"pm_score": 4,
"selected": true,
"text": "ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0\n"
},
{
"answer_id": 6066172,
"author": "HansUp",
... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137/"
] |
47,537 | <p>Does anyone know if there is a c# Console app, similar to the Python or Ruby console? I know the whole "Compiled versus Interpreted" difference, but with C#'s reflection power I think it could be done.</p>
<p><strong>UPDATE</strong>
Well, it only took about 200 lines, but I wrote a simple one...It works a lot like osql. You enter commands and then run them with go.</p>
<p><a href="http://www.gfilter.net/junk/sharpconsole.jpg">SharpConsole http://www.gfilter.net/junk/sharpconsole.jpg</a></p>
<p>If anyone wants it, let me know.</p>
| [
{
"answer_id": 47548,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 5,
"selected": true,
"text": "irb"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
47,589 | <p>I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning.</p>
<p>I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropriately. Ideally I would like to know what kind of warning MySQL has thrown so that I can branch the code to handle it.</p>
<p>Is this possible? If not, is it because MySQL doesn't have this ability, PHP doesn't have this ability, or both?</p>
| [
{
"answer_id": 47597,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 2,
"selected": false,
"text": "mysql_query()"
},
{
"answer_id": 47606,
"author": "yukondude",
"author_id": 726,
"author_profile": "htt... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2056/"
] |
47,591 | <p>Specifically, I am looking to use CA on properties of types other than </p>
<ul>
<li>integers and doubles</li>
<li>CGRect, CGPoint, CGSize, and CGAffineTransform structures</li>
<li>CATransform3D data structures</li>
<li>CGColor and CGImage references</li>
</ul>
<p>and in objects other than CALayers or NSViews</p>
| [
{
"answer_id": 59168,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 1,
"selected": false,
"text": "[[someObject animator] setValue:[NSNumber numberWithFloat:1.0] forKeyPath:@\"someCustomProperty.progress\"];\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
47,605 | <p>Assuming String a and b:</p>
<pre><code>a += b
a = a.concat(b)
</code></pre>
<p>Under the hood, are they the same thing?</p>
<p>Here is concat decompiled as reference. I'd like to be able to decompile the <code>+</code> operator as well to see what that does.</p>
<pre><code>public String concat(String s) {
int i = s.length();
if (i == 0) {
return this;
}
else {
char ac[] = new char[count + i];
getChars(0, count, ac, 0);
s.getChars(0, i, ac, count);
return new String(0, count + i, ac);
}
}
</code></pre>
| [
{
"answer_id": 47624,
"author": "Bartosz Bierkowski",
"author_id": 3666,
"author_profile": "https://Stackoverflow.com/users/3666",
"pm_score": 2,
"selected": false,
"text": "a.concat(b)"
},
{
"answer_id": 47626,
"author": "Eli Courtwright",
"author_id": 1694,
"author_... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] |
47,612 | <p>I've got a C# class with a <code>Dispose</code> function via <code>IDisposable</code>. It's intended to be used inside a <code>using</code> block so the expensive resource it handles can be released right away.</p>
<p>The problem is that a bug occurred when an exception was thrown before <code>Dispose</code> was called, and the programmer neglected to use <code>using</code> or <code>finally</code>.</p>
<p>In C++, I never had to worry about this. The call to a class's destructor would be automatically inserted at the end of the object's scope. The only way to avoid that happening would be to use the new operator and hold the object behind a pointer, but that required extra work for the programmer isn't something they would do by accident, like forgetting to use <code>using</code>.</p>
<p>Is there any way to for a <code>using</code> block to be automatically used in C#?</p>
<p>Many thanks.</p>
<p>UPDATE:</p>
<p>I'd like to explain why I'm not accepting the finalizer answers. Those answers are technically correct in themselves, but they are not C++ style destructors.</p>
<p>Here's the bug I found, reduced to the essentials...</p>
<pre><code>try
{
PleaseDisposeMe a = new PleaseDisposeMe();
throw new Exception();
a.Dispose();
}
catch (Exception ex)
{
Log(ex);
}
// This next call will throw a time-out exception unless the GC
// runs a.Dispose in time.
PleaseDisposeMe b = new PleaseDisposeMe();
</code></pre>
<p>Using <code>FXCop</code> is an excellent suggestion, but if that's my only answer, my question would have to become a plea to the C# people, or use C++. Twenty nested using statements anyone?</p>
| [
{
"answer_id": 47617,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 2,
"selected": false,
"text": "~ClassName()\n{\n}\n"
},
{
"answer_id": 47665,
"author": "Hershi",
"author_id": 1596,
"author_profile... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3568/"
] |
47,639 | <p>I just noticed that Chromium was installed in AppData in both Vista and XP. If Google does that and if other applications does this, than is that becuase there is some form of protection? Should we write installers that does the same thing as Google?</p>
| [
{
"answer_id": 47649,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 5,
"selected": true,
"text": "%PROGRAMFILES%"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/370899/"
] |
47,656 | <p>I would like to do full-text searching of data in my Ruby on Rails application. What options exist?</p>
| [
{
"answer_id": 47680,
"author": "sock",
"author_id": 4028,
"author_profile": "https://Stackoverflow.com/users/4028",
"pm_score": 5,
"selected": true,
"text": "acts_as_tsearch"
},
{
"answer_id": 59523303,
"author": "Joshua Pinter",
"author_id": 293280,
"author_profile"... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4028/"
] |
47,658 | <p>I am writing a coding standards document for a team of about 15 developers with a project load of between 10 and 15 projects a year. Amongst other sections (which I may post here as I get to them) I am writing a section on code formatting. So to start with, I think it is wise that, for whatever reason, we establish some basic, consistent code formatting/naming standards.</p>
<p>I've looked at roughly 10 projects written over the last 3 years from this team and I'm, obviously, finding a pretty wide range of styles. Contractors come in and out and at times, and sometimes even double the team size.</p>
<p>I am looking for a few suggestions for code formatting and naming standards that have really paid off ... but that can also really be justified. I think consistency and shared-patterns go a long way to making the code more maintainable ... but, are there other things I ought to consider when defining said standards?</p>
<ul>
<li><p>How do you lineup parenthesis? Do you follow the same parenthesis guidelines when dealing with classes, methods, try catch blocks, switch statements, if else blocks, etc.</p></li>
<li><p>Do you line up fields on a column? Do you notate/prefix private variables with an underscore? Do you follow any naming conventions to make it easier to find particulars in a file? How do you order the members of your class?</p></li>
</ul>
<p>What about suggestions for namespaces, packaging or source code folder/organization standards? I tend to start with something like:</p>
<pre><code><com|org|...>.<company>.<app>.<layer>.<function>.ClassName
</code></pre>
<p>I'm curious to see if there are other, more accepted, practices than what I am accustomed to -- before I venture off dictating these standards. Links to standards already published online would be great too -- even though I've done a bit of that already.</p>
| [
{
"answer_id": 48121,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 2,
"selected": false,
"text": "if(...)\n{\n\n}\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4910/"
] |
47,676 | <p>The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds".</p>
<p>For development (localhost), we might be running Tomcat and when declared in the <context> section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree.</p>
<p><strong>Problem:</strong> in Weblogic, the JNDI lookup is "appds" whilst in Tomcat, it seems that that I must provide the formal "java:comp/env/jdbc/appds". I'm afraid the Tomcat version is an implicit standard but unfortunately, I can't change Weblogic's config ... so that means we end up with two different spring config files (we're using spring 2.5) to facilitate the different environments.</p>
<p>Is there an elegant way to address this. Can I look JNDI names up directly in Tomcat? Can Spring take a name and look in both places? Google searches or suggestions would be great.</p>
| [
{
"answer_id": 50552,
"author": "Binil Thomas",
"author_id": 3973,
"author_profile": "https://Stackoverflow.com/users/3973",
"pm_score": 0,
"selected": false,
"text": "WEB-INF/classes/application.properties"
},
{
"answer_id": 444367,
"author": "martsraits",
"author_id": 5... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4910/"
] |
47,683 | <p>We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBossMQ? I'm new to JMS so any help will be greatly appreciated. Thanks.</p>
| [
{
"answer_id": 47963,
"author": "Todd",
"author_id": 3803,
"author_profile": "https://Stackoverflow.com/users/3803",
"pm_score": 4,
"selected": true,
"text": " public void onException (JMSException jsme)\n {\n if (!closeRequested)\n {\n this.disconnect();\n... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3098/"
] |
47,701 | <p>I'm trying to debug a deadlock in a multi-threaded Python application after it has locked up. Is there a way to attach a debugger to inspect the state of the process? </p>
<p>Edit: I'm attempting this on Linux, but it would be great if there were a cross-platform solution. It's Python after all :)</p>
| [
{
"answer_id": 56510,
"author": "asksol",
"author_id": 5577,
"author_profile": "https://Stackoverflow.com/users/5577",
"pm_score": 5,
"selected": true,
"text": "(gdb) thr 2\n[Switching to thread 2 (process 6159 thread 0x3f1b)]\n(gdb) backtrace\n....\n"
},
{
"answer_id": 550795,
... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
47,709 | <p>When you print from Google Docs (using the "print" link, not File/Print) you end up printing a nicely formated PDF file instead of relying on the print engine of the browser. Same is true for some of the reports in Google Analytics . . . the printed reports as PDF's are beautiful. How do they do that? I can't imagine they use something like Adobe Acrobat to facilitate it but maybe they do. I've seen some expensive HTML to PDF converters online from time to time but have never tired it. Any thoughts?</p>
| [
{
"answer_id": 88919,
"author": "Brian",
"author_id": 700,
"author_profile": "https://Stackoverflow.com/users/700",
"pm_score": 1,
"selected": false,
"text": "<pd4ml:transform>\n<!-- Your HTML is here -->\n\n<c:import url=\"/page.html\" />\n</pd4ml:transform>\n"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4835/"
] |
47,749 | <p>A while ago I read the <a href="http://www.martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a> article by Martin Fowler and I must admit I'm a bit scared of external dependencies with regards to added complexity so I would like to ask:</p>
<p>What is the best method to use when unit testing?</p>
<p>Is it better to always use a mock framework to automatically mock the dependencies of the method being tested, or would you prefer to use simpler mechanisms like for instance test stubs?</p>
| [
{
"answer_id": 47787,
"author": "Toran Billups",
"author_id": 2701,
"author_profile": "https://Stackoverflow.com/users/2701",
"pm_score": 2,
"selected": false,
"text": "<TestMethod()> _\nPublic Sub Should_Populate_Products_List_OnViewLoad_When_PostBack_Is_False()\n mMockery = New Mock... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1324220/"
] |
47,752 | <p>Anyone have a quick method for de-duplicating a generic List in C#?</p>
| [
{
"answer_id": 47755,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": false,
"text": "list.Sort();\nInt32 index = list.Count - 1;\nwhile (index > 0)\n{\n if (list[index] == list[index - 1])\n {\n ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] |
47,762 | <p>I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.</p>
<p>problem statement: </p>
<ul>
<li>a user enters several keywords/tokens</li>
<li>the application searches for matches to the tokens</li>
<li>need one result for each token
<ul>
<li>ie, if an entry has 3 tokens, i need the entry id 3 times</li>
</ul></li>
<li>rank the results
<ul>
<li>assign X points for token match</li>
<li>sort the entry ids based on points</li>
<li>if point values are the same, use date to sort results</li>
</ul></li>
</ul>
<p>What I want to be able to do, but have not figured out, is to send 1 query that returns something akin to the results of an in(), but returns a duplicate entry id for each token matches for each entry id checked.</p>
<p>Is there a better way to do this than what I'm doing, of using multiple, individual queries running one query per token? If so, what's the easiest way to implement those?</p>
<p><strong>edit</strong><br>
I've already tokenized the entries, so, for example, "see spot run" has an entry id of 1, and three tokens, 'see', 'spot', 'run', and those are in a separate token table, with entry ids relevant to them so the table might look like this:</p>
<pre><code>'see', 1
'spot', 1
'run', 1
'run', 2
'spot', 3
</code></pre>
| [
{
"answer_id": 47796,
"author": "Robin Barnes",
"author_id": 1349865,
"author_profile": "https://Stackoverflow.com/users/1349865",
"pm_score": 4,
"selected": true,
"text": "SELECT * FROM `entries` \nWHERE token like \"%x%\" union all \n SELECT * FROM `entries` \n WHERE token like \... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4418/"
] |
47,780 | <p>I have an inherited project that uses a build script (not make) to build and link the project with various libraries.</p>
<p>When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming from.</p>
<p>The script is compiling and linking with GNU tools.</p>
| [
{
"answer_id": 47809,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 1,
"selected": false,
"text": "nm"
}
] | 2008/09/06 | [
"https://Stackoverflow.com/questions/47780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] |
47,786 | <p>Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do:</p>
<pre><code>SELECT blah FROM blah WHERE blah LIKE '%text%'
</code></pre>
<p>The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?</p>
| [
{
"answer_id": 47811,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 7,
"selected": true,
"text": "="
},
{
"answer_id": 1096744,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stacko... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366/"
] |
47,789 | <p>When should you use generator expressions and when should you use list comprehensions in Python?</p>
<pre><code># Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
</code></pre>
| [
{
"answer_id": 47826,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 9,
"selected": true,
"text": "def gen():\n return (something for something in get_some_stuff())\n\nprint gen()[:2] # generators don't support... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
47,817 | <p>Html Textarea elements only wrap when they reach a space or tab character. This is fine, until the user types a looooooooooooooooooooooong enough word. I'm looking for a way to strictly enforce line breaks (eg.: even if it results in "loooooooooooo \n ooooooooooong").</p>
<p><img src="https://i.stack.imgur.com/sUmHB.png" alt="alt text"></p>
<p>The best I've found is to add a zero-width unicode space after every letter, but this breaks copy and paste operations. Anyone know of a better way?</p>
<p>Note: I'm referring to the "textarea" element here (i.e.: the one that behaves similarly to a text input) - not just a plain old block of text.</p>
| [
{
"answer_id": 47866,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 3,
"selected": false,
"text": "word-wrap: break-word"
},
{
"answer_id": 604928,
"author": "Kim Reece",
"author_id": 1911072,
"autho... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4939/"
] |
47,824 | <p>Using core jQuery, how do you remove all the options of a select box, then add one option and select it?</p>
<p>My select box is the following.</p>
<pre><code><Select id="mySelect" size="9"> </Select>
</code></pre>
<p>EDIT: The following code was helpful with chaining. However, (in Internet Explorer) <code>.val('whatever')</code> did not select the option that was added. (I did use the same 'value' in both <code>.append</code> and <code>.val</code>.)</p>
<pre><code>$('#mySelect').find('option').remove().end()
.append('<option value="whatever">text</option>').val('whatever');
</code></pre>
<p>EDIT: Trying to get it to mimic this code, I use the following code whenever the page/form is reset. This select box is populated by a set of radio buttons. <code>.focus()</code> was closer, but the option did not appear selected like it does with <code>.selected= "true"</code>. Nothing is wrong with my existing code - I am just trying to learn jQuery.</p>
<pre><code>var mySelect = document.getElementById('mySelect');
mySelect.options.length = 0;
mySelect.options[0] = new Option ("Foo (only choice)", "Foo");
mySelect.options[0].selected="true";
</code></pre>
<p>EDIT: selected answer was close to what I needed. This worked for me:</p>
<pre><code>$('#mySelect').children().remove().end()
.append('<option selected value="whatever">text</option>') ;
</code></pre>
<p>But both answers led me to my final solution..</p>
| [
{
"answer_id": 47829,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 12,
"selected": true,
"text": "$('#mySelect')\n .find('option')\n .remove()\n .end()\n .append('<option value=\"whatever\">text</option>')\n .va... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] |
47,827 | <p>At work, we have a dedicated SEO Analyst who's job is to pour over lots of data (KeyNote/Compete etc) and generate up fancy reports for the executives so they can see how we are doing against our competitors in organic search ranking. He also leads initiatives to improve the SEO rankings on our sites by optimizing things as best we can.</p>
<p>We also have a longstanding mission to decrease our page load time, which right now is pretty shoddy on some pages.</p>
<p>The SEO guy mentioned that semantic, valid HTML gets more points by crawlers than jumbled messy HTML. I've been working on a real time HTML compressor that will decrease our page sizes my a pretty good chunk. Will compressing the HTML hurt us in site rankings?</p>
| [
{
"answer_id": 47834,
"author": "Brian Lyttle",
"author_id": 636,
"author_profile": "https://Stackoverflow.com/users/636",
"pm_score": 3,
"selected": false,
"text": "<p class=\"headerOne\">Header 1</"
},
{
"answer_id": 30213963,
"author": "East End",
"author_id": 4887099,... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
47,833 | <p>I know you can look at the row.count or tables.count, but are there other ways to tell if a dataset is empty?</p>
| [
{
"answer_id": 47841,
"author": "ljs",
"author_id": 3394,
"author_profile": "https://Stackoverflow.com/users/3394",
"pm_score": 5,
"selected": true,
"text": " bool nonEmptyDataSet = dataSet != null && \n (from DataTable t in dataSet.Tables where t.Rows.Count > 0 select t).Any();\n"
... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445815/"
] |
47,837 | <p>I'm struggling to find the right terminology here, but if you have jQuery object...</p>
<pre><code>$('#MyObject')
</code></pre>
<p>...is it possible to extract the base element? Meaning, the equivalent of this:</p>
<pre><code>document.getElementById('MyObject')
</code></pre>
| [
{
"answer_id": 47844,
"author": "VolkerK",
"author_id": 4833,
"author_profile": "https://Stackoverflow.com/users/4833",
"pm_score": 7,
"selected": true,
"text": ".get(index)"
},
{
"answer_id": 47848,
"author": "Aaron Wagner",
"author_id": 3909,
"author_profile": "http... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1923/"
] |
47,838 | <p>I have wondered about the appropriateness of reflection in C# code. For example I have written a function which iterates through the properties of a given source object and creates a new instance of a specified type, then copies the values of properties with the same name from one to the other. I created this to copy data from one auto-generated LINQ object to another in order to get around the lack of inheritance from multiple tables in LINQ.</p>
<p>However, I can't help but think code like this is really 'cheating', i.e. rather than using using the provided language constructs to achieve a given end it allows you to circumvent them.</p>
<p>To what degree is this sort of code acceptable? What are the risks? What are legitimate uses of this approach?</p>
| [
{
"answer_id": 48223,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 1,
"selected": false,
"text": "static class AtoBCopier\n{\n public static B Copy(A item)\n {\n return new B() { Prop1 = item.Prop1, Pr... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] |
47,845 | <p>I've heard that creating a new process on a Windows box is more expensive than on Linux. Is this true? Can somebody explain the technical reasons for why it's more expensive and provide any historical reasons for the design decisions behind those reasons?</p>
| [
{
"answer_id": 47964,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 4,
"selected": false,
"text": "fork"
},
{
"answer_id": 67293,
"author": "Chris Smith",
"author_id": 9073,
"author_profile": "https://St... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
47,849 | <p>I'm trying to refer to a drive whose letter may change. I'd like to refer to it by its label (e.g., MyLabel (v:) within a Batch File. It can be referred to by V:\ . I'd like to refer to it by MyLabel.</p>
<p>(This was posted on Experts Echange for a month with no answer. Let's see how fast SO answers it )</p>
| [
{
"answer_id": 47856,
"author": "VolkerK",
"author_id": 4833,
"author_profile": "https://Stackoverflow.com/users/4833",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM Win32_LogicalDisk WHERE VolumeName=\"MyLabel\""
},
{
"answer_id": 47860,
"author": "Rob Walker",
... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] |
47,862 | <p>I'm loading a <strong><em>SQL Server 2000</em></strong> database into my new <strong><em>SQL Server 2005</em></strong> <strong><em>instance</em></strong>. <strong><em>As expected, the full-text catalogs don't come with it.</strong> <strong>How can I rebuild them?</em></strong></p>
<p>Right-clicking my full text catalogs and hitting "<strong><em>rebuild indexes</em></strong>" just hangs for hours and hours without doing anything, so it doesn't appear to be that simple...</p>
| [
{
"answer_id": 47900,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": true,
"text": "--Change to accent insensitive\nUSE AdventureWorks;\nGO\nALTER FULLTEXT CATALOG ftCatalog \nREBUILD WITH ACCENT_SENSITIV... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2590/"
] |
47,864 | <p>ValidateEvents is a great ASP.net function, but the Yellow Screen of Death is not so nice. I found a way how to handle the HttpRequestValidationException gracefully <a href="http://www.romsteady.net/blog/2007/06/how-to-catch-httprequestvalidationexcep.html" rel="nofollow noreferrer">here</a>, but that does not work with ASP.net AJAX properly.</p>
<p>Basically, I got an UpdatePanel with a TextBox and a Button, and when the user types in HTML into the Textbox, a JavaScript Popup with a Error message saying not to modify the Response pops up.</p>
<p>So I wonder what is the best way to handle HttpRequestValidationException gracefully? For "normal" requests I would like to just display an error message, but when it's an AJAX Request i'd like to throw the request away and return something to indicate an error, so that my frontend page can react on it?</p>
| [
{
"answer_id": 50671,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 3,
"selected": true,
"text": "<script type=\"text/javascript\" language=\"javascript\">\nvar prm = Sys.WebForms.PageRequestManager.getInstance();\nprm.add_... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] |
47,882 | <p>What is a magic number?</p>
<p>Why should it be avoided?</p>
<p>Are there cases where it's appropriate?</p>
| [
{
"answer_id": 47890,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 7,
"selected": false,
"text": "SELECT TOP 50 * FROM orders"
},
{
"answer_id": 47902,
"author": "Marcio Aguiar",
"author_id": 4213,
"aut... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
47,883 | <p>I'm trying to install 'quadrupel', a library that relies on ffmpeg on Solaris x86.</p>
<p>I managed to build ffmpeg and its libraries live in /opt/gnu/lib and the includes are in /opt/gnu/include but when I try to build quadrupel, it can't find the ffmpeg headers.</p>
<p>What flags/configuration is required to include those two directories in the proper search paths for libraries and includes? I'm not much of a Makefile hacker.</p>
| [
{
"answer_id": 47913,
"author": "stimms",
"author_id": 361,
"author_profile": "https://Stackoverflow.com/users/361",
"pm_score": 2,
"selected": true,
"text": "crle -l -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/opt/gnu/lib\n"
},
{
"answer_id": 47916,
"author": "DGentry",... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/555/"
] |
47,884 | <p>I simply wondered whether people thought it was worth learning to use the MSBuild syntax in order to customise the build process for a .net project, or whether it is really not worth it given the ease with which one can build a project using visual studio. </p>
<p>I am thinking in terms of nightly builds, etc., but then couldn't I use a scheduled event which uses the command-line build option built into VS? Are there superior tools out there?</p>
| [
{
"answer_id": 108691,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 1,
"selected": false,
"text": "msbuild /?"
},
{
"answer_id": 14589196,
"author": "yantaq",
"author_id": 554060,
"author_profile": "h... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] |
47,886 | <p>We have an SEO team at my office, and one of their dictums is that having lots of <script> blocks inline with the HTML is apocalypticly bad. As a developer that makes no sense to me at all. Surely the Google search engineers, who are the smartest people on the planet, know how to skip over such blocks? <br />
My gut instinct is that minimizing script blocks is a superstition that comes from the early ages of search engine optimizations, and that in today's world it means nothing. Does anyone have any insight on this?</p>
<hr>
<p>per our SEO guru, script blocks (especially those that are in-line, or occur before actual content) are very, very bad, and make the google bots give up before processing your actual content. Seems like bull to me, but I'd like to see what others say.</p>
| [
{
"answer_id": 14243630,
"author": "Michael Thamm",
"author_id": 1964121,
"author_profile": "https://Stackoverflow.com/users/1964121",
"pm_score": 0,
"selected": false,
"text": "<p>"
},
{
"answer_id": 21980464,
"author": "Swift Computers",
"author_id": 3167778,
"autho... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757/"
] |
47,919 | <p>I'm used to doing all my coding in one C file. However, I'm working on a project large enough that it becomes impractical to do so. I've been #including them together but I've run into cases where I'm #including some files multiple times, etc. I've heard of .h files, but I'm not sure what their function is (or why having 2 files is better than 1).</p>
<p>What strategies should I use for organizing my code? Is it possible to separate "public" functions from "private" ones for a particular file?</p>
<p><a href="https://stackoverflow.com/questions/47878/codereview-tiny-encryption-algorithm-for-arbitrary-sized-data">This</a> question precipitated my inquiry. The tea.h file makes no reference to the tea.c file. Does the compiler "know" that every .h file has a corresponding .c file?</p>
| [
{
"answer_id": 47928,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 3,
"selected": false,
"text": "#ifndef ACCOUNTS_H\n#define ACCOUNTS_H\n....\n#endif\n"
},
{
"answer_id": 47955,
"author": "smh",
"author_id": 1... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] |
47,941 | <p>I'm trying to upload an application to the iPhone App Store, but I get this error message from iTunes Connect:</p>
<blockquote>
<p>The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate.</p>
</blockquote>
<hr>
<p>Note: The details of original question have been removed, as this page has turned into a repository for all information about possible causes of that particular error message.</p>
<p>For general information on submitting iPhone applications to the App Store, see <a href="https://stackoverflow.com/questions/796482/steps-to-upload-an-iphone-application-to-the-appstore">Steps to upload an iPhone application to the AppStore</a>.</p>
| [
{
"answer_id": 956502,
"author": "Eddie",
"author_id": 118089,
"author_profile": "https://Stackoverflow.com/users/118089",
"pm_score": 4,
"selected": false,
"text": "C384C90C0F9939FA00E76E41 /* Distribution */ = {\nisa = XCBuildConfiguration;\nbuildSettings = {\nARCHS = \"$(ARCHS_STANDAR... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175/"
] |
47,960 | <p>What are the best code snippets for C#? (using visual studio) VB has a lot that are pre-defined, but there are only a handful for C#. Do you have any really useful ones for C#?</p>
<p>Anyone want to post a good custom one you created yourself?</p>
<p><a href="http://en.wikipedia.org/wiki/Ferris_Bueller" rel="noreferrer">Anyone?... Bueller?</a></p>
| [
{
"answer_id": 1053225,
"author": "Dario",
"author_id": 105459,
"author_profile": "https://Stackoverflow.com/users/105459",
"pm_score": 3,
"selected": false,
"text": "cw"
},
{
"answer_id": 1053276,
"author": "Mark Seemann",
"author_id": 126014,
"author_profile": "http... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1874/"
] |
47,972 | <p>I'm researching and experimenting more with Groovy and I'm trying to wrap my mind around the pros and cons of implementing things in Groovy that I can't/don't do in Java. Dynamic programming is still just a concept to me since I've been deeply steeped static and strongly typed languages. </p>
<p>Groovy gives me the ability to <a href="http://en.wikipedia.org/wiki/Duck_typing" rel="noreferrer">duck-type</a>, but I can't really see the value. How is duck-typing more productive than static typing? What kind of things can I do in my code practice to help me grasp the benefits of it?</p>
<p>I ask this question with Groovy in mind but I understand it isn't necessarily a Groovy question so I welcome answers from every code camp.</p>
| [
{
"answer_id": 250119,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 4,
"selected": false,
"text": "class SimpleResults {\n def results\n def total\n def categories\n}\n"
},
{
"answer_id": 275962,
"au... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3030/"
] |
47,975 | <p>More out of interest than anything else, but can you compile a DirectX app under linux?</p>
<p>Obviously there's no official SDK, but I was thinking it might be possible with wine.</p>
<p>Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edit: This is called winelib)</p>
<p>Failing that, maybe a mingw cross compiler with the app running under wine.</p>
<p>Half answered my own question here, but wondered if anyone had heard of anything like this being done?</p>
| [
{
"answer_id": 70695,
"author": "Nick",
"author_id": 4949,
"author_profile": "https://Stackoverflow.com/users/4949",
"pm_score": 4,
"selected": true,
"text": "wineg++ -ld3d9 -ld3dx9 triangle.cpp\n"
},
{
"answer_id": 15586569,
"author": "Guest1337",
"author_id": 2202177,
... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4949/"
] |
47,980 | <p>I'm really beginning to understand what people mean when they say that C++'s error messages are pretty terrible in regards to templates. I've seen horrendously long errors for things as simple as a function not matching its prototype.</p>
<p>Are there any tricks to deciphering these errors?</p>
<p>EDIT: I'm using both gcc and MSVC. They both seem to be pretty terrible.</p>
| [
{
"answer_id": 48263,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 3,
"selected": false,
"text": "s/std::basic_string<char,std::char_traits<char>,std::allocator<char>>/string/g \n"
},
{
"answer_id": 61526908,
"aut... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] |
47,981 | <p>How do I set, clear, and toggle a bit?</p>
| [
{
"answer_id": 47990,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 13,
"selected": true,
"text": "|"
},
{
"answer_id": 50691,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_prof... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] |
48,006 | <p>Right up front: I do <em>not</em> want to start a religious war.</p>
<p>I've used <em>vi</em> for as long as I can remember, and the few times I've tried to pick up <em>Emacs</em> I've been so lost that I've quickly given up. Lots of people find Emacs very powerful, however. Its programmability is somewhat legendary. I'm primarily doing Solaris+Java development, and I'd like to ask a simple question: will my productivity increase if I invest time in getting my head around Emacs? Is the functionality that it offers over <em>Vim</em> going to be paid back in productivity increases in a reasonable timeframe?</p>
<p><em>Repeat: I don't want a "my editor is better than yours" answer. I just want a yes or no answer as to whether it's worth investing the time or not. Will my productivity really increase?</em></p>
| [
{
"answer_id": 71397,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 5,
"selected": false,
"text": ".vimrc"
},
{
"answer_id": 977462,
"author": "dbr",
"author_id": 745,
"author_profile": "https... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/826/"
] |
48,009 | <p>What are the performance, security, or "other" implications of using the following form to declare a new class instance in PHP</p>
<pre><code><?php
$class_name = 'SomeClassName';
$object = new $class_name;
?>
</code></pre>
<p>This is a contrived example, but I've seen this form used in Factories (OOP) to avoid having a big if/switch statement.</p>
<p>Problems that come immediately to mind are </p>
<ol>
<li><s>You lose the ability to pass arguments into a constructor</s> (LIES. Thanks Jeremy)</li>
<li>Smells like eval(), with all the security concerns it brings to the table (but not necessarily the performance concerns?)</li>
</ol>
<p>What other implications are there, or what search engine terms other than "Rank PHP Hackery" can someone use to research this?</p>
| [
{
"answer_id": 48035,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<?php\n\nclass Test {\n function __construct($x) {\n echo $x;\n }\n}\n\n$class = 'Test';\n$object = new $class... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4668/"
] |
48,017 | <p>Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?</p>
| [
{
"answer_id": 48033,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 5,
"selected": false,
"text": "MyJump(int c)\n{\n switch(state)\n {\n case 0:\n goto func0label;\n case 1:\n goto func1labe... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] |
48,053 | <p>I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.</p>
<p>Is there another way to do this other than keeping a counter variable and manually overflowing to 0 at the mod point?<p></p>
<pre><code>const int FIZZ = 6;
for(int x = 0; x < MAXCOUNT; x++)
{
if(!(x % FIZZ)) print("Fizz\n"); // slow on some systems
}
</code></pre>
<p>vs:</p>
<p>The way I am currently doing it:</p>
<pre><code>const int FIZZ = 6;
int fizzcount = 1;
for(int x = 1; x < MAXCOUNT; x++)
{
if(fizzcount >= FIZZ)
{
print("Fizz\n");
fizzcount = 0;
}
}
</code></pre>
| [
{
"answer_id": 48058,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 1,
"selected": false,
"text": "&"
},
{
"answer_id": 48075,
"author": "Matt Sheppard",
"author_id": 797,
"author_profile": "https://... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] |
48,070 | <p>We are trying to lighten our page load as much as possible. Since ViewState can sometimes swell up to 100k of the page, I'd love to completely eliminate it.</p>
<p>I'd love to hear some techniques other people have used to move ViewState to a custom provider.</p>
<p>That said, a few caveats:</p>
<ul>
<li>We serve on average 2 Million unique visitors per hour.</li>
<li>Because of this, Database reads have been a serious issue in performance, so I don't want to store ViewState in the database.</li>
<li>We also are behind a load balancer, so any solution has to work with the user bouncing from machine to machine per postback.</li>
</ul>
<p>Ideas?</p>
| [
{
"answer_id": 48133,
"author": "Mike",
"author_id": 1573,
"author_profile": "https://Stackoverflow.com/users/1573",
"pm_score": 3,
"selected": false,
"text": " protected override PageStatePersister PageStatePersister {\n get { return new SessionPageStatePersister(this); }\n ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
48,087 | <p>I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random elements from a <code>List<string></code>.</p>
| [
{
"answer_id": 48114,
"author": "Tyler",
"author_id": 3561,
"author_profile": "https://Stackoverflow.com/users/3561",
"pm_score": 5,
"selected": false,
"text": "# Returns a container s with k distinct random numbers from {0, 1, ..., n-1}\ndef ChooseRandomSubset(n, k):\n for i in range(k... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] |
48,088 | <p>I was surprised recently to find that it's possible to have a return statement in a finally block in Java.</p>
<p>It seems like lots of people think it's a bad thing to do as described in '<a href="https://web.archive.org/web/20070922061412/http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.html" rel="noreferrer">Don't return in a finally clause</a>'. Scratching a little deeper, I also found '<a href="https://web.archive.org/web/20190528011825/http://www.cs.arizona.edu/projects/sumatra/hallofshame/" rel="noreferrer">Java's return doesn't always</a>' which shows some pretty horrible examples of other types of flow control in finally blocks.</p>
<p>So, my question is, can anyone give me an example where a return statement (or other flow control) in a finally block produces better / more readable code?</p>
| [
{
"answer_id": 48740,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 7,
"selected": false,
"text": "Object problemMethod() {\n Object rtn = null;\n try {\n rtn = somethingThatThrewAnException();\n }\n ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
48,094 | <p>So I have a pointer to an array of pointers. If I delete it like this:</p>
<pre><code>delete [] PointerToPointers;
</code></pre>
<p>Will that delete all the pointed to pointers as well? If not, do I have to loop over all of the pointers and delete them as well, or is there an easier way to do it? My google-fu doesn't seem to give me any good answers to this question.</p>
<p>(And yeah, I know I need to use a vector. This is one of those "catch up on C++" type assignments in school.)</p>
| [
{
"answer_id": 48670,
"author": "Ray",
"author_id": 456786,
"author_profile": "https://Stackoverflow.com/users/456786",
"pm_score": 4,
"selected": false,
"text": "int main()\n{\n int *pI = new int;\n int *pArr = new int[10];\n"
},
{
"answer_id": 3822166,
"author": "RikSaund... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] |
48,115 | <p>I'm using an Ubuntu 8.04 (x86_64) machine to connect to my employer's Cisco VPN. (The client didn't compile out of the box, but I found <a href="http://projects.tuxx-home.at/?id=cisco_vpn_client" rel="nofollow noreferrer">patches to update the client to compile on kernels released in the last two years</a>.) This all works great, until my DHCP client decides to renew its lease and updates /etc/resolv.conf, replacing the VPN-specific name servers with my general network servers.</p>
<p>Is there a good way to prevent my DHCP client from updating /etc/resolv.conf while my VPN is active?</p>
| [
{
"answer_id": 48130,
"author": "Sean",
"author_id": 4919,
"author_profile": "https://Stackoverflow.com/users/4919",
"pm_score": 3,
"selected": false,
"text": "sudo apt-get install resolvconf"
},
{
"answer_id": 202040,
"author": "Community",
"author_id": -1,
"author_p... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4659/"
] |
48,123 | <p>I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.</p>
<p>The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.</p>
<p>I was wondering if the more experienced ones among us (remember, I'm just a beginner) could point out the benefits and caveats of using Glade as opposed to creating everything in the code itself (assuming that learning the correct gtk bindings wouldn't exactly be a problem).</p>
| [
{
"answer_id": 524614,
"author": "Bruce van der Kooij",
"author_id": 63736,
"author_profile": "https://Stackoverflow.com/users/63736",
"pm_score": 2,
"selected": false,
"text": "container = gtk.HBox()\nlabel = gtk.Label(str=\"test\")\ncontainer.add(label)\n"
}
] | 2008/09/07 | [
"https://Stackoverflow.com/questions/48123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/802/"
] |
48,124 | <p>How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?</p>
| [
{
"answer_id": 48125,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 8,
"selected": true,
"text": " $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';\n"
},
{
"answer_id": 48285,
"author": "Daniel",
"auth... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
48,126 | <p>Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter?</p>
| [
{
"answer_id": 48161,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 5,
"selected": true,
"text": "$mysqli = new mysqli( \"HOST\", \"USR\", \"PWD\", \"DBNAME\" );\n$ivalue=1;\n$res = $mysqli->multi_query( \"CALL myproc($i... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] |
48,176 | <p>You can embed the <a href="http://ipython.scipy.org/" rel="noreferrer">IPython</a> shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain port and launch a remote IPython shell? </p>
<p>Any tips for redirecting the input/output streams for IPython or how to hook it up to a telnet server library or recommendations for other libraries that could be used to implement this are much appreciated. </p>
| [
{
"answer_id": 48266,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 0,
"selected": false,
"text": "SocketServer"
}
] | 2008/09/07 | [
"https://Stackoverflow.com/questions/48176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
48,198 | <p>How do I find out which process is listening on a TCP or UDP port on Windows?</p>
| [
{
"answer_id": 48199,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 13,
"selected": true,
"text": "Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess\n"
},
{
"answer_id": 48202,
... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
48,203 | <p>Simply, are there any Java Developer specific Linux distros?</p>
| [
{
"answer_id": 698093,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "[package manager command to install] jdk\n"
},
{
"answer_id": 65344183,
"author": "perymerdeka",
"author_id": ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] |
48,224 | <p>I need to automate a process involving a website that is using a login form. I need to capture some data in the pages following the login page.</p>
<p>I know how to screen-scrape normal pages, but not those behind a secure site.</p>
<ol>
<li>Can this be done with the .NET WebClient class?
<ul>
<li>How would I automatically login?</li>
<li>How would I keep logged in for the other pages?</li>
</ul></li>
</ol>
| [
{
"answer_id": 48228,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 1,
"selected": false,
"text": "<form name=\"loginForm\" method=\"post\" Action=\"target_page.html\">\n <input type=\"Text\" name=\"Username\">\n <input type... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] |
48,225 | <p>I want to put songs on a web page and have a little play button, like you can see on Last.fm or Pandora. There can be multiple songs listed on the site, and if you start playing a different song with one already playing, it will pause the first track and begin playing the one you just clicked on. I think they use Flash for this, and I could probably implement it in a few hours, but is there already code I could use for this? Maybe just a flash swf file that you stick hidden on a web page with a basic Javascript API that I can use to stream mp3 files?</p>
<p>Also, what about WMA or AAC files? Is there a universal solution that will play these 3 file types?</p>
<hr>
<p><a href="http://musicplayer.sourceforge.net/" rel="nofollow noreferrer">http://musicplayer.sourceforge.net/</a></p>
| [
{
"answer_id": 48231,
"author": "Sean",
"author_id": 4919,
"author_profile": "https://Stackoverflow.com/users/4919",
"pm_score": 1,
"selected": false,
"text": "flash mp3 player"
},
{
"answer_id": 48368,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] |
48,235 | <p>I really enjoy Chrome, and the sheer exercise of helping a port would boost my knowledge-base.</p>
<p>Where do I start?</p>
<p>What are the fundamental similarities and differences between the code which will operated under Windows and Linux?</p>
<p>What skills and software do I need?</p>
<hr />
<h3>Note:</h3>
<p>The official website is Visual Studio oriented!<br />
Netbeans or Eclipse are my only options.<br />
I will not pay Microsoft to help an Open Source project.</p>
| [
{
"answer_id": 48236,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "$ sudo apt-get install subversion pkg-config python perl g++ bison flex gperf libnss3-dev\n"
},
{
"answer_id": 692397,
... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] |
48,239 | <p>Is there any way to get the ID of the element that fires an event?</p>
<p>I'm thinking something like:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
$("a").click(function() {
var test = caller.id;
alert(test.val());
});
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script type="text/javascript" src="starterkit/jquery.js"></script>
<form class="item" id="aaa">
<input class="title"></input>
</form>
<form class="item" id="bbb">
<input class="title"></input>
</form></code></pre>
</div>
</div>
</p>
<p>Except of course that the var <code>test</code> should contain the id <code>"aaa"</code>, if the event is fired from the first form, and <code>"bbb"</code>, if the event is fired from the second form.</p>
| [
{
"answer_id": 48242,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 6,
"selected": false,
"text": "(this)"
},
{
"answer_id": 48684,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stacko... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1090/"
] |
48,240 | <p>I am working with an API that provides bus arrival data. For every request, I get back (among other things) a list of which routes serve the stop in question. For example, if the list includes result for bus route #1, 2, and 5, then I know that those serve this stop.</p>
<p>I have a many-to-many relationship set up between Route and Stop, and I want to dynamically check and update these associations on every request. There is no "master list" of which routes serve which stops, so this seems like the best way to get this data.</p>
<p>I believe that the way I'm doing it now is very inefficient:</p>
<pre><code># routes is an array of [number, destination] that I build while iterating over the data
routes.uniq.each do |route|
number = route[0]
destination = route[1]
r = Route.find_by_number_and_destination(number, destination)
if !r
r = Route.new :number => number, :destination => destination
r.save
end
# I have to check if it already exists because I can't find a way
# to create a uniqueness constraint on the join table with 2 foreign keys
r.stops << stop unless r.stops.include? stop
end
</code></pre>
<p>Basically, I have to do 2 things for every route I find:
1) Create it if it doesn't already exist, 2) Add a relationship to the current stop if it doesn't already exist.</p>
<p>Is there a better way to do this, for example by getting a bunch of the data in memory and doing some of the processing on the app server side, in order to avoid the multitude of database calls I'm currently doing?</p>
| [
{
"answer_id": 48529,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 1,
"selected": false,
"text": "class Route < ActiveRecord::Base\n has_and_belongs_to_many :stops\n belongs_to :stop, :foreign_key => 'destination_i... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/124/"
] |
48,249 | <p>Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?</p>
| [
{
"answer_id": 10381446,
"author": "11684",
"author_id": 1087848,
"author_profile": "https://Stackoverflow.com/users/1087848",
"pm_score": 1,
"selected": false,
"text": "JEditorPane"
}
] | 2008/09/07 | [
"https://Stackoverflow.com/questions/48249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] |
48,253 | <p>I know PHP scripts don't actually compile until they are run. However, say I want to create a small simple program and compile it to a binary without requiring the PHP binary. How could I do this?</p>
<p>I've seen a few IDE's out there that would do this, but either they are all for windows or the Linux versions don't actually build properly.<br>
What I would like is something like py2exe that does it in the script itself.</p>
| [
{
"answer_id": 48264,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 2,
"selected": false,
"text": "#!/usr/bin/php\n"
}
] | 2008/09/07 | [
"https://Stackoverflow.com/questions/48253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4985/"
] |
48,278 | <p>I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts.</p>
<p>Is there a way to make the webbrowser print the background of the displayed document too?</p>
<p>Edit:
Since I wanted to do this programatically, I opted for this solution:</p>
<pre><code>using Microsoft.Win32;
...
RegistryKey regKey = Registry.CurrentUser
.OpenSubKey("Software")
.OpenSubKey("Microsoft")
.OpenSubKey("Internet Explorer")
.OpenSubKey("Main");
//Get the current setting so that we can revert it after printjob
var defaultValue = regKey.GetValue("Print_Background");
regKey.SetValue("Print_Background", "yes");
//Do the printing
//Revert the registry key to the original value
regKey.SetValue("Print_Background", defaultValue);
</code></pre>
<p>Another way to handle this might be to just read the value, and notify the user to adjust this himself before printing. I have to agree that tweaking with the registry like this is not a good practice, so I am open for any suggestions.</p>
<p>Thanks for all your feedback</p>
| [
{
"answer_id": 48292,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "* File > Page Setup > Check Off \"Print Background\"\n* File > Print Preview\n"
},
{
"answer_id": 51298,
"author": "... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4582/"
] |
48,288 | <p>I've been trying to understand <a href="http://msdn.microsoft.com/en-gb/library/system.diagnostics.process.mainwindowhandle.aspx" rel="nofollow noreferrer">Process.MainWindowHandle</a>.</p>
<p>According to MSDN; "The main window is the window that is created when the process is started. After initialization, other windows may be opened, including the Modal and TopLevel windows, but <em>the first window associated with the process remains the main window</em>." (Emphasis added)</p>
<p>But while debugging I noticed that MainWindowHandle seemed to change value... which I wasn't expecting, especially after consulting the documentation above.</p>
<p>To confirm the behaviour I created a standalone WinForms app with a timer to check the MainWindowHandle of the "DEVENV" (Visual Studio) process every 100ms.</p>
<p>Here's the interesting part of this test app...</p>
<pre><code> IntPtr oldHWnd = IntPtr.Zero;
void GetMainwindowHandle()
{
Process[] processes = Process.GetProcessesByName("DEVENV");
if (processes.Length!=1)
return;
IntPtr newHWnd = processes[0].MainWindowHandle;
if (newHWnd != oldHWnd)
{
oldHWnd = newHWnd;
textBox1.AppendText(processes[0].MainWindowHandle.ToString("X")+"\r\n");
}
}
private void timer1Tick(object sender, EventArgs e)
{
GetMainwindowHandle();
}
</code></pre>
<p>You can see the value of MainWindowHandle changing when you (for example) click on a drop-down menu inside VS.</p>
<p><img src="https://i.stack.imgur.com/r54iB.png" alt="MainWindowHandleMystery"></p>
<p>Perhaps I've misunderstood the documentation. </p>
<p>Can anyone shed light?</p>
| [
{
"answer_id": 48318,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 5,
"selected": true,
"text": "private bool IsMainWindow(IntPtr handle)\n{\n return (!(NativeMethods.GetWindow(new HandleRef(this, handle), 4) != IntPtr.Zero)... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4200/"
] |
48,307 | <p>I would like to know how people implement the following data structures in C# without using the base class library implementations:-</p>
<ul>
<li>Linked List</li>
<li>Hash Table</li>
<li>Binary Search Tree</li>
<li>Red-Black Tree</li>
<li>B-Tree</li>
<li>Binomial Heap</li>
<li>Fibonacci Heap</li>
</ul>
<p>and any other fundamental data structures people can think of!</p>
<p>I am curious as I want to improve my understanding of these data structures and it'd be nice to see C# versions rather than the typical C examples out there on the internet!</p>
| [
{
"answer_id": 48319,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "Vector"
},
{
"answer_id": 48464,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https:... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] |
48,340 | <p>i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract. </p>
<p>here is the code below;</p>
<pre><code>public void Foo()
{
try
{
DoSomething(); // throws FaultException<FooFault>
}
catch (FaultException)
{
throw;
}
catch (Exception ex)
{
myProject.Exception.Throw<FooFault>(ex);
}
}
</code></pre>
<p>in service contract;</p>
<pre><code>[FaultException(typeof(FooFault))]
void Foo();
</code></pre>
<p>when a FaultException was thrown by DoSomething() method while i was running the application, firstly the exception was caught at "catch(Exception ex)" line and breaks in there. then when i pressed f5 again, it does what normally it has to. i wonder why that break exists? and if not could it be problem on publish?</p>
| [
{
"answer_id": 284215,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 1,
"selected": false,
"text": "throw;\n"
},
{
"answer_id": 295188,
"author": "Jonathan C Dickinson",
"author_id": 24064,
"author... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4215/"
] |
48,356 | <p>Greetings, I'm trying to find a way to 'unbind' a socket from a particular IP/Port combination. My pseudocode looks like this:</p>
<pre><code>ClassA a = new ClassA(); //(class A instantiates socket and binds it to 127.0.0.1:4567)
//do something
//...much later, a has been garbage-collected away.
ClassA aa = new ClassA(); //crash here.
</code></pre>
<p>At this point, .Net informs me that I've already got a socket bound to 127.0.0.1:4567, which is technically true. But no matter what code I put in ClassA's destructor, or no matter what functions I call on the socket (I've tried .Close() and .Disconnect(true)), the socket remains proudly bound to 127.0.0.1:4567. What do I do to be able to 'un-bind' the socket?</p>
<hr>
<p>EDIT: I'm not relying solely on garbage collection (though I tried that approach as well). I tried calling a.Close() or a.Disconnect() and only then instantiating aa; this doesn't solve the problem.</p>
<hr>
<p>EDIT: I've also tried implementing IDisposable, but the code never got there without my calling the method (which was the equivalent of earlier attempts, as the method would simply try .Close and .Disconnect). Let me try calling .Dispose directly and get back to you.</p>
<hr>
<p>EDIT (lots of edits, apologies): Implementing IDisposable and calling a.Dispose() from where 'a' loses scope doesn't work - my Dispose implementation still has to call either .Close or .Disconnect(true) (or .Shutdown(Both)) but none of those unbind the socket.</p>
<p>Any help would be appreciated!</p>
| [
{
"answer_id": 48362,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 0,
"selected": false,
"text": "Socket.Close()"
},
{
"answer_id": 48383,
"author": "AlexeyMK",
"author_id": 5021,
"author_profile":... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5021/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.