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 |
|---|---|---|---|---|---|---|
516,946 | <p>I've got a legacy application which is implemented in a number of Excel workbooks. It's not something that I have the authority to re-implement, however another application that I do maintain does need to be able to call functions in the Excel workbook. </p>
<p>It's been given a python interface using the Win32Com ... | [
{
"answer_id": 516983,
"author": "Toby Allen",
"author_id": 6244,
"author_profile": "https://Stackoverflow.com/users/6244",
"pm_score": 0,
"selected": false,
"text": "<p>If you application uses a single excel file which contains macros which you call, I fear the answer is probably no sin... | 2009/02/05 | [
"https://Stackoverflow.com/questions/516946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] | I've got a legacy application which is implemented in a number of Excel workbooks. It's not something that I have the authority to re-implement, however another application that I do maintain does need to be able to call functions in the Excel workbook.
It's been given a python interface using the Win32Com library. O... | I don't know a thing about Python, unfortunately, but if it works through COM, Excel is not a Single-Instance application, so you should be able to create as many instances of Excel as memory permits.
Using C# you can create multiple Excel Application instances via:
```
Excel.Application xlApp1 = new Excel.Applicatio... |
516,951 | <p>I'm writing a bookmarklet, i.e. a bookmark that contains javascript instead of a URL, and I have some trouble. In fact, I cannot remember how I can get the content of the page as a string, so I can apply a regular expression to find what I want. Can you please help me on this?</p>
<p>Before anyone suggests it, I c... | [
{
"answer_id": 516966,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "<p>You can access it through:</p>\n\n<pre><code>document.body.innerHTML\n</code></pre>\n"
},
{
"answer_i... | 2009/02/05 | [
"https://Stackoverflow.com/questions/516951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29568/"
] | I'm writing a bookmarklet, i.e. a bookmark that contains javascript instead of a URL, and I have some trouble. In fact, I cannot remember how I can get the content of the page as a string, so I can apply a regular expression to find what I want. Can you please help me on this?
Before anyone suggests it, I cannot use g... | You can access it through:
```
document.body.innerHTML
``` |
516,978 | <p>I have a SOAP object that I want to capture as a string. This is what I have now:</p>
<pre><code>RateRequest request = new RateRequest();
//Do some stuff to request here
SoapFormatter soapFormat = new SoapFormatter();
using (MemoryStream myStream = new MemoryStream())
{
soapFormat.Serialize(myStream, request);
... | [
{
"answer_id": 516966,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "<p>You can access it through:</p>\n\n<pre><code>document.body.innerHTML\n</code></pre>\n"
},
{
"answer_i... | 2009/02/05 | [
"https://Stackoverflow.com/questions/516978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610/"
] | I have a SOAP object that I want to capture as a string. This is what I have now:
```
RateRequest request = new RateRequest();
//Do some stuff to request here
SoapFormatter soapFormat = new SoapFormatter();
using (MemoryStream myStream = new MemoryStream())
{
soapFormat.Serialize(myStream, request);
myStream.Posi... | You can access it through:
```
document.body.innerHTML
``` |
516,992 | <p>I have an IIS7 web application which primarily serves web service requests. As part of our solution we have two web servers and a load balancer, and the load balancer requests a page from each of its load balanced boxes periodically. The page the load balancer loads is named "Health.aspx", it does <em>not</em> hav... | [
{
"answer_id": 521190,
"author": "ajma",
"author_id": 60117,
"author_profile": "https://Stackoverflow.com/users/60117",
"pm_score": 1,
"selected": false,
"text": "<p>You should create Health.html and just use that instead. That will also give you some idea of whether it's ASP.NET giving ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/516992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645/"
] | I have an IIS7 web application which primarily serves web service requests. As part of our solution we have two web servers and a load balancer, and the load balancer requests a page from each of its load balanced boxes periodically. The page the load balancer loads is named "Health.aspx", it does *not* have a code beh... | Turns out that the problem was just the sheer number of requests and an untimely response time (or really *request* time - our client connections are very slow) for handling the requests. Requests for Health.aspx were getting caught up with slow client connections and the default `MaxConcurrentRequestsPerCPU` of 12 was... |
516,995 | <p>Given a .NET DLL that consists of a class "Place" and a function "Where" that returns an integer; I need to load the dll into an application domain, execute the function and unload the application domain.</p>
<pre><code>
Dim domain As AppDomain = AppDomain.CreateDomain("Executor")
Dim buffer() As Byte =... | [
{
"answer_id": 517606,
"author": "Renze de Waal",
"author_id": 58276,
"author_profile": "https://Stackoverflow.com/users/58276",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to know what dependency could not be loaded, try using fuslogvw. Check <a href=\"http://msdn.microsof... | 2009/02/05 | [
"https://Stackoverflow.com/questions/516995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62572/"
] | Given a .NET DLL that consists of a class "Place" and a function "Where" that returns an integer; I need to load the dll into an application domain, execute the function and unload the application domain.
```
Dim domain As AppDomain = AppDomain.CreateDomain("Executor")
Dim buffer() As Byte = IO.File.ReadA... | You are correct in stating that the error is due to a missing reference. The reference most likely can't be resolved because of how you are loading the assembly. Since you are loading from a Byte Array, the Assembly.Location will not point to the location of the dll. Since the dll you are referencing is not in the GAC,... |
517,000 | <p>This is a pretty basic question, but here goes:</p>
<p>I have an array of VARCHAR2 strings in PL/SQL.</p>
<p>How can I print every element in that array?</p>
| [
{
"answer_id": 525467,
"author": "darreljnz",
"author_id": 10538,
"author_profile": "https://Stackoverflow.com/users/10538",
"pm_score": 4,
"selected": true,
"text": "<pre><code>for i in my_array.first..my_array.last loop\n --print me\nend loop;\n</code></pre>\n"
},
{
"answer_id... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | This is a pretty basic question, but here goes:
I have an array of VARCHAR2 strings in PL/SQL.
How can I print every element in that array? | ```
for i in my_array.first..my_array.last loop
--print me
end loop;
``` |
517,002 | <p>I want to hide the selected item from the opened WPF combo box, basically to show instead of this:</p>
<pre><code>item2
item1
item2
item3
</code></pre>
<p>this:</p>
<pre><code>item2
item1
item3
</code></pre>
<p>How can this be done?</p>
| [
{
"answer_id": 517571,
"author": "Jeno Csupor",
"author_id": 6176,
"author_profile": "https://Stackoverflow.com/users/6176",
"pm_score": 0,
"selected": false,
"text": "<p>Found a hack for this, putting a label on top of the combo box:<p>\nWindow1.xaml:</p>\n\n<pre><code><Window x:Clas... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6176/"
] | I want to hide the selected item from the opened WPF combo box, basically to show instead of this:
```
item2
item1
item2
item3
```
this:
```
item2
item1
item3
```
How can this be done? | Why don't you change the selected item's visibility instead? |
517,006 | <p>I always read that it is recommended to set objects to nothing, once I am done with them. But I normally use them only in functions inside forms.</p>
<p>Isn't the reference lost and memory released when the function scope is left, regardless of setting objects to Nothing? </p>
<p>i.e. is it really necessary to do:... | [
{
"answer_id": 517046,
"author": "John Mo",
"author_id": 38988,
"author_profile": "https://Stackoverflow.com/users/38988",
"pm_score": 2,
"selected": false,
"text": "<p>References are supposed to be cleaned up when the variable goes out of scope. Presumably this has improved with later v... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57684/"
] | I always read that it is recommended to set objects to nothing, once I am done with them. But I normally use them only in functions inside forms.
Isn't the reference lost and memory released when the function scope is left, regardless of setting objects to Nothing?
i.e. is it really necessary to do:
```
Set db = No... | VB uses a so-called "reference counting" garbage collector.
Basically, the moment a variable goes out of scope, the reference counter on the referenced object is decremented. When you assign the object reference to another variable, the reference counter is incremented.
When the counter reaches zero, the object is re... |
517,008 | <p>I want to turn off PHP's magic quotes. I don't have access to php.ini.</p>
<p>When I tried to add <code>php_flag magic_quotes_gpc off</code> to my .htaccess file, I get a 500 internal server error. This is what my .htaccess file looks like:</p>
<pre><code>AddType x-mapp-php5 .php
php_flag magic_quotes_gpc off
</c... | [
{
"answer_id": 517023,
"author": "Philip Morton",
"author_id": 21709,
"author_profile": "https://Stackoverflow.com/users/21709",
"pm_score": 0,
"selected": false,
"text": "<p>Different hosting providers have different procedures for doing this, so I would ask on their forums or file a su... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27305/"
] | I want to turn off PHP's magic quotes. I don't have access to php.ini.
When I tried to add `php_flag magic_quotes_gpc off` to my .htaccess file, I get a 500 internal server error. This is what my .htaccess file looks like:
```
AddType x-mapp-php5 .php
php_flag magic_quotes_gpc off
```
Then I tried to use `ini_set('... | As per [the manual](http://php.net/manual/security.magicquotes.disabling.php#82777) you can often install a custom php.ini on shared hosting, where mod\_php isn't used and the `php_value` directive thus leads to an error. For suexec/FastCGI setups it is quite common to have a per-webspace `php.ini` in any case.
--
I ... |
517,020 | <p>I need a tool which tells the classname of the UI control on which my mouse pointer is. My GUI is in Swing. Does such a tool exist? </p>
| [
{
"answer_id": 517051,
"author": "iny",
"author_id": 27067,
"author_profile": "https://Stackoverflow.com/users/27067",
"pm_score": 0,
"selected": false,
"text": "<p>It should be possible to write a mouse listener doing such thing.</p>\n"
},
{
"answer_id": 517099,
"author": "L... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56297/"
] | I need a tool which tells the classname of the UI control on which my mouse pointer is. My GUI is in Swing. Does such a tool exist? | You can get the current location of the mouse pointer by doing:
```
Point location = MousePointer.getPointerInfo().getLocation();
```
Once you have the location, you can convert it to your parent containers coordinate system by doing:
```
Point relativeLocation = SwingUtilities.convertPointFromScreen(location, pare... |
517,028 | <p>[Update: Using SQL Server 2005]</p>
<p>Hi, what I want to do is query my stored procedure with a comma-delimited list of values (ids) to retrieve rows of data. </p>
<p>The problem I am receiving is a conversion error:</p>
<pre><code>Conversion failed when converting the varchar value ' +
@PassedInIDs + ' to data... | [
{
"answer_id": 517120,
"author": "david.mchonechase",
"author_id": 387154,
"author_profile": "https://Stackoverflow.com/users/387154",
"pm_score": 0,
"selected": false,
"text": "<p>You need to treat ufn_CSVToTable like it's a table. So you can join the function:</p>\n\n<pre><code>JOIN uf... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55057/"
] | [Update: Using SQL Server 2005]
Hi, what I want to do is query my stored procedure with a comma-delimited list of values (ids) to retrieve rows of data.
The problem I am receiving is a conversion error:
```
Conversion failed when converting the varchar value ' +
@PassedInIDs + ' to data type int.
```
The statemen... | I would strongly suggest that you use the second method from that link. Create a user-defined function that turns your comma-delimited string into a table, which you can then select from easily.
If you do a Google on Erland and "Dynamic SQL" he has a good writeup of the pitfalls that it entails. |
517,036 | <p>I want to read some Excel files and convert to my own Excel template. I want to read B column every line (B1,B2,B3... going like this).</p>
<p>If there is a number in this column; in B3 there is number like "1,2,3,4,5,6,7,8,9" then I'll get this whole line and take it to an array[i]. If there is "5" number in B4 th... | [
{
"answer_id": 519392,
"author": "lakshmanaraj",
"author_id": 44541,
"author_profile": "https://Stackoverflow.com/users/44541",
"pm_score": 0,
"selected": false,
"text": "<p>Please look at </p>\n\n<p><a href=\"http://support.microsoft.com/kb/306572\" rel=\"nofollow noreferrer\">http://su... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50985/"
] | I want to read some Excel files and convert to my own Excel template. I want to read B column every line (B1,B2,B3... going like this).
If there is a number in this column; in B3 there is number like "1,2,3,4,5,6,7,8,9" then I'll get this whole line and take it to an array[i]. If there is "5" number in B4 then it'll g... | 1. [Download](http://www.microsoft.com/downloads/details.aspx?FamilyID=c41bd61e-3060-4f71-a6b4-01feba508e52&displaylang=en) and install Office 2003 Primary Interop Assemblies on your computer
2. Create a Visual studio Project and add a reference to 'Microsoft.Office.Interop.Excel.dll' from the GAC.
3. Now you can write... |
517,045 | <p>Here's the proxy method that was created for the web service I'm trying to access. How would I go about modifying it to get the raw XML from the web service call?</p>
<pre><code> /// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("CallOptionsValue")]
[System.Web.Services.Protocol... | [
{
"answer_id": 518029,
"author": "marc_s",
"author_id": 13302,
"author_profile": "https://Stackoverflow.com/users/13302",
"pm_score": 0,
"selected": false,
"text": "<p>Well, as far as I remember, a buddy of mine that this once with regular ASMX webservices, and it was quite a hack....</p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401165/"
] | Here's the proxy method that was created for the web service I'm trying to access. How would I go about modifying it to get the raw XML from the web service call?
```
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("CallOptionsValue")]
[System.Web.Services.Protocols.SoapHeaderAttribut... | Fortunately there is a nice way to do it, just modify the generated proxy class so it inherits from different base. The alternative implementation comes from Web Services Enhancements 3.0 pack:
[Microsoft.Web.Services3.WebServicesClientProtocol](http://www.microsoft.com/downloads/details.aspx?familyid=018a09fd-3a74-43... |
517,049 | <p>If I set a Friend-level scope on a setter, like this...</p>
<pre><code>Public Class MyClass
Public Property IsDirty() As Boolean
Get
Return _isDirty
End Get
Friend Set(ByVal trueFalse As Boolean)
_isDirty = trueFalse
End Set
End Property
End Class
</c... | [
{
"answer_id": 518029,
"author": "marc_s",
"author_id": 13302,
"author_profile": "https://Stackoverflow.com/users/13302",
"pm_score": 0,
"selected": false,
"text": "<p>Well, as far as I remember, a buddy of mine that this once with regular ASMX webservices, and it was quite a hack....</p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16082/"
] | If I set a Friend-level scope on a setter, like this...
```
Public Class MyClass
Public Property IsDirty() As Boolean
Get
Return _isDirty
End Get
Friend Set(ByVal trueFalse As Boolean)
_isDirty = trueFalse
End Set
End Property
End Class
```
...And then... | Fortunately there is a nice way to do it, just modify the generated proxy class so it inherits from different base. The alternative implementation comes from Web Services Enhancements 3.0 pack:
[Microsoft.Web.Services3.WebServicesClientProtocol](http://www.microsoft.com/downloads/details.aspx?familyid=018a09fd-3a74-43... |
517,058 | <p>So here is my problem.</p>
<ul>
<li>My (test) project references both Castle Windsor and Rhino Mocks. </li>
<li>I am creating a class which implements Castle.Core.Interceptor.IInterceptor from the Castle.Core.dll assembly</li>
<li>In building Rhino Mocks, Ayende used Castle.Core.Interceptor and includes the whole d... | [
{
"answer_id": 517075,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 3,
"selected": false,
"text": "<p>You can use an <a href=\"https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias\"... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | So here is my problem.
* My (test) project references both Castle Windsor and Rhino Mocks.
* I am creating a class which implements Castle.Core.Interceptor.IInterceptor from the Castle.Core.dll assembly
* In building Rhino Mocks, Ayende used Castle.Core.Interceptor and includes the whole darn namespace inside the Rhin... | Let's throw the specific answer up here in case someone comes along later.
From article [here](http://blogs.msdn.com/ansonh/archive/2006/09/27/774692.aspx).
* Select one of the two assemblies under project references (in my case I selected Castle.Core). Hit F4 to bring up properties and enter alias CastleCore
* At the... |
517,060 | <p>I found the following behavior at least <em>weird</em>:</p>
<pre><code>def errors():
try:
ErrorErrorError
finally:
return 10
print errors()
# prints: 10
# It should raise: NameError: name 'ErrorErrorError' is not defined
</code></pre>
<p>The exception disappears when you use <code>return</... | [
{
"answer_id": 517080,
"author": "Max Schmeling",
"author_id": 3226,
"author_profile": "https://Stackoverflow.com/users/3226",
"pm_score": 2,
"selected": false,
"text": "<p>Returning from a finally is <strong>not</strong> a good idea. I know C# specifically forbids doing this.</p>\n"
}... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17160/"
] | I found the following behavior at least *weird*:
```
def errors():
try:
ErrorErrorError
finally:
return 10
print errors()
# prints: 10
# It should raise: NameError: name 'ErrorErrorError' is not defined
```
The exception disappears when you use `return` inside a `finally` clause. Is that a b... | You asked about the Python developers' reasoning. I can't speak for them, but no other behavior makes sense. A function can either return a value, or it can raise an exception; it can't do both. The purpose of a "finally" clause is to provide cleanup code that is "guaranteed" to be run, regardless of exceptions. By put... |
517,064 | <p>I'm de/serializing an object like so:</p>
<pre><code>public class myClass : ISerializable
{
public List<OType> value;
public myClass(SerializationInfo info, StreamingContext context)
{
this.value = (List<OType>)info.GetValue("value", typeof(List<OType>));
}
void ISerializable.GetOb... | [
{
"answer_id": 517101,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 3,
"selected": true,
"text": "<p>Well the list is always empty to begin with, are you setting it via <code>myClass.value = new List<...>()... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48553/"
] | I'm de/serializing an object like so:
```
public class myClass : ISerializable
{
public List<OType> value;
public myClass(SerializationInfo info, StreamingContext context)
{
this.value = (List<OType>)info.GetValue("value", typeof(List<OType>));
}
void ISerializable.GetObjectData(SerializationInfo info,... | Well the list is always empty to begin with, are you setting it via `myClass.value = new List<...>();` ? Also have you saved the serialized data in both binary and xml formats so you can verify data is actually being saved?
Just a note as well, if you are using 2.0+ you don't have to implement ISerializable if you don... |
517,083 | <p>trying to add an ExpiresDefault ExpiresByType to content on my website so that way it is cached. I use cachebusting in the URL (a revision number in the path) for Javascript, CSS, and images so that way I can set it to forever for these mimetypes. I have the following rules set up in apache httpd:</p>
<pre><code> ... | [
{
"answer_id": 517109,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>Your javascript files are being sent out as <code>application/x-javascript</code>, so aren't getting a far-future Expires h... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66475/"
] | trying to add an ExpiresDefault ExpiresByType to content on my website so that way it is cached. I use cachebusting in the URL (a revision number in the path) for Javascript, CSS, and images so that way I can set it to forever for these mimetypes. I have the following rules set up in apache httpd:
```
ExpiresActive ... | Your javascript files are being sent out as `application/x-javascript`, so aren't getting a far-future Expires header. |
517,095 | <p>I have a textbox in my SSRS 2005 report. The expresssion for this textbox is:</p>
<pre><code>=IIF(IsDBNull(Fields!fOrgID), Code.SetMyVar("null"), Code.SetMyVar(Fields!fOrgID.Value))
</code></pre>
<p>I have also tried <code>IsNothing(Fields!fOrgID)</code> and a few other variations of checking for <code>nulls</code... | [
{
"answer_id": 517176,
"author": "AaronSieb",
"author_id": 16911,
"author_profile": "https://Stackoverflow.com/users/16911",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you're right about about Iif always evaluating both of its value arguments (at least, it does in Visual Bas... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1457761/"
] | I have a textbox in my SSRS 2005 report. The expresssion for this textbox is:
```
=IIF(IsDBNull(Fields!fOrgID), Code.SetMyVar("null"), Code.SetMyVar(Fields!fOrgID.Value))
```
I have also tried `IsNothing(Fields!fOrgID)` and a few other variations of checking for `nulls`.
I have modified the `SetMyVar` function for ... | From the sound of things, it seems likely that the issue is that SSRS is having a problem displaying zero records. I'd recommend one of the following:
1) Use a control that handles zero records appropriately (Tables do. I think Lists do as well).
2) Modify your query to return a single record with blank values if it ... |
517,107 | <p>I was going through a few queries I am maintaining, and a programmer had put in the queries "where 1=1" to me that always seems to evaluate to true.</p>
<p>Are there benefits to this?</p>
<p><strong>Duplicate:</strong> <a href="https://stackoverflow.com/questions/242822/why-would-someone-use-where-11-and-conditio... | [
{
"answer_id": 517115,
"author": "Tundey",
"author_id": 1453,
"author_profile": "https://Stackoverflow.com/users/1453",
"pm_score": 6,
"selected": true,
"text": "<p>Was it dynamic queries? Sometimes that's helpful when building dynamic queries based on parameters that are optional.</p>\n... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48943/"
] | I was going through a few queries I am maintaining, and a programmer had put in the queries "where 1=1" to me that always seems to evaluate to true.
Are there benefits to this?
**Duplicate:** [Why would someone use WHERE 1=1 AND in a SQL clause?](https://stackoverflow.com/questions/242822/why-would-someone-use-where-... | Was it dynamic queries? Sometimes that's helpful when building dynamic queries based on parameters that are optional. |
517,113 | <p>I am trying to build a Lisp grammar. Easy, right? Apparently not.</p>
<p>I present these inputs and receive errors...</p>
<pre><code>( 1 1)
23 23 23
ui ui
</code></pre>
<p>This is the grammar...</p>
<pre><code>%%
sexpr: atom {printf("matched sexpr\n");}
| list
;
list: '(' members ')' ... | [
{
"answer_id": 517236,
"author": "Beardo",
"author_id": 33724,
"author_profile": "https://Stackoverflow.com/users/33724",
"pm_score": 2,
"selected": false,
"text": "<p>You are correct in that you need to define a non-terminal. That would be defined as a set of sexpr. I'm not sure of the ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | I am trying to build a Lisp grammar. Easy, right? Apparently not.
I present these inputs and receive errors...
```
( 1 1)
23 23 23
ui ui
```
This is the grammar...
```
%%
sexpr: atom {printf("matched sexpr\n");}
| list
;
list: '(' members ')' {printf("matched list\n");}
| '('')' ... | The error is really in the lexer. Your parentheses end up as the last "." in the lexer, and don't show up as parentheses in the parser.
Add rules like
```
\) { return RPAREN; }
\( { return LPAREN; }
```
to the lexer and change all occurences of '(', ')' to LPAREN and RPAREN respectively in the parser. (also... |
517,125 | <p>I'm sort of a biztalk newbie and we run 2006 here with plans to migrate to 2006 R2 in the future. I have a schema that I need to work with called Siri, which is public at:</p>
<p><s><a href="http://www.kizoom.com/standards/siri/schema/1.0/siri-1.0.zip" rel="nofollow noreferrer">link text</a></s> or <s><a href="http... | [
{
"answer_id": 517236,
"author": "Beardo",
"author_id": 33724,
"author_profile": "https://Stackoverflow.com/users/33724",
"pm_score": 2,
"selected": false,
"text": "<p>You are correct in that you need to define a non-terminal. That would be defined as a set of sexpr. I'm not sure of the ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm sort of a biztalk newbie and we run 2006 here with plans to migrate to 2006 R2 in the future. I have a schema that I need to work with called Siri, which is public at:
~~[link text](http://www.kizoom.com/standards/siri/schema/1.0/siri-1.0.zip)~~ or ~~[link text](http://www.kizoom.com/standards/siri/schema/1.0/siri... | The error is really in the lexer. Your parentheses end up as the last "." in the lexer, and don't show up as parentheses in the parser.
Add rules like
```
\) { return RPAREN; }
\( { return LPAREN; }
```
to the lexer and change all occurences of '(', ')' to LPAREN and RPAREN respectively in the parser. (also... |
517,127 | <p>I am new to python and am writing some scripts to automate downloading files from FTP servers, etc. I want to show the progress of the download, but I want it to stay in the same position, such as:</p>
<p>output:</p>
<blockquote>
<p>Downloading File FooFile.txt [47%]</p>
</blockquote>
<p>I'm trying to avoid som... | [
{
"answer_id": 517148,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 4,
"selected": false,
"text": "<p>Print the backspace character <code>\\b</code> several times, and then overwrite the old number with the new numb... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53007/"
] | I am new to python and am writing some scripts to automate downloading files from FTP servers, etc. I want to show the progress of the download, but I want it to stay in the same position, such as:
output:
>
> Downloading File FooFile.txt [47%]
>
>
>
I'm trying to avoid something like this:
```
Downloading... | You can also use the carriage return:
```
sys.stdout.write("Download progress: %d%% \r" % (progress) )
sys.stdout.flush()
``` |
517,137 | <p>I am working on a proof of concept that makes use of the jquery ui draggable/droppable.</p>
<p>I am looking for a way to set a variable equal to the index of a div that is dropped into the droppable area. (Say I have divs named "div0", "div1", "div2", etc...)</p>
<p>So imagine the code would look something like th... | [
{
"answer_id": 517173,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to parse the id of the div by using </p>\n\n<pre><code>$.droppedItems = {};\n\nvar droppedId = $(th... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62983/"
] | I am working on a proof of concept that makes use of the jquery ui draggable/droppable.
I am looking for a way to set a variable equal to the index of a div that is dropped into the droppable area. (Say I have divs named "div0", "div1", "div2", etc...)
So imagine the code would look something like this:
```
<div id=... | ```
<div id="div0" class="draggableDiv">some cotent</div>
<div id="div1" class="draggableDiv">more content</div>
<div id="div2" class="draggableDiv">yet more content</div>
<div id='dropplace' class="droppableDiv">drop it here</div>
<script language='javascript'>
$(document).ready(function() {
$('.draggableDiv').... |
517,145 | <p>What is the best way of searching XML documents using XPath in Delphi7?</p>
| [
{
"answer_id": 517286,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 4,
"selected": true,
"text": "<p>It depends on the size of the xml document. But I have good experience with both MSXML and its Saxon counterpart.</... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | What is the best way of searching XML documents using XPath in Delphi7? | It depends on the size of the xml document. But I have good experience with both MSXML and its Saxon counterpart.
If the xml is large (>50 MB) or the queries are heavy (use some // to make your system crawl) expect some delay time. But else it is perfectly doable.
In later versions, msxml is available as a unit. In ... |
517,152 | <p>I am working on a product that runs an SQL server which allows some applications to login and their logins are granted permission to run a stored procedure- AND NOTHING ELSE. The stored procedure is owned by an admin; the stored procedure takes a query and executes it, then the results are returned to the applicati... | [
{
"answer_id": 517170,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 2,
"selected": false,
"text": "<p>Users also need to have SELECT grant on the tables </p>\n"
},
{
"answer_id": 517185,
"author": "DJ.",
"au... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28760/"
] | I am working on a product that runs an SQL server which allows some applications to login and their logins are granted permission to run a stored procedure- AND NOTHING ELSE. The stored procedure is owned by an admin; the stored procedure takes a query and executes it, then the results are returned to the application.
... | Since you are using dynamic sql, SQL server can't tell which tables you are using, so you have to grant SELECT rights to all the tables as well |
517,201 | <p>Alt A below is a statement from a php-mysql tutorial. It works as it should.<br>
I found the id-value rather obfuscated and tested alt B. This also worked!<br>
What is the point with the id-value of alt A? </p>
<p>MySQL 5.0.51, PHP 5.2.6 </p>
<pre><code>// Alt A :
$sql = "SELECT * FROM example WHERE id = '".$q... | [
{
"answer_id": 517221,
"author": "cbrulak",
"author_id": 29505,
"author_profile": "https://Stackoverflow.com/users/29505",
"pm_score": -1,
"selected": false,
"text": "<p>in 'alt B', $q must be an int or float or other numeric</p>\n\n<p>in 'alt A', $q can be anything a string, int, etc. <... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Alt A below is a statement from a php-mysql tutorial. It works as it should.
I found the id-value rather obfuscated and tested alt B. This also worked!
What is the point with the id-value of alt A?
MySQL 5.0.51, PHP 5.2.6
```
// Alt A :
$sql = "SELECT * FROM example WHERE id = '".$q."'";
// Alt B :
$sql... | This are just two different approaches to building a string from static and variable data.
Alternative A uses concatenation, or the joining of string and variable tokens using the concatenation operator.
Alternative B uses variable expansion, wherein the variables inside a double-quote-delimited string are expanded t... |
517,219 | <p>I need a quick way to find out if a given port is open with Ruby. I currently am fiddling around with this:</p>
<pre><code>require 'socket'
def is_port_open?(ip, port)
begin
TCPSocket.new(ip, port)
rescue Errno::ECONNREFUSED
return false
end
return true
end
</code></pre>
<p>It works great if the p... | [
{
"answer_id": 517638,
"author": "joast",
"author_id": 8674,
"author_profile": "https://Stackoverflow.com/users/8674",
"pm_score": 7,
"selected": true,
"text": "<p>Something like the following might work:</p>\n\n<pre><code>require 'socket'\nrequire 'timeout'\n\ndef is_port_open?(ip, port... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | I need a quick way to find out if a given port is open with Ruby. I currently am fiddling around with this:
```
require 'socket'
def is_port_open?(ip, port)
begin
TCPSocket.new(ip, port)
rescue Errno::ECONNREFUSED
return false
end
return true
end
```
It works great if the port is open, but the downs... | Something like the following might work:
```
require 'socket'
require 'timeout'
def is_port_open?(ip, port)
begin
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
s.close
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
en... |
517,238 | <p>im having trouble with the result of a webservice call. When the result comes in and kicks off the resultHandler function i set a break point so i can examine the result. I can see that there are 0 records in the array collection however i can see content so im assuming that the zero is just referring to the first i... | [
{
"answer_id": 517303,
"author": "Chetan S",
"author_id": 31284,
"author_profile": "https://Stackoverflow.com/users/31284",
"pm_score": 2,
"selected": false,
"text": "<p>If the webservice returns just one element, it will be deserialized as ObjectProxy. You will have to manually convert ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | im having trouble with the result of a webservice call. When the result comes in and kicks off the resultHandler function i set a break point so i can examine the result. I can see that there are 0 records in the array collection however i can see content so im assuming that the zero is just referring to the first inde... | Chetan is right -- the cast operation to ArrayCollection is failing, because the source object is not an ArrayCollection. Try this instead:
```
public function resultHandler(event:ResultEvent):void
{
var ac:ArrayCollection = new ArrayCollection([event.result])
// ...
}
```
The "as" operator will return `null... |
517,279 | <p>Does anyone know how to change the brush for a menu's background? This sounds simple, but I don't see any obvious way to do this. You'd think that the Background property would change it, but it doesn't.</p>
<p>Here's what my menu looks like (notice the default white background):</p>
<p><strong>Example Code:</stro... | [
{
"answer_id": 517325,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>You can't do it without overriding the template for the menu item. Deep inside the template is a control called \"Part_Po... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62998/"
] | Does anyone know how to change the brush for a menu's background? This sounds simple, but I don't see any obvious way to do this. You'd think that the Background property would change it, but it doesn't.
Here's what my menu looks like (notice the default white background):
**Example Code:**
```
<Window x:Class="WpfA... | I'd suggest using a tool called kaxaml for writing styles. It includes several code snippets, a color picker and a nice way to instantly see what changes in the xaml code does. Here is a full menu style for what you are trying to do. Just change the brush colors at the top to suit to your needs.
```
<Page
xmlns="htt... |
517,336 | <p>I am attempting to setup our servers to allow traffic over SSL. I am aware that SSL does not work with Name Virtual Host, but we have all of our Apache servers on virtual machines with dedicated private IPs. We have a primary virtual machine that has mod_proxy setup to route traffic to the appropriate VMs.</p>
<p>Ho... | [
{
"answer_id": 517823,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 5,
"selected": true,
"text": "<p>It sounds like Apache is warning you that you have multiple <code><VirtualHost></code> sections with the same IP a... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62401/"
] | I am attempting to setup our servers to allow traffic over SSL. I am aware that SSL does not work with Name Virtual Host, but we have all of our Apache servers on virtual machines with dedicated private IPs. We have a primary virtual machine that has mod\_proxy setup to route traffic to the appropriate VMs.
However, i... | It sounds like Apache is warning you that you have multiple `<VirtualHost>` sections with the same IP address and port... as far as getting it to work without warnings, I think you would need to use something like Server Name Indication (SNI), a way of identifying the hostname requested as part of the SSL handshake. Ba... |
517,349 | <p>I have a twenty byte hex hash that I would like to store in a django model.
If I use a text field, it's interpreted as unicode and it comes back garbled. </p>
<p>Currently I'm encoding it and decoding it, which really clutters up the code,
because I have to be able to filter by it.</p>
<pre><code>def get_changese... | [
{
"answer_id": 517492,
"author": "Yoni Samlan",
"author_id": 59058,
"author_profile": "https://Stackoverflow.com/users/59058",
"pm_score": 3,
"selected": true,
"text": "<p>I'm assuming if you were writing raw SQL you'd be using a Postgres bytea or a MySQL VARBINARY. There's a <a href=\"h... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62997/"
] | I have a twenty byte hex hash that I would like to store in a django model.
If I use a text field, it's interpreted as unicode and it comes back garbled.
Currently I'm encoding it and decoding it, which really clutters up the code,
because I have to be able to filter by it.
```
def get_changeset(self):
return b... | I'm assuming if you were writing raw SQL you'd be using a Postgres bytea or a MySQL VARBINARY. There's a [ticket with a patch](http://code.djangoproject.com/ticket/2417) (marked "needs testing") that purportedly makes a field like this (Ticket 2417: Support for binary type fields (aka: bytea in postgres and VARBINARY i... |
517,355 | <p>I want to do something like <code>String.Format("[{0}, {1}, {2}]", 1, 2, 3)</code> which returns:</p>
<pre><code>[1, 2, 3]
</code></pre>
<p>How do I do this in Python?</p>
| [
{
"answer_id": 517363,
"author": "JosefAssad",
"author_id": 53936,
"author_profile": "https://Stackoverflow.com/users/53936",
"pm_score": 2,
"selected": false,
"text": "<p>You haven't formulated yourself very commendably, but I'll venture a guess this is what you're looking for:</p>\n\n<... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | I want to do something like `String.Format("[{0}, {1}, {2}]", 1, 2, 3)` which returns:
```
[1, 2, 3]
```
How do I do this in Python? | The previous answers have used % formatting, which is being phased out in Python 3.0+. Assuming you're using Python 2.6+, a more future-proof formatting system is described here:
<http://docs.python.org/library/string.html#formatstrings>
Although there are more advanced features as well, the simplest form ends up loo... |
517,357 | <p>I have a NSArray of UIImageViews that I want to loop over and quickly swap out an "on" and "off" state. I wrote the code to do so in a for loop instead a method that was called when the user tapped a UIButton ( the button's action ). </p>
<p>Here's that loop:</p>
<pre><code>for(int i = 0; i < [Images count]; i+... | [
{
"answer_id": 517375,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Hey Patrick. Have a look at UIImageView's animationImages property, as well as the animationRepeatCount and animationDurati... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51104/"
] | I have a NSArray of UIImageViews that I want to loop over and quickly swap out an "on" and "off" state. I wrote the code to do so in a for loop instead a method that was called when the user tapped a UIButton ( the button's action ).
Here's that loop:
```
for(int i = 0; i < [Images count]; i++) {
if( i > 0 ){
... | You're on the right track with moving the loop to a background thread, but you also need to make sure that you give the main run loop a chance to update the UI. You should be able to replace the direct calls to toggleImageViewOn: and toggleImageViewOff: with something like
```
[self performSelectorOnMainThread:@select... |
517,386 | <p>I'm trying to get the x, y, and state of my mouse in SDL. I tried using the lines</p>
<pre><code>int mstate, mx, my = 0;
mstate, mx, my = SDL_GetCursor().SDL_GetMouseState();
</code></pre>
<p>But it gives me the error</p>
<blockquote>
<p>C:[path]\particletest2\main.cpp|107|error: request for member <code>SDL_Ge... | [
{
"answer_id": 518578,
"author": "Avram",
"author_id": 61883,
"author_profile": "https://Stackoverflow.com/users/61883",
"pm_score": 1,
"selected": false,
"text": "<p>We moved our projects from MSMQ to <a href=\"http://activemq.apache.org/\" rel=\"nofollow noreferrer\">ActiveMQ</a>. its ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62122/"
] | I'm trying to get the x, y, and state of my mouse in SDL. I tried using the lines
```
int mstate, mx, my = 0;
mstate, mx, my = SDL_GetCursor().SDL_GetMouseState();
```
But it gives me the error
>
> C:[path]\particletest2\main.cpp|107|error: request for member `SDL_GetMouseState' in`SDL\_GetCursor()', which is of n... | Rhino Queues from Ayende is exactly what you are looking for, this is the blog post introducing it:
<http://ayende.com/Blog/archive/2008/08/01/Rhino-Queues.aspx>
I think that all of the limitations mentioned in this post have been fixed since then.
From the blog post, what rhino queues is:
* XCopyable, Zero Adminis... |
517,411 | <p>Given a function, I'm trying to find out the names of the nested functions in it (only one level deep).</p>
<p>A simple regex against <code>toString()</code> worked until I started using functions with comments in them. It turns out that some browsers store parts of the raw source while others reconstruct the sourc... | [
{
"answer_id": 517999,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 0,
"selected": false,
"text": "<pre><code><pre>\n<script type=\"text/javascript\">\nfunction someFn() {\n /**\n * Some comment\n ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23501/"
] | Given a function, I'm trying to find out the names of the nested functions in it (only one level deep).
A simple regex against `toString()` worked until I started using functions with comments in them. It turns out that some browsers store parts of the raw source while others reconstruct the source from what's compile... | **Cosmetic changes and bugfix**
The regular expression **must** read `\bfunction\b` to avoid false positives!
Functions defined in blocks (e.g. in the bodies of loops) will be ignored if `nested` does not evaluate to `true`.
```
function tokenize(code) {
var code = code.split(/\\./).join(''),
regex = /\b... |
517,491 | <p>I am developing my stuff in python. In this process I encountered a situation where I have a string called "import django". And I want to validate this string. Which means, I want to check whether the module mentioned('django' in this case) is in the python-path. How can I do it?</p>
| [
{
"answer_id": 517530,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 1,
"selected": false,
"text": "<p>I doub't that it's safe, but it's the most naïve solution:</p>\n\n<pre><code>try:\n exec('import django')\nexce... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45629/"
] | I am developing my stuff in python. In this process I encountered a situation where I have a string called "import django". And I want to validate this string. Which means, I want to check whether the module mentioned('django' in this case) is in the python-path. How can I do it? | My previous answer was wrong -- i didn't think to test my code. This actually works, though: look at the [imp](http://docs.python.org/library/imp.html) module.
To just check for the module's importability in the current sys.path:
```
try:
imp.find_module('django', sys.path)
except ImportError:
print "Boo! no... |
517,505 | <p>[UPDATE: MS SQL Server 2005]</p>
<p>Hi is it possible to select a bunch of values, and then assign a column in the select statement as the primary key?</p>
<pre><code>SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS
</code></pre>
<p>I ask this because I wa... | [
{
"answer_id": 517535,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 3,
"selected": true,
"text": "<p>After populating your dataset, you have to specify the primary key with the DataTable object, not in your sql query.</p>\n\n... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55057/"
] | [UPDATE: MS SQL Server 2005]
Hi is it possible to select a bunch of values, and then assign a column in the select statement as the primary key?
```
SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS
```
I ask this because I want to take advantage of the DataR... | After populating your dataset, you have to specify the primary key with the DataTable object, not in your sql query.
```
myTable.PrimaryKey = new DataColumn[] {
myTable.Columns["SomeColumn"]
};
```
Then you can use the Find() method |
517,519 | <p>I've got a jquery json request and in that json data I want to be able to sort by unique values. so I have </p>
<pre><code>{
"people": [{
"pbid": "626",
"birthDate": "1976-02-06",
"name": 'name'
}, {
"pbid": "648",
"birthDate": "1987-05-22",
"name": 'name'
... | [
{
"answer_id": 517603,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not sure how performant this will be, but basically I'm using an object as a key/value dictionary. I haven't teste... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48067/"
] | I've got a jquery json request and in that json data I want to be able to sort by unique values. so I have
```
{
"people": [{
"pbid": "626",
"birthDate": "1976-02-06",
"name": 'name'
}, {
"pbid": "648",
"birthDate": "1987-05-22",
"name": 'name'
}, .....
`... | I'm not sure how performant this will be, but basically I'm using an object as a key/value dictionary. I haven't tested this, but this should be sorted in the loop.
```
function(data) {
var birthDates = {};
var param = "birthDate"
$.each(data.people, function() {
if (!birthDates[this[param]])
... |
517,522 | <p>In bash, how do I determine what sound card is installed? I'm trying to create a plugin for Rhythmbox, and I'd like to test for this in a configuration script.</p>
<p><strong>Edit:</strong>
On my machine, I needed to use <code>sudo</code> to be able to use <code>lspci</code> and <code>lsmod</code>. @<a href="http... | [
{
"answer_id": 517547,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 3,
"selected": false,
"text": "<pre><code>lspci | grep -i audio\n</code></pre>\n"
},
{
"answer_id": 517549,
"author": "Quassnoi",
"au... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6688/"
] | In bash, how do I determine what sound card is installed? I'm trying to create a plugin for Rhythmbox, and I'd like to test for this in a configuration script.
**Edit:**
On my machine, I needed to use `sudo` to be able to use `lspci` and `lsmod`. @[Quassnoi](https://stackoverflow.com/questions/517522/how-do-i-determin... | ```
cat /proc/asound/cards
``` |
517,527 | <p>I'm some what lost as to why spring isn't enforcing the @Secured("ROLE_USER") on my service interface. My controllers are established using annotations.</p>
<p>An example of my service Interface</p>
<pre><code>public interface MyServiceManager {
@Secured("ROLE_USER")
public void delete(int cid);
@Ro... | [
{
"answer_id": 518802,
"author": "Kent Lai",
"author_id": 2085392,
"author_profile": "https://Stackoverflow.com/users/2085392",
"pm_score": 3,
"selected": false,
"text": "<p>Do you have the statement</p>\n\n<pre><code><global-method-security secured-annotations=\"enabled\" jsr250-an... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] | I'm some what lost as to why spring isn't enforcing the @Secured("ROLE\_USER") on my service interface. My controllers are established using annotations.
An example of my service Interface
```
public interface MyServiceManager {
@Secured("ROLE_USER")
public void delete(int cid);
@RolesAllowed({"ROLE_USE... | Do you have the statement
```
<global-method-security secured-annotations="enabled" jsr250-annotations="enabled" />
```
in the same configuration file as the one you defined the MyServiceManager bean? I had the same problem until I turned on debug for org.springframework, and noticed that spring security was only ... |
517,545 | <p>I've read that the latest version of the Ruby interpreter (YARV) will have substantial performance improvements due to bytecode compilation. My question is has anyone tried running this against JRuby? Any noticable differences in execution on Windows?</p>
<p>This link had some good metrics but most were run on Linu... | [
{
"answer_id": 520452,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>That fib entry is almost 2 years old. JRuby is way faster than that now. Fib is hardly a good benchmark for runtime perfor... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59880/"
] | I've read that the latest version of the Ruby interpreter (YARV) will have substantial performance improvements due to bytecode compilation. My question is has anyone tried running this against JRuby? Any noticable differences in execution on Windows?
This link had some good metrics but most were run on Linux...<http:... | That fib entry is almost 2 years old. JRuby is way faster than that now. Fib is hardly a good benchmark for runtime performance but here are some numbers on my machine (32 bit MBP running SoyLatte (Java 6)):
```
jruby --server bench/bench_fib_recursive.rb
0.661000 0.000000 0.661000 ( 0.661139)
0.346000 0.00... |
517,556 | <p>I want to close a tab in my tab control when the mouse wheel is clicked. How can I capture this event in WPF?</p>
<p>EDIT:
Here's the code:</p>
<pre><code>private void tabMain_MouseDown(object sender, MouseButtonEventArgs e)
{
if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseB... | [
{
"answer_id": 517583,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 5,
"selected": true,
"text": "<p>Mousewheel is actually the MiddleButton, So the condition for Wheel click on a MouseDown event is <strong><em>ChangedBut... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I want to close a tab in my tab control when the mouse wheel is clicked. How can I capture this event in WPF?
EDIT:
Here's the code:
```
private void tabMain_MouseDown(object sender, MouseButtonEventArgs e)
{
if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
{
... | Mousewheel is actually the MiddleButton, So the condition for Wheel click on a MouseDown event is ***ChangedButton == Middle && ButtonState == Pressed*** |
517,557 | <p>I've come across some SQL queries in Oracle that contain '(+)' and I have no idea what that means. Can someone explain its purpose or provide some examples of its use?
Thanks</p>
| [
{
"answer_id": 517567,
"author": "Quassnoi",
"author_id": 55159,
"author_profile": "https://Stackoverflow.com/users/55159",
"pm_score": 7,
"selected": true,
"text": "<p>It's Oracle's synonym for <code>OUTER JOIN</code>.</p>\n\n<pre><code>SELECT *\nFROM a, b\nWHERE b.id(+) = a.id\n</code>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54789/"
] | I've come across some SQL queries in Oracle that contain '(+)' and I have no idea what that means. Can someone explain its purpose or provide some examples of its use?
Thanks | It's Oracle's synonym for `OUTER JOIN`.
```
SELECT *
FROM a, b
WHERE b.id(+) = a.id
```
gives same result as
```
SELECT *
FROM a
LEFT OUTER JOIN b
ON b.id = a.id
``` |
517,562 | <p>I'm trying to dig through some logs and need information before and after the line I can match on. How would I do this in PowerShell ala "grep -C 2"?</p>
<p>In version 1, I can't wait for r2, then I get to put it on production machines :)</p>
| [
{
"answer_id": 517611,
"author": "zdan",
"author_id": 4304,
"author_profile": "https://Stackoverflow.com/users/4304",
"pm_score": 1,
"selected": false,
"text": "<p>Alas, it looks like you will have to build it yourself or wait for the next version of powershell, as <a href=\"http://blogs... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635/"
] | I'm trying to dig through some logs and need information before and after the line I can match on. How would I do this in PowerShell ala "grep -C 2"?
In version 1, I can't wait for r2, then I get to put it on production machines :) | Getting closer here- because Select-String returns MatchInfo objects which I can pull a line number out of (39017), now I just need to pull the line surrounding... so:
```
gc $bigfile | Select-String melissao |
%{(gc $bigfile)[($_.LineNumber -2)..($_.LineNumber +2)]}
```
If anyone could clean this up a bit to make ... |
517,563 | <p>I'm getting these errors while linking, both messages have to do with the same object file.</p>
<pre><code>CALL16 reloc at 0x5f8 not against global symbol
</code></pre>
<p>and</p>
<pre><code>could not read symbols: Bad value
</code></pre>
<p>The 2nd message seems to be the reason I'm getting the CALL16 error, bu... | [
{
"answer_id": 517778,
"author": "INS",
"author_id": 13136,
"author_profile": "https://Stackoverflow.com/users/13136",
"pm_score": 1,
"selected": false,
"text": "<p>Try -mlong-calls flag to the compiler.</p>\n\n<p>Also see the <a href=\"http://linux.die.net/man/1/gcc\" rel=\"nofollow nor... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57377/"
] | I'm getting these errors while linking, both messages have to do with the same object file.
```
CALL16 reloc at 0x5f8 not against global symbol
```
and
```
could not read symbols: Bad value
```
The 2nd message seems to be the reason I'm getting the CALL16 error, but the file compiles just fine.
Any tips on fixin... | Aha!
Thanks to a colleague of mine, we found the issue.
Here was the issue:
There was a forward declaration/prototype of a function.
```
void FooBarIsBest(void);
```
Later on in the file the function was defined.
```
static void FooBarIsBest(void)
{
// do the best
}
```
The issue here was that in the proto... |
517,580 | <p>I'm building my first autoconf managed package.</p>
<p>However I can't find any simple examples anywhere of how to specify a required library, and find that library where it might be in various different places.</p>
<p>I've currently got:</p>
<pre><code>AC_CHECK_LIB(['event'], ['event_init'])
</code></pre>
<p>bu... | [
{
"answer_id": 517884,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 5,
"selected": true,
"text": "<p>You need to manually set <code>CFLAGS</code>, <code>CXXFLAGS</code> and <code>LDFLAGS</code> if you want gcc/g++ to lo... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6782/"
] | I'm building my first autoconf managed package.
However I can't find any simple examples anywhere of how to specify a required library, and find that library where it might be in various different places.
I've currently got:
```
AC_CHECK_LIB(['event'], ['event_init'])
```
but:
1. It doesn't find the version insta... | You need to manually set `CFLAGS`, `CXXFLAGS` and `LDFLAGS` if you want gcc/g++ to look in non-standard locations.
So, before calling `AC_CHECK_LIB()`, do something like
```
CFLAGS="$CFLAGS -I/opt/local/include"
CXXFLAGS="$CXXFLAGS -I/opt/local/include"
LDFLAGS="$LDFLAGS -L/opt/local/lib"
```
You don't need CXXFLA... |
517,607 | <p>I need to get elevated credentials (to start a service) in a VB6 application, but only if the user needs to restart the service (I.e. I don't want to get elevated credentials whenever the application is started, only when the user selects restart). How can I do this in VB6?</p>
| [
{
"answer_id": 518150,
"author": "Ismael",
"author_id": 5999,
"author_profile": "https://Stackoverflow.com/users/5999",
"pm_score": 1,
"selected": false,
"text": "<p>One solution is to use the COM elevation moniker <a href=\"http://msdn.microsoft.com/en-us/library/ms679687(VS.85).aspx\" ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] | I need to get elevated credentials (to start a service) in a VB6 application, but only if the user needs to restart the service (I.e. I don't want to get elevated credentials whenever the application is started, only when the user selects restart). How can I do this in VB6? | Fairly easy, but the preferred way involves a new elevated process. This example uses itself run with a switch to know to perform the Service Start instead of normal operations:
```
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 3060
C... |
517,614 | <p>I have a Django site set up that uses the Django admin panel, prefixed with <code>/media/</code>, as well as static site content in a directory called <code>/static/</code>. The admin media stuff, of course, lives within the Django package, and the site's static content is stored along with the Python code for the s... | [
{
"answer_id": 517639,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>I don't symlink for either... </p>\n\n<p>I use the webserver's rewrites to point <code>/media/(.*)</code> directly to my me... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28804/"
] | I have a Django site set up that uses the Django admin panel, prefixed with `/media/`, as well as static site content in a directory called `/static/`. The admin media stuff, of course, lives within the Django package, and the site's static content is stored along with the Python code for the site.
Currently, my `publ... | I just use
```
Alias /media /home/akaihola/usr/lib/python2.4/site-packages/django/contrib/admin/media/
Alias /static /home/akaihola/mysite/public/static/
```
but I do it in a real Apache configuration file instead of `.htaccess` and I use mod\_wsgi, although I don't know if it makes a difference. |
517,628 | <p>I'm trying to P/Invoke into CryptImportKey from C# to set a known key before encrypting data that will be decrypted in a C++ Win32 service at some point. I have the method signature for the P/Invoke and that all works fine but i can't get it to accept my key blob. The C++ structs are in comments below and my C# on... | [
{
"answer_id": 517639,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>I don't symlink for either... </p>\n\n<p>I use the webserver's rewrites to point <code>/media/(.*)</code> directly to my me... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to P/Invoke into CryptImportKey from C# to set a known key before encrypting data that will be decrypted in a C++ Win32 service at some point. I have the method signature for the P/Invoke and that all works fine but i can't get it to accept my key blob. The C++ structs are in comments below and my C# ones fo... | I just use
```
Alias /media /home/akaihola/usr/lib/python2.4/site-packages/django/contrib/admin/media/
Alias /static /home/akaihola/mysite/public/static/
```
but I do it in a real Apache configuration file instead of `.htaccess` and I use mod\_wsgi, although I don't know if it makes a difference. |
517,650 | <p>i am trying to load a variable through php from a sql database but i get nothing</p>
<p>here is the code</p>
<pre><code>var Idfield;
var loader:URLLoader = new URLLoader();
// data will come as URL encoded variables
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(new URLRequest("pull.php"));
loader.... | [
{
"answer_id": 517672,
"author": "Ryan Guill",
"author_id": 7186,
"author_profile": "https://Stackoverflow.com/users/7186",
"pm_score": 0,
"selected": false,
"text": "<p>well for one thing, you need to add your event listener before you actually call load(). </p>\n\n<p>When you say you ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16458/"
] | i am trying to load a variable through php from a sql database but i get nothing
here is the code
```
var Idfield;
var loader:URLLoader = new URLLoader();
// data will come as URL encoded variables
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(new URLRequest("pull.php"));
loader.addEventListener(Even... | I believe the variables format expects the variables in the name=value format so try something like:
```
echo 'id=' . $row[0];
``` |
517,652 | <p>I have a boolean variable declared at the top of a class and when a radio button is selected on a page, the variable gets set to true, but when the page is reloaded, the variable gets reset back to false. One way I have handled this was by using the static keyword, but I am not sure if this is the best way to handl... | [
{
"answer_id": 517664,
"author": "James Orr",
"author_id": 41457,
"author_profile": "https://Stackoverflow.com/users/41457",
"pm_score": 5,
"selected": true,
"text": "<p>When the page gets reloaded, a new instance of your page class is created so any values from the last server interacti... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I have a boolean variable declared at the top of a class and when a radio button is selected on a page, the variable gets set to true, but when the page is reloaded, the variable gets reset back to false. One way I have handled this was by using the static keyword, but I am not sure if this is the best way to handle th... | When the page gets reloaded, a new instance of your page class is created so any values from the last server interaction are lost. Put the value into viewstate if you want it to persist across postbacks:
```
bool AllSelected
{
get
{
object o = ViewState["AllSelected"];
if(o == null) return fals... |
517,661 | <p>I have this recorded in SQL Server:</p>
<p><strong>1- startTime (datetime): 5/2/2009 08:30 (brazilian time format: d/m/y)</strong></p>
<p><strong>2- startTime (datetime): 4/2/2009 14:30 (brazilian time format: d/m/y)</strong></p>
<p>My application just records time... the date it's SQL that generates by i... | [
{
"answer_id": 517690,
"author": "RandomProgrammer",
"author_id": 58864,
"author_profile": "https://Stackoverflow.com/users/58864",
"pm_score": 4,
"selected": true,
"text": "<pre><code>from d in dates\n orderby d.TimeOfDay\n select d;\n</code></pre>\n\n<p>or</p>\n\n<pre><code>dat... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60286/"
] | I have this recorded in SQL Server:
**1- startTime (datetime): 5/2/2009 08:30 (brazilian time format: d/m/y)**
**2- startTime (datetime): 4/2/2009 14:30 (brazilian time format: d/m/y)**
My application just records time... the date it's SQL that generates by itself be getting the date of today.
When I ask VS 2008 to... | ```
from d in dates
orderby d.TimeOfDay
select d;
```
or
```
dates.OrderBy(d => d.TimeOfDay);
```
---
**Note:** This will work as long as this is plain LINQ and not LINQ-to-SQL. If you're using LINQ-to-SQL to query your database, you'll need something that will translate to SQL. |
517,694 | <p>Anyone knows how to get selected text from other application using UI Automation and .Net?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms745158.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms745158.aspx</a></p>
| [
{
"answer_id": 2383854,
"author": "NetMage",
"author_id": 2557128,
"author_profile": "https://Stackoverflow.com/users/2557128",
"pm_score": 4,
"selected": true,
"text": "<pre><code>private void button1_Click(object sender, EventArgs e) {\n Process[] plist = Process.GetProcesses();... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20126/"
] | Anyone knows how to get selected text from other application using UI Automation and .Net?
<http://msdn.microsoft.com/en-us/library/ms745158.aspx> | ```
private void button1_Click(object sender, EventArgs e) {
Process[] plist = Process.GetProcesses();
foreach (Process p in plist) {
if (p.ProcessName == "notepad") {
AutomationElement ae = AutomationElement.FromHandle(p.MainWindowHandle);
AutomationElemen... |
517,695 | <p>Had a coworker ask me this, and in my brain befuddled state I didn't have an answer:</p>
<p>Why is it that you can do:</p>
<pre><code>string ham = "ham " + 4;
</code></pre>
<p>But not:</p>
<pre><code>string ham = 4;
</code></pre>
<p>If there's an implicit cast/operation for string conversion when you are <em>co... | [
{
"answer_id": 517711,
"author": "Mark Canlas",
"author_id": 40725,
"author_profile": "https://Stackoverflow.com/users/40725",
"pm_score": 0,
"selected": false,
"text": "<p>The value of the righthand side of the first expression is a string, while the value of the righthand side of the s... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2108310/"
] | Had a coworker ask me this, and in my brain befuddled state I didn't have an answer:
Why is it that you can do:
```
string ham = "ham " + 4;
```
But not:
```
string ham = 4;
```
If there's an implicit cast/operation for string conversion when you are *concatenating*, why not the same when *assigning* it as a str... | When concatenating the compiler turns the statement `"ham" + 4` into a call to `String.Concat`, which takes two `object` parameters, so the value `4` is boxed and then `ToString` is called on that.
For the assignment there is no implicit conversion from `int` to `string`, and thus you cannot assign `4` to a `string` ... |
517,704 | <p>I'm trying to implement pop-up menus in Java JTree. I've sub-classed DefaultTreeCellRenderer (to change node appearance) and DefaultTreeCellEditor (to create Components to attach event listeners to, since apparently the Components that DefaultTreeCellRenderer.getTreeCellRendererComponent() returns can't do it?). I d... | [
{
"answer_id": 517731,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 1,
"selected": false,
"text": "<p>The Renderer is only a transient \"rubber stamp\", so adding an input listener on that wont be particularly... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to implement pop-up menus in Java JTree. I've sub-classed DefaultTreeCellRenderer (to change node appearance) and DefaultTreeCellEditor (to create Components to attach event listeners to, since apparently the Components that DefaultTreeCellRenderer.getTreeCellRendererComponent() returns can't do it?). I don'... | This task is simple to accomplish, the following is all you need:
```
//create a class which implements the MouseListener interface and
//implement the following in your overridden mouseClicked method
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
int row ... |
517,719 | <p>I have a WPF ListBox with a defined DataTemplate. In that template, I have a grid, where the first column width should take up all remaining room in the grid.</p>
<p>This seems to work outside the ListBox, but not inside. Why is that, and how can I get it to behave the same?</p>
<p>Here is my code. See line 36, an... | [
{
"answer_id": 517767,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 0,
"selected": false,
"text": "<p>Try editing the ControlTemplate of ListBox and remove the scrollviewer inside that, Let it be just ItemsPresenter inside... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32772/"
] | I have a WPF ListBox with a defined DataTemplate. In that template, I have a grid, where the first column width should take up all remaining room in the grid.
This seems to work outside the ListBox, but not inside. Why is that, and how can I get it to behave the same?
Here is my code. See line 36, and line 70
```
<... | This is because the ListBoxItem containing the grid is sizing to content. Therefore the "remaining space" for the star-sized column to fill is only as much as the column needs.
To fix this, use the ListBox.ItemContainerStyle to set ListBoxItem.HorizontalContentAlignment to Stretch. |
517,751 | <p>I have a method like this:</p>
<pre><code>public static <T> boolean isMemberOf(T item, T[] set)
{
for (T t : set) {
if (t.equals(item)) {
return true;
}
}
return false;
}
</code></pre>
<p>Now I try to call this method using a <code>char</code> for <code>T</code>:</p>
... | [
{
"answer_id": 517769,
"author": "Eddie",
"author_id": 57752,
"author_profile": "https://Stackoverflow.com/users/57752",
"pm_score": 7,
"selected": true,
"text": "<p>There is no autoboxing for arrays, only for primitives. I believe this is your problem.</p>\n"
},
{
"answer_id": ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | I have a method like this:
```
public static <T> boolean isMemberOf(T item, T[] set)
{
for (T t : set) {
if (t.equals(item)) {
return true;
}
}
return false;
}
```
Now I try to call this method using a `char` for `T`:
```
char ch = 'a';
char[] chars = new char[] { 'a', 'b', '... | There is no autoboxing for arrays, only for primitives. I believe this is your problem. |
517,765 | <p>I am working to improve performance of a function that takes an XML string and replaces certain characters (encoding) before returning the string. The function gets pounded, so it is important to run as quickly as possible. The USUAL case is that none of the characters are present - so I would like to especially o... | [
{
"answer_id": 517860,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": false,
"text": "<p>You can use a hash lookup:</p>\n\n<pre><code>str.replace(\n /(\\\\34|\\\\39|\\\\62|\\\\60|\\\\13\\\\10|\\\\09|\\\... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/525/"
] | I am working to improve performance of a function that takes an XML string and replaces certain characters (encoding) before returning the string. The function gets pounded, so it is important to run as quickly as possible. The USUAL case is that none of the characters are present - so I would like to especially optimi... | I have benchmarked your original version, Ates Gorals hash, my improved hash, a version using switch, and the simple solution. The winner? The simple solution!
With matching data (string of 85 chars)
```
original simple hash switch ag-hash
FF3 194 188 250 240 424
IE7 188 ... |
517,771 | <p>Is there a way to define code snippets for another language, other then the default ones (C#, VB ...) in VS 2008 ?
I'm using Intel's fortran compiler with Visual studio, and its integration in it is pretty complete apart from the code snippets part. I thought I read somewhere on msdn that you can't define new ones, ... | [
{
"answer_id": 517860,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": false,
"text": "<p>You can use a hash lookup:</p>\n\n<pre><code>str.replace(\n /(\\\\34|\\\\39|\\\\62|\\\\60|\\\\13\\\\10|\\\\09|\\\... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62699/"
] | Is there a way to define code snippets for another language, other then the default ones (C#, VB ...) in VS 2008 ?
I'm using Intel's fortran compiler with Visual studio, and its integration in it is pretty complete apart from the code snippets part. I thought I read somewhere on msdn that you can't define new ones, for... | I have benchmarked your original version, Ates Gorals hash, my improved hash, a version using switch, and the simple solution. The winner? The simple solution!
With matching data (string of 85 chars)
```
original simple hash switch ag-hash
FF3 194 188 250 240 424
IE7 188 ... |
517,781 | <p>I have NSMutableArray and used it like queue for waiting actions.</p>
<p>Example in array: </p>
<p>0: "Do something"<br>
1: "Do something else"<br>
2: "Do something 2"</p>
<p>When I used <code>[myarray removeObjectAtIndex:0]</code> the array is not reordering and next time when I use <code>[myarray objectAtIndex... | [
{
"answer_id": 517809,
"author": "Chuck",
"author_id": 50742,
"author_profile": "https://Stackoverflow.com/users/50742",
"pm_score": 2,
"selected": false,
"text": "<p>NSArray already behaves the way you want, and in fact cannot contain nil. It sounds like your array might be somehow gett... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32034/"
] | I have NSMutableArray and used it like queue for waiting actions.
Example in array:
0: "Do something"
1: "Do something else"
2: "Do something 2"
When I used `[myarray removeObjectAtIndex:0]` the array is not reordering and next time when I use `[myarray objectAtIndex:o]` the result is `nil`.
How can I put "D... | ```
/* gcc -framework Cocoa myprogram.m -o myprogram */
#import <Cocoa/Cocoa.h>
int main( int argc, char **argv )
{
NSMutableArray *array = [ [ NSMutableArray alloc ]
initWithObjects: @"1", @"2", @"3",
nil ]; /* don't forget nil */
/* "pop" ... |
517,794 | <p>I have a webpage and files that show up fine in the latest version of IE. Need it to show up the same in the latest version of Firefox and Safari.</p>
<p>The webpage and supporting files are archived for review. I'll paste the page below followed by the CSS. It is easier to see with images.</p>
<h3>HTML</h3>
<pre... | [
{
"answer_id": 517816,
"author": "Tyson",
"author_id": 43004,
"author_profile": "https://Stackoverflow.com/users/43004",
"pm_score": 3,
"selected": false,
"text": "<p>It would help greatly if you could point us to a live version of the page. There's a lot of things that can affect the di... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a webpage and files that show up fine in the latest version of IE. Need it to show up the same in the latest version of Firefox and Safari.
The webpage and supporting files are archived for review. I'll paste the page below followed by the CSS. It is easier to see with images.
### HTML
```
<!DOCTYPE html PUBL... | It would help greatly if you could point us to a live version of the page. There's a lot of things that can affect the display of pages in browsers (standards or quirks rendering mode, doctypes, valid/invalid HTML and CSS, etc.)
As it stands, there's not enough information in your question to let people accurately pin... |
517,799 | <p>Hello i have the next code:
php side:</p>
<pre><code><?php
print_r($_POST);
print_r($_GET);
die();
?>
</code></pre>
<p>In javascript:</p>
<pre><code>voteAjax = function(typez, actionz, idz){
new Ajax.Request(
'http://localhost/reporeade/Vote/Ajax/?rand='+Math.random()*500000,
{asynchron... | [
{
"answer_id": 517821,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 2,
"selected": false,
"text": "<p>I'd suggest installing WireShark and monitoring your HTTP traffic to see if you can isolate the problem that way... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47846/"
] | Hello i have the next code:
php side:
```
<?php
print_r($_POST);
print_r($_GET);
die();
?>
```
In javascript:
```
voteAjax = function(typez, actionz, idz){
new Ajax.Request(
'http://localhost/reporeade/Vote/Ajax/?rand='+Math.random()*500000,
{asynchronous:true,
evalScripts:true,
... | I also suggest you should monitor your network traffic through Wireshark:
1. Start it on either server or client.
2. Start capturing your network interface.
3. Use the AJAX and
4. when it fails stop the capture and
5. type http in Wireshark to help you find the request.
6. Right-click and select "Follow TCP Stream".
... |
517,801 | <p>We have this pattern everywhere in our code:</p>
<pre><code>using (ServiceAccess ws = new ServiceAccess())
{
//...
//code here to talk to webservice ws
//...
}
</code></pre>
<p>How can I replace this boiler plate code with an attribute on the functions that need to talk to the web service? (I'm thinking back to wh... | [
{
"answer_id": 517807,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>I think the best you can do is create a shortcut for inserting that code as a snippet. You can't shoehorn a variab... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9484/"
] | We have this pattern everywhere in our code:
```
using (ServiceAccess ws = new ServiceAccess())
{
//...
//code here to talk to webservice ws
//...
}
```
How can I replace this boiler plate code with an attribute on the functions that need to talk to the web service? (I'm thinking back to when I did some stuff with H... | Take a look at [aspects](http://www.springframework.net/docs/1.2.0/reference/html/aop.html) in spring.net. |
517,825 | <p>Is there a cross-browser way from a Javascript event handler to determine whether the event has been cancelled by a previous handler? IE and other browsers like Chrome etc. have an <code>event.returnValue </code>property that can be tested, but FireFox doesn't appear to have any such property.</p>
<p>Here's an examp... | [
{
"answer_id": 517819,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 3,
"selected": false,
"text": "<p>Run test coverage reports automatically during your build process. We do this with CruiseControl. Otherwise, you have to ac... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8037/"
] | Is there a cross-browser way from a Javascript event handler to determine whether the event has been cancelled by a previous handler? IE and other browsers like Chrome etc. have an `event.returnValue` property that can be tested, but FireFox doesn't appear to have any such property.
Here's an example of the scenario I... | This is probably a social problem rather than a technological one. Firstly, do you want unit tests that result in 100% code coverage, or can you settle for less, and trust your developers to put in unit tests where they really matter, and where they make sense. You could probably get some kind of system in place that w... |
517,826 | <p>I am dynamically creating a CheckBox and setting the disabled property like this:</p>
<pre><code>chk.Disabled = false.
</code></pre>
<p>This renders the following HTML:</p>
<pre><code><input type="checkbox" disabled="disabled" .../>
</code></pre>
<p>On the click of the checkbox, I have a JS function that t... | [
{
"answer_id": 517847,
"author": "Allen Rice",
"author_id": 49885,
"author_profile": "https://Stackoverflow.com/users/49885",
"pm_score": 1,
"selected": false,
"text": "<p>If your checkbox is disabled, your onclick wont be called</p>\n"
},
{
"answer_id": 517849,
"author": "Da... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58348/"
] | I am dynamically creating a CheckBox and setting the disabled property like this:
```
chk.Disabled = false.
```
This renders the following HTML:
```
<input type="checkbox" disabled="disabled" .../>
```
On the click of the checkbox, I have a JS function that tries to enable it by doing a:
```
//get reference to t... | If your checkbox is disabled, your onclick wont be called |
517,839 | <p>Let me just preface by saying it's actually my crappy code that's leaking and crashing my browser, I just thought I better make the languages being used as clear as I could from the outset.</p>
<p>I have a test page <a href="http://www.hallofbrightcarvings.com/game/grid" rel="nofollow noreferrer">here</a> and the j... | [
{
"answer_id": 517893,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 0,
"selected": false,
"text": "<p>It feels like some event-handlers are registered multiple times, but I'm unsure. (Reason below.)</p>\n\n<hr>\n\n<... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60598/"
] | Let me just preface by saying it's actually my crappy code that's leaking and crashing my browser, I just thought I better make the languages being used as clear as I could from the outset.
I have a test page [here](http://www.hallofbrightcarvings.com/game/grid) and the javascript can be found [here](http://www.hallof... | I don't think this is actually your problem, but it seems like your making an extra method call on register and check\_ allowable\_moves
```
return {
register_map: function(ob) { map = ob; },
register_piece: function(ob) {
ob.config.tracker = this;
register_draggable(ob);
},... |
517,861 | <p>I have Shipment and Product entities. Each shipment consists of any amount of any numbers of products. I.e. a shipment has a field named products which is a java.util.Map where they key is the product being shipped and the value is the number of instances of that product being shipped.</p>
<p>How do I map that to a... | [
{
"answer_id": 518431,
"author": "wds",
"author_id": 10098,
"author_profile": "https://Stackoverflow.com/users/10098",
"pm_score": 0,
"selected": false,
"text": "<p>This seems like a bit of an odd design to me, but if I understand correctly you'll want a database schema that has:</p>\n\n... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63051/"
] | I have Shipment and Product entities. Each shipment consists of any amount of any numbers of products. I.e. a shipment has a field named products which is a java.util.Map where they key is the product being shipped and the value is the number of instances of that product being shipped.
How do I map that to a db with h... | This is what you have to do. The field `map` belongs to the `Shipment` class, and it maps each `Product` to the number of products shipped.
**This will not work unless you properly define equals and hashCode methods in the class Product that do not depend on hibernate generated ids. (Or read the full story [here](htt... |
517,869 | <p>I have a DB migration like so:</p>
<pre><code> class CreateParticipations < ActiveRecord::Migration
def self.up
create_table(:participations, :primary_key => 'Seat') do |t|
t.integer :Seat
t.string :Nickname
t.string :Clan
t.string :FirstName
... | [
{
"answer_id": 517958,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 0,
"selected": false,
"text": "<p>Is there a reason you can't use rails' id key and manually add an index called Seat?</p>\n\n<p>I've seen some hacks j... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a DB migration like so:
```
class CreateParticipations < ActiveRecord::Migration
def self.up
create_table(:participations, :primary_key => 'Seat') do |t|
t.integer :Seat
t.string :Nickname
t.string :Clan
t.string :FirstName
t.string :LastNa... | For the record, if you absolutely need to do this (it shouldn't happen often), here's the way to do a non-autoincrementing primary key with the Rails migration DSL:
```
create_table(:table_name, :id => false) do |t|
t.integer :id, :options => 'PRIMARY KEY'
end
```
That will work for MySQL anyway, if your DB uses d... |
517,903 | <p>This shouldn't be hard to do. I'd expect Enterprise Manager to show a folder of trigger and a list and an icon... but I don't see it anywhere. My google results get me answers where I have to write code. Are you kidding me? The only way is by writing code?</p>
| [
{
"answer_id": 517967,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SELECT\nCASE OBJECTPROPERTY(OBJECT_ID('trigger name goes here'), 'ExecIsTriggerDisabled')\nWHEN 0 THEN 'ENABLED'\nEL... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This shouldn't be hard to do. I'd expect Enterprise Manager to show a folder of trigger and a list and an icon... but I don't see it anywhere. My google results get me answers where I have to write code. Are you kidding me? The only way is by writing code? | ```
SELECT
CASE OBJECTPROPERTY(OBJECT_ID('trigger name goes here'), 'ExecIsTriggerDisabled')
WHEN 0 THEN 'ENABLED'
ELSE 'DISABLED'
END
``` |
517,909 | <p>I'm having a problem with my LEFT OUTER JOIN on 3 tables, with a SUM clause.
This is my code:</p>
<pre><code>SELECT r.ret_desc, vmp.vlt_id,
SUM((vmp.cash_in + vmp.per_cash_in_sec)
+ (CASE WHEN vmp.acc_id = t.db_id AND t.txn_type_id = 1 THEN t.amount ELSE 0 END)
- (CASE WHEN vmp.acc_id = t.cr_id AND t.txn_type... | [
{
"answer_id": 517981,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 0,
"selected": false,
"text": "<p>I'm going to make some guesses about your data design. Please update the question with more detail if these are not a... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm having a problem with my LEFT OUTER JOIN on 3 tables, with a SUM clause.
This is my code:
```
SELECT r.ret_desc, vmp.vlt_id,
SUM((vmp.cash_in + vmp.per_cash_in_sec)
+ (CASE WHEN vmp.acc_id = t.db_id AND t.txn_type_id = 1 THEN t.amount ELSE 0 END)
- (CASE WHEN vmp.acc_id = t.cr_id AND t.txn_type_id = 1 THEN t... | You should be aware that a JOIN produces a set of all combinations matching the join clause.
Therefore, if you have multiple txn and vmp records for a single ret record, you get count(txn) \* count(vmp) records per ret, thus creating a sum of count(vmp) \* txn.amount and count(txn) \* vmp.amount.
I think the best sol... |
517,919 | <p>I'm having some problems to come up with a sane type naming scheme for our new line of applications. I want to follow the <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx" rel="nofollow noreferrer">.NET Framework Developer's Guide - Design Guidelines for Developing Class Libraries</a>, but I'm starting... | [
{
"answer_id": 517941,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 1,
"selected": false,
"text": "<p>If it makes logical sense, then do it. They are just guidelines, not the LAW. (not that you cant break that too.)</p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6345/"
] | I'm having some problems to come up with a sane type naming scheme for our new line of applications. I want to follow the [.NET Framework Developer's Guide - Design Guidelines for Developing Class Libraries](http://msdn.microsoft.com/en-us/library/ms229042.aspx), but I'm starting to wonder if that's such a good idea.
... | Microsoft clearly favors some redundancy. A common example is:
```
System.Xml.XmlDocument
```
General class names, even bound within a proper named namespace can cause headaches for the many programmers who like to avoid fully qualifying their class instantiations. "Document" could be an Xml, Html or word document. ... |
517,923 | <p>I have a Unicode string in Python, and I would like to remove all the accents (diacritics).</p>
<p>I found on the web an elegant way to do this (in Java):</p>
<ol>
<li>convert the Unicode string to its <em><strong>long normalized form</strong></em> (with a separate character for letters and diacritics)</li>
<li>remo... | [
{
"answer_id": 517974,
"author": "MiniQuark",
"author_id": 38626,
"author_profile": "https://Stackoverflow.com/users/38626",
"pm_score": 8,
"selected": false,
"text": "<p>I just found this answer on the Web:</p>\n\n<pre><code>import unicodedata\n\ndef remove_accents(input_str):\n nfkd... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38626/"
] | I have a Unicode string in Python, and I would like to remove all the accents (diacritics).
I found on the web an elegant way to do this (in Java):
1. convert the Unicode string to its ***long normalized form*** (with a separate character for letters and diacritics)
2. remove all the characters whose Unicode type is ... | How about this:
```
import unicodedata
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
```
This works on greek letters, too:
```
>>> strip_accents(u"A \u00c0 \u0394 \u038E")
u'A A \u0394 \u03a5'
>>>
```
The [character catego... |
517,935 | <p>Hope someone can help me. I am using c# and I am somewhat new to it.
I am loading a text file into my app and splitting the data on "," I am reading part of string into a <code><list></code> when the data is read there is a lot of duplicates that vary depending on the txt file that I load. Can someone tell me... | [
{
"answer_id": 517954,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.kirupa.com/net/removingDuplicates.htm\" rel=\"nofollow noreferrer\">Here's</a> an article with s... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hope someone can help me. I am using c# and I am somewhat new to it.
I am loading a text file into my app and splitting the data on "," I am reading part of string into a `<list>` when the data is read there is a lot of duplicates that vary depending on the txt file that I load. Can someone tell me how to check the and... | If you are targeting .NET 3.5, use the Distinct extension method:
```
var deduplicated = list.Distinct();
``` |
517,940 | <p>I use <code>wp_list_categories()</code> to get the list of all the categories and generate the navigation bar. Is there a way to order these categories in a particular order other than alphabetical ordering. </p>
<p>eg: Connect, News & Views, Q&A, Hello Startup, Startup 101...</p>
| [
{
"answer_id": 5786370,
"author": "Ezhil",
"author_id": 724810,
"author_profile": "https://Stackoverflow.com/users/724810",
"pm_score": 2,
"selected": false,
"text": "<p>This is inbuilt in <code>wordpress_wp_list_categories</code></p>\n\n<pre><code>wp_list_categories('orderby=name');\n</... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62780/"
] | I use `wp_list_categories()` to get the list of all the categories and generate the navigation bar. Is there a way to order these categories in a particular order other than alphabetical ordering.
eg: Connect, News & Views, Q&A, Hello Startup, Startup 101... | Most themes don't use the description of the category for anything. Easy workaround I did was to use numbers in description. The top post here currently has some jQuery hack from here, it's unneeded.
You can add custom order fields I suppose as well.
Just
```
$categories = get_categories( array(
'orderby' => ... |
517,944 | <p>I have a Delphi DLL that I did not write, but need to call from a C# ASP.NET 3.5 app. Here is the function definition I got from the developers:</p>
<pre><code>function CreateCode(SerialID : String;
StartDateOfYear, YearOfStartDate, YearOfEndDate, DatePeriod : Word;
CodeType,RecordNumber,StartHour,EndHou... | [
{
"answer_id": 517969,
"author": "PetriW",
"author_id": 1604,
"author_profile": "https://Stackoverflow.com/users/1604",
"pm_score": 1,
"selected": false,
"text": "<p>I've never done this but try changing your code to:</p>\n\n<pre><code>function CreateCode(SerialID : String;\n StartDat... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63062/"
] | I have a Delphi DLL that I did not write, but need to call from a C# ASP.NET 3.5 app. Here is the function definition I got from the developers:
```
function CreateCode(SerialID : String;
StartDateOfYear, YearOfStartDate, YearOfEndDate, DatePeriod : Word;
CodeType,RecordNumber,StartHour,EndHour : Byte) : PCh... | Delphi uses the so called ***fastcall*** calling convention by default. This means that the compiler tries to pass parameters to a function in the CPU registers and only uses the stack if there are more parameters than free registers. For example Delphi uses (EAX, EDX, ECX) for the first three parameters to a function.... |
517,951 | <p>Instead of </p>
<pre><code><pre>
<canvas id="theCanvas" width="500" height="500"></canvas>
</pre>
</code></pre>
<p>where I specify the size of the canvas is there a way to make the canvas take up the entire browser window?</p>
| [
{
"answer_id": 517971,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 3,
"selected": true,
"text": "<pre><code><html>\n <body style=\"height: 100%; margin: 0;\">\n <canvas style=\"width: 100%; height: ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | Instead of
```
<pre>
<canvas id="theCanvas" width="500" height="500"></canvas>
</pre>
```
where I specify the size of the canvas is there a way to make the canvas take up the entire browser window? | ```
<html>
<body style="height: 100%; margin: 0;">
<canvas style="width: 100%; height: 100%;"></canvas>
</body>
</html>
``` |
517,956 | <p>Normally, when you want to call a stored procedure directly through Linq to Sql, you can use the ExecuteQuery method:</p>
<pre><code>result = dc.ExecuteQuery<MyTable>("Exec myStoredProcedure");
</code></pre>
<p>And if you need to call it with parameters, you can add them through string substitution:</p>
<pr... | [
{
"answer_id": 560662,
"author": "Maksym Gontar",
"author_id": 67407,
"author_profile": "https://Stackoverflow.com/users/67407",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure, but you can try to declare variable in query, pass it as an output parameter and then select it:</p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1249/"
] | Normally, when you want to call a stored procedure directly through Linq to Sql, you can use the ExecuteQuery method:
```
result = dc.ExecuteQuery<MyTable>("Exec myStoredProcedure");
```
And if you need to call it with parameters, you can add them through string substitution:
```
string query = "Exec myStoredProced... | Alper Ozcetin's is right you can map StoredProcedures in \*.dbml and you can use StoredProcedures as Method.
Below is demo doing this with the AdventureWorks DB and works for both vs2008 and vs2010
Wtih AdventureWorks I created the following Proc
```
CREATE PROC sp_test (@City Nvarchar(60) , @AddressID int out )
... |
517,970 | <p>Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, <code>dir()</code> stuff, <code>help() stuff</code>, etc.</p>
<p>Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing whe... | [
{
"answer_id": 517992,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 7,
"selected": false,
"text": "<p>Well, here's a quick hack:</p>\n\n<pre><code>>>> clear = \"\\n\" * 100\n>>> print clear\n>>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, `dir()` stuff, `help() stuff`, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command se... | As you mentioned, you can do a system call:
For Windows:
```
>>> import os
>>> clear = lambda: os.system('cls')
>>> clear()
```
For Linux it would be:
```
>>> import os
>>> clear = lambda: os.system('clear')
>>> clear()
``` |
517,976 | <p>I've upgraded to Rails 2.2.2 and installed the MySQL 2.7 gem and am seeing this error when I try to run a migration or start the server:</p>
<pre><code>dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /Library/... | [
{
"answer_id": 517986,
"author": "Gabe Hollombe",
"author_id": 30632,
"author_profile": "https://Stackoverflow.com/users/30632",
"pm_score": 3,
"selected": true,
"text": "<p>Answering my own question for the benefit of others.</p>\n\n<p>I found the fix <a href=\"http://installingcats.com... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30632/"
] | I've upgraded to Rails 2.2.2 and installed the MySQL 2.7 gem and am seeing this error when I try to run a migration or start the server:
```
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /Library/Ruby/Gems/1.8/... | Answering my own question for the benefit of others.
I found the fix [here](http://installingcats.com/2007/12/13/mysql-ruby-gem-install-problem-on-mac-os-x-leopard/).
Run:
```
sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/... |
517,989 | <p>Say I've got a query</p>
<pre><code>SELECT TOP 10 ... FROM ... ORDER BY ...
</code></pre>
<p>in Access (well, really Jet). The question is: how can I get all the other rows... everything <em>except</em> the top 10?</p>
| [
{
"answer_id": 518008,
"author": "Wayne Molina",
"author_id": 40667,
"author_profile": "https://Stackoverflow.com/users/40667",
"pm_score": 6,
"selected": true,
"text": "<p>Couldn't you do something like</p>\n\n<pre><code>SELECT ... FROM ...\nWHERE PK NOT IN (SELECT TOP 10 PK FROM ...)\n... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4/"
] | Say I've got a query
```
SELECT TOP 10 ... FROM ... ORDER BY ...
```
in Access (well, really Jet). The question is: how can I get all the other rows... everything *except* the top 10? | Couldn't you do something like
```
SELECT ... FROM ...
WHERE PK NOT IN (SELECT TOP 10 PK FROM ...)
ORDER BY ...
```
it might not be that efficient but that's the only way off the top of my head I can think to do something like that. AFAIK there's no "BOTTOM" clause in SQL :) |
517,998 | <p>I have a set of objects in a hierachy. There's a top "root" node and that has child nodes, which in turn have child nodes etc. I'm trying to save this structure into a DB using the nested set model, where each "side" of each node is numbered to define the hierarchy, as in <a href="http://mikehillyer.com/articles/man... | [
{
"answer_id": 518089,
"author": "soulmerge",
"author_id": 44562,
"author_profile": "https://Stackoverflow.com/users/44562",
"pm_score": 0,
"selected": false,
"text": "<p>It is not possible to solve this problem without recursion. You need something like the following:</p>\n\n<pre><code>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39428/"
] | I have a set of objects in a hierachy. There's a top "root" node and that has child nodes, which in turn have child nodes etc. I'm trying to save this structure into a DB using the nested set model, where each "side" of each node is numbered to define the hierarchy, as in [Managing Hierarchical Data in MySQL](http://mi... | I figured it out, here's the solution (simplifed):
```
$iterator = new RecursiveIteratorIterator(
new Site_Node_List(array($root)),
RecursiveIteratorIterator::SELF_FIRST);
$sides = array();
$s = 0;
$i = 0;
$parents = array();
foreach ($iterator as $item) {
$js = array_splice($parents, $depth, count($paren... |
518,000 | <p>The primitive types (number, string, etc.) are passed by value, but objects are unknown, because they can be both passed-by-value (in case we consider that a variable holding an object is in fact a reference to the object) and passed-by-reference (when we consider that the variable to the object holds the object its... | [
{
"answer_id": 518066,
"author": "Jack Sleight",
"author_id": 39428,
"author_profile": "https://Stackoverflow.com/users/39428",
"pm_score": -1,
"selected": false,
"text": "<p>There's some discussion about the use of the term \"pass by reference\" in JavaScript <a href=\"https://developer... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3219/"
] | The primitive types (number, string, etc.) are passed by value, but objects are unknown, because they can be both passed-by-value (in case we consider that a variable holding an object is in fact a reference to the object) and passed-by-reference (when we consider that the variable to the object holds the object itself... | It's interesting in JavaScript. Consider this example:
```js
function changeStuff(a, b, c)
{
a = a * 10;
b.item = "changed";
c = {item: "changed"};
}
var num = 10;
var obj1 = {item: "unchanged"};
var obj2 = {item: "unchanged"};
changeStuff(num, obj1, obj2);
console.log(num);
console.log(obj1.item);
console.lo... |
518,012 | <p>I have a "datadump" table that has a bunch of mixed performance-related data.
Something like: </p>
<pre><code>MachID TestDate MachType Value1 Value2 ...
00001 01/01/09 Server 15 48
00001 01/02/09 Server 16 99
19999 01/01/09 Switch 32 4.9880
19999 0... | [
{
"answer_id": 518033,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 0,
"selected": false,
"text": "<p>Create a table storing the header-name for each value for that individual type of query.</p>\n\n<p>Then, create a sto... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21398/"
] | I have a "datadump" table that has a bunch of mixed performance-related data.
Something like:
```
MachID TestDate MachType Value1 Value2 ...
00001 01/01/09 Server 15 48
00001 01/02/09 Server 16 99
19999 01/01/09 Switch 32 4.9880
19999 01/02/09 Switc... | This will do them all together - you can modify as appropriate if you want them all split up.
```
DECLARE @template AS varchar(max)
DECLARE @sql AS varchar(max)
DECLARE @column_list AS varchar(max)
SELECT @column_list = COALESCE(@column_list + ', ', '')
+ QUOTENAME([Description])
FROM xRef
SET @template =... |
518,020 | <p>I am struggling to get my form to have a transparent background in vb.net </p>
<p>Currently in the form New I set </p>
<pre><code>Me.SetStyle(ControlStyles.SupportsTransparentBackColor, true)
</code></pre>
<p>But still the form shows up as having the default grey background</p>
<p>Can anyone help??</p>
<p>EDIT... | [
{
"answer_id": 518054,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<pre><code>Me.Opacity = 0\n</code></pre>\n\n<p>Be warned that:</p>\n\n<ol>\n<li>This is for the entire form, rather t... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | I am struggling to get my form to have a transparent background in vb.net
Currently in the form New I set
```
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, true)
```
But still the form shows up as having the default grey background
Can anyone help??
EDIT: I need the controls on the form to be visible... | Use TransparencyKey for transparent form.
eg.
```
TransparencyKey = Color.Red
Button1.BackColor = Color.Red
```
Now run the form you will find that the button1 has a hole in it.
So using this method you can create a mask image in paint for which part has to be transparent and apply that image to form and voila the... |
518,021 | <p>In <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="noreferrer">Python</a>, is the following the only way to get the number of elements?</p>
<pre><code>arr.__len__()
</code></pre>
<p>If so, why the strange syntax?</p>
| [
{
"answer_id": 518038,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 11,
"selected": true,
"text": "<pre><code>my_list = [1,2,3,4,5]\nlen(my_list)\n# 5\n</code></pre>\n\n<p>The same works for tuples:</p>\n\n<pre><code>my_tu... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | In [Python](http://en.wikipedia.org/wiki/Python_%28programming_language%29), is the following the only way to get the number of elements?
```
arr.__len__()
```
If so, why the strange syntax? | ```
my_list = [1,2,3,4,5]
len(my_list)
# 5
```
The same works for tuples:
```
my_tuple = (1,2,3,4,5)
len(my_tuple)
# 5
```
And strings, which are really just arrays of characters:
```
my_string = 'hello world'
len(my_string)
# 11
```
It was [intentionally done this way](http://effbot.org/pyfaq/why-does-python-u... |
518,028 | <p>C++ has so much stuff that I don't know. </p>
<p>Is there any way to create a function within a class, that will always be called whenever any other function of that class is called? (like making the function attach itself to the first execution path of a function)</p>
<p>I know this is tricky but I'm curious.</p>... | [
{
"answer_id": 518052,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 2,
"selected": false,
"text": "<p>There is no \"automatic\" way to do this. You would need to add a call to the function in each class method.</p>\n"
}... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | C++ has so much stuff that I don't know.
Is there any way to create a function within a class, that will always be called whenever any other function of that class is called? (like making the function attach itself to the first execution path of a function)
I know this is tricky but I'm curious. | Yes-ish, with a bit of extra code, some indirection and another class and using the -> instead of the . operator.
```
// The class for which calling any method should call PreMethod first.
class DogImplementation
{
public:
void PreMethod();
void Bark();
private:
DogImplementation(); // constructor private so ... |
518,037 | <p>I've got a User model that has many Items. A Rating belongs to a User and an Item.</p>
<p>In the DB, I have set ratings.user_id to be not NULL.</p>
<p>when I am creating an Item, I would like to do this:</p>
<pre><code> def create
current_user.items.create(params[:item]).ratings.create(params[:rating]
re... | [
{
"answer_id": 518090,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 0,
"selected": false,
"text": "<p>Because Item has many Ratings and that association does not know about the user id. Given that association chain It... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52092/"
] | I've got a User model that has many Items. A Rating belongs to a User and an Item.
In the DB, I have set ratings.user\_id to be not NULL.
when I am creating an Item, I would like to do this:
```
def create
current_user.items.create(params[:item]).ratings.create(params[:rating]
redirect_to items_path
end
... | I'd recommend you normalize this if possible in the database. Maybe take out the user\_id attribute from the ratings table and if you need it in your model get it through a join using a :through method
```
class Rating
has_many :items
has_one :user, :through=>:items
``` |
518,082 | <p>Why can't htmlspecialchars() continually encode characters after each form submission? Take a look at the following example:</p>
<pre><code><?php $_POST['txt'] = htmlspecialchars($_POST['txt']); ?>
<form method="post">
<input name="txt" value="<?=$_POST['txt'] ?>" />
<input type="submit"... | [
{
"answer_id": 518118,
"author": "soulmerge",
"author_id": 44562,
"author_profile": "https://Stackoverflow.com/users/44562",
"pm_score": 0,
"selected": false,
"text": "<p>The values in $_POST are already html-decoded for convenience. So when your script starts, the following is true:</p>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27305/"
] | Why can't htmlspecialchars() continually encode characters after each form submission? Take a look at the following example:
```
<?php $_POST['txt'] = htmlspecialchars($_POST['txt']); ?>
<form method="post">
<input name="txt" value="<?=$_POST['txt'] ?>" />
<input type="submit" name="save" value="test" />
</form>
```
... | This simply is HTML entity encoding. When using "&" in an HTML attribute, it should be encoded. And this is what you are doing.
So, the browser reads
```
<input value="&" />
```
and translates it to an "textbox widget with value '&'".
The same would be true for other special chars:
```
<input value=""" />... |
518,087 | <p>What is the best "rule of thumb" to determine when to use method overloads and when to use a separate "request" class? for example:</p>
<pre><code>MakePancakes(int size)
MakePancakes(int size, bool addBlueBerries)
MakePancakes(int size, bool addBlueBerries, ...)
</code></pre>
<p>As opposed to:</p>
<pre><code>Mak... | [
{
"answer_id": 518176,
"author": "Jeremy",
"author_id": 62657,
"author_profile": "https://Stackoverflow.com/users/62657",
"pm_score": 1,
"selected": false,
"text": "<p>I wouldn't need many overloads myself before I created a request type or enum (array of enum seems like a pretty simple ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52682/"
] | What is the best "rule of thumb" to determine when to use method overloads and when to use a separate "request" class? for example:
```
MakePancakes(int size)
MakePancakes(int size, bool addBlueBerries)
MakePancakes(int size, bool addBlueBerries, ...)
```
As opposed to:
```
MakePancakes(PancakeOptions options)
```... | The real advantage of using MakePancakes(PancakeOptions options) is that you can change the number of attributes of PacakeOptions without having to change the method implementation. It can be helpful when the number of parameters can change or are optional. It does make sense to represent configuration/properties/optio... |
518,105 | <p>Does anyone know how to find the most recent backup for a database using SMO?</p>
| [
{
"answer_id": 554829,
"author": "Marcus Erickson",
"author_id": 38373,
"author_profile": "https://Stackoverflow.com/users/38373",
"pm_score": 3,
"selected": true,
"text": "<p>The backup times are stored in the table msdb.dbo.backupset. Here is a routine that takes an open SQLconnection,... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37379/"
] | Does anyone know how to find the most recent backup for a database using SMO? | The backup times are stored in the table msdb.dbo.backupset. Here is a routine that takes an open SQLconnection, databasename and a flag indicating whether you want full backups or any backups and returns the time of the last backup.
Note that this table sometimes gets groomed so it could indicate no backups if it has... |
518,129 | <p>I'm looking for the "best practice" as to where the JSON should be stored if it's just a string array. Should it be stored in a variable in a script block in the HTML page? Should it be stored in a JavaScript file outside of the HTML for separation? Or should it be stored in the plugin itself?</p>
<p>If it should b... | [
{
"answer_id": 518154,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 4,
"selected": true,
"text": "<p>Depends, if you need the JSON right away you can store it anywhere to get it executed:</p>\n\n<pre><code><script... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21318/"
] | I'm looking for the "best practice" as to where the JSON should be stored if it's just a string array. Should it be stored in a variable in a script block in the HTML page? Should it be stored in a JavaScript file outside of the HTML for separation? Or should it be stored in the plugin itself?
If it should be an exter... | Depends, if you need the JSON right away you can store it anywhere to get it executed:
```
<script> var myJsonObj = { ... }; </script>
```
If it's a lot of Data and you don't need the data right away, you can always make an ajax call to a file named something like "data.json".
For naming the plugin name, well it's ... |
518,131 | <p>I'm trying to use JNA with a DLL in Windows, so far I was able to successfully call a function called <code>c_aa_find_devices()</code>. But all the functions start with <code>c_aa</code> and I would like to rename it to <code>find_devices()</code>.</p>
<p>From what I gather the way to do this is with <a href="https... | [
{
"answer_id": 518463,
"author": "Michael Rutherfurd",
"author_id": 33889,
"author_profile": "https://Stackoverflow.com/users/33889",
"pm_score": 2,
"selected": false,
"text": "<p>From the documentation you need to provide a FunctionMapper in the original call to loadLibrary that convert... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44330/"
] | I'm trying to use JNA with a DLL in Windows, so far I was able to successfully call a function called `c_aa_find_devices()`. But all the functions start with `c_aa` and I would like to rename it to `find_devices()`.
From what I gather the way to do this is with [`StdCallFunctionMapper`](https://jna.dev.java.net/javado... | A complete working example, using a function mapper.
```
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import com.sun.jna.win32.StdCallFunctionMapper;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
public class JnaTest ... |
518,138 | <p>I have 3 different kinds of ajax popups that need to exist across my site. I was hoping that I could simply create a user control for each one and place the panel and modal popup extender inside each one but this doesn't seem to be working. Has anyone tried this before or do you have a recommendation as to how I can... | [
{
"answer_id": 518463,
"author": "Michael Rutherfurd",
"author_id": 33889,
"author_profile": "https://Stackoverflow.com/users/33889",
"pm_score": 2,
"selected": false,
"text": "<p>From the documentation you need to provide a FunctionMapper in the original call to loadLibrary that convert... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52551/"
] | I have 3 different kinds of ajax popups that need to exist across my site. I was hoping that I could simply create a user control for each one and place the panel and modal popup extender inside each one but this doesn't seem to be working. Has anyone tried this before or do you have a recommendation as to how I can av... | A complete working example, using a function mapper.
```
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import com.sun.jna.win32.StdCallFunctionMapper;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
public class JnaTest ... |
518,162 | <p>I have a couple of models in django which are connected many-to-many. I want to create instances of these models <em>in memory</em>, present them to the user (via custom method-calls inside the view-templates) and if the user is satisfied, save them to the database.</p>
<p>However, if I try to do anything on the mo... | [
{
"answer_id": 518290,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 3,
"selected": false,
"text": "<p>I would add a field which indicates whether the objects are \"draft\" or \"live\". That way they are persisted acr... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3506/"
] | I have a couple of models in django which are connected many-to-many. I want to create instances of these models *in memory*, present them to the user (via custom method-calls inside the view-templates) and if the user is satisfied, save them to the database.
However, if I try to do anything on the model-instances (ca... | I think that using django forms may be the answer, as outlined in [this](http://docs.djangoproject.com/en/dev/topics/forms/modelforms/) documentation (search for m2m...).
Edited to add some explanation for other people who might have the same problem:
say you have a model like this:
```
from django.db import models
... |
518,178 | <p>Update: I'm going to leave it as is: The performance hit of a exception (very rare) is better than the probably performance hit for checking on each operation (common)</p>
<hr>
<p>I'm trying to support an "EstimatedRowCount" that in one case would be the product of two sub-cursors that are joined together:</p>
<p... | [
{
"answer_id": 518213,
"author": "JMD",
"author_id": 56793,
"author_profile": "https://Stackoverflow.com/users/56793",
"pm_score": 2,
"selected": false,
"text": "<p>Your solution seems quite reasonable. Is there something specific you want to optimize? Does that product cause the overf... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9169/"
] | Update: I'm going to leave it as is: The performance hit of a exception (very rare) is better than the probably performance hit for checking on each operation (common)
---
I'm trying to support an "EstimatedRowCount" that in one case would be the product of two sub-cursors that are joined together:
```
estimatedRowC... | This sounds like a good use case for the ['unchecked' keyword](http://msdn.microsoft.com/en-us/library/a569z7k8.aspx).
To use, simply wrap your assignment in an 'unchecked' block:
```
Int64 estimRowCount = 0;
unchecked
{
estimRowCount = leftRowCount * rightRowCount;
}
```
Then test to see if the result is negat... |
518,181 | <p>I am attempting to request a page like "<a href="http://www.google.com/?q=random" rel="noreferrer">http://www.google.com/?q=random</a>" using the webrequest class in vb.net.
we are behind a firewall, so we have to authenticate our requests.
I have gotten past the authentication part by adding my credentials.
But onc... | [
{
"answer_id": 518230,
"author": "Darryl Braaten",
"author_id": 1834,
"author_profile": "https://Stackoverflow.com/users/1834",
"pm_score": 6,
"selected": true,
"text": "<p>Make sure you have a cookie container setup.</p>\n\n<pre><code>CookieContainer cookieContainer = new CookieContaine... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42604/"
] | I am attempting to request a page like "<http://www.google.com/?q=random>" using the webrequest class in vb.net.
we are behind a firewall, so we have to authenticate our requests.
I have gotten past the authentication part by adding my credentials.
But once that works it seems to go into a redirecting loop.
Does anyon... | Make sure you have a cookie container setup.
```
CookieContainer cookieContainer = new CookieContainer();
loHttp.CookieContainer = cookieContainer;
```
You are probably not saving cookies and getting caught in a redirect loop. |
518,192 | <p>I'm trying to construct a CABasicAnimation to animate the backgroundColor property of a Core Animation CALayer, but I can't figure out how to properly wrap a CGColorRef value to pass to the animation. For example: </p>
<pre><code>CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = {1... | [
{
"answer_id": 518719,
"author": "Jason Medeiros",
"author_id": 19255,
"author_profile": "https://Stackoverflow.com/users/19255",
"pm_score": 7,
"selected": true,
"text": "<p>You don't need to wrap <code>CGColorRef</code>s when setting the <code>toValue</code> or <code>fromValue</code> p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19679/"
] | I'm trying to construct a CABasicAnimation to animate the backgroundColor property of a Core Animation CALayer, but I can't figure out how to properly wrap a CGColorRef value to pass to the animation. For example:
```
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = {1.0, 0.0, 0.0, 1... | You don't need to wrap `CGColorRef`s when setting the `toValue` or `fromValue` properties of a `CABasicAnimation`. Simply use the `CGColorRef`. To avoid the compiler warning, you can cast the `CGColorRef` to an `id`.
In my sample app, the following code animated the background to red.
```
CABasicAnimation* selectionA... |
518,197 | <p>I have an object <em>Dog</em> which holds a set of <em>DogMetadata</em>.</p>
<p>Each DogMetadata has two values: a String ("<em>desc</em>") and an int ("<em>rank</em>").</p>
<p>Descriptions of dogs have different rankings such as: "small" is 5, "furry" is 2, "friendly" is 9, "dalmation" is 11, "mutt" is 22.</p>
<... | [
{
"answer_id": 518483,
"author": "kazanaki",
"author_id": 60593,
"author_profile": "https://Stackoverflow.com/users/60593",
"pm_score": 0,
"selected": false,
"text": "<p>Just from the top of my head (without actually verifying it in HQL)</p>\n\n<pre><code>from Dog d where d.dogMetadata.d... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62255/"
] | I have an object *Dog* which holds a set of *DogMetadata*.
Each DogMetadata has two values: a String ("*desc*") and an int ("*rank*").
Descriptions of dogs have different rankings such as: "small" is 5, "furry" is 2, "friendly" is 9, "dalmation" is 11, "mutt" is 22.
I need to search for dogs based on **any** of thei... | This query won't work:
```
select d from Dog as d
left join fetch d.dogMetadata as dMeta
where ( (dMeta.desc = 'furry') OR (dMeta.desc = 'small') )
group by d
order by sum(dMeta.rank) desc
```
Because of this bug:
<http://opensource.atlassian.com/projects/hibernate/browse/HHH-1615?focusedCommentId=24530#action_24530... |
518,207 | <p>I have a project that needs to access resources within its own JAR file. When I create the JAR file for the project, I would like to copy a directory into that JAR file (I guess the ZIP equivalent would be "adding" the directory to the existing ZIP file). I only want the copy to happen after the JAR has been creat... | [
{
"answer_id": 518246,
"author": "Handerson",
"author_id": 62499,
"author_profile": "https://Stackoverflow.com/users/62499",
"pm_score": 2,
"selected": false,
"text": "<p>One way is to use the Ant tasks:</p>\n\n<ol>\n<li><a href=\"http://ant.apache.org/manual/Tasks/unzip.html\" rel=\"nof... | 2009/02/05 | [
"https://Stackoverflow.com/questions/518207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47923/"
] | I have a project that needs to access resources within its own JAR file. When I create the JAR file for the project, I would like to copy a directory into that JAR file (I guess the ZIP equivalent would be "adding" the directory to the existing ZIP file). I only want the copy to happen after the JAR has been created (a... | The Jar/Ear Ant tasks are subtasks of the more general [Zip task](http://ant.apache.org/manual/Tasks/zip.html). This means that you can also use `zipfileset` in your Jar task:
```
<jar destfile="${jar.file}" basedir="...">
<zipfileset dir="${project.path}" includes="*.jar" prefix="libs"/>
</jar>
```
I've also se... |