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 |
|---|---|---|---|---|---|---|
221,474 | <p>When you create a link to an executable file intended for download (like say update.exe), on a web page, IE7 gives the user the option to "Run" or "Save". I don't want users to be running the update file they should be downloading.</p>
<p>Is it possible to disable the "Save" option on the dialog the IE displays, or... | [
{
"answer_id": 221486,
"author": "Rob Stevenson-Leggett",
"author_id": 4950,
"author_profile": "https://Stackoverflow.com/users/4950",
"pm_score": 2,
"selected": false,
"text": "<p>Download behaviour is built into the browser. The user should have the choice. What difference does it make... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5019/"
] | When you create a link to an executable file intended for download (like say update.exe), on a web page, IE7 gives the user the option to "Run" or "Save". I don't want users to be running the update file they should be downloading.
Is it possible to disable the "Save" option on the dialog the IE displays, or even forc... | EDIT: Sorry, I thought this piece of code would be self-explaining. Given the OP tagged it ASP.NET, I thought we were in the context of ASP.NET.
This could should go in a proxy file that is linked to, instead of directly to the .exe file. The proxy file then sends the .exe file and forces (tries to persuade) the brows... |
221,475 | <p>In LinqToSql, it is lovely easy to load a row, change a column, and submit the changes to the database:</p>
<pre><code>using (MyDataContext wdc = new MyDataContext())
{
Article article = wdc.Article.First(p => p.ID == id);
article.ItemsInStock = itemsinstock;
wdc.SubmitChanges();
}
</code></pre>
<... | [
{
"answer_id": 221547,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 3,
"selected": false,
"text": "<p>You need to set UpdateCheck on all properties of the Article class except the primary key (click on the class propert... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] | In LinqToSql, it is lovely easy to load a row, change a column, and submit the changes to the database:
```
using (MyDataContext wdc = new MyDataContext())
{
Article article = wdc.Article.First(p => p.ID == id);
article.ItemsInStock = itemsinstock;
wdc.SubmitChanges();
}
```
The only drawback: Article ... | ligget78 gave me another idea how to make an update of a single column:
Create a new DataContext just for this kind of update, and only include the needed columns into this DataContext.
This way the unneeded columns will not even be loaded, and of course not sent back to the database. |
221,502 | <p>I'm comparing the results produced when i use the 'Make .exe' compared to when i run the exact same process using the exact same variables though the IDE vb 6 debugger.</p>
<p>I've tried an array of different compiler options but to no avail.</p>
<p>So my question is why would i get a difference between the debugg... | [
{
"answer_id": 221622,
"author": "dummy",
"author_id": 6297,
"author_profile": "https://Stackoverflow.com/users/6297",
"pm_score": 2,
"selected": false,
"text": "<p><code>Debug.Assert</code> and <code>Debug.Print</code> Statement are not compiled into the binary. I sometimes use this to ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5186/"
] | I'm comparing the results produced when i use the 'Make .exe' compared to when i run the exact same process using the exact same variables though the IDE vb 6 debugger.
I've tried an array of different compiler options but to no avail.
So my question is why would i get a difference between the debugger and the 'Make ... | `Debug.Assert` and `Debug.Print` Statement are not compiled into the binary. I sometimes use this to detect whether I am in the IDE or a compiled binary:
```
On Error Resume Next
Debug.Print 1/0
If Err=0 then
'Compiled Binary
else
'in the IDE
End if
```
Be careful with statements like this:
```
Debug.Assert( D... |
221,503 | <p>I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate:</p>
<pre><code>class Usable : IUsable
{
public void Use(Action action) // implements IUsable
{
// acquire resources
action();
// release resources
}
}
</code></pre>
<p>and in use... | [
{
"answer_id": 221522,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 1,
"selected": false,
"text": "<p>You can already have most of this by using an anonymous delegate like this:</p>\n\n<pre><code>using(new Usable(dele... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18575/"
] | I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate:
```
class Usable : IUsable
{
public void Use(Action action) // implements IUsable
{
// acquire resources
action();
// release resources
}
}
```
and in user code:
```
using (new Us... | IMHO, I don't see any great use for this pattern because:
1. using block already requires the object to have IDisposable interface, so we can use the IDisposable interface for controlled execution
2. From where do we pass the Action object here?
I had already used this kind of pattern successfully for database action... |
221,514 | <p>Suppose, objects of type <i>A</i> are stored in DB. Here's the way I load specific one from DB using hibernate:</p>
<pre><code>org.hibernate.Session session = ...;
long id = 1;
A obj = session.load(A.class, id);
</code></pre>
<p>If object with id=1 doesn't exist I will get <i>ObjectNotFoundException</i>. But is th... | [
{
"answer_id": 221526,
"author": "Juanma",
"author_id": 3730,
"author_profile": "https://Stackoverflow.com/users/3730",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <code>session.get</code>:</p>\n\n<pre><code>public Object get(Class clazz,\n Serializable id)\... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose, objects of type *A* are stored in DB. Here's the way I load specific one from DB using hibernate:
```
org.hibernate.Session session = ...;
long id = 1;
A obj = session.load(A.class, id);
```
If object with id=1 doesn't exist I will get *ObjectNotFoundException*. But is there a way to check if such object ex... | You can use `session.get`:
```
public Object get(Class clazz,
Serializable id)
throws HibernateException
```
It will return null if the object does not exist in the database. You can find more information in [Hibernate API Documentation](http://www.hibernate.org/hib_docs/v3/api/ "Hiberna... |
221,519 | <p>The following Code does not compile</p>
<pre><code>Dim BasicGroups As String() = New String() {"Node1", "Node2"}
Dim NodesToRemove = From Element In SchemaDoc.Root.<Group> _
Where Element.@Name not in BasicGroups
For Each XNode In NodesToRemove
XNode.Remove()
Next
</code></pre>
<p>It ... | [
{
"answer_id": 221605,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 3,
"selected": true,
"text": "<p>You probably want to move the 'not' part. Eg (psuedo code)</p>\n\n<pre><code>where (not (list.Contains(foo))\n</code></pr... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11356/"
] | The following Code does not compile
```
Dim BasicGroups As String() = New String() {"Node1", "Node2"}
Dim NodesToRemove = From Element In SchemaDoc.Root.<Group> _
Where Element.@Name not in BasicGroups
For Each XNode In NodesToRemove
XNode.Remove()
Next
```
It is supposed to Remove any Immedi... | You probably want to move the 'not' part. Eg (psuedo code)
```
where (not (list.Contains(foo))
``` |
221,520 | <p>I don't understand, why does the following regular expression:</p>
<pre><code>^*$
</code></pre>
<p>Match the string "127.0.0.1"? Using <code>Regex.IsMatch("127.0.0.1", "^*$");</code></p>
<p>Using Expresso, it does not match, which is also what I would expect. Using the expression <code>^.*$</code> does match the ... | [
{
"answer_id": 221537,
"author": "Richard Nienaber",
"author_id": 9539,
"author_profile": "https://Stackoverflow.com/users/9539",
"pm_score": -1,
"selected": false,
"text": "<p>Using <a href=\"http://www.sellsbrothers.com/tools/#regexd\" rel=\"nofollow noreferrer\">RegexDesigner</a>, I c... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12469/"
] | I don't understand, why does the following regular expression:
```
^*$
```
Match the string "127.0.0.1"? Using `Regex.IsMatch("127.0.0.1", "^*$");`
Using Expresso, it does not match, which is also what I would expect. Using the expression `^.*$` does match the string, which I would also expect.
Technically, `^*$` ... | Well, theoretically you are right, it should not match. But this depends on how the implementation works internally. Most regex impl. will take your regex and strip ^ from the front (taking note that it must match from start of the string) and strip $ from the end (noting that it must to the end of the string), what is... |
221,523 | <p>I would like to hide the UISearchBar most of the time and only call it to appear when user wants it. </p>
<p>I've put a UISearchBar in Interface Builder and hide it behind a view, when user click a button, it calls the following code, which I hoped it would bring the search bar to the front and slide the keyboard t... | [
{
"answer_id": 221581,
"author": "Stephen Darlington",
"author_id": 2998,
"author_profile": "https://Stackoverflow.com/users/2998",
"pm_score": 2,
"selected": false,
"text": "<p>I placed the search bar on top of the view and made it hidden. Then you just need:</p>\n\n<pre><code>mySearchB... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9774/"
] | I would like to hide the UISearchBar most of the time and only call it to appear when user wants it.
I've put a UISearchBar in Interface Builder and hide it behind a view, when user click a button, it calls the following code, which I hoped it would bring the search bar to the front and slide the keyboard to view. Bu... | If you want to pop the keyboard, you'll need to call [mySearchBar becomeFirstResponder] |
221,539 | <p>I've seen this in a few <a href="https://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript#221357">places</a></p>
<pre><code>function fn() {
return +new Date;
}
</code></pre>
<p>And I can see that it is returning a timestamp rather than a date object, but I can't find any documentatio... | [
{
"answer_id": 221560,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 6,
"selected": false,
"text": "<p>JavaScript is loosely typed, so it performs type coercion/conversion in certain circumstances:</p>\n\n<p><a href=\... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | I've seen this in a few [places](https://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript#221357)
```
function fn() {
return +new Date;
}
```
And I can see that it is returning a timestamp rather than a date object, but I can't find any documentation on what the plus sign is doing.
Ca... | That's the `+` unary operator. It's equivalent to:
```
function(){ return Number(new Date); }
```
See <http://xkr.us/articles/javascript/unary-add> and [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus). |
221,550 | <p><strong>Scenario:</strong></p>
<p>(If anyone has answered/viewed my questions recently this will be somewhat familar)</p>
<p>I have 3 different web services which expose a set of objects that have commonality. I've written wrapper classes and conversion logic using generic methods to change between the intermediar... | [
{
"answer_id": 221670,
"author": "Jakub Šturc",
"author_id": 2361,
"author_profile": "https://Stackoverflow.com/users/2361",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure if it fits to your scenario but reading through your question <a href=\"http://en.wikipedia.org/wiki/In... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950/"
] | **Scenario:**
(If anyone has answered/viewed my questions recently this will be somewhat familar)
I have 3 different web services which expose a set of objects that have commonality. I've written wrapper classes and conversion logic using generic methods to change between the intermediary objects and the service obje... | I think in general, if you want your code to have different type signatures, you'll have to write the code three different times. Since the types are different, it's not "the same code" at all.
You could put what you have into an inherited method and then wrap the results in each subclass. |
221,568 | <p>Is there a way in SWT to get a monospaced font simply, that works across various operating systems?</p>
<p>For example. this works on Linux, but not Windows:</p>
<pre>
<code>
Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE);
</code>
</pre>
<p>or do I need to have a method that tries loading varying... | [
{
"answer_id": 222885,
"author": "fhe",
"author_id": 4445,
"author_profile": "https://Stackoverflow.com/users/4445",
"pm_score": 5,
"selected": true,
"text": "<p>According to the section on <a href=\"http://java.sun.com/javase/6/docs/technotes/guides/intl/fontconfig.html\" rel=\"noreferr... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17832/"
] | Is there a way in SWT to get a monospaced font simply, that works across various operating systems?
For example. this works on Linux, but not Windows:
```
Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE);
```
or do I need to have a method that tries loading varying fonts (Consolas, Terminal, Monaco,... | According to the section on [Font Configuration Files](http://java.sun.com/javase/6/docs/technotes/guides/intl/fontconfig.html) in the JDK documentation of [Internationalization Support](http://java.sun.com/javase/6/docs/technotes/guides/intl/)-related APIs, the concept of **Logical Font**s is used to define certain pl... |
221,578 | <p>I'm trying to make a script that sleeps my wireless card in linux. For that I'm using the <code>deepsleep</code> command of <code>iwpriv</code>:</p>
<pre><code>iwpriv wlan0 deepsleep 1
</code></pre>
<p>The problem is that this command only works if the wireless card is disconnected and disassociated. When it's con... | [
{
"answer_id": 221607,
"author": "jvasak",
"author_id": 5840,
"author_profile": "https://Stackoverflow.com/users/5840",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have a fix, but you could try setting the ESSID of the card to a random string and hope that no access points near... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28855/"
] | I'm trying to make a script that sleeps my wireless card in linux. For that I'm using the `deepsleep` command of `iwpriv`:
```
iwpriv wlan0 deepsleep 1
```
The problem is that this command only works if the wireless card is disconnected and disassociated. When it's connected there is no problem because if I disconne... | Many drivers use the convention that associating with the NULL AP disconnects from the current AP. Add to this a brief delay, and you might have what you want. For example,
```
iwconfig wlan0 ap 00:00:00:00:00:00
sleep 1
iwpriv wlan0 deepsleep 1
```
Typically, it shouldn't take more than 250-500 milliseconds to disc... |
221,582 | <p>This question comes up occasionally, but I haven't seen a satisfactory answer.</p>
<p>A typical pattern is (row is a <strong>DataRow</strong>):</p>
<pre><code> if (row["value"] != DBNull.Value)
{
someObject.Member = row["value"];
}
</code></pre>
<p>My first question is which is more efficient (I've flippe... | [
{
"answer_id": 221590,
"author": "Jon Grant",
"author_id": 18774,
"author_profile": "https://Stackoverflow.com/users/18774",
"pm_score": 5,
"selected": false,
"text": "<p>You should use the method:</p>\n\n<pre><code>Convert.IsDBNull()\n</code></pre>\n\n<p>Considering it's built-in to the... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | This question comes up occasionally, but I haven't seen a satisfactory answer.
A typical pattern is (row is a **DataRow**):
```
if (row["value"] != DBNull.Value)
{
someObject.Member = row["value"];
}
```
My first question is which is more efficient (I've flipped the condition):
```
row["value"] == DBNul... | I must be missing something. Isn't checking for `DBNull` exactly what the [`DataRow.IsNull`](http://msdn.microsoft.com/en-us/library/3fwatee0.aspx) method does?
I've been using the following two extension methods:
```cs
public static T? GetValue<T>(this DataRow row, string columnName) where T : struct
{
if (row.I... |
221,584 | <p>I have some products that belongs to the some category.</p>
<p>Each category can have different properties.</p>
<p>For example, </p>
<ul>
<li>category <em>cars</em> has properties <em>color</em>,
power, ... </li>
<li>category <em>pets</em> have properties <em>weight</em>, <em>age</em>, ...</li>
</ul>
<p>Number ... | [
{
"answer_id": 221597,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "<p>If the user of the application <em>has</em> to select a category before they can search, I would separate your pr... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have some products that belongs to the some category.
Each category can have different properties.
For example,
* category *cars* has properties *color*,
power, ...
* category *pets* have properties *weight*, *age*, ...
Number of categories is about 10-15.
Number of properties in each category is 3-15.
Number of... | The classic design approach would be (the star denotes the primary key column):
```
Product
ProductId*
CategoryId: FK to Category.CategroyId
Name
Category
CategoryId*
Name
Property
PropertyId*
Name
Type
CategoryProperty
CategoryId*: FK to Category.CategoryId
PropertyId*: FK to Property.PropertyI... |
221,592 | <p>Does anyone know whether the iPhone supports or will soon support the <a href="http://dev.w3.org/geo/api/spec-source.html" rel="noreferrer">W3C Geolocation specification</a>?</p>
<p>I'm looking to build an app for mobile users, but rather than spend the time developing apps for every different platform (iPhone, And... | [
{
"answer_id": 221656,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": -1,
"selected": false,
"text": "<p>Currently, it's not possible to obtain an iPhone's GPS position using just JavaScript APIs. There's been talk that ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] | Does anyone know whether the iPhone supports or will soon support the [W3C Geolocation specification](http://dev.w3.org/geo/api/spec-source.html)?
I'm looking to build an app for mobile users, but rather than spend the time developing apps for every different platform (iPhone, Android, etc...), I'd much prefer to crea... | This code worked for me -- on the iPhone web browser **Safari** *and* as an added bonus it even worked with **FireFox 3.5** on my laptop! The Geolocation API Specification is part of the W3 Consortium’s standards **But be warned: it hasn’t been finalized as yet.**
[](htt... |
221,593 | <p>I am building an ObjectQuery like this:</p>
<pre><code> string query = "select value obj from Entities.Class as obj " +
"where obj.Property = @Value";
ObjectQuery<Class> oQuery = new ObjectQuery<Class>(query, EntityContext.Instance);
oQuery.Parameters.Add(n... | [
{
"answer_id": 221630,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p><code>ObjectQuery<T></code> implements <code>IQueryable<T></code>, so can't you simply use the extensio... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3610/"
] | I am building an ObjectQuery like this:
```
string query = "select value obj from Entities.Class as obj " +
"where obj.Property = @Value";
ObjectQuery<Class> oQuery = new ObjectQuery<Class>(query, EntityContext.Instance);
oQuery.Parameters.Add(new ObjectParameter("Value"... | `ObjectQuery<T>` implements `IQueryable<T>`, so can't you simply use the extension method:
```
int count = oQuery.Count();
```
What happens if you execute this? I would have expected the overall query to just do a Count()... (not that I've done much EF...). |
221,595 | <p>I have a button inside an update panel that I would like to update the whole page. I have set <code>ChildrenAsTriggers="false"</code> and <code>UpdateMode="Conditional"</code>.</p>
<p>I have some sample code here that demonstrates my problem.</p>
<pre><code><asp:UpdatePanel ID="myFirstPanel" runat="server" Chil... | [
{
"answer_id": 221653,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": -1,
"selected": false,
"text": "<p>If the label is not in an update panel the only way to refresh the value is by refreshing the entire page like in a nor... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18107/"
] | I have a button inside an update panel that I would like to update the whole page. I have set `ChildrenAsTriggers="false"` and `UpdateMode="Conditional"`.
I have some sample code here that demonstrates my problem.
```
<asp:UpdatePanel ID="myFirstPanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional... | Try adding a PostBackTrigger to the first UpdatePanel, for the secound button. That will tell that update panel, that the button should make a full postback. |
221,611 | <p>For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this?</p>
<ul>
<li><p>What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware?</p></li... | [
{
"answer_id": 221660,
"author": "bernardn",
"author_id": 21548,
"author_profile": "https://Stackoverflow.com/users/21548",
"pm_score": 2,
"selected": false,
"text": "<p>A good approach is to have a common base class for all your entities. In this base class, you can have your id propert... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23109/"
] | For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this?
* What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware?
* What data types would yo... | If you are using the JPA annotations, you can use `@PrePersist` and `@PreUpdate` event hooks do this:
```
@Entity
@Table(name = "entities")
public class Entity {
...
private Date created;
private Date updated;
@PrePersist
protected void onCreate() {
created = new Date();
}
@PreUpdate
protect... |
221,669 | <p>The offending command that msi executes is:</p>
<pre><code> .\devenv.com /command "View.Toolbox" /setup
</code></pre>
<p>This fails with Date execution prevention error.</p>
<p>devenv.exe log contains a bunch of errors like this:</p>
<pre><code> <entry>
<record>120</record>
<time>... | [
{
"answer_id": 221679,
"author": "Patrik Svensson",
"author_id": 936,
"author_profile": "https://Stackoverflow.com/users/936",
"pm_score": 0,
"selected": false,
"text": "<p>Have you sent this information to the developers of the MVC framework?\nI assume that they are glad for information... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28912/"
] | The offending command that msi executes is:
```
.\devenv.com /command "View.Toolbox" /setup
```
This fails with Date execution prevention error.
devenv.exe log contains a bunch of errors like this:
```
<entry>
<record>120</record>
<time>2008/10/21 12:32:01.277</time>
<type>Warning</type>
<source>... | Working with msiexec and forcing update/uninstall and uninstallation of clone detective (for VS.NET) solved this problem . |
221,687 | <p>I want to make a generic class that accepts only serializable classes, can it be done with the where constraint?</p>
<p>The concept I'm looking for is this:</p>
<pre><code>public class MyClass<T> where T : //[is serializable/has the serializable attribute]
</code></pre>
| [
{
"answer_id": 221695,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "<p>Nope, I'm afraid not. The only things you can do with constraints are:</p>\n\n<ul>\n<li><code>where T : class</code> -... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] | I want to make a generic class that accepts only serializable classes, can it be done with the where constraint?
The concept I'm looking for is this:
```
public class MyClass<T> where T : //[is serializable/has the serializable attribute]
``` | Nope, I'm afraid not. The only things you can do with constraints are:
* `where T : class` - T must be a reference type
* `where T : struct` - T must be a non-nullable value type
* `where T : SomeClass` - T must be SomeClass or derive from it
* `where T : ISomeInterface` - T must be ISomeInterface or implement it
* `w... |
221,730 | <p>I want to create a .bat file so I can just click on it so it can run:</p>
<pre><code>svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service
</code></pre>
<p>Can someone help me with the structure of the .bat file?</p>
| [
{
"answer_id": 221744,
"author": "GavinCattell",
"author_id": 21644,
"author_profile": "https://Stackoverflow.com/users/21644",
"pm_score": 5,
"selected": false,
"text": "<p>Just put that line in the bat file...</p>\n\n<p>Alternatively you can even make a shortcut for svcutil.exe, then a... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to create a .bat file so I can just click on it so it can run:
```
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service
```
Can someone help me with the structure of the .bat file? | To start a program and then close command prompt without waiting for program to exit:
```
start /d "path" file.exe
``` |
221,732 | <p>I've been searching a lot but couldn't find a solution. How do you deal with a DateTime that should be able to contain an uninitialized value (equivalent to null)? I have a class which might have a DateTime property value set or not. I was thinking of initializing the property holder to DateTime.MinValue, which then... | [
{
"answer_id": 221740,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 10,
"selected": true,
"text": "<p>For normal DateTimes, if you don't initialize them at all then they will match <code>DateTime.MinValue</code>, bec... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | I've been searching a lot but couldn't find a solution. How do you deal with a DateTime that should be able to contain an uninitialized value (equivalent to null)? I have a class which might have a DateTime property value set or not. I was thinking of initializing the property holder to DateTime.MinValue, which then co... | For normal DateTimes, if you don't initialize them at all then they will match `DateTime.MinValue`, because it is a value type rather than a reference type.
You can also use a nullable DateTime, like this:
```
DateTime? MyNullableDate;
```
Or the longer form:
```
Nullable<DateTime> MyNullableDate;
```
And, final... |
221,745 | <p>I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callba... | [
{
"answer_id": 221832,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 4,
"selected": true,
"text": "<p>Since Twisted is event driven, you don't need a timeout per se. You simply need to set a state variable (like datagr... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20572/"
] | I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callback ... | Since Twisted is event driven, you don't need a timeout per se. You simply need to set a state variable (like datagramRecieved) when you receive a datagram and register a [looping call](http://twistedmatrix.com/projects/core/documentation/howto/time.html) that checks the state variable, stops the reactor if appropriate... |
221,774 | <p>I have a MySQL database of keywords that are presently mixed-case. However, I want to convert them all to lowercase. Is there an easy command to do this, either using MySQL or MySQL and PHP?</p>
| [
{
"answer_id": 221780,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": false,
"text": "<p><code>SELECT LOWER(foo) AS foo FROM bar</code></p>\n"
},
{
"answer_id": 221787,
"author": "Paul Dixon",
"a... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] | I have a MySQL database of keywords that are presently mixed-case. However, I want to convert them all to lowercase. Is there an easy command to do this, either using MySQL or MySQL and PHP? | ```
UPDATE table SET colname=LOWER(colname);
``` |
221,783 | <p>Consider the following code:</p>
<pre><code>client.Send(data, data.Length, endpoint);
byte[] response = client.Receive(ref endpoint);
</code></pre>
<p>While, according to WireShark (network sniffer), the remote host does reply with data,
the application here just waits for data forever... it does not receive the a... | [
{
"answer_id": 222503,
"author": "ageektrapped",
"author_id": 631,
"author_profile": "https://Stackoverflow.com/users/631",
"pm_score": 4,
"selected": true,
"text": "<p>You probably want to setup two UdpClients: one for listening, one for sending.</p>\n\n<p>For the receiving UdpClient, u... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28149/"
] | Consider the following code:
```
client.Send(data, data.Length, endpoint);
byte[] response = client.Receive(ref endpoint);
```
While, according to WireShark (network sniffer), the remote host does reply with data,
the application here just waits for data forever... it does not receive the answer from the remote host... | You probably want to setup two UdpClients: one for listening, one for sending.
For the receiving UdpClient, use the constructor that takes a port. |
221,800 | <p>I want to learn MSBuild, was wondering if someone could get me started with a simple build script to filter out my vs.net 2008 project of all files with the .cs extension.</p>
<ol>
<li>how do I run the build?</li>
<li>where do you usually store the build also?</li>
</ol>
| [
{
"answer_id": 221854,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 0,
"selected": false,
"text": "<pre><code>C:\\projects\\_Play\\SimpleIpService>type \\\\sysrdswbld1\\public\\bin\\mrb-vs2008.cmd\n@echo off\n\ncall \"c:\\... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to learn MSBuild, was wondering if someone could get me started with a simple build script to filter out my vs.net 2008 project of all files with the .cs extension.
1. how do I run the build?
2. where do you usually store the build also? | You typically run an MSBuild script from the command line using the following syntax:
```
MSBuild <scriptfilename> /t:targetname
```
You can get more information here: <http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx>
What are you trying to accomplish by parsing out all of the .cs files from the project file?... |
221,804 | <p>I need to find the min and max value in an array. The <code>.max</code> function works but <code>.min</code> keeps showing zero.</p>
<pre><code>Public Class Program_2_Grade
Dim max As Integer
Dim min As Integer
Dim average As Integer
Dim average1 As Integer
Dim grade As String
Private Sub Bu... | [
{
"answer_id": 221834,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>You haven't shown where grade_enter is being created. My guess is that it's bigger than it needs to be, so there are ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to find the min and max value in an array. The `.max` function works but `.min` keeps showing zero.
```
Public Class Program_2_Grade
Dim max As Integer
Dim min As Integer
Dim average As Integer
Dim average1 As Integer
Dim grade As String
Private Sub Button1_Click(ByVal sender As System.O... | You haven't shown where grade\_enter is being created. My guess is that it's bigger than it needs to be, so there are "empty" entries (with value 0) which are being picked up when you try to find the minimum.
You could change it to:
```
max = grade_enter.Take(counter).Max()
min = grade_enter.Take(counter).Min()
```
... |
221,822 | <p>I'm familiar with Sybase / SQL server, where I can create a temp. table like this: </p>
<pre><code>SELECT *
INTO #temp
FROM tab1 ,
tab2
WHERE tab1.key = tab2.fkey
SELECT *
FROM #temp
WHERE field1 = 'value'
</code></pre>
<p>#temp only exists for the duration of this session, and can only be se... | [
{
"answer_id": 221880,
"author": "carson",
"author_id": 25343,
"author_profile": "https://Stackoverflow.com/users/25343",
"pm_score": 1,
"selected": false,
"text": "<p>I believe <a href=\"http://www.oracle-base.com/articles/8i/TemporaryTables.php\" rel=\"nofollow noreferrer\">global temp... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7211/"
] | I'm familiar with Sybase / SQL server, where I can create a temp. table like this:
```
SELECT *
INTO #temp
FROM tab1 ,
tab2
WHERE tab1.key = tab2.fkey
SELECT *
FROM #temp
WHERE field1 = 'value'
```
#temp only exists for the duration of this session, and can only be seen by me.
I would like t... | Your first approach ought to be to do this as a single query:
```
SELECT *
FROM
(
SELECT *
FROM tab1 ,
tab2
WHERE tab1.key = tab2.fkey
)
WHERE field1 = 'value';
```
For very complex situations or where temp# is very large, try a subquery factoring clause, optionally with the materialize hint:
```
... |
221,830 | <p>I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image.</p>
<p>I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me.</p>
<p>I know how to load/save the images, I just need the bit where I go from two Buffered... | [
{
"answer_id": 221869,
"author": "Zarkonnen",
"author_id": 15255,
"author_profile": "https://Stackoverflow.com/users/15255",
"pm_score": 0,
"selected": false,
"text": "<p>Actually, I've figured it out. This is probably not a <em>fast</em> way of doing it, but it works:</p>\n\n<pre><code>... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15255/"
] | I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image.
I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me.
I know how to load/save the images, I just need the bit where I go from two BufferedImages to one Buf... | Your solution could be improved by fetching the RGB data more than one pixel at a time(see <http://java.sun.com/javase/6/docs/api/java/awt/image/BufferedImage.html>), and by not creating three Color objects on every iteration of the inner loop.
```
final int width = image.getWidth();
int[] imgData = new int[width];
in... |
221,892 | <p>Is there a way to write an enumeration that can be extended. I have several methods that I would like to always have available for my enumerations. For example I use an enumeration for my database fields. I include the actual field name in the database. </p>
<pre><code>public enum ORDERFIELDS
{
... | [
{
"answer_id": 221902,
"author": "Guido",
"author_id": 12388,
"author_profile": "https://Stackoverflow.com/users/12388",
"pm_score": 4,
"selected": false,
"text": "<p>All enums implicitly extend <code>java.lang.Enum</code>. Since Java does not support multiple inheritance, an enum cannot... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | Is there a way to write an enumeration that can be extended. I have several methods that I would like to always have available for my enumerations. For example I use an enumeration for my database fields. I include the actual field name in the database.
```
public enum ORDERFIELDS
{
OrderID("Order... | If I understand correctly, what you'd like to do is something like this:
```
public abstract class DatabaseField {
private String fieldName;
private DatabaseField(String fieldName) {
this.fieldName = fieldName;
}
public String getFieldName() {
return fieldName;
}
}
```
Then defi... |
221,909 | <p>I'm writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I've always avoided using them in PL/SQL as well. My conditioning in this stored proc mostly revolves around whether or not a record exists, which I cou... | [
{
"answer_id": 221960,
"author": "Steve Bosman",
"author_id": 4389,
"author_profile": "https://Stackoverflow.com/users/4389",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, you're missing using cursors</p>\n\n<pre><code>DECLARE\n CURSOR foo_cur IS \n SELECT NEEDED_FIELD WHERE con... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27457/"
] | I'm writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I've always avoided using them in PL/SQL as well. My conditioning in this stored proc mostly revolves around whether or not a record exists, which I could do... | I would not use an explicit cursor to do this. Steve F. no longer advises people to use explicit cursors when an implicit cursor could be used.
The method with `count(*)` is unsafe. If another session deletes the row that met the condition after the line with the `count(*)`, and before the line with the `select ... i... |
221,919 | <p>Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other?</p>
<p>example 1:</p>
<pre><code>#!/usr/bin/perl
use warnings;
</code></pre>
<p>example 2:</p>
<pre><code>#!/usr/bin/perl -w
</code></pre>
| [
{
"answer_id": 221931,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 6,
"selected": true,
"text": "<p>Using the switch will enable all warnings in <strong>all</strong> modules used by your program. Using the pragma y... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6406/"
] | Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other?
example 1:
```
#!/usr/bin/perl
use warnings;
```
example 2:
```
#!/usr/bin/perl -w
``` | Using the switch will enable all warnings in **all** modules used by your program. Using the pragma you enable it only in that specific module (or script). Ideally, you use warnings in all your modules, but often that's not the case. Using the switch can get you a lot of warnings when you use a third party module that ... |
221,921 | <p>I'm looking for the string <code>foo=</code> in text files in a directory tree. It's on a common Linux machine, I have bash shell:</p>
<pre><code>grep -ircl "foo=" *
</code></pre>
<p>In the directories are also many binary files which match <code>"foo="</code>. As these results are not relevant a... | [
{
"answer_id": 221929,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 11,
"selected": true,
"text": "<p>Use the shell <a href=\"https://man7.org/linux/man-pages/man7/glob.7.html\" rel=\"noreferrer\">globbing syntax</a... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19746/"
] | I'm looking for the string `foo=` in text files in a directory tree. It's on a common Linux machine, I have bash shell:
```
grep -ircl "foo=" *
```
In the directories are also many binary files which match `"foo="`. As these results are not relevant and slow down the search, I want grep to skip searching these files... | Use the shell [globbing syntax](https://man7.org/linux/man-pages/man7/glob.7.html):
```
grep pattern -r --include=\*.cpp --include=\*.h rootdir
```
The syntax for `--exclude` is identical.
Note that the star is escaped with a backslash to prevent it from being expanded by the shell (quoting it, such as `--include="... |
221,925 | <p>What is the prefered method for creating a byte array from an input stream? </p>
<p>Here is my current solution with .NET 3.5. </p>
<pre><code>Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s))
{
b = br.ReadBytes((int)s.Length);
}
</code></pre>
<p>Is it still a better idea to read and write ch... | [
{
"answer_id": 221941,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 11,
"selected": true,
"text": "<p>It really depends on whether or not you can trust <code>s.Length</code>. For many streams, you just don't know how mu... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] | What is the prefered method for creating a byte array from an input stream?
Here is my current solution with .NET 3.5.
```
Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s))
{
b = br.ReadBytes((int)s.Length);
}
```
Is it still a better idea to read and write chunks of the stream? | It really depends on whether or not you can trust `s.Length`. For many streams, you just don't know how much data there will be. In such cases - and before .NET 4 - I'd use code like this:
```
public static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[16*1024];
using (MemoryStream ms = new MemoryS... |
221,930 | <p>I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)</p>
<p>I <em>am</em> using the CSSFriendly adapters from here</p>
<p><a href="http://www.asp.net/CSSAdapters/Menu.aspx" rel="noreferrer">http://www.asp.net/CSSAdapters/Menu.aspx</a></p>
<p>and they do make the ... | [
{
"answer_id": 222008,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 2,
"selected": true,
"text": "<p>The short story is that it isn't <a href=\"http://forums.asp.net/p/1006669/1336527.aspx\" rel=\"nofollow norefe... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28584/"
] | I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)
I *am* using the CSSFriendly adapters from here
<http://www.asp.net/CSSAdapters/Menu.aspx>
and they do make the rendered HTML much cleaner however I am still getting inline styles output into the HEAD element in t... | The short story is that it isn't [easily](http://forums.asp.net/p/1006669/1336527.aspx) accomplished. That code is added to the header by the menu during the prerender phase.
A possible workaround might be overriding the menu's onprerender in a custom menu control and don't call base. You could then replace the defau... |
221,950 | <p>This <a href="http://themechanicalbride.blogspot.com/2008/04/using-operators-with-generics.html" rel="nofollow noreferrer">article</a> describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:</p>
<pre><code>public T Add... | [
{
"answer_id": 221961,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 5,
"selected": true,
"text": "<p>Due to the way templates are compiled in C++, simply doing:</p>\n\n<pre><code>template < class T >\nT add(T const &am... | 2008/10/21 | [
"https://Stackoverflow.com/questions/221950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4055/"
] | This [article](http://themechanicalbride.blogspot.com/2008/04/using-operators-with-generics.html) describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:
```
public T Add(T val1, T val2)
{
return val1 + val2;
}
```
T... | Due to the way templates are compiled in C++, simply doing:
```
template < class T >
T add(T const & val1, T const & val2)
{
return val1 + val2;
}
```
will work, you'll get a compile error for every type where an operator+ is not defined.
C++ templates generate code for every type instantiation, so for every ty... |
222,018 | <p>How to format numbers in JavaScript?</p>
<hr>
<ul>
<li><a href="https://stackoverflow.com/questions/51564/javascript-culture-sensitive-currency-formatting">JavaScript culture sensitive currency formatting</a></li>
</ul>
| [
{
"answer_id": 222038,
"author": "SaaS Developer",
"author_id": 7215,
"author_profile": "https://Stackoverflow.com/users/7215",
"pm_score": 5,
"selected": true,
"text": "<p>The best you have with JavaScript is toFixed() and toPrecision() functions on your numbers.</p>\n\n<pre><code>var n... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | How to format numbers in JavaScript?
---
* [JavaScript culture sensitive currency formatting](https://stackoverflow.com/questions/51564/javascript-culture-sensitive-currency-formatting) | The best you have with JavaScript is toFixed() and toPrecision() functions on your numbers.
```
var num = 10;
var result = num.toFixed(2); // result will equal 10.00
num = 930.9805;
result = num.toFixed(3); // result will equal 930.981
num = 500.2349;
result = num.toPrecision(4); // result will equal 500.2
num = 50... |
222,019 | <p>How do i take advantage of MySQL's ability to cache prepared statements?
One reason to use prepared statements is that there is no need to send the prepared statement itself multiple times if the same prepared statement is to be used again. </p>
<pre><code>Class.forName("com.mysql.jdbc.Driver");
Connection conn = D... | [
{
"answer_id": 222085,
"author": "Keith Lawrence",
"author_id": 28299,
"author_profile": "https://Stackoverflow.com/users/28299",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Is it possible to mimic this using\n pure JDBC?</p>\n</blockquote>\n\n<p>Is this not in fact wh... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11411/"
] | How do i take advantage of MySQL's ability to cache prepared statements?
One reason to use prepared statements is that there is no need to send the prepared statement itself multiple times if the same prepared statement is to be used again.
```
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.g... | >
> Is it possible to mimic this using
> pure JDBC?
>
>
>
Is this not in fact what you've done by moving your prepared statement call out of the loop?
I may be misunderstanding the way the MySQL cache works, but does the log file necessarily report the cache's work? It may be that Spring or Hibernate has its own... |
222,028 | <p>Lots of frameworks let me expose an ejb as a webservice. </p>
<p>But then 2 months after publishing the initial service I need to change the ejb or any part of its interface. I still have clients that need to access the old interface, so I obviously need to have 2 webservices with different signatures.</p>
<p>Anyo... | [
{
"answer_id": 222105,
"author": "jezell",
"author_id": 27453,
"author_profile": "https://Stackoverflow.com/users/27453",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not an EBJ guy, but I can tell you how this is generally handled in the web service world. If you have a non-breakin... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23691/"
] | Lots of frameworks let me expose an ejb as a webservice.
But then 2 months after publishing the initial service I need to change the ejb or any part of its interface. I still have clients that need to access the old interface, so I obviously need to have 2 webservices with different signatures.
Anyone have any sugge... | I don't think, you need any additional frameworks to do this. Java EE lets you directly expose the EJB as a web service (since [EJB 2.1](http://www.jcp.org/en/jsr/detail?id=153); see [example for J2EE 1.4](http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Session3.html#wp79822)), but with EE 5 it's even simpler:
```
@Web... |
222,029 | <p>the WPF Popup control is nice, but somewhat limited in my opinion. is there a way to "drag" a popup around when it is opened (like with the DragMove() method of windows)?</p>
<p>can this be done without big problems or do i have to write a substitute for the popup class myself?
thanks</p>
| [
{
"answer_id": 222219,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 4,
"selected": false,
"text": "<p>There is no DragMove for PopUp. Just a small work around, there is lot of improvements you can add to this. </p>\n\n<pre... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] | the WPF Popup control is nice, but somewhat limited in my opinion. is there a way to "drag" a popup around when it is opened (like with the DragMove() method of windows)?
can this be done without big problems or do i have to write a substitute for the popup class myself?
thanks | Here's a simple solution using a Thumb.
* Subclass Popup in XAML and codebehind
* Add a Thumb with width/height set to 0 (this could also be done in XAML)
* Listen for MouseDown events on the Popup and raise the same event on the Thumb
* Move popup on DragDelta
XAML:
```
<Popup x:Class="PopupTest.DraggablePopup" ...... |
222,043 | <p>I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-order, subnet. I'm trying to add them together and add one to get the first IP in the subnet.</p>
<p>To get the ASCII representation, I ... | [
{
"answer_id": 222096,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 5,
"selected": true,
"text": "<p>What's happening is that you make a byte string with <code>$ip&$netmask</code>, and then try to treat it as a ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7548/"
] | I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-order, subnet. I'm trying to add them together and add one to get the first IP in the subnet.
To get the ASCII representation, I can do `inet... | What's happening is that you make a byte string with `$ip&$netmask`, and then try to treat it as a number. This is not going to work, as such. What you have to feed to `inet_ntoa` is.
```
pack("N", unpack("N", $ip&$netmask) + 1)
```
I don't think there is a simpler way to do it. |
222,052 | <p>I have a ControlTemplate that is made up of a ToolBarTray and a ToolBar. In my ToolBar, I have several buttons and then a label. I want to be able to update the label in my toolbar with something like "1 of 10" </p>
<p>My first thought is to programatically find the label and set it, but I'm reading that this s... | [
{
"answer_id": 222106,
"author": "Bryan Anderson",
"author_id": 21186,
"author_profile": "https://Stackoverflow.com/users/21186",
"pm_score": 1,
"selected": false,
"text": "<p>I would set the label to the \"Content\" attribute of your control e.g.</p>\n\n<pre><code><Label x:Name=\"myS... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I have a ControlTemplate that is made up of a ToolBarTray and a ToolBar. In my ToolBar, I have several buttons and then a label. I want to be able to update the label in my toolbar with something like "1 of 10"
My first thought is to programatically find the label and set it, but I'm reading that this should be done ... | The purpose of a ControlTemplate is to define the look of a control. For your problem, I'm not sure if a control template is the right solution.
As Bryan also points out, you should bind the *Content* property of the Label to a property that is already present in your control. This should be done via *TemplateBinding*... |
222,053 | <p>this is my first question here so I hope I can articulate it well and hopefully it won't be too mind-numbingly easy.</p>
<p>I have the following class <em>SubSim</em> which extends <em>Sim</em>, which is extending <em>MainSim</em>. In a completely separate class (and library as well) I need to check if an object be... | [
{
"answer_id": 222059,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<pre><code>if (sim is MainSim)\n</code></pre>\n\n<p>is all you need. \"is\" looks up the inheritance tree.</p>\n"
}... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13064/"
] | this is my first question here so I hope I can articulate it well and hopefully it won't be too mind-numbingly easy.
I have the following class *SubSim* which extends *Sim*, which is extending *MainSim*. In a completely separate class (and library as well) I need to check if an object being passed through is a type of... | There are 4 related standard ways:
```
sim is MainSim;
(sim as MainSim) != null;
sim.GetType().IsSubclassOf(typeof(MainSim));
typeof(MainSim).IsAssignableFrom(sim.GetType());
```
You can also create a recursive method:
```
bool IsMainSimType(Type t)
{ if (t == typeof(MainSim)) return true;
if (t == typeof(o... |
222,089 | <p>With the following file reading code:</p>
<pre><code>using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None))
{
using (TextReader tr = new StreamReader(fileStream))
{
string fileContents = tr.ReadToEnd();
}
}
</code></pre>
<p>And the following fil... | [
{
"answer_id": 222100,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "<p>You can use a <code>Mutex</code> object for this.</p>\n"
},
{
"answer_id": 222111,
"author": "Jeff Yates",
... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5993/"
] | With the following file reading code:
```
using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None))
{
using (TextReader tr = new StreamReader(fileStream))
{
string fileContents = tr.ReadToEnd();
}
}
```
And the following file write code:
```
using (... | You can open a file for writing and only lock write access, thereby allowing others to still read the file.
For example,
```
using (FileStream stream = new FileStream(@"C:\Myfile.txt", FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
{
// Do your writing here.
}
```
Other file access just opens the file for... |
222,108 | <p>On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I've not managed to figure out who is the culprit, after much research and debugging, but it seems like it should be possible. Here are the gory details:</p>
<p><strong><em>Current debugging notes... | [
{
"answer_id": 222150,
"author": "Steve K",
"author_id": 739,
"author_profile": "https://Stackoverflow.com/users/739",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <a href=\"http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html\" rel=\"noreferrer\">JConsole</a> ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2961/"
] | On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I've not managed to figure out who is the culprit, after much research and debugging, but it seems like it should be possible. Here are the gory details:
***Current debugging notes:***
1) **ps -eL 189... | It looks like the **nid** in the jstack output is the Linux LWP id.
```
"http-342.877.573.944-8080-360" daemon prio=10 tid=0x0000002adaba9c00 nid=0x754c in Object.wait() [0x00000000595bc000..0x00000000595bccb0]
```
Convert the nid to decimal and you have the LWP id. In your case 0x754c is 30028. This process is not ... |
222,119 | <p>I have encapsulated a backup database command in a Try/Catch and it appears that the error message is being lost somewhere. For example:</p>
<pre><code>BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak'
</code></pre>
<p>..gives error:<br>
<strong><em>Could not locate entry in sysdatabases for dat... | [
{
"answer_id": 222277,
"author": "Josef",
"author_id": 5581,
"author_profile": "https://Stackoverflow.com/users/5581",
"pm_score": 3,
"selected": true,
"text": "<p>It's a limitation of try/catch.</p>\n\n<p>If you look carefully at the error generated by executing </p>\n\n<pre><code> BACK... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] | I have encapsulated a backup database command in a Try/Catch and it appears that the error message is being lost somewhere. For example:
```
BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak'
```
..gives error:
***Could not locate entry in sysdatabases for database 'NonExistantDB'. No entry found... | It's a limitation of try/catch.
If you look carefully at the error generated by executing
```
BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak'
```
you'll find that there are two errors that get thrown. The first is msg 911, which states
>
> Could not locate entry in sysdatabases for database... |
222,127 | <p>Say I have a data structure, such as</p>
<pre><code>d dog DS qualified
d name 20
d breed 20
d birthdate 8 0
</code></pre>
<p>I can then define </p>
<pre><code>d poochie likeds(dog)
</code></... | [
{
"answer_id": 222356,
"author": "Mike Wills",
"author_id": 2535,
"author_profile": "https://Stackoverflow.com/users/2535",
"pm_score": 0,
"selected": false,
"text": "<p>To the best of my knowledge, no. But it might be possible to do something similar with subprocedures.</p>\n\n<p>Post t... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Say I have a data structure, such as
```
d dog DS qualified
d name 20
d breed 20
d birthdate 8 0
```
I can then define
```
d poochie likeds(dog)
```
and use poochie.name, etc.
But can I ju... | Two options come to mind. The first is to create a source member with the d-specs for the dog attributes and instead of using likeds(dog), have a /copy after each data structure that will use that subfield definition. In my opinion, this can make for some sloppy code and can make things difficult for someone to analyze... |
222,133 | <p>I'm working on a web application that will return a variable set of modules depending on user input. Each module is a Python class with a constructor that accepts a single parameter and has an '.html' property that contains the output.</p>
<p>Pulling the class dynamically from the global namespace works:</p>
<pre>... | [
{
"answer_id": 222307,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, it sounds like you may be reinventing the wheel a little bit... most Python web frameworks (CherryPy/T... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7341/"
] | I'm working on a web application that will return a variable set of modules depending on user input. Each module is a Python class with a constructor that accepts a single parameter and has an '.html' property that contains the output.
Pulling the class dynamically from the global namespace works:
```
result = global... | A flaw with this approach is that it may give the user the ability to to more than you want them to. They can call *any* single-parameter function in that namespace just by providing the name. You can help guard against this with a few checks (eg. isinstance(SomeBaseClass, theClass), but its probably better to avoid th... |
222,161 | <p>What interop signature would you use for the following COM method? I am interested particularly in the final two parameters, and whether to try to use <code>MarshalAs</code> with a <code>SizeParamIndex</code> or not.</p>
<pre><code>HRESULT GetOutputSetting(
DWORD dwOutputNum,
LPCWSTR pszName,
WMT_ATTR_DAT... | [
{
"answer_id": 222172,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 2,
"selected": false,
"text": "<p>You could try the <a href=\"http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120\" rel=\"... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7532/"
] | What interop signature would you use for the following COM method? I am interested particularly in the final two parameters, and whether to try to use `MarshalAs` with a `SizeParamIndex` or not.
```
HRESULT GetOutputSetting(
DWORD dwOutputNum,
LPCWSTR pszName,
WMT_ATTR_DATATYPE* pType,
BYTE* pValue,
... | You could try the [PInvoke Signature Toolkit](http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120 "PInvoke Signature Toolkit"). It's rather useful for getting marshaling right when performing platform interops. It quite possibly won't cover your particular problem, but you may find a compara... |
222,175 | <p>I expected <code>A::~A()</code> to be called in this program, but it isn't:</p>
<pre><code>#include <iostream>
struct A {
~A() { std::cout << "~A()" << std::endl; }
};
void f() {
A a;
throw "spam";
}
int main() { f(); }
</code></pre>
<p>However, if I change last line to </p>
<pre><code>... | [
{
"answer_id": 222196,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "<p>In the second example, the dtor is called when it leaves the try{} block.</p>\n\n<p>In the first example, the dtor... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20310/"
] | I expected `A::~A()` to be called in this program, but it isn't:
```
#include <iostream>
struct A {
~A() { std::cout << "~A()" << std::endl; }
};
void f() {
A a;
throw "spam";
}
int main() { f(); }
```
However, if I change last line to
```
int main() try { f(); } catch (...) { throw; }
```
then `A::~A()... | The destructor is not being called because terminate() for the unhandled exception is called before the stack gets unwound.
The specific details of what the C++ spec says is outside of my knowledge, but a debug trace with gdb and g++ seems to bear this out.
According to the [draft standard](http://www.csci.csusb.edu/... |
222,182 | <p>In our desktop application, we have implemented a simple search engine using an <a href="http://en.wikipedia.org/wiki/Inverted_index" rel="nofollow noreferrer">inverted index</a>.</p>
<p>Unfortunately, some of our users' datasets can get very large, e.g. taking up ~1GB of memory before the inverted index has been c... | [
{
"answer_id": 222198,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 3,
"selected": true,
"text": "<p>If it's going to be 1GB... put it on disk. Use something like Berkeley DB. It will still be very fast.</p>\n\n<p>H... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7261/"
] | In our desktop application, we have implemented a simple search engine using an [inverted index](http://en.wikipedia.org/wiki/Inverted_index).
Unfortunately, some of our users' datasets can get very large, e.g. taking up ~1GB of memory before the inverted index has been created. The inverted index itself takes up a lo... | If it's going to be 1GB... put it on disk. Use something like Berkeley DB. It will still be very fast.
Here is a project that provides a .net interface to it:
<http://sourceforge.net/projects/libdb-dotnet> |
222,195 | <p>I have this piece of code (summarized)...</p>
<pre><code>AnsiString working(AnsiString format,...)
{
va_list argptr;
AnsiString buff;
va_start(argptr, format);
buff.vprintf(format.c_str(), argptr);
va_end(argptr);
return buff;
}
</code></pre>
<p>And, on the basis that pass by reference is... | [
{
"answer_id": 222221,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "<p>A good analysis why you don't want this is found in <a href=\"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1995/... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | I have this piece of code (summarized)...
```
AnsiString working(AnsiString format,...)
{
va_list argptr;
AnsiString buff;
va_start(argptr, format);
buff.vprintf(format.c_str(), argptr);
va_end(argptr);
return buff;
}
```
And, on the basis that pass by reference is preferred where possible,... | If you look at what va\_start expands out to, you'll see what's happening:
```
va_start(argptr, format);
```
becomes (roughly)
```
argptr = (va_list) (&format+1);
```
If format is a value-type, it gets placed on the stack right before all the variadic arguments. If format is a reference type, only the address ge... |
222,214 | <p>In some of our projects, there's an class hierarchy that adds more parameters as it goes down the chain. At the bottom, some of the classes can have up to 30 parameters, 28 of which are just being passed into the super constructor.</p>
<p>I'll acknowledge that using automated DI through something like Guice would b... | [
{
"answer_id": 222227,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 2,
"selected": false,
"text": "<p>Refactoring to reduce the number of parameters and depth of you inheritance hierarchy is pretty much all I can thin... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28038/"
] | In some of our projects, there's an class hierarchy that adds more parameters as it goes down the chain. At the bottom, some of the classes can have up to 30 parameters, 28 of which are just being passed into the super constructor.
I'll acknowledge that using automated DI through something like Guice would be nice, bu... | The Builder Design Pattern might help. Consider the following example
```
public class StudentBuilder
{
private String _name;
private int _age = 14; // this has a default
private String _motto = ""; // most students don't have one
public StudentBuilder() { }
public Student buildStudent()
... |
222,217 | <p>I am currently using...</p>
<pre><code>select Table_Name, Column_name, data_type, is_Nullable
from information_Schema.Columns
</code></pre>
<p>...to determine information about columns in a given database for the purposes of generating a DataAccess Layer.</p>
<p><strong>From where can I retrieve information about... | [
{
"answer_id": 222224,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 7,
"selected": true,
"text": "<p>Here is one way (replace 'keycol' with the column name you are searching\nfor):</p>\n\n<pre><code>SELECT K.TABLE_NAME ,... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11356/"
] | I am currently using...
```
select Table_Name, Column_name, data_type, is_Nullable
from information_Schema.Columns
```
...to determine information about columns in a given database for the purposes of generating a DataAccess Layer.
**From where can I retrieve information about if these columns are participants in t... | Here is one way (replace 'keycol' with the column name you are searching
for):
```
SELECT K.TABLE_NAME ,
K.COLUMN_NAME ,
K.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS C
JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS K ON C.TABLE_NAME = K.TABLE_NAME
... |
222,218 | <p>I want to change a flash object enclosed within with jQuery after an onClick event. The code I wrote, essentially:</p>
<pre><code>$(enclosing div).html('');
$(enclosing div).html(<object>My New Object</object>);
</code></pre>
<p>works in Firefox but not in IE. I would appreciate pointers or suggestion... | [
{
"answer_id": 222290,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>empty()</code> method is the better way of deleting content. Don't know if that will solve your problem thoug... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to change a flash object enclosed within with jQuery after an onClick event. The code I wrote, essentially:
```
$(enclosing div).html('');
$(enclosing div).html(<object>My New Object</object>);
```
works in Firefox but not in IE. I would appreciate pointers or suggestions on doing this. Thanks. | The `empty()` method is the better way of deleting content. Don't know if that will solve your problem though :)
```
$('#mydiv').empty();
```
You could also try the `replaceWith(content)` method. |
222,248 | <p>When I run this code:</p>
<pre><code>MIXERLINE MixerLine;
memset( &MixerLine, 0, sizeof(MIXERLINE) );
MixerLine.cbStruct = sizeof(MIXERLINE);
MixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &MixerLine, MIXER_GETLINEINFOF_COMPONENTTYPE... | [
{
"answer_id": 226201,
"author": "Tim Farley",
"author_id": 4425,
"author_profile": "https://Stackoverflow.com/users/4425",
"pm_score": 0,
"selected": false,
"text": "<p>Long time Microsoftie <a href=\"http://blogs.msdn.com/larryosterman/\" rel=\"nofollow noreferrer\">Larry Osterman has ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17958/"
] | When I run this code:
```
MIXERLINE MixerLine;
memset( &MixerLine, 0, sizeof(MIXERLINE) );
MixerLine.cbStruct = sizeof(MIXERLINE);
MixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &MixerLine, MIXER_GETLINEINFOF_COMPONENTTYPE );
```
Under XP Mix... | If you run your application in "XP compatibility" mode, the mixer APIs should work much closer to the way they did in XP.
If you're not running in XP mode, then the mixer APIs reflect the mix format - if your PC's audio solution is configured for mono, then you'll see only one channel, but if you're machine is configu... |
222,266 | <p>In an Open Source <a href="http://honeypot.net/project/pgdbf" rel="nofollow noreferrer">program I
wrote</a>, I'm reading binary data (written by another program) from a file and outputting ints, doubles,
and other assorted data types. One of the challenges is that it needs to
run on 32-bit and 64-bit machines of bo... | [
{
"answer_id": 222285,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": false,
"text": "<p>I highly suggest you read <a href=\"http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-ali... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32538/"
] | In an Open Source [program I
wrote](http://honeypot.net/project/pgdbf), I'm reading binary data (written by another program) from a file and outputting ints, doubles,
and other assorted data types. One of the challenges is that it needs to
run on 32-bit and 64-bit machines of both endiannesses, which means that I
end u... | Since you seem to know enough about your implementation to be sure that int64\_t and double are the same size, and have suitable storage representations, you might hazard a memcpy. Then you don't even have to think about aliasing.
Since you're using a function pointer for a function that might easily be inlined if you... |
222,300 | <p>I have something similar to the following method: </p>
<pre><code> public ActionResult Details(int id)
{
var viewData = new DetailsViewData
{
Booth = BoothRepository.Find(id),
Category = ItemType.HotBuy
};
return View(viewData);
}
</code></pre>
<p>... | [
{
"answer_id": 222366,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 2,
"selected": true,
"text": "<p>It's hard for me to tell what you expect to happen and what is happening from your post. Is it possible there's an error in ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12356/"
] | I have something similar to the following method:
```
public ActionResult Details(int id)
{
var viewData = new DetailsViewData
{
Booth = BoothRepository.Find(id),
Category = ItemType.HotBuy
};
return View(viewData);
}
```
and the following Route:
... | It's hard for me to tell what you expect to happen and what is happening from your post. Is it possible there's an error in your BoothRepository.Find method such that it returns the same thing every time?
ModelBinder should not be affecting this method because the parameter to the action method is a simple type, int.
... |
222,304 | <p>I have an ActiveRecord model that I would like to convert to xml, but I do not want all the properties rendered in xml. Is there a parameter I can pass into the render method to keep a property from being rendered in xml? </p>
<p>Below is an example of what I am talking about.</p>
<pre><code>def show
@person = P... | [
{
"answer_id": 222357,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 5,
"selected": true,
"text": "<p>You can pass an array of model attribute names to the <code>:only</code> and <code>:except</code> options, so for your... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/215086/"
] | I have an ActiveRecord model that I would like to convert to xml, but I do not want all the properties rendered in xml. Is there a parameter I can pass into the render method to keep a property from being rendered in xml?
Below is an example of what I am talking about.
```
def show
@person = Person.find(params[:id... | You can pass an array of model attribute names to the `:only` and `:except` options, so for your example it would be:
```
def show
@person = Person.find(params[:id])
respond_to do |format|
format.xml { render :text => @person.to_xml, :except => [:phone] }
end
end
```
* [to\_xml documentation](http://api.ru... |
222,309 | <p>If you provide <code>0</code> as the <code>dayValue</code> in <code>Date.setFullYear</code> you get the last day of the previous month:</p>
<pre><code>d = new Date(); d.setFullYear(2008, 11, 0); // Sun Nov 30 2008
</code></pre>
<p>There is reference to this behaviour at <a href="http://developer.mozilla.org/en/Co... | [
{
"answer_id": 222329,
"author": "Gad",
"author_id": 25152,
"author_profile": "https://Stackoverflow.com/users/25152",
"pm_score": 6,
"selected": false,
"text": "<p>I would use an intermediate date with the first day of the next month, and return the date from the previous day:</p>\n\n<p... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | If you provide `0` as the `dayValue` in `Date.setFullYear` you get the last day of the previous month:
```
d = new Date(); d.setFullYear(2008, 11, 0); // Sun Nov 30 2008
```
There is reference to this behaviour at [mozilla](http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date/setFullYea... | ```js
var month = 0; // January
var d = new Date(2008, month + 1, 0);
console.log(d.toString()); // last day in January
```
```
IE 6: Thu Jan 31 00:00:00 CST 2008
IE 7: Thu Jan 31 00:00:00 CST 2008
IE 8: Beta 2: Thu Jan 31 00:00:00 CST 2008
Opera 8.54: ... |
222,319 | <p>I have a query which is starting to cause some concern in my application. I'm trying to understand this EXPLAIN statement better to understand where indexes are potentially missing:</p>
<pre>
+----+-------------+-------+--------+---------------+------------+---------+-------------------------------+----... | [
{
"answer_id": 222338,
"author": "Keith Lawrence",
"author_id": 28299,
"author_profile": "https://Stackoverflow.com/users/28299",
"pm_score": 2,
"selected": false,
"text": "<p>Well looking at the query would be useful, but there's at least one thing that's obviously worth looking into - ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a query which is starting to cause some concern in my application. I'm trying to understand this EXPLAIN statement better to understand where indexes are potentially missing:
```
+----+-------------+-------+--------+---------------+------------+---------+-------------------------------+------+-----... | Well looking at the query would be useful, but there's at least one thing that's obviously worth looking into - the final line shows the ALL type for that part of the query, which is generally not great to see. If the suggested possible key (userfield) makes sense as an added index to table c, it might be worth adding ... |
222,339 | <p>Is there any performance impact or any kind of issues?
The reason I am doing this is that we are doing some synchronization between two set of DBs with similar tables and we want to avoid duplicate PK errors when synchronizing data.</p>
| [
{
"answer_id": 222351,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, it's okay.</p>\n\n<p>Note: If you have perfomance concerns you could use the \"CACHE\" option on \"CREATE SEQUENCE\... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25368/"
] | Is there any performance impact or any kind of issues?
The reason I am doing this is that we are doing some synchronization between two set of DBs with similar tables and we want to avoid duplicate PK errors when synchronizing data. | Yes, it's okay.
Note: If you have perfomance concerns you could use the "CACHE" option on "CREATE SEQUENCE":
*"Specify how many values of the sequence the database preallocates and keeps in memory for faster access. This integer value can have 28 or fewer digits. The minimum value for this parameter is 2. For sequenc... |
222,348 | <p>I have a list of about 600 jobs that I can't delete from the command line because they are attached to changelists. The only way I know how to detach them is via the GUI, but that would take forever. Does anyone know a better (i.e., faster) way?</p>
| [
{
"answer_id": 222657,
"author": "raven",
"author_id": 4228,
"author_profile": "https://Stackoverflow.com/users/4228",
"pm_score": 3,
"selected": true,
"text": "<p>I figured it out using the \"fix\" and \"fixes\" commands. Here's the procedure:</p>\n\n<p>Dump the output of the \"fixes\"... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4228/"
] | I have a list of about 600 jobs that I can't delete from the command line because they are attached to changelists. The only way I know how to detach them is via the GUI, but that would take forever. Does anyone know a better (i.e., faster) way? | I figured it out using the "fix" and "fixes" commands. Here's the procedure:
Dump the output of the "fixes" command to a file
```
p4 fixes > tmp.txt
```
The file will contain a bunch of lines like this:
```
job005519 fixed by change 3177 on 2007/11/06 by raven@raven1 (closed)
job005552 fixed by change 3320 on 2007... |
222,375 | <p>I am having trouble using the attribute XPath Selector in ElementTree, which I should be able to do according to the <a href="http://effbot.org/zone/element-xpath.htm" rel="noreferrer">Documentation</a></p>
<p>Here's some sample code</p>
<p><strong>XML</strong></p>
<pre><code><root>
<target name="1">... | [
{
"answer_id": 222473,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 6,
"selected": true,
"text": "<p>The syntax you're trying to use is new in <strong><a href=\"http://effbot.org/zone/element-xpath.htm\" rel=\"noref... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] | I am having trouble using the attribute XPath Selector in ElementTree, which I should be able to do according to the [Documentation](http://effbot.org/zone/element-xpath.htm)
Here's some sample code
**XML**
```
<root>
<target name="1">
<a></a>
<b></b>
</target>
<target name="2">
<a></a>
<b></b>
<... | The syntax you're trying to use is new in **[ElementTree 1.3](http://effbot.org/zone/element-xpath.htm)**.
Such version is shipped with **Python 2.7** or higher.
If you have Python 2.6 or less you still have ElementTree 1.2.6 or less. |
222,383 | <p>Is there an open source or public domain framework that can document shell scripts similar to what JavaDoc produces? I don't need to limit this just to a specific flavor of shell script, ideally I would like a generic framework for documenting API or command line type commands on a web page that is easy to extend or... | [
{
"answer_id": 222419,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 0,
"selected": false,
"text": "<p>You might consider <a href=\"http://www.doxygen.org/\" rel=\"nofollow noreferrer\">Doxygen</a>. While it's mostly use... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14680/"
] | Is there an open source or public domain framework that can document shell scripts similar to what JavaDoc produces? I don't need to limit this just to a specific flavor of shell script, ideally I would like a generic framework for documenting API or command line type commands on a web page that is easy to extend or ev... | If you have Perl, [here](http://bahut.alma.ch/2007_08_01_archive.html) is an example of someone who used Perl's POD system for documentation of a shell script.
>
> The trick is to have the Perl POD section in a bash "Here-Document", right after the null command (no-op) `:`.
>
>
> * Start with `: <<=cut`
> * Write y... |
222,403 | <p>I have the following interface:</p>
<pre><code>internal interface IRelativeTo<T> where T : IObject
{
T getRelativeTo();
void setRelativeTo(T relativeTo);
}
</code></pre>
<p>and a bunch of classes that (should) implement it, such as:</p>
<pre><code>public class AdminRateShift : IObject, IRelativeTo<A... | [
{
"answer_id": 222423,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 4,
"selected": false,
"text": "<p>unfortunately inheritance doesn't work with generics. If your function expects IRelativeTo, you can make the function gen... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3851/"
] | I have the following interface:
```
internal interface IRelativeTo<T> where T : IObject
{
T getRelativeTo();
void setRelativeTo(T relativeTo);
}
```
and a bunch of classes that (should) implement it, such as:
```
public class AdminRateShift : IObject, IRelativeTo<AdminRateShift>
{
AdminRateShift getRela... | If I understand the question, then the most common approach would be to declare a non-generic base-interface, i.e.
```
internal interface IRelativeTo
{
object getRelativeTo(); // or maybe something else non-generic
void setRelativeTo(object relativeTo);
}
internal interface IRelativeTo<T> : IRelativeTo
whe... |
222,413 | <p>I have a undirected graph with about 100 nodes and about 200 edges. One node is labelled 'start', one is 'end', and there's about a dozen labelled 'mustpass'.</p>
<p>I need to find the shortest path through this graph that starts at 'start', ends at 'end', <strong>and passes through all of the 'mustpass' nodes (in... | [
{
"answer_id": 222434,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 5,
"selected": false,
"text": "<p>run <a href=\"http://en.wikipedia.org/wiki/Shortest_Path_First\" rel=\"noreferrer\">Djikstra's Algorithm</a> to fi... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30014/"
] | I have a undirected graph with about 100 nodes and about 200 edges. One node is labelled 'start', one is 'end', and there's about a dozen labelled 'mustpass'.
I need to find the shortest path through this graph that starts at 'start', ends at 'end', **and passes through all of the 'mustpass' nodes (in any order).**
(... | Everyone else comparing this to the Travelling Salesman Problem probably hasn't read your question carefully. In TSP, the objective is to find the shortest cycle that visits *all* the vertices (a Hamiltonian cycle) -- it corresponds to having *every* node labelled 'mustpass'.
In your case, given that you have only abo... |
222,414 | <p>I've got a PHP script that needs to invoke a shell script but doesn't care at all about the output. The shell script makes a number of SOAP calls and is slow to complete, so I don't want to slow down the PHP request while it waits for a reply. In fact, the PHP request should be able to exit without terminating the s... | [
{
"answer_id": 222445,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 9,
"selected": true,
"text": "<p>If it \"doesn't care about the output\", couldn't the exec to the script be called with the <code>&</code> to backgroun... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1103/"
] | I've got a PHP script that needs to invoke a shell script but doesn't care at all about the output. The shell script makes a number of SOAP calls and is slow to complete, so I don't want to slow down the PHP request while it waits for a reply. In fact, the PHP request should be able to exit without terminating the shel... | If it "doesn't care about the output", couldn't the exec to the script be called with the `&` to background the process?
**EDIT** - incorporating what @[AdamTheHut](https://stackoverflow.com/users/1103/adamthehutt) commented to this post, you can add this to a call to `exec`:
```
" > /dev/null 2>/dev/null &"
```
Th... |
222,450 | <p>I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use <code>win32com.client.Dispatch</code>. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008:</p>
<pre><code>import win32com.client
app1 = win32com.client.Dispatch( 'E... | [
{
"answer_id": 222459,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "<p>You can try <em>.Net</em>'s own version, <a href=\"http://www.codeplex.com/ironpython\" rel=\"nofollow noreferrer\">IronPyt... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10559/"
] | I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use `win32com.client.Dispatch`. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008:
```
import win32com.client
app1 = win32com.client.Dispatch( 'Excel.Application' ) # ok
ap... | I don't know if this will help you with 2008, but with Visual Studio 2005 and win32com I'm able to do this:
```
>>> import win32com.client
>>> b = win32com.client.Dispatch('VisualStudio.DTE')
>>> b
<COMObject VisualStudio.DTE>
>>> b.name
u'Microsoft Visual Studio'
>>> b.Version
u'8.0'
```
Unfortunately I don't have ... |
222,453 | <p>I have a property on a domain object that is declared in a many-to-one element. The basic syntax of this property looks like this:</p>
<pre><code><many-to-one name="propertyName" class="propertyClass" fetch="select" not-found="ignore" lazy="proxy" />
</code></pre>
<p>Now, the idea is to have Hibernate NOT e... | [
{
"answer_id": 222481,
"author": "leeand00",
"author_id": 18149,
"author_profile": "https://Stackoverflow.com/users/18149",
"pm_score": 0,
"selected": false,
"text": "<p>If you're passing the hibernate object from the model to the view via the controller, don't! </p>\n\n<p>Instead make ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8026/"
] | I have a property on a domain object that is declared in a many-to-one element. The basic syntax of this property looks like this:
```
<many-to-one name="propertyName" class="propertyClass" fetch="select" not-found="ignore" lazy="proxy" />
```
Now, the idea is to have Hibernate NOT eagerly fetch this property. It ma... | If the other end of the association can be *null*, I believe hibernate must query for the association end in order to determine if it should use a proxy or not (no need for proxy if the other end is *null*). I can't find the reference to this right now, but I remember reading it somewhere.
In order to provide lazy-loa... |
222,455 | <p>Here's some background on what I'm trying to do:</p>
<ol>
<li>Open a serial port from a mobile device to a Bluetooth printer.</li>
<li>Send an EPL/2 form to the Bluetooth printer, so that it understands how to treat the data it is about to receive.</li>
<li>Once the form has been received, send some data to the pri... | [
{
"answer_id": 222508,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 2,
"selected": false,
"text": "<p>The issue is likely not with the serial port code, but with the underlying bluetooth stack. The port you're using is pu... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9732/"
] | Here's some background on what I'm trying to do:
1. Open a serial port from a mobile device to a Bluetooth printer.
2. Send an EPL/2 form to the Bluetooth printer, so that it understands how to treat the data it is about to receive.
3. Once the form has been received, send some data to the printer which will be printe... | Flow control is the correct answer here, and it may not be present/implemented/applicable to your bluetooth connection.
Check out the Zebra specification and see if they implement, or if you can turn on, software flow control (xon, xoff) which will allow you to see when the various buffers are getting full.
Further, ... |
222,464 | <p>I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface.</p>
<p>However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it seems to have conflicts with ACtiveScaffold: I get the followi... | [
{
"answer_id": 222702,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": true,
"text": "<p>I think your best bet may be checking the <a href=\"http://groups.google.com/group/activescaffold\" rel=\"nofollow nor... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404206/"
] | I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface.
However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it seems to have conflicts with ACtiveScaffold: I get the following error:
... | I think your best bet may be checking the [ActiveScaffold Google Group](http://groups.google.com/group/activescaffold) as it's monitored by core developers of ActiveScaffold and they would ultimately be able to solve your problem and explain why composite keys with the plugin won't work with ActiveScaffold.
Good luck ... |
222,470 | <p>I have to copy quite a lot of files from one folder to another. Currently I am doing it in this way:</p>
<pre><code>string[] files = Directory.GetFiles(rootFolder, "*.xml");
foreach (string file in files)
{
string otherFile = Path.Combine(otherFolder, Path.GetFileName(file));
File.Copy(file, otherFile);
}
<... | [
{
"answer_id": 222516,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 1,
"selected": false,
"text": "<p>You could use the operating system to move the files. This is what tools like WinMerge do. You click the \"copy\" butto... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5363/"
] | I have to copy quite a lot of files from one folder to another. Currently I am doing it in this way:
```
string[] files = Directory.GetFiles(rootFolder, "*.xml");
foreach (string file in files)
{
string otherFile = Path.Combine(otherFolder, Path.GetFileName(file));
File.Copy(file, otherFile);
}
```
Is that t... | I can't think of a more efficient way than File.Copy, it goes directly to the OS.
On the other hand if it takes that long, I would strongly suggest to show a progress dialog - like [SHFileOperation](http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx) does it for you. At least your users will know what is ha... |
222,511 | <p>These two methods exhibit repetition: </p>
<pre><code>public static Expression<Func<Foo, FooEditDto>> EditDtoSelector()
{
return f => new FooEditDto
{
PropertyA = f.PropertyA,
PropertyB = f.PropertyB,
PropertyC = f.PropertyC,
PropertyD = f.PropertyD,
P... | [
{
"answer_id": 222542,
"author": "Neil",
"author_id": 24315,
"author_profile": "https://Stackoverflow.com/users/24315",
"pm_score": 0,
"selected": false,
"text": "<p>The repetition is in the names, but C# has no idea that PropertyA in one class is connected with PropertyA in another. You... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29493/"
] | These two methods exhibit repetition:
```
public static Expression<Func<Foo, FooEditDto>> EditDtoSelector()
{
return f => new FooEditDto
{
PropertyA = f.PropertyA,
PropertyB = f.PropertyB,
PropertyC = f.PropertyC,
PropertyD = f.PropertyD,
PropertyE = f.PropertyE
};
... | If `FooEditDto` is a sublass of `FooDto` and you don't need the MemberInitExpressions, use a constructor:
```
class FooDto
{ public FooDto(Bar a, Bar b, Bar c)
{ PropertyA = a;
PropertyB = b;
PropertyC = c;
}
public Bar PropertyA {get;set;}
public Bar PropertyB {get;set;}
public Bar Prop... |
222,520 | <p>At the moment my code looks like this:</p>
<pre><code># Assign values for saving to the db
$data = array(
'table_of_contents' => $_POST['table_of_contents'],
'length' => $_POST['length']
);
# Check for fields that may not be set
if ( isset($_POST['lossless_copy']) )
{
$data = array(
'lossle... | [
{
"answer_id": 222633,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<pre><code>foreach ($_POST as $key => $value) {\n $data[$key] = $value;\n}\n</code></pre>\n\n<p>remember to sanitize your $... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196/"
] | At the moment my code looks like this:
```
# Assign values for saving to the db
$data = array(
'table_of_contents' => $_POST['table_of_contents'],
'length' => $_POST['length']
);
# Check for fields that may not be set
if ( isset($_POST['lossless_copy']) )
{
$data = array(
'lossless_copy' => $_POST['... | How about this:
```
// this is an array of default values for the fields that could be in the POST
$defaultValues = array(
'table_of_contents' => '',
'length' => 25,
'lossless_copy' => false,
);
$data = array_merge($defaultValues, $_POST);
// $data is now the post with all the keys set
```
`array_merge()... |
222,531 | <p>I have something like the following in an ASP.NET MVC application:</p>
<pre><code>IEnumerable<string> list = GetTheValues();
var selectList = new SelectList(list, "SelectedValue");
</code></pre>
<p>And even thought the selected value is defined, it is not being selected on the view. I have this feeling I'm ... | [
{
"answer_id": 222584,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 4,
"selected": false,
"text": "<p>Try this instead:</p>\n\n<pre><code>IDictionary<string,string> list = GetTheValues();\nvar selectList = new Sel... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5802/"
] | I have something like the following in an ASP.NET MVC application:
```
IEnumerable<string> list = GetTheValues();
var selectList = new SelectList(list, "SelectedValue");
```
And even thought the selected value is defined, it is not being selected on the view. I have this feeling I'm missing something here, so if any... | Try this instead:
```
IDictionary<string,string> list = GetTheValues();
var selectList = new SelectList(list, "Key", "Value", "SelectedValue");
```
SelectList (at least in Preview 5) is not clever enough to see that elements of IEnumerable are value type and so it should use the item for both value and text. Instead... |
222,551 | <p>To use Google Analytics, you put some JavaScript code in your web page which will make an asynchronous request to Google when the page loads.</p>
<p>From what I have read, this shouldn't block or slow down page load times if you include it directly before the end of your HTML Body. To verify this, I want to make t... | [
{
"answer_id": 222571,
"author": "Liam",
"author_id": 18333,
"author_profile": "https://Stackoverflow.com/users/18333",
"pm_score": 0,
"selected": false,
"text": "<p>That should do it. Put some quotes around the call:</p>\n\n<pre><code>window.setTimeout(\"pageTracker._trackPageview()\", ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16148/"
] | To use Google Analytics, you put some JavaScript code in your web page which will make an asynchronous request to Google when the page loads.
From what I have read, this shouldn't block or slow down page load times if you include it directly before the end of your HTML Body. To verify this, I want to make the request ... | `window.setTimeout(pageTracker._trackPageview(), 5000);` will call the code immediately - what you want is
`window.setTimeout(function() { pageTracker._trackPageview(); }, 5000);` |
222,557 | <p>Has anyone here ever used C++'s "placement new"? If so, what for? It looks to me like it would only be useful on memory-mapped hardware.</p>
| [
{
"answer_id": 222566,
"author": "mstrobl",
"author_id": 25965,
"author_profile": "https://Stackoverflow.com/users/25965",
"pm_score": 3,
"selected": false,
"text": "<p>It is useful if you are building a kernel - where do you place the kernel code you read from disk or the pagetable? You... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] | Has anyone here ever used C++'s "placement new"? If so, what for? It looks to me like it would only be useful on memory-mapped hardware. | Placement new allows you to construct an object in memory that's already allocated.
-----------------------------------------------------------------------------------
You may want to do this for optimization when you need to construct multiple instances of an object, and it is faster not to re-allocate memory each ti... |
222,572 | <p>I'm curious as to the best route (more looking towards simplicity, not speed or efficiency) to sort a DropDownList in C#/ASP.NET - I've looked at a few recommendations but they aren't clicking well with me.</p>
<p>Edit: Folks, I do not have control over how the data comes into the DropDownList - I cannot modify t... | [
{
"answer_id": 222582,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 3,
"selected": false,
"text": "<p>I usually load a DropDownList with values from a database table, so the easiest way is to sort your results as desi... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24565/"
] | I'm curious as to the best route (more looking towards simplicity, not speed or efficiency) to sort a DropDownList in C#/ASP.NET - I've looked at a few recommendations but they aren't clicking well with me.
Edit: Folks, I do not have control over how the data comes into the DropDownList - I cannot modify the SQL. | If you get a DataTable with the data, you can create a DataView off of this and then bind the drop down list to that. Your code would look something like...
```
DataView dvOptions = new DataView(DataTableWithOptions);
dvOptions.Sort = "Description";
ddlOptions.DataSource = dvOptions;
ddlOptions.DataTextField = "Descr... |
222,581 | <p>I'm looking for a simple Python script that can minify CSS as part of a web-site deployment process. (Python is the only scripting language supported on the server and full-blown parsers like <a href="http://cthedot.de/cssutils/" rel="noreferrer">CSS Utils</a> are overkill for this project).</p>
<p>Basically I'd li... | [
{
"answer_id": 222704,
"author": "Jeffrey Martinez",
"author_id": 29703,
"author_profile": "https://Stackoverflow.com/users/29703",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know of any ready made python css minifiers, but like you said css utils has the option. After checkin... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7167/"
] | I'm looking for a simple Python script that can minify CSS as part of a web-site deployment process. (Python is the only scripting language supported on the server and full-blown parsers like [CSS Utils](http://cthedot.de/cssutils/) are overkill for this project).
Basically I'd like [jsmin.py](http://www.crockford.com... | This seemed like a good task for me to get into python, which has been pending for a while. I hereby present my first ever python script:
```
import sys, re
with open( sys.argv[1] , 'r' ) as f:
css = f.read()
# remove comments - this will break a lot of hacks :-P
css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css )... |
222,592 | <p>I'm using flex builder to compile my SWF. Im using mp3's on my local machine and computeSpectrum() to analyze the mp3. </p>
<p>After playing for 20secs, my computeSpectrum stops returning values, instead, it starts returning this error:</p>
<pre><code>SecurityError: Error #2121: Security sandbox violation: SoundMi... | [
{
"answer_id": 222622,
"author": "Iain",
"author_id": 11911,
"author_profile": "https://Stackoverflow.com/users/11911",
"pm_score": 0,
"selected": false,
"text": "<p>Issues I've had with computeSpectrum in the past were caused by the global way Flash checks the audio sandbox, meaning oth... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18671/"
] | I'm using flex builder to compile my SWF. Im using mp3's on my local machine and computeSpectrum() to analyze the mp3.
After playing for 20secs, my computeSpectrum stops returning values, instead, it starts returning this error:
```
SecurityError: Error #2121: Security sandbox violation: SoundMixer.computeSpectrum: ... | The flash player thinks it's trying to open a local file from a website. This is ignored if you run it from the flash ide. It should also work as it is if you upload it to a webserver.
To be able to test locally add access to your swf (or the entire project folder) using the security tab on <http://www.macromedia.com/... |
222,598 | <p>I have a generic list of objects in C#, and wish to clone the list. The items within the list are cloneable, but there doesn't seem to be an option to do <code>list.Clone()</code>.</p>
<p>Is there an easy way around this?</p>
| [
{
"answer_id": 222611,
"author": "Anthony Potts",
"author_id": 22777,
"author_profile": "https://Stackoverflow.com/users/22777",
"pm_score": 7,
"selected": false,
"text": "<p>For a shallow copy, you can instead use the GetRange method of the generic List class.</p>\n\n<pre><code>List<... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30025/"
] | I have a generic list of objects in C#, and wish to clone the list. The items within the list are cloneable, but there doesn't seem to be an option to do `list.Clone()`.
Is there an easy way around this? | You can use an extension method.
```
static class Extensions
{
public static IList<T> Clone<T>(this IList<T> listToClone) where T: ICloneable
{
return listToClone.Select(item => (T)item.Clone()).ToList();
}
}
``` |
222,601 | <p>Why is it that in a C# switch statement, for a variable used in multiple cases, you only declare it in the first case?</p>
<p>For example, the following throws the error "A local variable named 'variable' is already defined in this scope".</p>
<pre><code>switch (Type)
{
case Type.A:
string variable... | [
{
"answer_id": 222612,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 7,
"selected": true,
"text": "<p>I believe it has to do with the overall scope of the variable, it is a block level scope that is defined at the ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10693/"
] | Why is it that in a C# switch statement, for a variable used in multiple cases, you only declare it in the first case?
For example, the following throws the error "A local variable named 'variable' is already defined in this scope".
```
switch (Type)
{
case Type.A:
string variable = "x";
... | I believe it has to do with the overall scope of the variable, it is a block level scope that is defined at the switch level.
Personally if you are setting a value to something inside a switch in your example for it to really be of any benefit, you would want to declare it outside the switch anyway. |
222,606 | <p>I need a way to detect mouse/keyboard activity on Linux. Something similar to what any IM program would do. If no activity is detected for, say 5 minutes, it will set your IM status to "I'm not here right now".</p>
<p>Any help towards this is appreciated.</p>
<p>Thanks.</p>
| [
{
"answer_id": 222624,
"author": "Keith Twombley",
"author_id": 23866,
"author_profile": "https://Stackoverflow.com/users/23866",
"pm_score": 2,
"selected": false,
"text": "<p>Try executing <code>who -u -H</code> at the command line. It will tell you who's logged in and how long they've ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need a way to detect mouse/keyboard activity on Linux. Something similar to what any IM program would do. If no activity is detected for, say 5 minutes, it will set your IM status to "I'm not here right now".
Any help towards this is appreciated.
Thanks. | Complete [c](/questions/tagged/c "show questions tagged 'c'") solution : (cut & paste the whole code in a terminal)
```
cat>/tmp/idletime.c<<EOF
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/scrnsaver.h>
int GetIdleTime () {
time... |
222,629 | <p>I have this simple regex,</p>
<pre><code>[\d]{1,5}
</code></pre>
<p>that matches any integer between 0 and 99999.</p>
<p>How would I modify it so that it didn't match 0, but matches 01 and 10, etc?</p>
<p>I know there is a way to do an OR like so...</p>
<pre><code>[\d]{1,5}|[^0]{1}
</code></pre>
<p>(doesn't ma... | [
{
"answer_id": 222641,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>My vote is to keep the regex simple and do that as a separate compare outside the regex. If the regex passes, conv... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6161/"
] | I have this simple regex,
```
[\d]{1,5}
```
that matches any integer between 0 and 99999.
How would I modify it so that it didn't match 0, but matches 01 and 10, etc?
I know there is a way to do an OR like so...
```
[\d]{1,5}|[^0]{1}
```
(doesn't make much sense)
There a way to do an AND? | probably better off with something like:
0\*[1-9]+[\d]{0,4}
If I'm right that translates to "zero or more zeros followed by at least one of the characters included in '1-9' and then up to 4 trailing decimal characters"
Mike |
222,649 | <p>We are seeing this error in a Winform application. Can anyone help on why you would see this error, and more importantly how to fix it or avoid it from happening.</p>
<pre>
System.ComponentModel.Win32Exception: Error creating window handle.
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
a... | [
{
"answer_id": 222690,
"author": "AtliB",
"author_id": 18274,
"author_profile": "https://Stackoverflow.com/users/18274",
"pm_score": 2,
"selected": false,
"text": "<p>I think it's normally related to the computer running out of memory so it's not able to create any more window handles. ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | We are seeing this error in a Winform application. Can anyone help on why you would see this error, and more importantly how to fix it or avoid it from happening.
```
System.ComponentModel.Win32Exception: Error creating window handle.
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.... | Have you run Process Explorer or the Windows Task Manager to look at the GDI Objects, Handles, Threads and USER objects? If not, select those columns to be viewed (Task Manager choose View->Select Columns... Then run your app and take a look at those columns for that app and see if one of those is growing really large.... |
222,652 | <p>A UITableViewCell comes "pre-built" with a UILabel as its one and only subview after you've init'ed it. I'd <em>really</em> like to change the background color of said label, but no matter what I do the color does not change. The code in question:</p>
<pre><code>UILabel* label = (UILabel*)[cell.contentView.subviews... | [
{
"answer_id": 222685,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 4,
"selected": true,
"text": "<p>Your code snippet works fine for me, but it must be done after the cell has been added to the table and shown, I beli... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23498/"
] | A UITableViewCell comes "pre-built" with a UILabel as its one and only subview after you've init'ed it. I'd *really* like to change the background color of said label, but no matter what I do the color does not change. The code in question:
```
UILabel* label = (UILabel*)[cell.contentView.subviews objectAtIndex:0];
la... | Your code snippet works fine for me, but it must be done after the cell has been added to the table and shown, I believe. If called from the `initWithFrame:reuseIdentifier:`, you'll get an exception, as the `UILabel` **subview** has not yet been created.
Probably the best solution is to add your own `UILabel`, configu... |
222,661 | <p>VB.net web system with a SQL Server 2005 backend. I've got a stored procedure that returns a varchar, and we're finally getting values that won't fit in a varchar(8000).</p>
<p>I've changed the return parameter to a varchar(max), but how do I tell the OleDbParameter.Size Property to accept any amount of text?</p>
... | [
{
"answer_id": 222669,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>What does this large string look like? Is it perhaps something that could be better returned through an additional... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | VB.net web system with a SQL Server 2005 backend. I've got a stored procedure that returns a varchar, and we're finally getting values that won't fit in a varchar(8000).
I've changed the return parameter to a varchar(max), but how do I tell the OleDbParameter.Size Property to accept any amount of text?
As a concrete ... | Upvoted Ed Altofer. (He answered first, so if you like my answer vote his too).
OleDb is your problem. It's a generic database connection that needs to talk to more than just SQL Server, and as a result you have a lowest common denominator situation where only the weakest composite feature set can be fully supported. ... |
222,688 | <p>In a WinForms UserControl, I would pass data to the main GUI thread by calling this.BeginInvoke() from any of the control's methods. What's the equivalent in a Silverlight UserControl?</p>
<p>In other words, how can I take data provided by an arbitrary worker thread and ensure that it gets processed on the main di... | [
{
"answer_id": 222744,
"author": "Timothy Lee Russell",
"author_id": 12919,
"author_profile": "https://Stackoverflow.com/users/12919",
"pm_score": 4,
"selected": true,
"text": "<p>Use the Dispatcher property on the UserControl class.</p>\n\n<pre><code>private void UpdateStatus()\n{\n th... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] | In a WinForms UserControl, I would pass data to the main GUI thread by calling this.BeginInvoke() from any of the control's methods. What's the equivalent in a Silverlight UserControl?
In other words, how can I take data provided by an arbitrary worker thread and ensure that it gets processed on the main displatch thr... | Use the Dispatcher property on the UserControl class.
```
private void UpdateStatus()
{
this.Dispatcher.BeginInvoke( delegate { StatusLabel.Text = "Updated"; });
}
``` |
222,740 | <p>I have an HTML input box</p>
<pre><code><input type="text" id="foo" value="bar">
</code></pre>
<p>I've attached a handler for the '<em>keyup</em>' event, but if I retrieve the current value of the input box during the event handler, I get the value as it was, and not as it will be!</p>
<p>I've tried picking... | [
{
"answer_id": 222767,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 6,
"selected": true,
"text": "<p>Can you post your code? I'm not finding any issue with this. Tested on Firefox 3.01/safari 3.1.2 with:</p>\n\n<pre><code>func... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6521/"
] | I have an HTML input box
```
<input type="text" id="foo" value="bar">
```
I've attached a handler for the '*keyup*' event, but if I retrieve the current value of the input box during the event handler, I get the value as it was, and not as it will be!
I've tried picking up '*keypress*' and '*change*' events, same p... | Can you post your code? I'm not finding any issue with this. Tested on Firefox 3.01/safari 3.1.2 with:
```
function showMe(e) {
// i am spammy!
alert(e.value);
}
....
<input type="text" id="foo" value="bar" onkeyup="showMe(this)" />
``` |
222,752 | <p>I have the following tuple, which contains tuples:</p>
<pre><code>MY_TUPLE = (
('A','Apple'),
('C','Carrot'),
('B','Banana'),
)
</code></pre>
<p>I'd like to sort this tuple based upon the <strong>second</strong> value contained in inner-tuples (i.e., sort Apple, Carrot, Banana rather than A, B, C).</p>... | [
{
"answer_id": 222762,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 6,
"selected": true,
"text": "<pre><code>from operator import itemgetter\n\nMY_SORTED_TUPLE = tuple(sorted(MY_TUPLE, key=itemgetter(1)))\n</code>... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I have the following tuple, which contains tuples:
```
MY_TUPLE = (
('A','Apple'),
('C','Carrot'),
('B','Banana'),
)
```
I'd like to sort this tuple based upon the **second** value contained in inner-tuples (i.e., sort Apple, Carrot, Banana rather than A, B, C).
Any thoughts? | ```
from operator import itemgetter
MY_SORTED_TUPLE = tuple(sorted(MY_TUPLE, key=itemgetter(1)))
```
or without `itemgetter`:
```
MY_SORTED_TUPLE = tuple(sorted(MY_TUPLE, key=lambda item: item[1]))
``` |
222,755 | <p>I am using Java Struts, sending it to user using the following codes</p>
<pre><code>response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + fileFullName);
</code></pre>
<p>Firstly I hope that this is the correct place for my question... :) I hope
tha... | [
{
"answer_id": 222781,
"author": "jakber",
"author_id": 29812,
"author_profile": "https://Stackoverflow.com/users/29812",
"pm_score": 1,
"selected": false,
"text": "<p>Check Tools - Internet Options - General Tab - Temporary Internet files - Settings... - And check that you have enough s... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25368/"
] | I am using Java Struts, sending it to user using the following codes
```
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + fileFullName);
```
Firstly I hope that this is the correct place for my question... :) I hope
that you can help me.
The er... | Check Tools - Internet Options - General Tab - Temporary Internet files - Settings... - And check that you have enough space allocated to hold the csv file and that the path looks like the one you posted. |
222,756 | <p>Background:
I'm working on a silverlight (1.0) application that dynamically builds a map of the United States with icons and text overlayed at specific locations. The map works great in the browser and now I need to get a static (printable and insertable into documents/powerpoints) copy of a displayed map.</p>
<p>O... | [
{
"answer_id": 224492,
"author": "Donnelle",
"author_id": 28074,
"author_profile": "https://Stackoverflow.com/users/28074",
"pm_score": 5,
"selected": true,
"text": "<p>This should be enough to get you started:</p>\n\n<pre><code>\nprivate void ExportCanvas(int width, int height)\n{\n ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Background:
I'm working on a silverlight (1.0) application that dynamically builds a map of the United States with icons and text overlayed at specific locations. The map works great in the browser and now I need to get a static (printable and insertable into documents/powerpoints) copy of a displayed map.
Objective:
... | This should be enough to get you started:
```
private void ExportCanvas(int width, int height)
{
string path = @"c:\temp\Test.tif";
FileStream fs = new FileStream(path, FileMode.Create);
RenderTargetBitmap renderBitmap = new RenderTargetBitmap(width,
... |
222,772 | <p>I wanted to compare the datetime which is in this format "7/20/2008" with the ones in the database which is in format "7/20/2008 7:14:53 AM".</p>
<p>I tried using "like" clause but it did not work beacuse the "like" clause uses only string and the one which I am using is date time format.</p>
<p>Can anyone tell ho... | [
{
"answer_id": 222857,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 1,
"selected": false,
"text": "<p>Although I cannot test your exact problem, I was able to compare dates with the following code.</p>\n\n<pre><code> //... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wanted to compare the datetime which is in this format "7/20/2008" with the ones in the database which is in format "7/20/2008 7:14:53 AM".
I tried using "like" clause but it did not work beacuse the "like" clause uses only string and the one which I am using is date time format.
Can anyone tell how to convert and ... | I assume you're having a problem because `date1` contains a date only, while your database contains full date/time values. To find matches you need to pick one of these approaches:
1) Remove the time information from the database values before comparing them to your target
2) Convert your target into a range, then fin... |
222,778 | <p>I have an annoying problem which I might be able to somehow circumvent, but on the other hand would much rather be on top of it and understand what exactly is going on, since it looks like this stuff is really here to stay.</p>
<p>Here's the story: I have a simple OpenGL app which works fine: never a major problem ... | [
{
"answer_id": 222795,
"author": "Reunanen",
"author_id": 19254,
"author_profile": "https://Stackoverflow.com/users/19254",
"pm_score": 0,
"selected": false,
"text": "<p>Now this got even a bit more interesting... If I just add this somewhere in the source:</p>\n\n<pre><code>boost::posix... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19254/"
] | I have an annoying problem which I might be able to somehow circumvent, but on the other hand would much rather be on top of it and understand what exactly is going on, since it looks like this stuff is really here to stay.
Here's the story: I have a simple OpenGL app which works fine: never a major problem in compili... | Boost.Thread has quite a few possible build combinations in order to try and cater for all the differences in linking scenarios possible with MSVC. Firstly, you can either link statically to Boost.Thread, or link to Boost.Thread in a separate DLL. You can then link to the DLL version of the MSVC runtime, or the static ... |
222,783 | <p>What is the simplest way to get: <code>http://www.[Domain].com</code> in asp.net?</p>
<p>There doesn't seem to be one method which can do this, the only way I know is to do some string acrobatics on server variables or Request.Url. Anyone?</p>
| [
{
"answer_id": 222812,
"author": "SaaS Developer",
"author_id": 7215,
"author_profile": "https://Stackoverflow.com/users/7215",
"pm_score": 1,
"selected": false,
"text": "<pre><code>System.Web.UI.Page.Request.Url\n</code></pre>\n"
},
{
"answer_id": 222822,
"author": "Steven A... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25809/"
] | What is the simplest way to get: `http://www.[Domain].com` in asp.net?
There doesn't seem to be one method which can do this, the only way I know is to do some string acrobatics on server variables or Request.Url. Anyone? | You can do it like this:
```
string.Format("{0}://{1}:{2}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
```
And you'll get the [generic URI syntax](http://www.faqs.org/rfcs/rfc2396.html) <protocol>://<host>:<port> |
222,790 | <p>I have a simple interface:</p>
<pre><code>public interface IVisitorsLogController
{
List<VisitorsLog> GetVisitorsLog();
int GetUniqueSubscribersCount();
int GetVisitorsCount();
string GetVisitorsSummary();
}
</code></pre>
<p>the class VisitorsLogController implements this interface.</p>
<p... | [
{
"answer_id": 222816,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>I would start by checking the namespaces on each of the files involved and make sure that you don't have a conf... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30046/"
] | I have a simple interface:
```
public interface IVisitorsLogController
{
List<VisitorsLog> GetVisitorsLog();
int GetUniqueSubscribersCount();
int GetVisitorsCount();
string GetVisitorsSummary();
}
```
the class VisitorsLogController implements this interface.
From a console application or a TestFi... | It would seem the other important bit of code would be VisitorsLogController, wouldn't it? It looks like VisitorsLogController is implementing a *different* IVistorsLogController interface.
Right clicking and GoTo Definition should clear things up, I think. |
222,792 | <p>How can <strong><code>REVOKE</code></strong> operations on a table be audited in Oracle? Grants can be audited with...</p>
<pre><code>AUDIT GRANT ON *schema.table*;
</code></pre>
<p>Both grants and revokes on system privileges and rolls can be audited with...</p>
<pre><code>AUDIT SYSTEM GRANT;
</code></pre>
<p>... | [
{
"answer_id": 222798,
"author": "Leigh Riffel",
"author_id": 27010,
"author_profile": "https://Stackoverflow.com/users/27010",
"pm_score": 0,
"selected": false,
"text": "<p>This can't be done.</p>\n"
},
{
"answer_id": 250665,
"author": "Leigh Riffel",
"author_id": 27010,... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27010/"
] | How can **`REVOKE`** operations on a table be audited in Oracle? Grants can be audited with...
```
AUDIT GRANT ON *schema.table*;
```
Both grants and revokes on system privileges and rolls can be audited with...
```
AUDIT SYSTEM GRANT;
```
Neither of these statements will audit object level revokes. My database i... | According to Oracle Support all revokes can be audited by doing the following:
1. Set the parameter `audit_sys_operations` to `true`.
2. Set the parameter `audit_trail` to `db_extended`.
3. Run audit grant table;
This covers both GRANT and REVOKE privileges ON tables views and materialized views. |
222,825 | <p>How do you retain the indentation of numbered lists? I have a page where the numbers are pushed off the page. How can I prevent this?</p>
<pre><code><ol style="padding: 0">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</code></pre>
| [
{
"answer_id": 222923,
"author": "savetheclocktower",
"author_id": 25720,
"author_profile": "https://Stackoverflow.com/users/25720",
"pm_score": 3,
"selected": true,
"text": "<p>With a CSS rule like this:</p>\n\n<pre><code>ol { margin-left: 30px; }\n</code></pre>\n\n<p>Here's some inform... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30043/"
] | How do you retain the indentation of numbered lists? I have a page where the numbers are pushed off the page. How can I prevent this?
```
<ol style="padding: 0">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
``` | With a CSS rule like this:
```
ol { margin-left: 30px; }
```
Here's some information about the [CSS box model](http://redmelon.net/tstme/box_model/). |
222,826 | <p>I have a canvas inside a scrollview. I attached a keydown event handler to the scrollview. For most keys, the handler gets called. </p>
<p>However, for the arrow keys, the handler does not get called. Instead, the scrollview gets scrolled in the appropriate direction.</p>
<p>I also attached a keyup handler to the ... | [
{
"answer_id": 223323,
"author": "Mike Blandford",
"author_id": 28643,
"author_profile": "https://Stackoverflow.com/users/28643",
"pm_score": 2,
"selected": true,
"text": "<p>I found this silly hack to make it work. Setting the scrollview to not be a tabstop keeps it from eating the key ... | 2008/10/21 | [
"https://Stackoverflow.com/questions/222826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28643/"
] | I have a canvas inside a scrollview. I attached a keydown event handler to the scrollview. For most keys, the handler gets called.
However, for the arrow keys, the handler does not get called. Instead, the scrollview gets scrolled in the appropriate direction.
I also attached a keyup handler to the scrollview and th... | I found this silly hack to make it work. Setting the scrollview to not be a tabstop keeps it from eating the key events.. but then I had another textbox on the page that all of a sudden ALWAYS had focus because the scrollview didn't anymore. So I fixed that by letting an invisible textbox get focus.
```
scrollView.IsT... |