qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
54,546 | <p>Assemblies A and B are privately deployed and strongly named. Assembly A contains references to Assembly B. There are two versions of Assembly B: B1 and B2. I want to be able to indicate for Assembly A that it may bind to either B1 or B2 -- ideally, by incorporating this information into the assembly itself. Wha... | [
{
"answer_id": 54553,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<p>You can set version policy in your app.config file. Alternatively you can manually load these assemblies with a cal... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/533/"
] | Assemblies A and B are privately deployed and strongly named. Assembly A contains references to Assembly B. There are two versions of Assembly B: B1 and B2. I want to be able to indicate for Assembly A that it may bind to either B1 or B2 -- ideally, by incorporating this information into the assembly itself. What are m... | There are several places you can indicate to the .Net Framework that a specific version of a strongly typed library should be preferred over another. These are:
* Publisher Policy file
* machine.config file
* app.config file
All these methods utilise the ["<bindingRedirect>"](http://msdn.microsoft.com/en-us/library/e... |
54,566 | <p>So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes.</p>
<pre><code>class PageAtrributes
{
private $db_connection;
private $page_title;
public function __construct($db_connection)
{
$this->db_connection = $db_connection;
$this->page_title ... | [
{
"answer_id": 54572,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 7,
"selected": true,
"text": "<p>It means that <code>$objPage</code> is not an instance of an object. Can we see the code you used to initialize the... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2863/"
] | So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes.
```
class PageAtrributes
{
private $db_connection;
private $page_title;
public function __construct($db_connection)
{
$this->db_connection = $db_connection;
$this->page_title = '';
}
publ... | It means that `$objPage` is not an instance of an object. Can we see the code you used to initialize the variable?
As you expect a specific object type, you can also make use of [PHPs type-hinting feature*Docs*](http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration) to get the error whe... |
54,567 | <p>I've got an <code>JComboBox</code> with a custom <code>inputVerifyer</code> set to limit MaxLength when it's set to editable.</p>
<p>The verify method never seems to get called.<br>
The same verifyer gets invoked on a <code>JTextField</code> fine.</p>
<p>What might I be doing wrong?</p>
| [
{
"answer_id": 54614,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 1,
"selected": false,
"text": "<p>Show us a small section of your code.</p>\n\n<pre><code>package inputverifier;\n\nimport javax.swing.*;\n\n ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | I've got an `JComboBox` with a custom `inputVerifyer` set to limit MaxLength when it's set to editable.
The verify method never seems to get called.
The same verifyer gets invoked on a `JTextField` fine.
What might I be doing wrong? | I found a workaround. I thought I'd let the next person with this problem know about.
Basically. Instead of setting the inputVerifier on the ComboBox you set it to it's "Editor Component".
```
JComboBox combo = new JComboBox();
JTextField tf = (JTextField)(combo.getEditor().getEditorComponent());
tf.setInputVerifie... |
54,578 | <p>How do I capture the output of "%windir%/system32/pnputil.exe -e"?
(assume windows vista 32-bit)</p>
<p>Bonus for technical explanation of why the app normally writes output to the cmd shell, but when stdout and/or stderr are redirected then the app writes nothing to the console or to stdout/stderr?</p>
<pre>
C:\W... | [
{
"answer_id": 54588,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "<p>Some applications are written so that it works in piping scenarios well e.g.</p>\n\n<pre><code>svn status | find \"? \"\n<... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5429/"
] | How do I capture the output of "%windir%/system32/pnputil.exe -e"?
(assume windows vista 32-bit)
Bonus for technical explanation of why the app normally writes output to the cmd shell, but when stdout and/or stderr are redirected then the app writes nothing to the console or to stdout/stderr?
```
C:\Windows\System32... | Doesn't seem like there is an easy way at all. You would have to start hooking the call to WriteConsole and dumping the string buffers. See [this post](http://objectmix.com/tcl/366746-autoexpect-under-windows-later-mac-linux.html#post1359780) for a similar discussion.
Of course, if this is a one off for interactive us... |
54,579 | <p>Does anyone know of a good example of how to expose a WCF service programatically without the use of a configuration file? I know the service object model is much richer now with WCF, so I know it's possible. I just have not seen an example of how to do so. Conversely, I would like to see how consuming without a con... | [
{
"answer_id": 54583,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 3,
"selected": false,
"text": "<p>It is not easy on the server <a href=\"http://blogs.msdn.com/drnick/archive/2006/12/04/overriding-the-default-configu... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] | Does anyone know of a good example of how to expose a WCF service programatically without the use of a configuration file? I know the service object model is much richer now with WCF, so I know it's possible. I just have not seen an example of how to do so. Conversely, I would like to see how consuming without a config... | Consuming a web service without a config file is very simple, as I've discovered. You simply need to create a binding object and address object and pass them either to the constructor of the client proxy or to a generic ChannelFactory instance. You can look at the default app.config to see what settings to use, then cr... |
54,612 | <p>Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would be constantly writing without waiting that's of course if the sourc... | [
{
"answer_id": 54631,
"author": "Thomas Kammeyer",
"author_id": 4410,
"author_profile": "https://Stackoverflow.com/users/4410",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you can use two processes</p>\n\n<pre><code>dd if=indevfile | dd of=outdevfile\n</code></pre>\n\n<p>I'll ass... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4778/"
] | Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would be constantly writing without waiting that's of course if the source disk... | Commodore Jaeger is right about:
```
dd if=/dev/sda of=/dev/sdb bs=1M
```
Also, adjusting "readahead" on the drives usually improves performance. The default may be something like 256, and optimal 1024. Each setup is different, so you would have to run benchmarks to find the best value.
```
# blockdev --getra /dev/... |
54,626 | <p>This code is from <em>Prototype.js</em>. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null.</p>
<pre><code>new Ajax.Request(/path/to / xml / file.xml, {
method: "get",
contentType: "application/xml",
onSuccess: function(transport) {
... | [
{
"answer_id": 54637,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 3,
"selected": true,
"text": "<p>If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a va... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This code is from *Prototype.js*. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null.
```
new Ajax.Request(/path/to / xml / file.xml, {
method: "get",
contentType: "application/xml",
onSuccess: function(transport) {
alert(transport.... | If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a valid XML file.
**Edit:** I just noticed that in our code here whenever we request an XML file we set the content type to 'text/xml'. I have no idea if that makes a difference or not. |
54,686 | <p>Does any one know how do I get the current open windows or process of a local machine using Java? </p>
<p>What I'm trying to do is: list the current open task, windows or process open, like in Windows Taskmanager, but using a multi-platform approach - using only Java if it's possible.</p>
| [
{
"answer_id": 54696,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 3,
"selected": false,
"text": "<p>The only way I can think of doing it is by invoking a command line application that does the job for you and then screen... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4358/"
] | Does any one know how do I get the current open windows or process of a local machine using Java?
What I'm trying to do is: list the current open task, windows or process open, like in Windows Taskmanager, but using a multi-platform approach - using only Java if it's possible. | Finally, with Java 9+ it is possible with [`ProcessHandle`](https://docs.oracle.com/javase/9/docs/api/java/lang/ProcessHandle.html):
```
public static void main(String[] args) {
ProcessHandle.allProcesses()
.forEach(process -> System.out.println(processDetails(process)));
}
private static String proce... |
54,708 | <p>This is an ASP.Net 2.0 web app. The Item template looks like this, for reference:</p>
<pre><code><ItemTemplate>
<tr>
<td class="class1" align=center><a href='url'><img src="img.gif"></a></td>
<td class="class1"><%# DataBinder.Eval(Container.DataItem,"fiel... | [
{
"answer_id": 54738,
"author": "ern",
"author_id": 5609,
"author_profile": "https://Stackoverflow.com/users/5609",
"pm_score": 2,
"selected": false,
"text": "<p>Since you are working with tabular data, I'd recommend using the GridView control. Then you'll be able to access individual ce... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1734/"
] | This is an ASP.Net 2.0 web app. The Item template looks like this, for reference:
```
<ItemTemplate>
<tr>
<td class="class1" align=center><a href='url'><img src="img.gif"></a></td>
<td class="class1"><%# DataBinder.Eval(Container.DataItem,"field1") %></td>
<td class="class1"><%# DataBinder.Eval(Container... | Off the top of my head, you can try something like this:
```
<ItemTemplate>
<tr>
<td "class1"><asp:Literal ID="litField1" runat="server" Text='<%# Bind("Field1") %>'/></td>
<td "class1"><asp:Literal ID="litField2" runat="server" Text='<%# Bind("Field2") %>'/></td>
<td "class1"><asp:Literal ID="litField3"... |
54,709 | <p>Multiple approaches exist to write your unit tests when using Rhino Mocks:</p>
<ul>
<li>The Standard Syntax</li>
<li>Record/Replay Syntax</li>
<li>The Fluent Syntax</li>
</ul>
<p>What is the ideal and most frictionless way?</p>
| [
{
"answer_id": 54819,
"author": "alastairs",
"author_id": 5296,
"author_profile": "https://Stackoverflow.com/users/5296",
"pm_score": 0,
"selected": false,
"text": "<p>Interesting question! My own preference is the for the reflection-based syntax (what I guess you mean by the Standard S... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Multiple approaches exist to write your unit tests when using Rhino Mocks:
* The Standard Syntax
* Record/Replay Syntax
* The Fluent Syntax
What is the ideal and most frictionless way? | For .NET 2.0, I recommend the record/playback model. We like this because it separates clearly your expectations from your verifications.
```
using(mocks.Record())
{
Expect.Call(foo.Bar());
}
using(mocks.Playback())
{
MakeItAllHappen();
}
```
If you're using .NET 3.5 and C# 3, then I'd recommend the fluent s... |
54,725 | <p>Sending a message from the Unix command line using <code>mail TO_ADDR</code> results in an email from <code>$USER@$HOSTNAME</code>. Is there a way to change the "From:" address inserted by <code>mail</code>?</p>
<p>For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedor... | [
{
"answer_id": 54752,
"author": "Thomas Kammeyer",
"author_id": 4410,
"author_profile": "https://Stackoverflow.com/users/4410",
"pm_score": 2,
"selected": false,
"text": "<p>Here are some options:</p>\n\n<ul>\n<li><p>If you have privelige enough, configure sendmail to do rewrites with th... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | Sending a message from the Unix command line using `mail TO_ADDR` results in an email from `$USER@$HOSTNAME`. Is there a way to change the "From:" address inserted by `mail`?
For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedora and RHEL).
[EDIT]
```
$ mail -s Testin... | In my version of mail ( Debian linux 4.0 ) the following options work for controlling the source / reply addresses
* the **-a** switch, for additional headers to apply, supplying a From: header on the command line that will be appended to the outgoing mail header
* the **$REPLYTO** environment variable specifies a Rep... |
54,754 | <p>For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this?</p>
| [
{
"answer_id": 54773,
"author": "NotMyself",
"author_id": 303,
"author_profile": "https://Stackoverflow.com/users/303",
"pm_score": 5,
"selected": false,
"text": "<p>How about using Linq to NHibernate as discussed in <a href=\"http://www.ayende.com/Blog/archive/2007/03/20/Linq-For-NHiber... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this? | `ICriteria` has a `SetFirstResult(int i)` method, which indicates the index of the first item that you wish to get (basically the first data row in your page).
It also has a `SetMaxResults(int i)` method, which indicates the number of rows you wish to get (i.e., your page size).
For example, this criteria object get... |
54,760 | <p>Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide?</p>
<p>I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors... | [
{
"answer_id": 57771,
"author": "John Calsbeek",
"author_id": 5696,
"author_profile": "https://Stackoverflow.com/users/5696",
"pm_score": 3,
"selected": true,
"text": "<p><code>-[NSPasteboard types]</code> will return all the available types for the data on the clipboard, but it should r... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4233/"
] | Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide?
I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors of said RT... | `-[NSPasteboard types]` will return all the available types for the data on the clipboard, but it should return them ["in the order they were declared."](http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPasteboard/types)
... |
54,833 | <p>I have the following webform:</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestWebApp.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="h... | [
{
"answer_id": 54834,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDF... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1980/"
] | I have the following webform:
```
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestWebApp.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ... | can't help with VB6 solution, can help with .net or java solution on the server.
Get iText or iTextSharp from <http://www.lowagie.com/iText/>.
It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc... |
54,861 | <p>I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc".</p>
<p>How can I make this work? I'm not averse to canning t... | [
{
"answer_id": 54967,
"author": "Dan Dyer",
"author_id": 5171,
"author_profile": "https://Stackoverflow.com/users/5171",
"pm_score": 4,
"selected": true,
"text": "<p>If you are using Java 6 you can just use the <a href=\"http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#open(ja... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc".
How can I make this work? I'm not averse to canning the whole pi... | If you are using Java 6 you can just use the [open method of java.awt.Desktop](http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#open(java.io.File)) to launch the file using the default application for the current platform. |
54,866 | <p>I have string like this</p>
<pre><code> /c SomeText\MoreText "Some Text\More Text\Lol" SomeText
</code></pre>
<p>I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.</p>
<p>This is in C# btw.</p>
... | [
{
"answer_id": 54876,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>The Microsoft.VisualBasic.FileIO namespace (in Microsoft.VisualBasic.dll) has a TextFieldParser you can use to split on spac... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I have string like this
```
/c SomeText\MoreText "Some Text\More Text\Lol" SomeText
```
I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.
This is in C# btw.
**EDIT:** My ugly version, while ugl... | The computer term for what you're doing is [lexical analysis](http://en.wikipedia.org/wiki/Lexical_analysis); read that for a good summary of this common task.
Based on your example, I'm guessing that you want whitespace to separate your words, but stuff in quotation marks should be treated as a "word" without the quo... |
54,877 | <p>I can't seem to figure out a good way to do this, but it seems like it should be simple. I have an element that I want to <code>append a div</code> to. Then I have another element that I want to clone and shove into that intermediate div. Here's what I was hoping to do:</p>
<pre><code>$("#somediv > ul").after... | [
{
"answer_id": 54897,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>How can I most efficiently select that intermediate div that I added with the \"after\" and put my \"#someotherd... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | I can't seem to figure out a good way to do this, but it seems like it should be simple. I have an element that I want to `append a div` to. Then I have another element that I want to clone and shove into that intermediate div. Here's what I was hoping to do:
```
$("#somediv > ul").after("<div id='xxx'></div>").append... | Go the other way around and use `insertAfter()`.
```
$("<div id='xxx'></div>")
.append($("#someotherdiv").clone())
.insertAfter("#somediv > ul")
```
Try to add your generated DOM nodes to the document only after finishing your work.
Once the nodes are added to the displayed document, the browser starts list... |
54,909 | <p>I have an <code>ArrayList<String></code> that I'd like to return a copy of. <code>ArrayList</code> has a clone method which has the following signature:</p>
<pre><code>public Object clone()
</code></pre>
<p>After I call this method, how do I cast the returned Object back to <code>ArrayList<String></co... | [
{
"answer_id": 54911,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 1,
"selected": false,
"text": "<pre><code>ArrayList first = new ArrayList ();\nArrayList copy = (ArrayList) first.clone ();\n</code></pre>\n"
},
{
... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I have an `ArrayList<String>` that I'd like to return a copy of. `ArrayList` has a clone method which has the following signature:
```
public Object clone()
```
After I call this method, how do I cast the returned Object back to `ArrayList<String>`? | ```
ArrayList newArrayList = (ArrayList) oldArrayList.clone();
``` |
54,952 | <p>We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs.</p>
<p>It is possible to configure the JVM so it generates UTF-8, using <code>-Dfile.encoding=UTF-8</code> as arguments to the JVM. It works... | [
{
"answer_id": 55262,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried <a href=\"http://en.wikipedia.org/wiki/PowerShell\" rel=\"nofollow noreferrer\">PowerShell</a> rather than... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1430323/"
] | We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs.
It is possible to configure the JVM so it generates UTF-8, using `-Dfile.encoding=UTF-8` as arguments to the JVM. It works fine, but the output... | Try `chcp 65001 && start.bat`
The `chcp` command changes the code page, and 65001 is the Win32 code page identifier for UTF-8 under Windows 7 and up. A code page, or character encoding, specifies how to convert a Unicode code point to a sequence of bytes or back again. |
54,963 | <p>I've got a lot of ugly code that looks like this:</p>
<pre><code>if (!string.IsNullOrEmpty(ddlFileName.SelectedItem.Text))
results = results.Where(x => x.FileName.Contains(ddlFileName.SelectedValue));
if (chkFileName.Checked)
results = results.Where(x => x.FileName == null);
if (!string.IsNullOrEmpty... | [
{
"answer_id": 54981,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 0,
"selected": false,
"text": "<pre><code>results = results.Where(x => \n (string.IsNullOrEmpty(ddlFileName.SelectedItem.Text) || x.FileName.Contains(d... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] | I've got a lot of ugly code that looks like this:
```
if (!string.IsNullOrEmpty(ddlFileName.SelectedItem.Text))
results = results.Where(x => x.FileName.Contains(ddlFileName.SelectedValue));
if (chkFileName.Checked)
results = results.Where(x => x.FileName == null);
if (!string.IsNullOrEmpty(ddlIPAddress.Select... | I'd convert it into a single Linq statement:
```
var results =
//get your inital results
from x in GetInitialResults()
//either we don't need to check, or the check passes
where string.IsNullOrEmpty(ddlFileName.SelectedItem.Text) ||
x.FileName.Contains(ddlFileName.SelectedValue)
where !chkFi... |
54,966 | <p>How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc?</p>
<p>I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible?</p>
| [
{
"answer_id": 55021,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 3,
"selected": true,
"text": "<p>From a comment on the first LifeHacker link,</p>\n\n<h3>How to make x² your default folder application</h3>\n\n... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1385358/"
] | How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc?
I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible? | From a comment on the first LifeHacker link,
### How to make x² your default folder application
As part of the installation process, x² adds "open with xplorer2" in the context menu for
filesystem folders.
If you want to have this the default action (so that folders always open in x2 when you click on
them) then mak... |
54,991 | <p>When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later.</p>
<p>The applicatio... | [
{
"answer_id": 54994,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 5,
"selected": false,
"text": "<p>This is a lot larger, but I think it looks a little more comprehensive:\n<a href=\"http://www.obviex.com/Samples/Password.... | 2008/09/10 | [
"https://Stackoverflow.com/questions/54991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/231/"
] | When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later.
The application is a Web... | There's always [`System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters`)](http://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword.aspx). |
55,042 | <p>I want to build a bot that asks someone a few simple questions and branches based on the answer. I realize parsing meaning from the human responses will be challenging, but how do you setup the program to deal with the "state" of the conversation?</p>
<p>It will be a one-to-one conversation between a human and the... | [
{
"answer_id": 55049,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest looking at Bayesian probabilities. Then just monitor the chat room for a period of time to create your pro... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | I want to build a bot that asks someone a few simple questions and branches based on the answer. I realize parsing meaning from the human responses will be challenging, but how do you setup the program to deal with the "state" of the conversation?
It will be a one-to-one conversation between a human and the bot. | You probably want to look into [Markov Chains](http://en.wikipedia.org/wiki/Markov_chain) as the basics for the bot AI. I wrote something a long time ago (the code to which I'm not proud of at all, and needs some mods to run on Python > 1.5) that may be a useful starting place for you: [<http://sourceforge.net/projects... |
55,054 | <p>What’s the best way to capitalize the first letter of each word in a string in SQL Server.</p>
| [
{
"answer_id": 55057,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 7,
"selected": true,
"text": "<p>From <a href=\"http://www.sql-server-helper.com/functions/initcap.aspx\" rel=\"noreferrer\">http://www.sql-server-helper.com/f... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5170/"
] | What’s the best way to capitalize the first letter of each word in a string in SQL Server. | From <http://www.sql-server-helper.com/functions/initcap.aspx>
```
CREATE FUNCTION [dbo].[InitCap] ( @InputString varchar(4000) )
RETURNS VARCHAR(4000)
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @PrevChar CHAR(1)
DECLARE @OutputString VARCHAR(255)
SET @OutputString = LOWER(... |
55,060 | <p>I'm pretty sure the answer to this question is no, but in case there's some PHP guru</p>
<p>is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of <code>'@'</code></p>
<p>Much like empty and isset do. You can pass in ... | [
{
"answer_id": 55065,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 1,
"selected": false,
"text": "<p>No, because this isn't really anything to do with the function; the error is coming from attempting to de-reference a ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | I'm pretty sure the answer to this question is no, but in case there's some PHP guru
is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of `'@'`
Much like empty and isset do. You can pass in a variable you just made up ... | Summing up, the proper answer is **no, you shouldn't** (see caveat below).
There are workarounds already mentioned by many people in this thread, like using reference variables or isset() or empty() in conditions and suppressing notices in PHP configuration. That in addition to the obvious workaround, using @, which ... |
55,083 | <p>Any ideas how to display a PDF file in a WPF Windows Application? </p>
<hr>
<p>I am using the following code to run the browser but the <code>Browser.Navigate</code> method does not do anything!</p>
<pre><code>WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
this.AddChild(browser)... | [
{
"answer_id": 55085,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": -1,
"selected": false,
"text": "<p>Check this out: <a href=\"http://itextsharp.sourceforge.net/\" rel=\"nofollow noreferrer\">http://itextsharp.sourceforge.... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] | Any ideas how to display a PDF file in a WPF Windows Application?
---
I am using the following code to run the browser but the `Browser.Navigate` method does not do anything!
```
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
this.AddChild(browser); // this is the System.Windows.W... | Oops. this is for a winforms app. Not for WPF. I will post this anyway.
try this
```
private AxAcroPDFLib.AxAcroPDF axAcroPDF1;
this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();
this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axAcroPDF1.Enabled = true;
this.axAcroPDF1.Name = "axAcroPDF1";
this.axAcroPD... |
55,093 | <p>I have a class to parse a matrix that keeps the result in an array member:</p>
<pre><code>class Parser
{
...
double matrix_[4][4];
};
</code></pre>
<p>The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more ea... | [
{
"answer_id": 55118,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 2,
"selected": false,
"text": "<p>I've used a union like this to pass around matrices in the past:</p>\n\n<pre><code>union matrix {\n double df... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | I have a class to parse a matrix that keeps the result in an array member:
```
class Parser
{
...
double matrix_[4][4];
};
```
The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more easily) that looks like this... | Here's a nice, clean way:
```
class Parser
{
public:
typedef double matrix[4][4];
// ...
const matrix& getMatrix() const
{
return matrix_;
}
// ...
private:
matrix matrix_;
};
```
Now you're working with a descriptive type name rather than an array, but since it's a `typedef` the compil... |
55,101 | <p>I have a Linq query that I want to call from multiple places:</p>
<pre><code>var myData = from a in db.MyTable
where a.MyValue == "A"
select new {
a.Key,
a.MyValue
};
</code></pre>
<p>How can I create a met... | [
{
"answer_id": 55110,
"author": "Ryan Lanciaux",
"author_id": 1385358,
"author_profile": "https://Stackoverflow.com/users/1385358",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.linq.iqueryable.aspx\" rel=\"nofollow noreferrer\"><c... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I have a Linq query that I want to call from multiple places:
```
var myData = from a in db.MyTable
where a.MyValue == "A"
select new {
a.Key,
a.MyValue
};
```
How can I create a method, put this code in it, ... | IQueryable and IEnumerable both work. But you want to use a type specific version, IQueryable`<`T`>` or IEnumerable `<`T`>`.
So you'll want to create a type to keep the data.
```
var myData = from a in db.MyTable
where a.MyValue == "A"
select new MyType
{
Key = ... |
55,114 | <p>Ok, so I'm an idiot. </p>
<p>So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb. </p>
<p>I sent a copy of ... | [
{
"answer_id": 55168,
"author": "Morten Christiansen",
"author_id": 4055,
"author_profile": "https://Stackoverflow.com/users/4055",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on the OS, of cause, but on Windows I would guess the application data directory. I can't remember ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1116922/"
] | Ok, so I'm an idiot.
So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb.
I sent a copy of the regex to a cowork... | On my XP box, it was in the registry here:
```
HKEY_CURRENT_USER\Software\JGsoft\RegexBuddy3\History
```
There were two REG\_BINARY keys called **Action0** and **Action1** that had hex data containing my two regexes from the history.

The... |
55,130 | <p>This is a segment of code from an app I've inherited, a user got a Yellow screen of death:</p>
<blockquote>
<p>Object reference not set to an instance of an object</p>
</blockquote>
<p>on the line: </p>
<pre><code>bool l_Success ...
</code></pre>
<p>Now I'm 95% sure the faulty argument is <code>ref l_Monitor<... | [
{
"answer_id": 55138,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>You sure that one of the properties trying to be accessed on the l_Monitor instance isn't null?</p>\n"
},
{
"answe... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1983/"
] | This is a segment of code from an app I've inherited, a user got a Yellow screen of death:
>
> Object reference not set to an instance of an object
>
>
>
on the line:
```
bool l_Success ...
```
Now I'm 95% sure the faulty argument is `ref l_Monitor` which is very weird considering the object is instantiated ... | You sure that one of the properties trying to be accessed on the l\_Monitor instance isn't null? |
55,159 | <p>In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a S... | [
{
"answer_id": 55164,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>You have to select the scope_identity() function. </p>\n\n<p>To do this from application code, I normally encapsula... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1096640/"
] | In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a Sele... | In .Net at least, you can send multiple queries to the server in one go. I do this in my app:
```
command.CommandText = "INSERT INTO [Employee] (Name) VALUES (@Name); SELECT SCOPE_IDENTITY()";
int id = (int)command.ExecuteScalar();
```
Works like a charm. |
55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | [
{
"answer_id": 55188,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 2,
"selected": false,
"text": "<p>This snippet will do it. If you're going to do it frequently, you might want to make a 'sortkeys' method to make... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added.
What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?
For example, y... | Do you mean that you need the values sorted by the value of the key?
In that case, this should do it:
```
for key in sorted(d):
print d[key]
```
**EDIT:** changed to use sorted(d) instead of sorted(d.keys()), thanks [Eli](https://stackoverflow.com/users/1694/eli-courtwright)! |
55,203 | <p>I have an asp.net web page written in C#.<br>
Using some javascript I popup another .aspx page which has a few controls that are filled in and from which I create a small snippet of text.<br>
When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "poppe... | [
{
"answer_id": 55222,
"author": "Dale Marshall",
"author_id": 1491425,
"author_profile": "https://Stackoverflow.com/users/1491425",
"pm_score": 2,
"selected": false,
"text": "<p>What you could do is create an ajax modal pop-up instead of a new window. The semantic and aesthetic value is... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I have an asp.net web page written in C#.
Using some javascript I popup another .aspx page which has a few controls that are filled in and from which I create a small snippet of text.
When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up"... | You will have to do something like:
```
parent.opener.document.getElemenyById('ParentTextBox').value = "New Text";
``` |
55,210 | <p>What would be the best strategy to generate anagrams.</p>
<blockquote>
<pre><code>An anagram is a type of word play, the result of rearranging the letters
of a word or phrase to produce a new word or phrase, using all the original
letters exactly once;
ex.
</code></pre>
<ul>
<li><strong>Eleven plus two</st... | [
{
"answer_id": 55239,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 0,
"selected": false,
"text": "<p>Off the top of my head, the solution that makes the most sense would be to pick a letter out of the input string... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123/"
] | What would be the best strategy to generate anagrams.
>
>
> ```
> An anagram is a type of word play, the result of rearranging the letters
> of a word or phrase to produce a new word or phrase, using all the original
> letters exactly once;
> ex.
>
> ```
>
> * **Eleven plus two** is anagram of ***Twelve plus one... | Most of these answers are horribly inefficient and/or will only give one-word solutions (no spaces). My solution will handle any number of words and is very efficient.
What you want is a trie data structure. Here's a **complete** Python implementation. You just need a word list saved in a file named `words.txt` You ca... |
55,218 | <p>I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key.</p>
<p>I have done the following:</p>
<pre><code>strtolower(substr(crypt(time()), 0, 7));
</code></pre>
<p>But I have found that once in a while I end up with a duplicate key (rarely, but often enough).</p>
<p>I have a... | [
{
"answer_id": 55224,
"author": "Humpton",
"author_id": 1444,
"author_profile": "https://Stackoverflow.com/users/1444",
"pm_score": 0,
"selected": false,
"text": "<p>Without writing the code, my logic would be:</p>\n\n<p>Generate a random string from whatever acceptable characters you li... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key.
I have done the following:
```
strtolower(substr(crypt(time()), 0, 7));
```
But I have found that once in a while I end up with a duplicate key (rarely, but often enough).
I have also thought of doing:
```
strtolower(su... | There are only 3 ways to generate unique values, rather they be passwords, user IDs, etc.:
1. Use an effective GUID generator - these are long and cannot be shrunk. If you only use part **you FAIL**.
2. At least part of the number is sequentially generated off of a single sequence. You can add fluff or encoding to mak... |
55,270 | <p>I have some code that modifies a value that several controls in other update panels are bound to. When this event handler fires, I'd like it to force the other update panels to refresh as well, so they can rebind.</p>
<p>Is this possible?</p>
<p>Edit: </p>
<p>To clarify, I have an update panel in one user control... | [
{
"answer_id": 55300,
"author": "Dale Marshall",
"author_id": 1491425,
"author_profile": "https://Stackoverflow.com/users/1491425",
"pm_score": 2,
"selected": false,
"text": "<p>You can set triggers on the events in the update panel you want updated or you can explicitly say updatepanel.... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I have some code that modifies a value that several controls in other update panels are bound to. When this event handler fires, I'd like it to force the other update panels to refresh as well, so they can rebind.
Is this possible?
Edit:
To clarify, I have an update panel in one user control, the other update panel... | You can set triggers on the events in the update panel you want updated or you can explicitly say updatepanel.update() in the code behind. |
55,296 | <p>I'm looking to implement httpOnly in my legacy ASP classic sites.
Anyone knows how to do it?</p>
| [
{
"answer_id": 55318,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 1,
"selected": false,
"text": "<p>You need to append \";HttpOnly\" to the Response cookies collection.</p>\n"
},
{
"answer_id": 55389,
"aut... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2385/"
] | I'm looking to implement httpOnly in my legacy ASP classic sites.
Anyone knows how to do it? | ```
Response.AddHeader "Set-Cookie", "mycookie=yo; HttpOnly"
```
Other options like `expires`, `path` and `secure` can be also added in this way. I don't know of any magical way to change your whole cookies collection, but I could be wrong about that. |
55,297 | <p>Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion.</p>
<p>I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net.
The site itself remains ASP for t... | [
{
"answer_id": 55358,
"author": "Euro Micelli",
"author_id": 2230,
"author_profile": "https://Stackoverflow.com/users/2230",
"pm_score": 2,
"selected": false,
"text": "<p>First my favorite advice of this week: do not treat your Web Service like it if was a local object or you are going t... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/925/"
] | Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion.
I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net.
The site itself remains ASP for the moment.... | If you wanted to stick with Classic ASP then I would suggest creating a Database handling object via ASP Classes then just use that object to do your recordset creations. This would centralize your database handling code and make it so that you only have to handle SQL Injection attacks in a single location.
A simple e... |
55,330 | <p>I already found this article:</p>
<p><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1</a></p>
<p>But I've got a different situation. I am embedding some hidde... | [
{
"answer_id": 76281,
"author": "Colin Neller",
"author_id": 12571,
"author_profile": "https://Stackoverflow.com/users/12571",
"pm_score": 1,
"selected": false,
"text": "<p>Rather than storing the position information in a hidden field, store it in a cookie. The information is small, so... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/750/"
] | I already found this article:
<http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1>
But I've got a different situation. I am embedding some hiddenFields inside of the master page and trying to store the position of the dragPanel in those.
I am using javascript to store the position of t... | Rather than storing the position information in a hidden field, store it in a cookie. The information is small, so it will have minimal effect on the page load performance. |
55,340 | <p>I'm just wondering if there's a better way of doing this in SQL Server 2005.</p>
<p>Effectively, I'm taking an originator_id (a number between 0 and 99) and a 'next_element' (it's really just a sequential counter between 1 and 999,999).
We are trying to create a 6-character 'code' from them. </p>
<p>The originator... | [
{
"answer_id": 55504,
"author": "nickd",
"author_id": 2373,
"author_profile": "https://Stackoverflow.com/users/2373",
"pm_score": 3,
"selected": true,
"text": "<p>Seeing as it's SQL Server 2005, any reason not to use a CLR stored procedure? You could use your CLR language of choice then ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3897/"
] | I'm just wondering if there's a better way of doing this in SQL Server 2005.
Effectively, I'm taking an originator\_id (a number between 0 and 99) and a 'next\_element' (it's really just a sequential counter between 1 and 999,999).
We are trying to create a 6-character 'code' from them.
The originator\_id is multipl... | Seeing as it's SQL Server 2005, any reason not to use a CLR stored procedure? You could use your CLR language of choice then and it'd probably be a relatively direct port of your existing Delphi code. |
55,342 | <p>I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator.</p>
<p>I don't want to just lock the database and let the users quit gracefully.</p>
<p>How would I script this?</p>
| [
{
"answer_id": 55359,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 7,
"selected": true,
"text": "<p>This answer is heavily influenced by a conversation here: <a href=\"http://www.tek-tips.com/viewthread.cfm?qid=1395151&page... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/685/"
] | I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator.
I don't want to just lock the database and let the users quit gracefully.
How would I script this? | This answer is heavily influenced by a conversation here: <http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3>
```
ALTER SYSTEM ENABLE RESTRICTED SESSION;
begin
for x in (
select Sid, Serial#, machine, program
from v$session
where
machine <> ... |
55,360 | <p>The __doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome??</p>
<p>It's a simple asp:LinkButton with an OnClick event</p>
<pre><code><asp:LinkButton ID="DeleteAllPicturesLinkButton" Enabled="False" OnClientClick="javascript:return c... | [
{
"answer_id": 55367,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>Is it because you are doing <strong>return</strong> confirm? seems like the return statement should prevent the rest of th... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4230/"
] | The \_\_doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome??
It's a simple asp:LinkButton with an OnClick event
```
<asp:LinkButton ID="DeleteAllPicturesLinkButton" Enabled="False" OnClientClick="javascript:return confirm('Are you sure you wa... | Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is.
From <http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&for... |
55,386 | <p>I'm using Windows and I'm trying to get ANT to work.</p>
<p>When I do an ant build from the command line, I get:
<code>C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.</code></p>
<p>I look into the <code>build.xml</code> file and I find:
<code>appserver.home=${user.home}/apache-tomcat-6.0.14</code> (which I ... | [
{
"answer_id": 55426,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "<p>Change it to </p>\n\n<pre><code>appserver.home=\"C:\\\\Program Files\\\\Apache Software Foundation\\\\Tomcat 6.0\"... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using Windows and I'm trying to get ANT to work.
When I do an ant build from the command line, I get:
`C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.`
I look into the `build.xml` file and I find:
`appserver.home=${user.home}/apache-tomcat-6.0.14` (which I just copied and pasted straight from a tutorial)
... | Change it to
```
appserver.home="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0"
``` |
55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of <code>fooId</code>, given that I know the line in the HTML follows the form... | [
{
"answer_id": 55399,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 0,
"selected": false,
"text": "<pre><code>/<input type=\"hidden\" name=\"fooId\" value=\"([\\d-]+)\" \\/>/\n</code></pre>\n"
},
{
"answer_id": 55401... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5675/"
] | I want to grab the value of a hidden input field in HTML.
```
<input type="hidden" name="fooId" value="12-3456789-1111111111" />
```
I want to write a regular expression in Python that will return the value of `fooId`, given that I know the line in the HTML follows the format
```
<input type="hidden" name="fooId" v... | For this particular case, BeautifulSoup is harder to write than a regex, but it is much more robust... I'm just contributing with the BeautifulSoup example, given that you already know which regexp to use :-)
```
from BeautifulSoup import BeautifulSoup
#Or retrieve it from the web, etc.
html_data = open('/yourwebsit... |
55,411 | <p>Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists... | [
{
"answer_id": 55423,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <strong>Path.GetTempPath()</strong> to find out which directory to which it's trying to write.</p>\n"
},... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678/"
] | Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists so I... | This is probably a combination of impersonation and a mismatch of different authentication methods occurring.
There are many pieces; I'll try to go over them one by one.
**Impersonation** is a technique to "temporarily" switch the user account under which a thread is running. Essentially, the thread briefly gains the... |
55,440 | <p>I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this.</p>
<pre><code>template<typename ImplemenationClass> class WrapperClass {
// the code goes here
}
</code></pre>
<p>Now, how do I make sure that <code>I... | [
{
"answer_id": 55444,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 2,
"selected": false,
"text": "<p>In the current state of things, there is no good way other than by comments or a third-party solution. Boost provides a <a ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/108465/"
] | I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this.
```
template<typename ImplemenationClass> class WrapperClass {
// the code goes here
}
```
Now, how do I make sure that `ImplementationClass` can be derived fr... | It's verbose, but you can do it like this:
```
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct base {};
template <typename ImplementationClass, class Enable = void>
class WrapperClass;
template <typename ImplementationClass>
class WrapperClass<ImplementationClass,
typ... |
55,449 | <p>I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.</p>
<p>I have files I never want to check in to source control (like ones found in bin ... | [
{
"answer_id": 55509,
"author": "raven",
"author_id": 4228,
"author_profile": "https://Stackoverflow.com/users/4228",
"pm_score": 7,
"selected": true,
"text": "<p>As of version 2012.1, Perforce supports the <code>P4IGNORE</code> environment variable. I updated my answer to <a href=\"http... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.
I have files I never want to check in to source control (like ones found in bin folder suc... | As of version 2012.1, Perforce supports the `P4IGNORE` environment variable. I updated my answer to [this question about ignoring directories](https://stackoverflow.com/a/3103898/4228) with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.
---
Assuming you have a client nam... |
55,482 | <p>I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. </p>
<p>Command line Execution:</p>
<pre><code>MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn
</code></pre>
<p>Inno Setup Command:</p>
<pre><code>[Run]
Filename: msiexec.exe; Flags:... | [
{
"answer_id": 55496,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Step 1:</strong> <a href=\"https://stackoverflow.com/questions/15109/visual-studio-2005-setup-project-install-... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115/"
] | I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer.
Command line Execution:
```
MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn
```
Inno Setup Command:
```
[Run]
Filename: msiexec.exe; Flags: runhidden waituntilterminated;
Parameters:... | Thanks to those offering help. This appears to be a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion's point, though the Local System account is a powerful account that has full access to the system -- <htt... |
55,502 | <p>I have an object in a multi-threaded environment that maintains a collection of information, e.g.:</p>
<pre><code>public IList<string> Data
{
get
{
return data;
}
}
</code></pre>
<p>I currently have <code>return data;</code> wrapped by a <code>ReaderWriterLockSlim</code> to protect the ... | [
{
"answer_id": 55507,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 6,
"selected": true,
"text": "<p>If your underlying data is stored as list you can use <a href=\"http://msdn.microsoft.com/en-us/library/e78dcd75.aspx\" rel=\"n... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5296/"
] | I have an object in a multi-threaded environment that maintains a collection of information, e.g.:
```
public IList<string> Data
{
get
{
return data;
}
}
```
I currently have `return data;` wrapped by a `ReaderWriterLockSlim` to protect the collection from sharing violations. However, to be dou... | If your underlying data is stored as list you can use [List(T).AsReadOnly](http://msdn.microsoft.com/en-us/library/e78dcd75.aspx) method.
If your data can be enumerated, you can use [Enumerable.ToList](http://msdn.microsoft.com/en-us/library/bb342261.aspx) method to cast your collection to List and call AsReadOnly o... |
55,503 | <p>I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath the application are several 2.0 apps. To completely logout a user can I just logout of the 1.1 app with FormsAuthentication.SignOut or is it more complicated than that?</p>
| [
{
"answer_id": 55554,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 0,
"selected": false,
"text": "<p>It could be easier if you are having a central session store for all your applications. You can then set the session ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4888/"
] | I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath the application are several 2.0 apps. To completely logout a user can I just logout of the 1.1 app with FormsAuthentication.SignOut or is it more complicated than that? | What you are looking to do is called Single Sign On and Single Sign Off. There are differences based on how you have the applications set up. I will try to clarify where those differences come into play.
To implement single sign on and single sign off you need to make the cookie name, protection, and path attributes t... |
55,506 | <p>As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.:</p>
<pre><code>if @version <> @expects
begin
declare @error varchar(100);
set @error = 'Invalid version.... | [
{
"answer_id": 55546,
"author": "Josh Hinman",
"author_id": 2527,
"author_profile": "https://Stackoverflow.com/users/2527",
"pm_score": 6,
"selected": true,
"text": "<p>Here's what I came up with:</p>\n\n<p>Wrap it in an EXEC(), like so:</p>\n\n<pre><code>if @version <> @expects\n ... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2527/"
] | As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.:
```
if @version <> @expects
begin
declare @error varchar(100);
set @error = 'Invalid version. Your version is ' +... | Here's what I came up with:
Wrap it in an EXEC(), like so:
```
if @version <> @expects
begin
...snip...
end
else
begin
exec('CREATE PROC MyProc AS SELECT ''Victory!''');
end
```
Works like a charm! |
55,510 | <p>I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.</p>
<pre><code>int globalgarbage;
unsigned int anumber = 42;
</code></pre>
<p>But what about static ones defined within a function?</p>
<pre><code>void doSomething()
{
static bool globalish... | [
{
"answer_id": 55515,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 2,
"selected": false,
"text": "<p>Static variables are allocated inside a code segment -- they are part of the executable image, and so are mapped in alr... | 2008/09/10 | [
"https://Stackoverflow.com/questions/55510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.
```
int globalgarbage;
unsigned int anumber = 42;
```
But what about static ones defined within a function?
```
void doSomething()
{
static bool globalish = true;
// ...
}
```
When is the... | I was curious about this so I wrote the following test program and compiled it with g++ version 4.1.2.
```
include <iostream>
#include <string>
using namespace std;
class test
{
public:
test(const char *name)
: _name(name)
{
cout << _name << " created" << endl;
... |
55,532 | <p>This came up from <a href="https://stackoverflow.com/questions/55093/how-to-deal-with-arrays-declared-on-the-stack-in-c#55183">this answer to a previous question of mine</a>.
Is it guaranteed for the compiler to treat <code>array[4][4]</code> the same as <code>array[16]</code>?</p>
<p>For instance, would either of ... | [
{
"answer_id": 55539,
"author": "Josh Matthews",
"author_id": 3830,
"author_profile": "https://Stackoverflow.com/users/3830",
"pm_score": 0,
"selected": false,
"text": "<p>I would be worried about padding being added for things like Matrix[5][5] to make each row word aligned, but that co... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | This came up from [this answer to a previous question of mine](https://stackoverflow.com/questions/55093/how-to-deal-with-arrays-declared-on-the-stack-in-c#55183).
Is it guaranteed for the compiler to treat `array[4][4]` the same as `array[16]`?
For instance, would either of the below calls to `api_func()` be safe?
`... | From the C++ standard, referring to the `sizeof` operator:
>
> When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of `n` elements is `n` times the size of an element.
>
>
>
From this, I'd say that `double[4][4]` and `double[16]` would have to hav... |
55,556 | <p>I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is</p>
<p>il10o8B3Evu![]{}</p>
<p>Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit... | [
{
"answer_id": 55568,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 3,
"selected": false,
"text": "<p>My preferred method is to get a word list of 3, 4 and 5 letter words. Then select at least 2 of those, and place a rand... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5552/"
] | I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is
il10o8B3Evu![]{}
Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit myself to those ... | Here are the character sets that Steve Gibson uses for his ["Perfect Paper Password"](https://www.grc.com/ppp.htm) system. They are "characters to allow" rather than "characters to avoid", but they seem pretty reasonable for what you want:
A standard set of 64 characters
```
!#%+23456789:=?@ABCDEFGHJKLMNPRS
TUVWXYZab... |
55,577 | <p>I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC.</p>
| [
{
"answer_id": 55578,
"author": "georgebrock",
"author_id": 5168,
"author_profile": "https://Stackoverflow.com/users/5168",
"pm_score": 7,
"selected": true,
"text": "<p><strong>Update:</strong> Microsoft now provide virtual machine images for various versions of IE that are ready to use ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5168/"
] | I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC. | **Update:** Microsoft now provide virtual machine images for various versions of IE that are ready to use on all of the major OS X virtualisation platforms ([VirtualBox](https://www.virtualbox.org), [VMWare Fusion](http://www.vmware.com/products/fusion/overview.html), and [Parallels](http://www.parallels.com/)).
Downl... |
55,607 | <p>What is the best way to use multiple EVAL fields in a GridView ItemTemplate?</p>
<p>Looking to have some control over formatting for appearance as well as setting up hyperlinks/javascript etc.</p>
| [
{
"answer_id": 55629,
"author": "Dhaust",
"author_id": 242,
"author_profile": "https://Stackoverflow.com/users/242",
"pm_score": 3,
"selected": false,
"text": "<p>I had previously used this (bad, I know): </p>\n\n<pre><code><%# Eval(\"Name1\", \"{0} - \")%> <%#Eval(\"Name2\")... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242/"
] | What is the best way to use multiple EVAL fields in a GridView ItemTemplate?
Looking to have some control over formatting for appearance as well as setting up hyperlinks/javascript etc. | Even clearer, IMO, is:
```
<%# String.Format("{0} - {1}", Eval("Name1"), Eval("Name2")) %>
``` |
55,611 | <p>To make a JavaScript class with a public method I'd do something like:</p>
<pre><code>function Restaurant() {}
Restaurant.prototype.buy_food = function(){
// something here
}
Restaurant.prototype.use_restroom = function(){
// something here
}
</code></pre>
<p>That way users of my class can:</p>
<pre><code... | [
{
"answer_id": 55637,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 10,
"selected": true,
"text": "<p>You can do it, but the downside is that it can't be part of the prototype:</p>\n\n<pre><code>function Restaurant() {\n ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3284/"
] | To make a JavaScript class with a public method I'd do something like:
```
function Restaurant() {}
Restaurant.prototype.buy_food = function(){
// something here
}
Restaurant.prototype.use_restroom = function(){
// something here
}
```
That way users of my class can:
```
var restaurant = new Restaurant();
r... | You can do it, but the downside is that it can't be part of the prototype:
```
function Restaurant() {
var myPrivateVar;
var private_stuff = function() { // Only visible inside Restaurant()
myPrivateVar = "I can set this here!";
}
this.use_restroom = function() { // use_restroom is visible ... |
55,677 | <p>What's the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)?</p>
<p>No legacy browser compatibility required, Safari, Opera and Firefox will do.</p>
| [
{
"answer_id": 55723,
"author": "Brian Gianforcaro",
"author_id": 3415,
"author_profile": "https://Stackoverflow.com/users/3415",
"pm_score": -1,
"selected": false,
"text": "<p>Hey, this is in dojo, just cause it's what I had the code in already for a project.</p>\n\n<p>It should be fair... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] | What's the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)?
No legacy browser compatibility required, Safari, Opera and Firefox will do. | If you like simplicity but still want cross-browser functionality I found this solution worked best for me. This is a simplification of @Aldekein´s solution but **without jQuery**.
```
function getCursorPosition(canvas, event) {
const rect = canvas.getBoundingClientRect()
const x = event.clientX - rect.left
... |
55,709 | <p>I am building a java server that needs to scale. One of the servlets will be serving images stored in Amazon S3.</p>
<p>Recently under load, I ran out of memory in my VM and it was after I added the code to serve the images so I'm pretty sure that streaming larger servlet responses is causing my troubles.</p>
<p>M... | [
{
"answer_id": 55717,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 4,
"selected": false,
"text": "<p>Why wouldn't you just point them to the S3 url? Taking an artifact from S3 and then streaming it through your own server... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4974/"
] | I am building a java server that needs to scale. One of the servlets will be serving images stored in Amazon S3.
Recently under load, I ran out of memory in my VM and it was after I added the code to serve the images so I'm pretty sure that streaming larger servlet responses is causing my troubles.
My question is : i... | When possible, you should not store the entire contents of a file to be served in memory. Instead, aquire an InputStream for the data, and copy the data to the Servlet OutputStream in pieces. For example:
```
ServletOutputStream out = response.getOutputStream();
InputStream in = [ code to get source input stream ];
St... |
55,713 | <p>In effect, if I have a <code>class c</code> and instances of <code>$c1</code> and <code>$c2</code>
which might have different private variable amounts but all their public methods return the same values I would like to be able to check that <code>$c1 == $c2?</code></p>
<p>Does anyone know an easy way to do this?</... | [
{
"answer_id": 55731,
"author": "Rushi",
"author_id": 3983,
"author_profile": "https://Stackoverflow.com/users/3983",
"pm_score": 1,
"selected": false,
"text": "<p>You can define PHP's <strong>__toString</strong> magic method inside your class. </p>\n\n<p>For example</p>\n\n<pre><code>cl... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | In effect, if I have a `class c` and instances of `$c1` and `$c2`
which might have different private variable amounts but all their public methods return the same values I would like to be able to check that `$c1 == $c2?`
Does anyone know an easy way to do this? | You can also implement a equal($other) function like
```
<?php
class Foo {
public function equals($o) {
return ($o instanceof 'Foo') && $o.firstName()==$this.firstName();
}
}
```
or use foreach to iterate over the public properties (this behaviour might be overwritten) of one object and compare them... |
55,754 | <p>What is the best way, using Bash, to rename files in the form:</p>
<pre><code>(foo1, foo2, ..., foo1300, ..., fooN)
</code></pre>
<p>With zero-padded file names:</p>
<pre><code>(foo00001, foo00002, ..., foo01300, ..., fooN)
</code></pre>
| [
{
"answer_id": 55775,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 2,
"selected": false,
"text": "<p>The following will do it:</p>\n\n<pre><code>for ((i=1; i<=N; i++)) ; do mv foo$i `printf foo%05d $i` ; done\n</code></pre>\... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3020/"
] | What is the best way, using Bash, to rename files in the form:
```
(foo1, foo2, ..., foo1300, ..., fooN)
```
With zero-padded file names:
```
(foo00001, foo00002, ..., foo01300, ..., fooN)
``` | In case `N` is not a priori fixed:
```
for f in foo[0-9]*; do
mv "$f" "$(printf 'foo%05d' "${f#foo}")"
done
``` |
55,843 | <p>I am currently using Linq to NHibernate (although that is not an issue with regards to this question) to execute queries against my database and I want to be able to test whether the current <code>IQueryable</code> result instance has been executed or not.</p>
<p>The debugger knows that my <code>IQueryable</code> h... | [
{
"answer_id": 55848,
"author": "Christian Hagelid",
"author_id": 202,
"author_profile": "https://Stackoverflow.com/users/202",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you can use <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.data.linq.datacontext.log\" re... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4884/"
] | I am currently using Linq to NHibernate (although that is not an issue with regards to this question) to execute queries against my database and I want to be able to test whether the current `IQueryable` result instance has been executed or not.
The debugger knows that my `IQueryable` has not been *'invoked'* because ... | How about writing an IQueryable wrapper like this:
```
class QueryableWrapper<T> : IQueryable<T>
{
private IQueryable<T> _InnerQueryable;
private bool _HasExecuted;
public QueryableWrapper(IQueryable<T> innerQueryable)
{
_InnerQueryable = innerQueryable;
}
public bool HasExecuted
... |
55,855 | <p>I am following the <a href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" rel="noreferrer">M-V-VM</a> pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is t... | [
{
"answer_id": 56081,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 2,
"selected": false,
"text": "<p>Can you not just handle the TextChanged event and execute the command from there?</p>\n\n<pre><code>private void _te... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/708/"
] | I am following the [M-V-VM](http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx) pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is to inherit from the TextBox cont... | First off, you've surely considered two-way data binding to your viewmodel, with an UpdateSourceTrigger of PropertyChanged? That way the property setter of the property you bind to will be called every time the text is changed?
If that's not enough, then I would tackle this problem using Attached Behaviours. On Julian... |
55,859 | <p>In C++, I'm trying to catch all types of exceptions in one catch (like <code>catch(Exception)</code> in C#). How is it done? And what's more, how can one catch divide-by-zero exceptions?</p>
| [
{
"answer_id": 55863,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 6,
"selected": true,
"text": "<pre><code>catch (...)\n{\n // Handle exceptions not covered.\n}\n</code></pre>\n\n<p>Important considerations:</p>\n\n<ul>\n<li... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195/"
] | In C++, I'm trying to catch all types of exceptions in one catch (like `catch(Exception)` in C#). How is it done? And what's more, how can one catch divide-by-zero exceptions? | ```
catch (...)
{
// Handle exceptions not covered.
}
```
Important considerations:
* A better approach is to catch specific types of exception that you can actually recover from as opposed to all possible exceptions.
* catch(...) will also catch certain serious system level exceptions (varies depending on compil... |
55,860 | <p>Okay, here is the 411 - I have the following event handler in my Global.asax.cs file:</p>
<pre><code>private void Global_PostRequestHandlerExecute(object sender, EventArgs e)
{
if (/* logic that determines that this is an ajax call */)
{
// we want to set a cookie
Response.Cookies.Add(new HttpCook... | [
{
"answer_id": 56261,
"author": "Erlend",
"author_id": 5746,
"author_profile": "https://Stackoverflow.com/users/5746",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried to use <code>;expires=Thu, 01-Jan-1970 00:00:01 GMT</code>?</p>\n"
},
{
"answer_id": 56287,
"aut... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1790/"
] | Okay, here is the 411 - I have the following event handler in my Global.asax.cs file:
```
private void Global_PostRequestHandlerExecute(object sender, EventArgs e)
{
if (/* logic that determines that this is an ajax call */)
{
// we want to set a cookie
Response.Cookies.Add(new HttpCookie("MyCookie",... | you have to delete your cookie at the same path where you created it.
so create your cookie with path=/ and delte it with path=/ as well.. |
55,869 | <p>I'm downloading some images from a service that doesn't always include a content-type and doesn't provide an extension for the file I'm downloading (ugh, don't ask).</p>
<p>What's the best way to determine the image format in .NET?</p>
<p>The application that is reading these downloaded images needs to have a prop... | [
{
"answer_id": 55873,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 0,
"selected": false,
"text": "<p>Try loading the stream into a System.IO.BinaryReader. </p>\n\n<p>Then you will need to refer to the specifications for each i... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5277/"
] | I'm downloading some images from a service that doesn't always include a content-type and doesn't provide an extension for the file I'm downloading (ugh, don't ask).
What's the best way to determine the image format in .NET?
The application that is reading these downloaded images needs to have a proper file extension... | A probably easier approach would be to use Image.FromFile() and then use the RawFormat property, as it already knows about the magic bits in the headers for the most common formats, like this:
```
Image i = Image.FromFile("c:\\foo");
if (System.Drawing.Imaging.ImageFormat.Jpeg.Equals(i.RawFormat))
MessageBox.Show... |
55,899 | <p>I'm using a custom-built inhouse application that generates a standard set of reports on a weekly basis. I have no access to the source code of the application, and everyone tells me there is no documentation available for the Oracle database schema. (Aargh!)</p>
<p>I've been asked to define the specs for a variant... | [
{
"answer_id": 55912,
"author": "David Crow",
"author_id": 2783,
"author_profile": "https://Stackoverflow.com/users/2783",
"pm_score": 2,
"selected": false,
"text": "<p>I think the <a href=\"http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm\" rel=\"nofol... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/480/"
] | I'm using a custom-built inhouse application that generates a standard set of reports on a weekly basis. I have no access to the source code of the application, and everyone tells me there is no documentation available for the Oracle database schema. (Aargh!)
I've been asked to define the specs for a variant of an exi... | On the data dictionary side there are a lot of tools you can use to such as [Schema Spy](http://schemaspy.sourceforge.net/)
To look at what queries are running look at views sys.v\_$sql and sys.v\_$sqltext. You will also need access to sys.all\_users
One thing to note that queries that use parameters will show up onc... |
55,943 | <p>Is their any profilers that support Silverlight? I have tried ANTS (Version 3.1) without any success? Does version 4 support it? Any other products I can try?</p>
<p><strong>Updated</strong>
since the release of Silverlight 4, it is now possible to do full profiling on SL applications... check out <a href="http://bl... | [
{
"answer_id": 55954,
"author": "Jon Galloway",
"author_id": 5,
"author_profile": "https://Stackoverflow.com/users/5",
"pm_score": 5,
"selected": true,
"text": "<p>Install XPerf and xperfview as available here: <a href=\"https://web.archive.org/web/20140825011849/http://blogs.msdn.com:80... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5147/"
] | Is their any profilers that support Silverlight? I have tried ANTS (Version 3.1) without any success? Does version 4 support it? Any other products I can try?
**Updated**
since the release of Silverlight 4, it is now possible to do full profiling on SL applications... check out [this](http://blogs.msdn.com/seema/archi... | Install XPerf and xperfview as available here: [http://msdn.microsoft.com/en-us/library/cc305218.aspx](https://web.archive.org/web/20140825011849/http://blogs.msdn.com:80/b/seema/archive/2008/10/08/xperf-a-cpu-sampler-for-silverlight.aspx)
(1) Startup your sample
(2) xperf -on base
(3) wait for a bit
(4) xperf –d m... |
55,956 | <p>is there an alternative for <code>mysql_insert_id()</code> php function for PostgreSQL? Most of the frameworks are solving the problem partially by finding the current value of the sequence used in the ID. However, there are times that the primary key is not a serial column....</p>
| [
{
"answer_id": 55959,
"author": "aib",
"author_id": 1088,
"author_profile": "https://Stackoverflow.com/users/1088",
"pm_score": 2,
"selected": false,
"text": "<p>Check out the <a href=\"http://www.postgresql.org/docs/current/interactive/sql-insert.html\" rel=\"nofollow noreferrer\">RETUR... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5742/"
] | is there an alternative for `mysql_insert_id()` php function for PostgreSQL? Most of the frameworks are solving the problem partially by finding the current value of the sequence used in the ID. However, there are times that the primary key is not a serial column.... | From the PostgreSQL point of view, in pseudo-code:
```
* $insert_id = INSERT...RETURNING foo_id;-- only works for PostgreSQL >= 8.2.
* INSERT...; $insert_id = SELECT lastval(); -- works for PostgreSQL >= 8.1
* $insert_id = SELECT nextval('foo_seq'); INSERT INTO table (foo...) values ($insert_id...) for older Pos... |
55,964 | <p>How can I make a major upgrade to an installation set (MSI) built with <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">WiX</a> install into the same folder as the original installation?</p>
<p>The installation is correctly detected as an upgrade, but the directory selection screen is still shown and wit... | [
{
"answer_id": 56123,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 6,
"selected": true,
"text": "<p>There's an example in the WiX tutorial: <a href=\"https://www.firegiant.com/wix/tutorial/getting-started/where-to-... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4683/"
] | How can I make a major upgrade to an installation set (MSI) built with [WiX](http://en.wikipedia.org/wiki/WiX) install into the same folder as the original installation?
The installation is correctly detected as an upgrade, but the directory selection screen is still shown and with the default value (not necessarily t... | There's an example in the WiX tutorial: <https://www.firegiant.com/wix/tutorial/getting-started/where-to-install/>
```
<Property Id="INSTALLDIR">
<RegistrySearch Id='AcmeFoobarRegistry' Type='raw'
Root='HKLM' Key='Software\Acme\Foobar 1.0' Name='InstallDir' />
</Property>
```
Of course, you've got to set the r... |
55,978 | <p>I know how to test an object to see if it is of a type, using the IS keyword e.g.</p>
<pre><code>if (foo is bar)
{
//do something here
}
</code></pre>
<p>but how do you test for it not being "bar"?, I can't seem to find a keyword that works with IS to test for a negative result. </p>
<p>BTW - I have a horrible... | [
{
"answer_id": 55980,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "<pre><code>if (!(foo is bar)) {\n}\n</code></pre>\n"
},
{
"answer_id": 55981,
"author": "aku",
"author... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] | I know how to test an object to see if it is of a type, using the IS keyword e.g.
```
if (foo is bar)
{
//do something here
}
```
but how do you test for it not being "bar"?, I can't seem to find a keyword that works with IS to test for a negative result.
BTW - I have a horrible feeling this is soooo obvious, so... | ```
if (!(foo is bar)) {
}
``` |
55,984 | <p>What is the difference between <strong><code>const</code></strong> and <strong><code>readonly</code></strong> in C#? </p>
<p>When would you use one over the other?</p>
| [
{
"answer_id": 55987,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 4,
"selected": false,
"text": "<p>I believe a <code>const</code> value is the same for all objects (and must be initialized with a literal expression),... | 2008/09/11 | [
"https://Stackoverflow.com/questions/55984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | What is the difference between **`const`** and **`readonly`** in C#?
When would you use one over the other? | Apart from the apparent difference of
* having to declare the value at the time of a definition for a `const` VS `readonly` values can be computed dynamically but need to be assigned before the constructor exits. After that it is frozen.
* `const`'s are implicitly `static`. You use a `ClassName.ConstantName` notation ... |
56,011 | <p>According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?</p>
| [
{
"answer_id": 56025,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 0,
"selected": false,
"text": "<p>Your team's taste or your project's coding guidelines.</p>\n\n<p>If you are in a multilanguage environment, you mi... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | I like to use double quotes around strings that are used for interpolation or that are natural language messages, and single quotes for small symbol-like strings, but will break the rules if the strings contain quotes, or if I forget. I use triple double quotes for docstrings and raw string literals for regular express... |
56,037 | <p>I am working with fixtures on rails and I want one of the fixture fields to be blank.</p>
<p>Example:</p>
<pre><code>two:
name: test
path: - I want this blank but not to act as a group heading.
test: 4
</code></pre>
<p>But, I do not know how to leave <code>path:</code> blank without it acting as a group title. D... | [
{
"answer_id": 56060,
"author": "Paul Wicks",
"author_id": 85,
"author_profile": "https://Stackoverflow.com/users/85",
"pm_score": 1,
"selected": false,
"text": "<p>Google <a href=\"http://groups.google.com/group/ruby-talk-google/browse_thread/thread/f8b1635528665a85\" rel=\"nofollow nor... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | I am working with fixtures on rails and I want one of the fixture fields to be blank.
Example:
```
two:
name: test
path: - I want this blank but not to act as a group heading.
test: 4
```
But, I do not know how to leave `path:` blank without it acting as a group title. Does anybody know how to do that? | YAML files are based on indentation. Once you actually have correct indentation it will read everything at the same level as siblings.
```
two:
name: test
path:
test: 4
``` |
56,045 | <p>I'm having some internationalisation woes:</p>
<p>My UTF-8 string fields are being rendered in the browser as ???? after being returned from the database.</p>
<p>After retrieval from the database using Hibernate, the String fields are presented correctly on inspection using the eclipse debugger.</p>
<p>However St... | [
{
"answer_id": 56358,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 0,
"selected": false,
"text": "<p>Try setting the lang attribute on the <html/> element.</p>\n\n<p>HTML example:</p>\n\n<pre>\n<!DOCTYPE HTM... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3966/"
] | I'm having some internationalisation woes:
My UTF-8 string fields are being rendered in the browser as ???? after being returned from the database.
After retrieval from the database using Hibernate, the String fields are presented correctly on inspection using the eclipse debugger.
However Struts2/Tiles is rendering... | You could try something like this.
It's taken from sun's page on [Character Sets and Encodings](http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html).
I think this has to be the very first line in your jsp.
```
<%@ page contentType="text/html; charset=UTF-8" %>
``` |
56,052 | <p>EditPad Lite has a nice feature (<kbd>CTRL</kbd>-<kbd>E</kbd>, <kbd>CTRL</kbd>-<kbd>I</kbd>) which inserts a time stamp e.g. "2008-09-11 10:34:53" into your code.</p>
<p>What is the best way to get this functionality in Vim?</p>
<p>(I am using Vim 6.1 on a Linux server via SSH. In the current situation a number of... | [
{
"answer_id": 56061,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 8,
"selected": true,
"text": "<p><a href=\"http://kenno.wordpress.com/2006/08/03/vim-tip-insert-time-stamp/\" rel=\"noreferrer\">http://kenno.wordpress... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | EditPad Lite has a nice feature (`CTRL`-`E`, `CTRL`-`I`) which inserts a time stamp e.g. "2008-09-11 10:34:53" into your code.
What is the best way to get this functionality in Vim?
(I am using Vim 6.1 on a Linux server via SSH. In the current situation a number of us share a login so I don't want to create abbreviat... | <http://kenno.wordpress.com/2006/08/03/vim-tip-insert-time-stamp/>
Tried it out, it works on my mac:
```
:r! date
```
produces:
```
Thu Sep 11 10:47:30 CEST 2008
```
This:
```
:r! date "+\%Y-\%m-\%d \%H:\%M:\%S"
```
produces:
```
2008-09-11 10:50:56
``` |
56,070 | <p><strong>Edit</strong>: Solved, there was a trigger with a loop on the table (read my own answer further below).</p>
<hr>
<p>We have a simple delete statement that looks like this:</p>
<pre><code>DELETE FROM tablename WHERE pk = 12345
</code></pre>
<p>This just hangs, no timeout, no nothing.</p>
<p>We've looked ... | [
{
"answer_id": 56128,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 2,
"selected": false,
"text": "<p>Try recreating the index on that table, and try regenerating the statistics.</p>\n\n<p><a href=\"http://msdn.microsoft.... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] | **Edit**: Solved, there was a trigger with a loop on the table (read my own answer further below).
---
We have a simple delete statement that looks like this:
```
DELETE FROM tablename WHERE pk = 12345
```
This just hangs, no timeout, no nothing.
We've looked at the execution plan, and it consists of many lookups... | One piece of information missing is the number of indices on the table you are deleting the data from. As SQL Server uses the Primary Key as a pointer in every index, any change to the primary index requires updating every index. Though, unless we are talking a high number, this shouldn't be an issue.
I am guessing, f... |
56,078 | <p>I got a Function that returns a <code>Collection<string></code>, and that calls itself recursively to eventually return one big <code>Collection<string></code>.</p>
<p>Now, i just wonder what the best approach to merge the lists? <code>Collection.CopyTo()</code> only copies to string[], and using a <cod... | [
{
"answer_id": 56092,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 1,
"selected": false,
"text": "<p>I think <a href=\"http://msdn.microsoft.com/en-us/library/bb359438.aspx\" rel=\"nofollow noreferrer\"><code>HashSet<T></co... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I got a Function that returns a `Collection<string>`, and that calls itself recursively to eventually return one big `Collection<string>`.
Now, i just wonder what the best approach to merge the lists? `Collection.CopyTo()` only copies to string[], and using a `foreach()` loop feels like being inefficient. However, sin... | If you're using List<> you can use .AddRange to add one list to the other list.
Or you can use yield return to combine lists on the fly like this:
```
public IEnumerable<string> Combine(IEnumerable<string> col1, IEnumerable<string> col2)
{
foreach(string item in col1)
yield return item;
foreach(strin... |
56,091 | <p>Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following:</p>
<pre><code>class MyClass
{
prot... | [
{
"answer_id": 56101,
"author": "Paulius",
"author_id": 1353085,
"author_profile": "https://Stackoverflow.com/users/1353085",
"pm_score": 1,
"selected": false,
"text": "<p>You can certainly do it, although the CaseMethod call isn't correct (it's a pointer to member function, so you have ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2958/"
] | Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following:
```
class MyClass
{
protected:
bool... | What you have there is a pointer-to-member-function. It will solve your problem. I am surprised that your "TestSwitch" function compiles, as the calling syntax is slightly different to what you might expect. It should be:
```
bool res = (this->*CaseMethod)( 999, "hello world" );
```
However, you might find a combina... |
56,112 | <p>I have written a Silverlight 2 application communicating with a WCF service (BasicHttpBinding). The site hosting the Silverlight content is protected using a ASP.NET Membership Provider. I can access the current user using HttpContext.Current.User.Identity.Name from my WCF service, and I have turned on AspNetCompati... | [
{
"answer_id": 57520,
"author": "Jeremy McGee",
"author_id": 3546,
"author_profile": "https://Stackoverflow.com/users/3546",
"pm_score": 2,
"selected": false,
"text": "<p>Web services, such as those created by WCF, are often best used in a \"stateless\" way, so each call to a Web service... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] | I have written a Silverlight 2 application communicating with a WCF service (BasicHttpBinding). The site hosting the Silverlight content is protected using a ASP.NET Membership Provider. I can access the current user using HttpContext.Current.User.Identity.Name from my WCF service, and I have turned on AspNetCompatibil... | I finally found a way to make this work. For authentication I'm using the "[WCF Authentication Service](http://msdn.microsoft.com/en-us/library/bb386582.aspx)". When authenticating the service will try to set an authentication cookie. I need to get this cookie out of the response, and add it to any other request made t... |
56,118 | <p>I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.</p>
<p>I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var... | [
{
"answer_id": 56126,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 2,
"selected": false,
"text": "<p>z is equivalent to 180 - angle of yH. Or: </p>\n\n<pre><code>180 - arctan(x/y) //Degrees\npi - arctan(x/y) //radians\n</code... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.
I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var z? A solu... | What you need is this:
```
var h:Number = Math.sqrt(x*x + y*y);
var z:Number = Math.atan2(y, x);
```
That should give you the angle in radians, you might need to swap x/y and possibly add or remove 90 degrees but it should do the trick! (Note that you don't even need **h** to get **z** when you're using atan2)
I us... |
56,168 | <p>The code in <a href="https://stackoverflow.com/questions/17181/test-cases-vs-assertion-statement">this question</a> made me think</p>
<pre><code>assert(value>0); //Precondition
if (value>0)
{
//Doit
}
</code></pre>
<p>I never write the if-statement. Asserting is enough/all you <em>can</em> do.
"Crash early... | [
{
"answer_id": 56173,
"author": "Tnilsson",
"author_id": 4165,
"author_profile": "https://Stackoverflow.com/users/4165",
"pm_score": 3,
"selected": false,
"text": "<p>The problem with trusting just Asserts, is that they may be turned off in a production environment. To quote the wikipedi... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1163/"
] | The code in [this question](https://stackoverflow.com/questions/17181/test-cases-vs-assertion-statement) made me think
```
assert(value>0); //Precondition
if (value>0)
{
//Doit
}
```
I never write the if-statement. Asserting is enough/all you *can* do.
"Crash early, crash often"
[CodeComplete](https://rads.stacko... | The problem with trusting just Asserts, is that they may be turned off in a production environment. To quote the wikipedia article:
>
> Most languages allow assertions to be
> enabled or disabled globally, and
> sometimes independently. Assertions
> are often enabled during development
> and disabled during final... |
56,208 | <p>I've having trouble directly accessing the <strong>Win32_OperatingSystem</strong> management class that is exposed via WMI.</p>
<p>It is a singleton class, and I'm pretty certain "Win32_OperatingSystem=@" is the correct path syntax to get the instance of a singleton.</p>
<p>The call to InvokeMethod produces the ex... | [
{
"answer_id": 57808,
"author": "Nick Randell",
"author_id": 5932,
"author_profile": "https://Stackoverflow.com/users/5932",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not 100% sure of the answer, but have you tried using reflector to look at what ManagementObjectSearcher does? It... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | I've having trouble directly accessing the **Win32\_OperatingSystem** management class that is exposed via WMI.
It is a singleton class, and I'm pretty certain "Win32\_OperatingSystem=@" is the correct path syntax to get the instance of a singleton.
The call to InvokeMethod produces the exception listed at the bottom... | Win32\_OperatingSystem is not a singleton class - if you check its qualifiers, you'll see that there is no Singleton qualifier defined for it, so you'll have to use ManagementObjectSearcher.Get() or ManagementClass.GetInstances() even though there is only one instance of the class. Win32\_OperatingSystem key property i... |
56,215 | <p>Not so long ago I was in an interview, that required solving two very interesting problems. I'm curious how would you approach the solutions.</p>
<p>Problem 1 :</p>
<p><strong>Product of everything except current</strong> </p>
<p>Write a function that takes as input two integer arrays of length len, input and in... | [
{
"answer_id": 56225,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 1,
"selected": false,
"text": "<p>For the first one, first calculate the product of entire contents of input, and then for every element of index, divide the ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Not so long ago I was in an interview, that required solving two very interesting problems. I'm curious how would you approach the solutions.
Problem 1 :
**Product of everything except current**
Write a function that takes as input two integer arrays of length len, input and index, and generates a third array, resu... | First question:
```
int countZeroes (int[] vec) {
int ret = 0;
foreach(int i in vec) if (i == 0) ret++;
return ret;
}
int[] mysticCalc(int[] values, int[] indexes) {
int zeroes = countZeroes(values);
int[] retval = new int[values.length];
int product = 1;
if (zeroes >= 2) { // 2 or more zeroes, al... |
56,227 | <p>I would like to start tagging my deployed binaries with the latest SVN revision number.</p>
<p>However, because SVN is file-based and not directory/project-based, I need to scan through all the directory's and subdirectory's files in order to determine the highest revision number.</p>
<p>Using <code>svn info</code... | [
{
"answer_id": 56240,
"author": "Charles Miller",
"author_id": 3052,
"author_profile": "https://Stackoverflow.com/users/3052",
"pm_score": 6,
"selected": true,
"text": "<p>One way. When you check out the code, look at the last line of svn output:</p>\n\n<pre><code>$ svn up\n...stuff...\n... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I would like to start tagging my deployed binaries with the latest SVN revision number.
However, because SVN is file-based and not directory/project-based, I need to scan through all the directory's and subdirectory's files in order to determine the highest revision number.
Using `svn info` on the root doesn't work (... | One way. When you check out the code, look at the last line of svn output:
```
$ svn up
...stuff...
Updated to revision 66593.
```
A more direct way:
```
$ svn info
Path: .
URL: https://svn.example.com/svn/myproject/trunk
Repository Root: https://svn.example.com/svn/
Repository UUID: d2a7a951-c712-0410-832a-9abccab... |
56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | [
{
"answer_id": 56262,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 2,
"selected": false,
"text": "<p>don't you actually want something like:</p>\n\n<pre><code>html(head(script(type='text/javascript', content='var a = .... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5190/"
] | I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?
This is similar to what I'm actually doing:
```
import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'head')
script = ET.Sub... | I assume that you're actually creating an XML DOM tree, because you want to validate that what goes into this file is valid XML, since otherwise you'd just write a static string to a file. If validating your output is indeed your goal, then I'd suggest
```
from xml.dom.minidom import parseString
doc = parseString("""... |
56,249 | <p>From what I've seen the tag is ignored when hosting a WCF service in IIS. I understand that when self-hosting this is required but is this harmful or even used when operating under IIS?</p>
<p>ex.</p>
<pre><code><system.serviceModel>
<service blah blah blah>
<host>
<baseAddresses... | [
{
"answer_id": 56286,
"author": "Paul Lalonde",
"author_id": 5782,
"author_profile": "https://Stackoverflow.com/users/5782",
"pm_score": 6,
"selected": true,
"text": "<p>As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address i... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5772/"
] | From what I've seen the tag is ignored when hosting a WCF service in IIS. I understand that when self-hosting this is required but is this harmful or even used when operating under IIS?
ex.
```
<system.serviceModel>
<service blah blah blah>
<host>
<baseAddresses>
<add baseAddress="http://localhost... | As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address is determined by the web site & virtual directory into which your wcf service is placed.
Even when self-hosting, baseAddresses is not required. It is merely a convenience that avoids you having to enter... |
56,271 | <p>I am using Forms authentication in my asp.net (3.5) application. I am also using roles to define what user can access which subdirectories of the app. Thus, the pertinent sections of my web.config file look like this:</p>
<pre><code><system.web>
<authentication mode="Forms">
<forms loginUrl="De... | [
{
"answer_id": 56506,
"author": "Jordan H.",
"author_id": 1540,
"author_profile": "https://Stackoverflow.com/users/1540",
"pm_score": 0,
"selected": false,
"text": "<p>this is just a random shot, but are you getting blocked because of the order of authorization for Admin? Maybe you shoul... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51/"
] | I am using Forms authentication in my asp.net (3.5) application. I am also using roles to define what user can access which subdirectories of the app. Thus, the pertinent sections of my web.config file look like this:
```
<system.web>
<authentication mode="Forms">
<forms loginUrl="Default.aspx" path="/" protecti... | **Here was the problem and solution**:
Earlier in development I had gone to the Website menu and clicked on Asp.net configuration. This resulted in the following line being added to the web.config:
```
<system.web>
<roleManager enabled="true" />
</system.web>
```
From that point on, the app was assuming that I ... |
56,303 | <p>I need to specify a date value in a sybase where clause. For example:</p>
<pre><code>select *
from data
where dateVal < [THE DATE]
</code></pre>
| [
{
"answer_id": 56310,
"author": "cmsherratt",
"author_id": 3512,
"author_profile": "https://Stackoverflow.com/users/3512",
"pm_score": 5,
"selected": false,
"text": "<p>Use the convert function, for example:</p>\n\n<pre><code>select * from data \nwhere dateVal < convert(datetime, '01/... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3512/"
] | I need to specify a date value in a sybase where clause. For example:
```
select *
from data
where dateVal < [THE DATE]
``` | Use the convert function, for example:
```
select * from data
where dateVal < convert(datetime, '01/01/2008', 103)
```
Where the convert style (103) determines the date format to use. |
56,324 | <p>I have a little routine that's run under Linux and Windows written in C and displays output on the console. I'm not linking in any form of curses or anything like that.</p>
<p>Currently I clear the screen using</p>
<pre><code>#ifdef __WIN32
system( "cls" );
#else
system( "clear" );
#endif
</code></pre>
<p>The... | [
{
"answer_id": 56335,
"author": "Paul Hargreaves",
"author_id": 5330,
"author_profile": "https://Stackoverflow.com/users/5330",
"pm_score": 1,
"selected": true,
"text": "<p>Looks like I may have found a windows specific way of doing it <a href=\"http://msdn.microsoft.com/en-us/library/ms... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330/"
] | I have a little routine that's run under Linux and Windows written in C and displays output on the console. I'm not linking in any form of curses or anything like that.
Currently I clear the screen using
```
#ifdef __WIN32
system( "cls" );
#else
system( "clear" );
#endif
```
Then I have a bunch of printf statem... | Looks like I may have found a windows specific way of doing it [SetConsoleCursorPosition](http://msdn.microsoft.com/en-us/library/ms686025(VS.85).aspx)
Ansi escape sequence \033[0;0H for Linux - just printf that to the console. |
56,334 | <p>Suppose that two tables exist: <code>users</code> and <code>groups</code>.</p>
<p><strong>How does one provide "simple search" in which a user enters text and results contain both users and groups whose names contain the text?</strong></p>
<p>The result of the search must distinguish between the two types.</p>
| [
{
"answer_id": 56336,
"author": "Bobby Jack",
"author_id": 5058,
"author_profile": "https://Stackoverflow.com/users/5058",
"pm_score": 3,
"selected": true,
"text": "<p>The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. In most (... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5058/"
] | Suppose that two tables exist: `users` and `groups`.
**How does one provide "simple search" in which a user enters text and results contain both users and groups whose names contain the text?**
The result of the search must distinguish between the two types. | The trick is to combine a `UNION` with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:
```
SELECT "group" type, name
FROM groups
WHERE name... |
56,340 | <p>I have a class in system-C with some data members as such: </p>
<pre><code>long double x[8];
</code></pre>
<p>I'm initializing it in the construction like this:</p>
<pre><code>for (i = 0; i < 8; ++i) {
x[i] = 0;
}
</code></pre>
<p>But the first time I use it in my code I have garbage there.</p>
<p>Becau... | [
{
"answer_id": 56336,
"author": "Bobby Jack",
"author_id": 5058,
"author_profile": "https://Stackoverflow.com/users/5058",
"pm_score": 3,
"selected": true,
"text": "<p>The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. In most (... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084/"
] | I have a class in system-C with some data members as such:
```
long double x[8];
```
I'm initializing it in the construction like this:
```
for (i = 0; i < 8; ++i) {
x[i] = 0;
}
```
But the first time I use it in my code I have garbage there.
Because of the way the system is built I can't connect a debugger... | The trick is to combine a `UNION` with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:
```
SELECT "group" type, name
FROM groups
WHERE name... |
56,347 | <p>I'm returning to c++ after being away for a bit and trying to dust off the old melon. </p>
<p>In Java Iterator is an interface to a container having methods: <code>hasNext()</code>, <code>next()</code> and <code>remove()</code>. The presence of <code>hasNext()</code> means it <strong>has the concept of a limit</str... | [
{
"answer_id": 56370,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, there is a large conceptual difference. C++ utilizes different \"classes\" of iterators. Some are used for random ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | I'm returning to c++ after being away for a bit and trying to dust off the old melon.
In Java Iterator is an interface to a container having methods: `hasNext()`, `next()` and `remove()`. The presence of `hasNext()` means it **has the concept of a limit** for the container being traversed.
```
//with an Iterator
Ite... | Yes, there is a large conceptual difference. C++ utilizes different "classes" of iterators. Some are used for random access (unlike Java), some are used for forward access (like java). While even others are used for writing data (for use with, say, `transform`).
See the iterators concept in the [C++ Documentation](ht... |
56,362 | <p>I'm starting to learn ruby. I'm also a day-to-day C++ dev.
For C++ projects I usually go with following dir structure</p>
<pre><code>/
-/bin <- built binaries
-/build <- build time temporary object (eg. .obj, cmake intermediates)
-/doc <- manuals and/or Doxygen docs
-/src
--/module-1
--/module-2
-- ... | [
{
"answer_id": 56377,
"author": "ujh",
"author_id": 4936,
"author_profile": "https://Stackoverflow.com/users/4936",
"pm_score": 1,
"selected": false,
"text": "<p>Why not use just the same layout? Normally you won't need build because there's no compilation step, but the rest seems OK to ... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5731/"
] | I'm starting to learn ruby. I'm also a day-to-day C++ dev.
For C++ projects I usually go with following dir structure
```
/
-/bin <- built binaries
-/build <- build time temporary object (eg. .obj, cmake intermediates)
-/doc <- manuals and/or Doxygen docs
-/src
--/module-1
--/module-2
-- non module specific sou... | Bundler includes the necessary infrastructure to generate a gem:
```
$ bundle gem --coc --mit --test=minitest --exe spider
Creating gem 'spider'...
MIT License enabled in config
Code of conduct enabled in config
create spider/Gemfile
create spider/lib/spider.rb
create spider/lib/spider/version.rb
... |
56,373 | <p>I am writing a unit test to check that a private method will close a stream.</p>
<p>The unit test calls methodB and the variable something is null</p>
<p>The unit test doesn't mock the class on test</p>
<p>The private method is within a public method that I am calling.</p>
<p>Using emma in eclipse (via the eclem... | [
{
"answer_id": 56816,
"author": "Stu Thompson",
"author_id": 2961,
"author_profile": "https://Stackoverflow.com/users/2961",
"pm_score": 0,
"selected": false,
"text": "<p>I assume when you say 'the unit test calls <code>methodB()</code>', you mean not directly and via <code>methodA()</co... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am writing a unit test to check that a private method will close a stream.
The unit test calls methodB and the variable something is null
The unit test doesn't mock the class on test
The private method is within a public method that I am calling.
Using emma in eclipse (via the eclemma plugin) the method call is d... | I have found that the eclipse plugin for EMMA is quite buggy, and have had similar experiences to the one you describe. Better to just use EMMA on its own (via ANT if required). Make sure you always regenerate the metadata files produced by EMMA, to avoid merging confusion (which I suspect is the problem with the eclip... |
56,391 | <p>Trying to honor a feature request from our customers, I'd like that my application, when Internet is available, check on our website if a new version is available.</p>
<p>The problem is that I have no idea about what have to be done on the server side.</p>
<p>I can imagine that my application (developped in C++ us... | [
{
"answer_id": 56404,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>The simplest way to make this happen is to fire an HTTP request using a library like <a href=\"http://curl.haxx.se/libcurl/\... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2796/"
] | Trying to honor a feature request from our customers, I'd like that my application, when Internet is available, check on our website if a new version is available.
The problem is that I have no idea about what have to be done on the server side.
I can imagine that my application (developped in C++ using Qt) has to se... | I would absolutely recommend to just do a plain HTTP request to your website. Everything else is bound to fail.
I'd make a HTTP GET request to a certain page on your site containing the version of the local application.
like
```
http://www.example.com/update?version=1.2.4
```
Then you can return what ever you want... |
56,402 | <p>I am trying to make SVG XML documents with a mixture of lines and brief text snippets (two or three words typically). The major problem I'm having is getting the text aligning with line segments.</p>
<p>For horizontal alignment I can use <code>text-anchor</code> with <code>left</code>, <code>middle</code> or <code>... | [
{
"answer_id": 73257,
"author": "Ian G",
"author_id": 5764,
"author_profile": "https://Stackoverflow.com/users/5764",
"pm_score": 7,
"selected": true,
"text": "<p>It turns out that you don't need explicit text paths. Firefox 3 has only partial support of the vertical alignment tags (<a h... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5764/"
] | I am trying to make SVG XML documents with a mixture of lines and brief text snippets (two or three words typically). The major problem I'm having is getting the text aligning with line segments.
For horizontal alignment I can use `text-anchor` with `left`, `middle` or `right`. I can't find a equivalent for vertical a... | It turns out that you don't need explicit text paths. Firefox 3 has only partial support of the vertical alignment tags ([see this thread](http://groups.google.com/group/mozilla.dev.tech.svg/browse_thread/thread/1be0c56cfbfb3053?fwc=1)). It also seems that dominant-baseline only works when applied as a style whereas te... |
56,430 | <p>I have a foxpro app, that contains hard coded path for icons and bitmaps. That's how foxpro does it and there is no way around it. And this works fine, except that when a removable drive has been used but is not connected, and when is connected windows assigns the same letter as hard coded path, when opening any for... | [
{
"answer_id": 56487,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 2,
"selected": false,
"text": "<p>Nelson:</p>\n\n<p>\"That's how foxpro does it and there is no way around it\"?</p>\n\n<p>I'm using FOX since FoxPro 2.5 to Vi... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a foxpro app, that contains hard coded path for icons and bitmaps. That's how foxpro does it and there is no way around it. And this works fine, except that when a removable drive has been used but is not connected, and when is connected windows assigns the same letter as hard coded path, when opening any form t... | Nelson:
"That's how foxpro does it and there is no way around it"?
I'm using FOX since FoxPro 2.5 to Visual FoxPro 9, and you are NEVER forced in any way to hard-code a path, you can use SET PATH TO (sYourPath), you can embed the icons and bitmaps in your EXE / APP file and therefore there's no need of including this... |
56,443 | <p>I currently have a class and I'm trying to create an easy GUI to create a collection of this class. Most of the attributes of this class are strings. However, one of the attributes I want the user to be able to set is an Enum. Therefore, I would like the user interface, to have a dropdownlist for this enum, to rest... | [
{
"answer_id": 56483,
"author": "Ozgur Ozcitak",
"author_id": 976,
"author_profile": "https://Stackoverflow.com/users/976",
"pm_score": 6,
"selected": true,
"text": "<p>I do not know if that would work with a DataGridView column but it works with ComboBoxes:</p>\n\n<pre><code>comboBox1.D... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4660/"
] | I currently have a class and I'm trying to create an easy GUI to create a collection of this class. Most of the attributes of this class are strings. However, one of the attributes I want the user to be able to set is an Enum. Therefore, I would like the user interface, to have a dropdownlist for this enum, to restrict... | I do not know if that would work with a DataGridView column but it works with ComboBoxes:
```
comboBox1.DataSource = Enum.GetValues(typeof(MyEnum));
```
and:
```
MyEnum value = (MyEnum)comboBox1.SelectedValue;
```
UPDATE: It works with DataGridView columns too, just remember to set the value type.
```
DataGridVi... |
56,446 | <p>Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:</p>
<pre><code>Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
</code></pre>
<p>Produces the desired results (an array of objects with a lower boun... | [
{
"answer_id": 56457,
"author": "Martin Marconcini",
"author_id": 2684,
"author_profile": "https://Stackoverflow.com/users/2684",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure about why that can't be passed as Object[], but wouldn't be easy if you just create a real class to... | 2008/09/11 | [
"https://Stackoverflow.com/questions/56446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1111/"
] | Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:
```
Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
```
Produces the desired results (an array of objects with a lower bound set to 9). However the c... | The reason why you can't cast from one to the other is that this is evil.
Lets say you create an array of object[5..9] and you pass it to a function F as an object[].
How would the function knows that this is a 5..9 ? F is expecting a general array but it's getting a constrained one. You could say it's possible for i... |